Class: WireMockMapper::RequestBuilder
- Inherits:
-
Object
- Object
- WireMockMapper::RequestBuilder
- Defined in:
- lib/request_builder.rb
Instance Method Summary collapse
-
#initialize(configuration = nil) ⇒ RequestBuilder
constructor
A new instance of RequestBuilder.
- #posts_to_path(url) ⇒ Object
- #to_hash ⇒ Object
- #to_json ⇒ Object
- #with_body(value) ⇒ Object
- #with_header(key, value) ⇒ Object
Constructor Details
#initialize(configuration = nil) ⇒ RequestBuilder
3 4 5 6 7 |
# File 'lib/request_builder.rb', line 3 def initialize(configuration = nil) = {} ['headers'] ||= {} ['headers'] = configuration.request_headers if configuration end |
Instance Method Details
#posts_to_path(url) ⇒ Object
9 10 11 12 13 |
# File 'lib/request_builder.rb', line 9 def posts_to_path(url) ['method'] = 'POST' ['urlPath'] = url self end |
#to_hash ⇒ Object
27 28 29 |
# File 'lib/request_builder.rb', line 27 def to_hash(*) end |
#to_json ⇒ Object
31 32 33 |
# File 'lib/request_builder.rb', line 31 def to_json(*) .to_json end |
#with_body(value) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/request_builder.rb', line 20 def with_body(value) ['bodyPatterns'] ||= [] value = value.to_json unless value.is_a? String ['bodyPatterns'] << { matches: value } self end |
#with_header(key, value) ⇒ Object
15 16 17 18 |
# File 'lib/request_builder.rb', line 15 def with_header(key, value) ['headers'][key] = { equalTo: value } self end |