Class: WebMock::URIPattern
Instance Method Summary
collapse
#rSpecHashIncludingMatcher?
Constructor Details
#initialize(pattern) ⇒ URIPattern
Returns a new instance of URIPattern.
105
106
107
108
109
110
111
112
113
|
# File 'lib/webmock/request_pattern.rb', line 105
def initialize(pattern)
@pattern = case pattern
when Addressable::URI, Addressable::Template
pattern
else
WebMock::Util::URI.normalize_uri(pattern)
end
@query_params = nil
end
|
Instance Method Details
#add_query_params(query_params) ⇒ Object
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/webmock/request_pattern.rb', line 115
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
WebMock::Util::QueryMapper.query_to_values(query_params, :notation => Config.instance.query_values_notation)
end
end
|
#to_s ⇒ Object
127
128
129
130
131
|
# File 'lib/webmock/request_pattern.rb', line 127
def to_s
str = @pattern.inspect
str += " with query params #{@query_params.inspect}" if @query_params
str
end
|