Sha256: b86fb6fa0282e1be1cd2fec0ea760df8ef84e992f91287e602918d3c8661c637

Contents?: true

Size: 674 Bytes

Versions: 2

Compression:

Stored size: 674 Bytes

Contents

module WebMock
  class Response

    def initialize(options = {})
      @options = options
    end

    def headers
      Util::Headers.normalize_headers(@options[:headers])
    end

    def body
      return '' unless @options.has_key?(:body)

      if !@options[:body].include?("\0") && File.exists?(@options[:body]) && !File.directory?(@options[:body])
        File.read(@options[:body])
      else
        @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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webmock-0.7.3 lib/webmock/response.rb
webmock-0.7.2 lib/webmock/response.rb