Sha256: ab19fee7eeeea85f92cfc59346c33fb0363a071ccdfcb3719444598db22e3b4c

Contents?: true

Size: 955 Bytes

Versions: 1

Compression:

Stored size: 955 Bytes

Contents

# encoding: UTF-8
require_relative './body'
require_relative './delay'
require_relative './parameter'

#
# A class to model a response in an expectation.
# @author:: Nayyara Samuel (mailto: nayyara.samuel@opower.com)
#
module MockServer::Model
  # Model for a mock response
  class Response < Hashie::Dash
    include Hashie::Extensions::MethodAccess
    include Hashie::Extensions::IgnoreUndeclared
    include Hashie::Extensions::Coercion

    property :status_code, default: 200
    property :cookies, default: Parameters.new([])
    property :headers, default: Parameters.new([])
    property :delay
    property :body

    coerce_key :cookies, Parameters
    coerce_key :headers, Parameters
    coerce_key :delay, Delay
    coerce_key :body, String
  end

  # DSL Methods for a response
  module DSL
    def response(&_)
      obj = Response.new
      yield obj if block_given?
      obj
    end

    alias_method :http_response, :response
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mockserver-client-0.0.1 lib/mockserver/model/response.rb