daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 50 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. # thinking_sphinx_macros.rb in test/shoulda_macros
  2. def should_be_thinking_sphinxed(options = {})
  3.   klass = self.to_s.scan(/(.*)Test/).flatten.first.constantize || options[:klass]
  4.   fields = Array(options[:fields])
  5.   attributes = Array(options[:attributes])
  6.  
  7.   should "be indexed by ThinkingSphinx" do
  8.     assert ThinkingSphinx.indexed_models.include?(klass.to_s), "class #{klass} is not indexed"
  9.   end
  10.  
  11.   unless options[:fields].blank?
  12.     indexed_fields = klass.sphinx_indexes[0].fields.map(&:unique_name)
  13.  
  14.     options[:fields].each do |field|
  15.       should "have indexed field #{field}" do
  16.         assert indexed_fields.include?(field), "field #{field} is not indexed"
  17.       end
  18.     end
  19.   end
  20.  
  21.   unless options[:attributes].blank?
  22.     indexed_attributes = klass.sphinx_indexes[0].attributes.map(&:unique_name)
  23.  
  24.     options[:attributes].each do |attribute|
  25.       should "have indexed attribute #{attribute}" do
  26.         assert indexed_attributes.include?(attribute), "attribute #{attribute} is not indexed"
  27.       end
  28.     end
  29.   end
  30. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top