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.



128
129
130
131
# File 'lib/sunspot_matchers/matchers.rb', line 128

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

Instance Method Details

#failure_messageObject



139
140
141
# File 'lib/sunspot_matchers/matchers.rb', line 139

def failure_message
  @matcher.missing_param_error_message
end

#failure_message_when_negatedObject



143
144
145
# File 'lib/sunspot_matchers/matchers.rb', line 143

def failure_message_when_negated
  @matcher.unexpected_match_error_message
end

#get_matcherObject



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

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)


133
134
135
136
137
# File 'lib/sunspot_matchers/matchers.rb', line 133

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