Class: WireMockMapper::Builders::ResponseBuilder
- Inherits:
-
Object
- Object
- WireMockMapper::Builders::ResponseBuilder
- Defined in:
- lib/builders/response_builder.rb
Instance Method Summary collapse
-
#initialize ⇒ ResponseBuilder
constructor
A new instance of ResponseBuilder.
- #to_hash ⇒ Object
- #to_json ⇒ Object
-
#with_body(value) ⇒ ResponseBuilder
Response body.
-
#with_delay(milliseconds) ⇒ ResponseBuilder
Add a response delay.
-
#with_header(key, value) ⇒ ResponseBuilder
Add a response header.
-
#with_status(status_code) ⇒ ResponseBuilder
Add a response http status.
-
#with_status_message(status_message) ⇒ ResponseBuilder
Add a response http status.
-
#with_transformer(transformer) ⇒ ResponseBuilder
Tell wiremock to use a transformer for the response.
Constructor Details
#initialize ⇒ ResponseBuilder
Returns a new instance of ResponseBuilder.
4 5 6 |
# File 'lib/builders/response_builder.rb', line 4 def initialize @options = {} end |
Instance Method Details
#to_hash ⇒ Object
60 61 62 |
# File 'lib/builders/response_builder.rb', line 60 def to_hash(*) @options end |
#to_json ⇒ Object
64 65 66 |
# File 'lib/builders/response_builder.rb', line 64 def to_json(*) @options.to_json end |
#with_body(value) ⇒ ResponseBuilder
Response body
11 12 13 14 15 |
# File 'lib/builders/response_builder.rb', line 11 def with_body(value) value = value.to_json unless value.is_a? String @options[:body] = value self end |
#with_delay(milliseconds) ⇒ ResponseBuilder
Add a response delay
20 21 22 23 |
# File 'lib/builders/response_builder.rb', line 20 def with_delay(milliseconds) @options[:fixedDelayMilliseconds] = milliseconds self end |
#with_header(key, value) ⇒ ResponseBuilder
Add a response header
29 30 31 32 33 |
# File 'lib/builders/response_builder.rb', line 29 def with_header(key, value) @options[:headers] ||= {} @options[:headers][key] = value self end |
#with_status(status_code) ⇒ ResponseBuilder
Add a response http status
38 39 40 41 |
# File 'lib/builders/response_builder.rb', line 38 def with_status(status_code) @options[:status] = status_code self end |
#with_status_message(status_message) ⇒ ResponseBuilder
Add a response http status
46 47 48 49 |
# File 'lib/builders/response_builder.rb', line 46 def () @options[:statusMessage] = self end |
#with_transformer(transformer) ⇒ ResponseBuilder
Tell wiremock to use a transformer for the response
54 55 56 57 58 |
# File 'lib/builders/response_builder.rb', line 54 def with_transformer(transformer) @options[:transformers] ||= [] @options[:transformers] << transformer self end |