Sha256: 66db481df1e3488870a10d1035119efff0509d0f2bbf45b651176c9916dba058

Contents?: true

Size: 877 Bytes

Versions: 1

Compression:

Stored size: 877 Bytes

Contents

module WebMock
  class Response
    attr_accessor :options

    def initialize(options = {})
      @options = options
      @options[:headers] = Util::Headers.normalize_headers(@options[:headers]) unless @options[:headers].is_a?(Proc)
    end

    def headers
      @options[:headers]
    end

    def body
      return '' unless @options.has_key?(:body)
      case @options[:body]
      when IO
        @options[:body].read
      when String
        @options[:body]
      end
    end

    def status
      @options.has_key?(:status) ? @options[:status] : 200
    end

    def raise_error_if_any
      raise @options[:exception].new('Exception from WebMock') if @options.has_key?(:exception)
    end

    def dup
      dup_response = super
      dup_response.options = options.dup
      dup_response
    end

    def ==(other)
      options == other.options
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webmock-0.8.0 lib/webmock/response.rb