Class: WebMock::URIAddressablePattern

Inherits:
URIPattern
  • Object
show all
Defined in:
lib/webmock/request_pattern.rb

Instance Method Summary collapse

Methods inherited from URIPattern

#initialize

Methods included from RSpecMatcherDetector

#rSpecHashExcludingMatcher?, #rSpecHashIncludingMatcher?

Constructor Details

This class inherits a constructor from WebMock::URIPattern

Instance Method Details

#add_query_params(query_params) ⇒ Object



166
167
168
169
170
171
172
173
# File 'lib/webmock/request_pattern.rb', line 166

def add_query_params(query_params)
  @@add_query_params_warned ||= false
  if not @@add_query_params_warned
    @@add_query_params_warned = true
    warn "WebMock warning: ignoring query params in RFC 6570 template and checking them with WebMock"
  end
  super(query_params)
end

#matches?(uri) ⇒ Boolean

Returns:

  • (Boolean)


155
156
157
158
159
160
161
162
163
164
# File 'lib/webmock/request_pattern.rb', line 155

def matches?(uri)
  if @query_params.nil?
    # Let Addressable check the whole URI
    matches_with_variations?(uri)
  else
    # WebMock checks the query, Addressable checks everything else
    matches_with_variations?(uri.omit(:query)) &&
      @query_params == WebMock::Util::QueryMapper.query_to_values(uri.query)
  end
end

#to_sObject



175
176
177
178
179
# File 'lib/webmock/request_pattern.rb', line 175

def to_s
  str = @pattern.pattern.inspect
  str += " with variables #{@pattern.variables.inspect}" if @pattern.variables
  str
end