Class: WireMockMapper::RequestBuilder
- Inherits:
-
Object
- Object
- WireMockMapper::RequestBuilder
- Defined in:
- lib/request_builder.rb
Instance Method Summary collapse
-
#initialize ⇒ RequestBuilder
constructor
A new instance of RequestBuilder.
- #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.
6 7 8 |
# File 'lib/request_builder.rb', line 6 def initialize = {} end |
Instance Method Details
#to_hash ⇒ Object
74 75 76 77 |
# File 'lib/request_builder.rb', line 74 def to_hash(*) = .merge(@url_match.to_hash) if @url_match || end |
#to_json ⇒ Object
79 80 81 |
# File 'lib/request_builder.rb', line 79 def to_json(*) to_hash.to_json end |
#with_basic_auth(username, password) ⇒ RequestBuilder
Expect basic auth
24 25 26 27 |
# File 'lib/request_builder.rb', line 24 def with_basic_auth(username, password) [:basicAuth] = { username: username, password: password } self end |
#with_body ⇒ MatchBuilder
Expect body
31 32 33 34 35 36 |
# File 'lib/request_builder.rb', line 31 def with_body [:bodyPatterns] ||= [] match_builder = MatchBuilder.new(self) [:bodyPatterns] << match_builder match_builder end |
#with_cookie(key) ⇒ MatchBuilder
Expect cookie
41 42 43 44 |
# File 'lib/request_builder.rb', line 41 def (key) [:cookies] ||= {} [:cookies][key] = MatchBuilder.new(self) end |
#with_header(key) ⇒ MatchBuilder
Expect header
49 50 51 52 |
# File 'lib/request_builder.rb', line 49 def with_header(key) [:headers] ||= {} [:headers][key] = MatchBuilder.new(self) end |
#with_query_param(key) ⇒ MatchBuilder
Expect query param
57 58 59 60 |
# File 'lib/request_builder.rb', line 57 def with_query_param(key) [:queryParameters] ||= {} [:queryParameters][key] = MatchBuilder.new(self) end |
#with_url ⇒ UrlMatchBuilder
Expect url path with query params
64 65 66 |
# File 'lib/request_builder.rb', line 64 def with_url @url_match = UrlMatchBuilder.new(self) end |
#with_url_path ⇒ UrlMatchBuilder
Expect url path only
70 71 72 |
# File 'lib/request_builder.rb', line 70 def with_url_path @url_match = UrlMatchBuilder.new(self, true) end |