Skip to content
This repository
Newer
Older
100644 50 lines (38 sloc) 1.214 kb
30ff1e5d » Bartosz Blimke
2009-11-22 Introduced RequestSignature to normalize domain and make code more re…
1 module WebMock
2
effe928d » Bartosz Blimke
2010-04-10 Refactored request matching code.
3 class RequestSignature
30ff1e5d » Bartosz Blimke
2009-11-22 Introduced RequestSignature to normalize domain and make code more re…
4
561c6e12 »
2010-11-10 Added headers setter to request signature which normalizes headers be…
5 attr_accessor :method, :uri, :body
6 attr_reader :headers
30ff1e5d » Bartosz Blimke
2009-11-22 Introduced RequestSignature to normalize domain and make code more re…
7
effe928d » Bartosz Blimke
2010-04-10 Refactored request matching code.
8 def initialize(method, uri, options = {})
9 self.method = method
10 self.uri = uri.is_a?(Addressable::URI) ? uri : WebMock::Util::URI.normalize_uri(uri)
11 assign_options(options)
30ff1e5d » Bartosz Blimke
2009-11-22 Introduced RequestSignature to normalize domain and make code more re…
12 end
13
effe928d » Bartosz Blimke
2010-04-10 Refactored request matching code.
14 def to_s
15 string = "#{self.method.to_s.upcase}"
16 string << " #{WebMock::Util::URI.strip_default_port_from_uri_string(self.uri.to_s)}"
17 string << " with body '#{body.to_s}'" if body && body.to_s != ''
18 if headers && !headers.empty?
19 string << " with headers #{WebMock::Util::Headers.sorted_headers_string(headers)}"
30ff1e5d » Bartosz Blimke
2009-11-22 Introduced RequestSignature to normalize domain and make code more re…
20 end
effe928d » Bartosz Blimke
2010-04-10 Refactored request matching code.
21 string
30ff1e5d » Bartosz Blimke
2009-11-22 Introduced RequestSignature to normalize domain and make code more re…
22 end
23
561c6e12 »
2010-11-10 Added headers setter to request signature which normalizes headers be…
24 def headers=(headers)
25 @headers = WebMock::Util::Headers.normalize_headers(headers)
26 end
27
a2000773 »
2010-11-10 Ensure that two request signatures with the same values are treated a…
28 def hash
29 self.to_s.hash
30 end
31
32 def eql?(other)
33 self.to_s == other.to_s
34 end
90dd4bc7 » myronmarston
2012-01-28 Fix RequestSignature#==.
35 alias == eql?
a2000773 »
2010-11-10 Ensure that two request signatures with the same values are treated a…
36
037daf5f »
2011-08-08 Refactored request snipped logic to allow creating snippets from stub…
37 def url_encoded?
38 headers && headers['Content-Type'] == 'application/x-www-form-urlencoded'
39 end
40
effe928d » Bartosz Blimke
2010-04-10 Refactored request matching code.
41 private
30ff1e5d » Bartosz Blimke
2009-11-22 Introduced RequestSignature to normalize domain and make code more re…
42
effe928d » Bartosz Blimke
2010-04-10 Refactored request matching code.
43 def assign_options(options)
44 self.body = options[:body] if options.has_key?(:body)
561c6e12 »
2010-11-10 Added headers setter to request signature which normalizes headers be…
45 self.headers = options[:headers] if options.has_key?(:headers)
3097944b » porras
2009-12-17 "with" now accepts a block
46 end
30ff1e5d » Bartosz Blimke
2009-11-22 Introduced RequestSignature to normalize domain and make code more re…
47
effe928d » Bartosz Blimke
2010-04-10 Refactored request matching code.
48 end
30ff1e5d » Bartosz Blimke
2009-11-22 Introduced RequestSignature to normalize domain and make code more re…
49
50 end
Something went wrong with that request. Please try again.