class SunspotMatchers::HaveSearchableField
Public Class Methods
new(field)
click to toggle source
# File lib/sunspot_matchers/matchers.rb, line 329 def initialize(field) @field = field end
Public Instance Methods
description()
click to toggle source
# File lib/sunspot_matchers/matchers.rb, line 338 def description "have searchable field '#{@field}'" end
failure_message()
click to toggle source
# File lib/sunspot_matchers/matchers.rb, line 342 def failure_message message = "expected class: #{@klass} to have searchable field: #{@field}" message << ", but Sunspot was not configured on #{@klass}" unless @sunspot end
failure_message_when_negated()
click to toggle source
# File lib/sunspot_matchers/matchers.rb, line 347 def failure_message_when_negated "expected class: #{@klass} NOT to have searchable field: #{@field}" end
fields_to_match()
click to toggle source
# File lib/sunspot_matchers/matchers.rb, line 355 def fields_to_match (sunspot.all_text_fields + sunspot.fields).collect(&:name) end
matches?(klass_or_object)
click to toggle source
# File lib/sunspot_matchers/matchers.rb, line 333 def matches?(klass_or_object) @klass = klass_or_object.class.name == 'Class' ? klass_or_object : klass_or_object.class sunspot && fields_to_match.include?(@field) end
sunspot()
click to toggle source
# File lib/sunspot_matchers/matchers.rb, line 351 def sunspot @sunspot ||= Sunspot::Setup.for(@klass) end