class WireMockMapper::Builders::ResponseBuilder

Public Class Methods

new() click to toggle source
# File lib/builders/response_builder.rb, line 4
def initialize
  @options = {}
end

Public Instance Methods

to_hash(*) click to toggle source
# File lib/builders/response_builder.rb, line 59
def to_hash(*)
  @options
end
to_json(*) click to toggle source
# File lib/builders/response_builder.rb, line 63
def to_json(*)
  @options.to_json
end
with_body(value) click to toggle source

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
with_delay(milliseconds) click to toggle source

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
with_header(key, value) click to toggle source

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
with_status(status_code) click to toggle source

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
with_status_message(status_message) click to toggle source

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
with_transformer(transformer) click to toggle source

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