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

#rSpecHashIncludingMatcher?

Constructor Details

This class inherits a constructor from WebMock::URIPattern

Instance Method Details

#add_query_params(query_params) ⇒ Object



159
160
161
162
# File 'lib/webmock/request_pattern.rb', line 159

def add_query_params(query_params)
  warn "WebMock warning: ignoring query params in RFC 6570 template and checking them with WebMock"
  super(query_params)
end

#matches?(uri) ⇒ Boolean

Returns:

  • (Boolean)


148
149
150
151
152
153
154
155
156
157
# File 'lib/webmock/request_pattern.rb', line 148

def matches?(uri)
  if @query_params.nil?
    # Let Addressable check the whole URI
    WebMock::Util::URI.variations_of_uri_as_strings(uri).any? { |u| @pattern.match(u) }
  else
    # WebMock checks the query, Addressable checks everything else
    WebMock::Util::URI.variations_of_uri_as_strings(uri.omit(:query)).any? { |u| @pattern.match(u) } &&
      @query_params == WebMock::Util::QueryMapper.query_to_values(uri.query)
  end
end

#to_sObject



164
165
166
167
168
# File 'lib/webmock/request_pattern.rb', line 164

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