Class: SunspotMatchers::BeASearchFor
- Inherits:
-
Object
- Object
- SunspotMatchers::BeASearchFor
- Defined in:
- lib/sunspot_matchers/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected_class) ⇒ BeASearchFor
constructor
A new instance of BeASearchFor.
- #matches?(actual) ⇒ Boolean
- #search_tuple ⇒ Object
- #search_types ⇒ Object
Constructor Details
#initialize(expected_class) ⇒ BeASearchFor
Returns a new instance of BeASearchFor.
290 291 292 |
# File 'lib/sunspot_matchers/matchers.rb', line 290 def initialize(expected_class) @expected_class = expected_class end |
Instance Method Details
#description ⇒ Object
317 318 319 |
# File 'lib/sunspot_matchers/matchers.rb', line 317 def description "be a search for #{@expected_class}" end |
#failure_message ⇒ Object
309 310 311 |
# File 'lib/sunspot_matchers/matchers.rb', line 309 def "expected search class: #{search_types.join(' and ')} to match expected class: #{@expected_class}" end |
#failure_message_when_negated ⇒ Object
313 314 315 |
# File 'lib/sunspot_matchers/matchers.rb', line 313 def "expected search class: #{search_types.join(' and ')} NOT to match expected class: #{@expected_class}" end |
#matches?(actual) ⇒ Boolean
294 295 296 297 |
# File 'lib/sunspot_matchers/matchers.rb', line 294 def matches?(actual) @actual = actual search_types.include?(@expected_class) end |
#search_tuple ⇒ Object
299 300 301 302 303 |
# File 'lib/sunspot_matchers/matchers.rb', line 299 def search_tuple search_tuple = @actual.is_a?(Array) ? @actual : @actual.searches.last raise 'no search found' unless search_tuple search_tuple end |
#search_types ⇒ Object
305 306 307 |
# File 'lib/sunspot_matchers/matchers.rb', line 305 def search_types search_tuple.first end |