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.
-
#receives_any ⇒ RequestBuilder
Sets the request HTTP method to ANY.
-
#receives_delete ⇒ RequestBuilder
Sets the request HTTP method to DELETE.
-
#receives_get ⇒ RequestBuilder
Sets the request HTTP method to GET.
-
#receives_head ⇒ RequestBuilder
Sets the request HTTP method to HEAD.
-
#receives_options ⇒ RequestBuilder
Sets the request HTTP method to OPTIONS.
-
#receives_post ⇒ RequestBuilder
Sets the request HTTP method to POST.
-
#receives_put ⇒ RequestBuilder
Sets the request HTTP method to PUT.
-
#receives_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 = {} end |
Instance Method Details
#receives_any ⇒ RequestBuilder
Sets the request HTTP method to ANY
|
|
# File 'lib/builders/request_builder.rb', line 11
|
#receives_delete ⇒ RequestBuilder
Sets the request HTTP method to DELETE
|
|
# File 'lib/builders/request_builder.rb', line 16
|
#receives_get ⇒ RequestBuilder
Sets the request HTTP method to GET
|
|
# File 'lib/builders/request_builder.rb', line 21
|
#receives_head ⇒ RequestBuilder
Sets the request HTTP method to HEAD
|
|
# File 'lib/builders/request_builder.rb', line 26
|
#receives_options ⇒ RequestBuilder
Sets the request HTTP method to OPTIONS
|
|
# File 'lib/builders/request_builder.rb', line 31
|
#receives_post ⇒ RequestBuilder
Sets the request HTTP method to POST
|
|
# File 'lib/builders/request_builder.rb', line 36
|
#receives_put ⇒ RequestBuilder
Sets the request HTTP method to PUT
|
|
# File 'lib/builders/request_builder.rb', line 41
|
#receives_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(*) = .merge(@url_match.to_hash) if @url_match || 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) [: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 [:bodyPatterns] ||= [] match_builder = MatchBuilder.new(self) [: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) [:cookies] ||= {} [: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) [:headers] ||= {} [: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) [:queryParameters] ||= {} [: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 |