Class: WireMockMapper::Builders::RequestBuilder
- Inherits:
-
Object
- Object
- WireMockMapper::Builders::RequestBuilder
- Defined in:
- lib/builders/request_builder.rb
Instance Method Summary collapse
-
#initialize ⇒ RequestBuilder
constructor
A new instance of RequestBuilder.
-
#is_a_any ⇒ RequestBuilder
Sets the request HTTP method to ANY.
-
#is_a_delete ⇒ RequestBuilder
Sets the request HTTP method to DELETE.
-
#is_a_get ⇒ RequestBuilder
Sets the request HTTP method to GET.
-
#is_a_head ⇒ RequestBuilder
Sets the request HTTP method to HEAD.
-
#is_a_options ⇒ RequestBuilder
Sets the request HTTP method to OPTIONS.
-
#is_a_post ⇒ RequestBuilder
Sets the request HTTP method to POST.
-
#is_a_put ⇒ RequestBuilder
Sets the request HTTP method to PUT.
-
#is_a_trace ⇒ RequestBuilder
Sets the request HTTP method to TRACE.
- #to_hash ⇒ Object
- #to_json ⇒ Object
-
#with_basic_auth(username, password) ⇒ RequestBuilder
Expect basic auth.
-
#with_body ⇒ MatchBuilder
Expect body.
-
#with_cookie(key) ⇒ MatchBuilder
Expect cookie.
-
#with_header(key) ⇒ MatchBuilder
Expect header.
-
#with_query_param(key) ⇒ MatchBuilder
Expect query param.
-
#with_url ⇒ UrlMatchBuilder
Expect url path with query params.
-
#with_url_path ⇒ UrlMatchBuilder
Expect url path only.
Constructor Details
#initialize ⇒ RequestBuilder
Returns a new instance of RequestBuilder.
7 8 9 |
# File 'lib/builders/request_builder.rb', line 7 def initialize @options = {} end |
Instance Method Details
#is_a_any ⇒ RequestBuilder
Sets the request HTTP method to ANY
|
# File 'lib/builders/request_builder.rb', line 11
|
#is_a_delete ⇒ RequestBuilder
Sets the request HTTP method to DELETE
|
# File 'lib/builders/request_builder.rb', line 16
|
#is_a_get ⇒ RequestBuilder
Sets the request HTTP method to GET
|
# File 'lib/builders/request_builder.rb', line 21
|
#is_a_head ⇒ RequestBuilder
Sets the request HTTP method to HEAD
|
# File 'lib/builders/request_builder.rb', line 26
|
#is_a_options ⇒ RequestBuilder
Sets the request HTTP method to OPTIONS
|
# File 'lib/builders/request_builder.rb', line 31
|
#is_a_post ⇒ RequestBuilder
Sets the request HTTP method to POST
|
# File 'lib/builders/request_builder.rb', line 36
|
#is_a_put ⇒ RequestBuilder
Sets the request HTTP method to PUT
|
# File 'lib/builders/request_builder.rb', line 41
|
#is_a_trace ⇒ RequestBuilder
Sets the request HTTP method to TRACE
50 |
# File 'lib/builders/request_builder.rb', line 50 HTTP_VERBS = %w[ANY DELETE GET HEAD OPTIONS POST PUT TRACE].freeze |
#to_hash ⇒ Object
114 115 116 117 |
# File 'lib/builders/request_builder.rb', line 114 def to_hash(*) = @options.merge(@url_match.to_hash) if @url_match || @options end |
#to_json ⇒ Object
119 120 121 |
# File 'lib/builders/request_builder.rb', line 119 def to_json(*) to_hash.to_json end |
#with_basic_auth(username, password) ⇒ RequestBuilder
Expect basic auth
64 65 66 67 |
# File 'lib/builders/request_builder.rb', line 64 def with_basic_auth(username, password) @options[:basicAuth] = { username: username, password: password } self end |
#with_body ⇒ MatchBuilder
Expect body
71 72 73 74 75 76 |
# 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_cookie(key) ⇒ MatchBuilder
Expect cookie
81 82 83 84 |
# File 'lib/builders/request_builder.rb', line 81 def (key) @options[:cookies] ||= {} @options[:cookies][key] = MatchBuilder.new(self) end |
#with_header(key) ⇒ MatchBuilder
Expect header
89 90 91 92 |
# 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) ⇒ MatchBuilder
Expect query param
97 98 99 100 |
# File 'lib/builders/request_builder.rb', line 97 def with_query_param(key) @options[:queryParameters] ||= {} @options[:queryParameters][key] = MatchBuilder.new(self) end |
#with_url ⇒ UrlMatchBuilder
Expect url path with query params
104 105 106 |
# File 'lib/builders/request_builder.rb', line 104 def with_url @url_match = UrlMatchBuilder.new(self) end |
#with_url_path ⇒ UrlMatchBuilder
Expect url path only
110 111 112 |
# File 'lib/builders/request_builder.rb', line 110 def with_url_path @url_match = UrlMatchBuilder.new(self, true) end |