Class: SunspotMatchers::HaveSearchableField
- Inherits:
-
Object
- Object
- SunspotMatchers::HaveSearchableField
- Defined in:
- lib/sunspot_matchers/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(field) ⇒ HaveSearchableField
constructor
A new instance of HaveSearchableField.
- #matches?(klass_or_object) ⇒ Boolean
Constructor Details
#initialize(field) ⇒ HaveSearchableField
Returns a new instance of HaveSearchableField.
323 324 325 |
# File 'lib/sunspot_matchers/matchers.rb', line 323 def initialize(field) @field = field end |
Instance Method Details
#description ⇒ Object
333 334 335 |
# File 'lib/sunspot_matchers/matchers.rb', line 333 def description "should have searchable field #{@field}" end |
#failure_message_for_should ⇒ Object
337 338 339 340 |
# File 'lib/sunspot_matchers/matchers.rb', line 337 def = "expected class: #{@klass} to have searchable field: #{@field}" << ", but Sunspot was not configured on #{@klass}" unless @sunspot end |
#failure_message_for_should_not ⇒ Object
342 343 344 |
# File 'lib/sunspot_matchers/matchers.rb', line 342 def "expected class: #{@klass} NOT to have searchable field: #{@field}" end |
#matches?(klass_or_object) ⇒ Boolean
327 328 329 330 331 |
# File 'lib/sunspot_matchers/matchers.rb', line 327 def matches?(klass_or_object) @klass = klass_or_object.class.name == 'Class' ? klass_or_object : klass_or_object.class @sunspot = Sunspot::Setup.for(@klass) @sunspot && (@sunspot.all_text_fields + @sunspot.fields).collect(&:name).include?(@field) end |