Class: SunspotMatchersTestunit::BeASearchFor

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot_matchers_testunit/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(session, expected_class) ⇒ BeASearchFor

Returns a new instance of BeASearchFor.



276
277
278
279
# File 'lib/sunspot_matchers_testunit/matchers.rb', line 276

def initialize(session, expected_class)
  @session = session
  @expected_class = expected_class
end

Instance Method Details

#failure_message_for_shouldObject



295
296
297
# File 'lib/sunspot_matchers_testunit/matchers.rb', line 295

def failure_message_for_should
  "expected search class: #{search_types.join(' and ')} to match expected class: #{@expected_class}"
end

#failure_message_for_should_notObject



299
300
301
# File 'lib/sunspot_matchers_testunit/matchers.rb', line 299

def failure_message_for_should_not
  "expected search class: #{search_types.join(' and ')} NOT to match expected class: #{@expected_class}"
end

#match?Boolean

Returns:

  • (Boolean)


281
282
283
# File 'lib/sunspot_matchers_testunit/matchers.rb', line 281

def match?
  search_types.include?(@expected_class)
end

#search_tupleObject



285
286
287
288
289
# File 'lib/sunspot_matchers_testunit/matchers.rb', line 285

def search_tuple
  search_tuple = @session.is_a?(Array) ? @session : @session.searches.last
  raise 'no search found' unless search_tuple
  search_tuple
end

#search_typesObject



291
292
293
# File 'lib/sunspot_matchers_testunit/matchers.rb', line 291

def search_types
  search_tuple.first
end