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.



38
39
40
41
# File 'lib/sunspot_matchers/test_helper.rb', line 38

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

Instance Method Details

#failure_message_for_shouldObject



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

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

#failure_message_for_should_notObject



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

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)


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

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

#search_tupleObject



47
48
49
50
51
# File 'lib/sunspot_matchers/test_helper.rb', line 47

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



53
54
55
# File 'lib/sunspot_matchers/test_helper.rb', line 53

def search_types
  search_tuple.first
end