class WebMock::URIPattern

Public Class Methods

new(pattern) click to toggle source
# File lib/webmock/request_pattern.rb, line 84
def initialize(pattern)
  @pattern = pattern.is_a?(Addressable::URI) ? pattern : WebMock::Util::URI.normalize_uri(pattern)
  @query_params = nil
end

Public Instance Methods

add_query_params(query_params) click to toggle source
# File lib/webmock/request_pattern.rb, line 89
def add_query_params(query_params)
  @query_params = if query_params.is_a?(Hash)
    query_params
  elsif query_params.is_a?(WebMock::Matchers::HashIncludingMatcher)
    query_params
  elsif rSpecHashIncludingMatcher?(query_params)
    WebMock::Matchers::HashIncludingMatcher.from_rspec_matcher(query_params)
  else
    Addressable::URI.parse('?' + query_params).query_values
  end
end
to_s() click to toggle source
# File lib/webmock/request_pattern.rb, line 101
def to_s
  str = @pattern.inspect
  str += " with query params #{@query_params.inspect}" if @query_params
  str
end