Class: SunspotMatchers::BeASearchForSession

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot_matchers/test_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(session, expected_class) ⇒ BeASearchForSession

Returns a new instance of BeASearchForSession.



41
42
43
44
# File 'lib/sunspot_matchers/test_helper.rb', line 41

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

Instance Method Details

#failure_message_for_shouldObject



60
61
62
# File 'lib/sunspot_matchers/test_helper.rb', line 60

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

#failure_message_for_should_notObject



64
65
66
# File 'lib/sunspot_matchers/test_helper.rb', line 64

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)


46
47
48
# File 'lib/sunspot_matchers/test_helper.rb', line 46

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

#search_tupleObject



50
51
52
53
54
# File 'lib/sunspot_matchers/test_helper.rb', line 50

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



56
57
58
# File 'lib/sunspot_matchers/test_helper.rb', line 56

def search_types
  search_tuple.first
end