Method: WebMock::URIPattern#add_query_params

Defined in:
lib/webmock/request_pattern.rb

#add_query_params(query_params) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/webmock/request_pattern.rb', line 128

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.is_a?(WebMock::Matchers::HashExcludingMatcher)
    query_params
  elsif rSpecHashIncludingMatcher?(query_params)
    WebMock::Matchers::HashIncludingMatcher.from_rspec_matcher(query_params)
  elsif rSpecHashExcludingMatcher?(query_params)
    WebMock::Matchers::HashExcludingMatcher.from_rspec_matcher(query_params)
  else
    WebMock::Util::QueryMapper.query_to_values(query_params, notation: Config.instance.query_values_notation)
  end
end