class WireMockMapper::Builders::ResponseBuilder
Public Class Methods
# File lib/builders/response_builder.rb, line 4 def initialize @options = {} end
Public Instance Methods
# File lib/builders/response_builder.rb, line 59 def to_hash(*) @options end
# File lib/builders/response_builder.rb, line 63 def to_json(*) @options.to_json end
Response body @param value [String] the value to set the response body to @return [ResponseBuilder] response builder for chaining
# 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
Add a response delay @param milliseconds [String, Numeric] the delay duration in milliseconds @return [ResponseBuilder] response builder for chaining
# File lib/builders/response_builder.rb, line 20 def with_delay(milliseconds) @options[:fixedDelayMilliseconds] = milliseconds self end
Add a response header @param key [String] the key of the header @param value [String] the value of the header @return [ResponseBuilder] response builder for chaining
# File lib/builders/response_builder.rb, line 29 def with_header(key, value) @options[:headers] ||= {} @options[:headers][key] = value self end
Add a response http status @param status_code [String, Numeric] the status code to respond with @return [ResponseBuilder] response builder for chaining
# File lib/builders/response_builder.rb, line 38 def with_status(status_code) @options[:status] = status_code self end
Add a response http status @param status_code [String] the status message to respond with @return [ResponseBuilder] response builder for chaining
# File lib/builders/response_builder.rb, line 46 def with_status_message(status_message) @options[:statusMessage] = status_message self end
Tell wiremock to use a transformer for the response @param transformer name [String] @return [ResponseBuilder] response builder for chaining
# File lib/builders/response_builder.rb, line 54 def with_transformer(transformer) @options[:transformer] = transformer self end