Class: SunspotMatchers::HaveSearchParams

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

Instance Method Summary collapse

Constructor Details

#initialize(method, *args, &block) ⇒ HaveSearchParams

Returns a new instance of HaveSearchParams.



126
127
128
129
# File 'lib/sunspot_matchers/matchers.rb', line 126

def initialize(method, *args, &block)
  @method = method
  @args = [*args, block].compact
end

Instance Method Details

#failure_message_for_shouldObject



137
138
139
# File 'lib/sunspot_matchers/matchers.rb', line 137

def failure_message_for_should
  @matcher.missing_param_error_message
end

#failure_message_for_should_notObject



141
142
143
# File 'lib/sunspot_matchers/matchers.rb', line 141

def failure_message_for_should_not
  @matcher.unexpected_match_error_message
end

#get_matcherObject



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/sunspot_matchers/matchers.rb', line 145

def get_matcher
  case @method
    when :with
      WithMatcher
    when :without
      WithoutMatcher
    when :keywords, :fulltext
      KeywordsMatcher
    when :boost
      BoostMatcher
    when :facet
      FacetMatcher
    when :order_by
      OrderByMatcher
    when :paginate
      PaginationMatcher
    when :group
      GroupMatcher
  end
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


131
132
133
134
135
# File 'lib/sunspot_matchers/matchers.rb', line 131

def matches?(actual)
  @actual = actual
  @matcher = get_matcher.new(@actual, @args)
  @matcher.match?
end