Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # thinking_sphinx_macros.rb in test/shoulda_macros
- def should_be_thinking_sphinxed(options = {})
- klass = self.to_s.scan(/(.*)Test/).flatten.first.constantize || options[:klass]
- fields = Array(options[:fields])
- attributes = Array(options[:attributes])
- should "be indexed by ThinkingSphinx" do
- assert ThinkingSphinx.indexed_models.include?(klass.to_s), "class #{klass} is not indexed"
- end
- unless options[:fields].blank?
- indexed_fields = klass.sphinx_indexes[0].fields.map(&:unique_name)
- options[:fields].each do |field|
- should "have indexed field #{field}" do
- assert indexed_fields.include?(field), "field #{field} is not indexed"
- end
- end
- end
- unless options[:attributes].blank?
- indexed_attributes = klass.sphinx_indexes[0].attributes.map(&:unique_name)
- options[:attributes].each do |attribute|
- should "have indexed attribute #{attribute}" do
- assert indexed_attributes.include?(attribute), "attribute #{attribute} is not indexed"
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment