Sha256: 8f53bc49096c93868190c130cc53027c3198d73ab56b87859eb563a0d1e61f46

Contents?: true

Size: 1.19 KB

Versions: 43

Compression:

Stored size: 1.19 KB

Contents

module WebMock

  class RequestSignature

    attr_accessor :method, :uri, :body
    attr_reader :headers

    def initialize(method, uri, options = {})
      self.method = method
      self.uri = uri.is_a?(Addressable::URI) ? uri : WebMock::Util::URI.normalize_uri(uri)
      assign_options(options)
    end

    def to_s
      string = "#{self.method.to_s.upcase}"
      string << " #{WebMock::Util::URI.strip_default_port_from_uri_string(self.uri.to_s)}"
      string << " with body '#{body.to_s}'" if body && body.to_s != ''
      if headers && !headers.empty?
        string << " with headers #{WebMock::Util::Headers.sorted_headers_string(headers)}"
      end
      string
    end

    def headers=(headers)
      @headers = WebMock::Util::Headers.normalize_headers(headers)
    end

    def hash
      self.to_s.hash
    end

    def eql?(other)
      self.to_s == other.to_s
    end
    alias == eql?

    def url_encoded?
      headers && headers['Content-Type'] == 'application/x-www-form-urlencoded'
    end

    private

    def assign_options(options)
      self.body = options[:body] if options.has_key?(:body)
      self.headers = options[:headers] if options.has_key?(:headers)
    end

  end

end

Version data entries

43 entries across 43 versions & 4 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/webmock-1.8.11/lib/webmock/request_signature.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/webmock-1.8.11/lib/webmock/request_signature.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/webmock-1.8.11/lib/webmock/request_signature.rb
whos_dated_who-0.1.0 vendor/bundle/gems/webmock-1.18.0/lib/webmock/request_signature.rb
whos_dated_who-0.0.1 vendor/bundle/gems/webmock-1.18.0/lib/webmock/request_signature.rb
webmock-1.18.0 lib/webmock/request_signature.rb
webmock-1.17.4 lib/webmock/request_signature.rb
webmock-1.17.3 lib/webmock/request_signature.rb
webmock-1.17.2 lib/webmock/request_signature.rb
webmock-1.17.1 lib/webmock/request_signature.rb
webmock-1.17.0 lib/webmock/request_signature.rb
webmock-1.16.1 lib/webmock/request_signature.rb
webmock-1.16.0 lib/webmock/request_signature.rb
webmock-1.15.2 lib/webmock/request_signature.rb
webmock-1.15.0 lib/webmock/request_signature.rb
webmock-1.14.0 lib/webmock/request_signature.rb
webmock-1.13.0 lib/webmock/request_signature.rb
webmock-1.12.3 lib/webmock/request_signature.rb
webmock-1.12.2 lib/webmock/request_signature.rb
webmock-1.12.1 lib/webmock/request_signature.rb