class WireMockMapper::Builders::RequestBuilder

Constants

HTTP_VERBS

@!method is_a_trace Sets the request HTTP method to TRACE @return [RequestBuilder] request builder for chaining

Public Class Methods

new() click to toggle source
# File lib/builders/request_builder.rb, line 7
def initialize
  @options = {}
end

Public Instance Methods

to_hash(*) click to toggle source
# File lib/builders/request_builder.rb, line 114
def to_hash(*)
  options_with_url_match = @options.merge(@url_match.to_hash) if @url_match
  options_with_url_match || @options
end
to_json(*) click to toggle source
# File lib/builders/request_builder.rb, line 119
def to_json(*)
  to_hash.to_json
end
with_basic_auth(username, password) click to toggle source

Expect basic auth @param username [String] username to expect @param password [String] password to expect @return [RequestBuilder] request builder for chaining

# File lib/builders/request_builder.rb, line 64
def with_basic_auth(username, password)
  @options[:basicAuth] = { username: username, password: password }
  self
end
with_body() click to toggle source

Expect body @return [MatchBuilder] match builder to declare the match on the body

# File lib/builders/request_builder.rb, line 71
def with_body
  @options[:bodyPatterns] ||= []
  match_builder = MatchBuilder.new(self)
  @options[:bodyPatterns] << match_builder
  match_builder
end
with_header(key) click to toggle source

Expect header @param key [String] the header key @return [MatchBuilder] match builder to declare the match on the header

# File lib/builders/request_builder.rb, line 89
def with_header(key)
  @options[:headers] ||= {}
  @options[:headers][key] = MatchBuilder.new(self)
end
with_query_param(key) click to toggle source

Expect query param @param key [String] the query param key @return [MatchBuilder] match builder to declare the match on the query param

# File lib/builders/request_builder.rb, line 97
def with_query_param(key)
  @options[:queryParameters] ||= {}
  @options[:queryParameters][key] = MatchBuilder.new(self)
end
with_url() click to toggle source

Expect url path with query params @return [UrlMatchBuilder] url match builder to declare the match on the url

# File lib/builders/request_builder.rb, line 104
def with_url
  @url_match = UrlMatchBuilder.new(self)
end
with_url_path() click to toggle source

Expect url path only @return [UrlMatchBuilder] url match builder to declare the match on the url

# File lib/builders/request_builder.rb, line 110
def with_url_path
  @url_match = UrlMatchBuilder.new(self, true)
end