webmock 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/Gemfile +2 -7
  4. data/README.md +54 -53
  5. data/Rakefile +1 -1
  6. data/lib/webmock/callback_registry.rb +1 -1
  7. data/lib/webmock/http_lib_adapters/curb_adapter.rb +68 -6
  8. data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +4 -4
  9. data/lib/webmock/http_lib_adapters/excon_adapter.rb +9 -9
  10. data/lib/webmock/http_lib_adapters/http_rb/request.rb +2 -2
  11. data/lib/webmock/http_lib_adapters/http_rb/response.rb +5 -5
  12. data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +3 -3
  13. data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +5 -5
  14. data/lib/webmock/http_lib_adapters/manticore_adapter.rb +7 -7
  15. data/lib/webmock/http_lib_adapters/net_http.rb +3 -3
  16. data/lib/webmock/http_lib_adapters/patron_adapter.rb +4 -4
  17. data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +14 -14
  18. data/lib/webmock/matchers/hash_including_matcher.rb +1 -1
  19. data/lib/webmock/rack_response.rb +3 -3
  20. data/lib/webmock/request_pattern.rb +8 -8
  21. data/lib/webmock/request_stub.rb +5 -5
  22. data/lib/webmock/util/uri.rb +2 -2
  23. data/lib/webmock/version.rb +1 -1
  24. data/minitest/webmock_spec.rb +3 -3
  25. data/spec/acceptance/curb/curb_spec.rb +64 -47
  26. data/spec/acceptance/curb/curb_spec_helper.rb +4 -4
  27. data/spec/acceptance/em_http_request/em_http_request_spec.rb +32 -32
  28. data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +9 -9
  29. data/spec/acceptance/excon/excon_spec.rb +14 -14
  30. data/spec/acceptance/excon/excon_spec_helper.rb +6 -6
  31. data/spec/acceptance/http_rb/http_rb_spec.rb +1 -1
  32. data/spec/acceptance/http_rb/http_rb_spec_helper.rb +7 -7
  33. data/spec/acceptance/httpclient/httpclient_spec.rb +20 -20
  34. data/spec/acceptance/httpclient/httpclient_spec_helper.rb +5 -5
  35. data/spec/acceptance/manticore/manticore_spec.rb +11 -11
  36. data/spec/acceptance/manticore/manticore_spec_helper.rb +3 -3
  37. data/spec/acceptance/net_http/net_http_shared.rb +4 -4
  38. data/spec/acceptance/net_http/net_http_spec.rb +25 -25
  39. data/spec/acceptance/net_http/net_http_spec_helper.rb +4 -4
  40. data/spec/acceptance/net_http/real_net_http_spec.rb +1 -1
  41. data/spec/acceptance/patron/patron_spec.rb +10 -10
  42. data/spec/acceptance/patron/patron_spec_helper.rb +5 -5
  43. data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +36 -36
  44. data/spec/acceptance/shared/callbacks.rb +11 -11
  45. data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +5 -5
  46. data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +4 -4
  47. data/spec/acceptance/shared/precedence_of_stubs.rb +4 -4
  48. data/spec/acceptance/shared/request_expectations.rb +90 -90
  49. data/spec/acceptance/shared/returning_declared_responses.rb +49 -49
  50. data/spec/acceptance/shared/stubbing_requests.rb +78 -78
  51. data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +11 -11
  52. data/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +8 -8
  53. data/spec/spec_helper.rb +6 -3
  54. data/spec/support/webmock_server.rb +1 -1
  55. data/spec/unit/api_spec.rb +2 -2
  56. data/spec/unit/errors_spec.rb +3 -3
  57. data/spec/unit/matchers/hash_including_matcher_spec.rb +16 -16
  58. data/spec/unit/rack_response_spec.rb +2 -2
  59. data/spec/unit/request_body_diff_spec.rb +1 -1
  60. data/spec/unit/request_execution_verifier_spec.rb +1 -1
  61. data/spec/unit/request_pattern_spec.rb +115 -115
  62. data/spec/unit/request_signature_snippet_spec.rb +2 -2
  63. data/spec/unit/request_signature_spec.rb +16 -16
  64. data/spec/unit/request_stub_spec.rb +20 -20
  65. data/spec/unit/response_spec.rb +28 -28
  66. data/spec/unit/stub_registry_spec.rb +10 -10
  67. data/spec/unit/stub_request_snippet_spec.rb +6 -6
  68. data/spec/unit/util/hash_keys_stringifier_spec.rb +4 -4
  69. data/spec/unit/util/query_mapper_spec.rb +2 -2
  70. data/spec/unit/util/uri_spec.rb +1 -1
  71. data/test/http_request.rb +3 -3
  72. data/test/shared_test.rb +6 -6
  73. data/webmock.gemspec +4 -2
  74. metadata +32 -4
@@ -13,7 +13,7 @@ RSpec.describe WebMock::RequestSignatureSnippet do
13
13
 
14
14
  let(:request_pattern) {
15
15
  WebMock::RequestPattern.new(
16
- method, uri, {:body => request_signature_body}
16
+ method, uri, {body: request_signature_body}
17
17
  )
18
18
  }
19
19
 
@@ -48,7 +48,7 @@ RSpec.describe WebMock::RequestSignatureSnippet do
48
48
 
49
49
  describe "#request_stubs" do
50
50
  before :each do
51
- WebMock.stub_request(:get, "https://www.example.com").with(:body => {"a" => "b"})
51
+ WebMock.stub_request(:get, "https://www.example.com").with(body: {"a" => "b"})
52
52
  end
53
53
 
54
54
  context "when showing the body diff is turned off" do
@@ -20,23 +20,23 @@ describe WebMock::RequestSignature do
20
20
  it "assigns normalized headers" do
21
21
  expect(WebMock::Util::Headers).to receive(:normalize_headers).with('A' => 'a').and_return('B' => 'b')
22
22
  expect(
23
- WebMock::RequestSignature.new(:get, "www.example.com", :headers => {'A' => 'a'}).headers
23
+ WebMock::RequestSignature.new(:get, "www.example.com", headers: {'A' => 'a'}).headers
24
24
  ).to eq({'B' => 'b'})
25
25
  end
26
26
 
27
27
  it "assign the body" do
28
- expect(WebMock::RequestSignature.new(:get, "www.example.com", :body => "abc").body).to eq("abc")
28
+ expect(WebMock::RequestSignature.new(:get, "www.example.com", body: "abc").body).to eq("abc")
29
29
  end
30
30
 
31
31
  it "symbolizes the method" do
32
- expect(WebMock::RequestSignature.new('get', "www.example.com", :body => "abc").method).to eq(:get)
32
+ expect(WebMock::RequestSignature.new('get', "www.example.com", body: "abc").method).to eq(:get)
33
33
  end
34
34
  end
35
35
 
36
36
  describe "#to_s" do
37
37
  it "describes itself" do
38
38
  expect(WebMock::RequestSignature.new(:get, "www.example.com",
39
- :body => "abc", :headers => {'A' => 'a', 'B' => 'b'}).to_s).to eq(
39
+ body: "abc", headers: {'A' => 'a', 'B' => 'b'}).to_s).to eq(
40
40
  "GET http://www.example.com/ with body 'abc' with headers {'A'=>'a', 'B'=>'b'}"
41
41
  )
42
42
  end
@@ -45,9 +45,9 @@ describe WebMock::RequestSignature do
45
45
  describe "#hash" do
46
46
  it "reporst same hash for two signatures with the same values" do
47
47
  signature1 = WebMock::RequestSignature.new(:get, "www.example.com",
48
- :body => "abc", :headers => {'A' => 'a', 'B' => 'b'})
48
+ body: "abc", headers: {'A' => 'a', 'B' => 'b'})
49
49
  signature2 = WebMock::RequestSignature.new(:get, "www.example.com",
50
- :body => "abc", :headers => {'A' => 'a', 'B' => 'b'})
50
+ body: "abc", headers: {'A' => 'a', 'B' => 'b'})
51
51
  expect(signature1.hash).to eq(signature2.hash)
52
52
  end
53
53
 
@@ -64,16 +64,16 @@ describe WebMock::RequestSignature do
64
64
  end
65
65
 
66
66
  it "reports different hash for two signatures with different body" do
67
- signature1 = WebMock::RequestSignature.new(:get, "www.example.com", :body => "abc")
68
- signature2 = WebMock::RequestSignature.new(:get, "www.example.com", :body => "def")
67
+ signature1 = WebMock::RequestSignature.new(:get, "www.example.com", body: "abc")
68
+ signature2 = WebMock::RequestSignature.new(:get, "www.example.com", body: "def")
69
69
  expect(signature1.hash).not_to eq(signature2.hash)
70
70
  end
71
71
 
72
72
  it "reports different hash for two signatures with different headers" do
73
73
  signature1 = WebMock::RequestSignature.new(:get, "www.example.com",
74
- :headers => {'A' => 'a'})
74
+ headers: {'A' => 'a'})
75
75
  signature2 = WebMock::RequestSignature.new(:get, "www.example.com",
76
- :headers => {'A' => 'A'})
76
+ headers: {'A' => 'A'})
77
77
  expect(signature1.hash).not_to eq(signature2.hash)
78
78
  end
79
79
  end
@@ -82,9 +82,9 @@ describe WebMock::RequestSignature do
82
82
  describe method do
83
83
  it "is true for two signatures with the same values" do
84
84
  signature1 = WebMock::RequestSignature.new(:get, "www.example.com",
85
- :body => "abc", :headers => {'A' => 'a', 'B' => 'b'})
85
+ body: "abc", headers: {'A' => 'a', 'B' => 'b'})
86
86
  signature2 = WebMock::RequestSignature.new(:get, "www.example.com",
87
- :body => "abc", :headers => {'A' => 'a', 'B' => 'b'})
87
+ body: "abc", headers: {'A' => 'a', 'B' => 'b'})
88
88
 
89
89
  expect(signature1.send(method, signature2)).to be_truthy
90
90
  end
@@ -102,16 +102,16 @@ describe WebMock::RequestSignature do
102
102
  end
103
103
 
104
104
  it "is false for two signatures with different body" do
105
- signature1 = WebMock::RequestSignature.new(:get, "www.example.com", :body => "abc")
106
- signature2 = WebMock::RequestSignature.new(:get, "www.example.com", :body => "def")
105
+ signature1 = WebMock::RequestSignature.new(:get, "www.example.com", body: "abc")
106
+ signature2 = WebMock::RequestSignature.new(:get, "www.example.com", body: "def")
107
107
  expect(signature1.send(method, signature2)).to be_falsey
108
108
  end
109
109
 
110
110
  it "is false for two signatures with different headers" do
111
111
  signature1 = WebMock::RequestSignature.new(:get, "www.example.com",
112
- :headers => {'A' => 'a'})
112
+ headers: {'A' => 'a'})
113
113
  signature2 = WebMock::RequestSignature.new(:get, "www.example.com",
114
- :headers => {'A' => 'A'})
114
+ headers: {'A' => 'A'})
115
115
  expect(signature1.send(method, signature2)).to be_falsey
116
116
  end
117
117
  end
@@ -17,20 +17,20 @@ describe WebMock::RequestStub do
17
17
  describe "with" do
18
18
 
19
19
  it "should assign body to request pattern" do
20
- @request_stub.with(:body => "abc")
21
- expect(@request_stub.request_pattern.to_s).to eq(WebMock::RequestPattern.new(:get, "www.example.com", :body => "abc").to_s)
20
+ @request_stub.with(body: "abc")
21
+ expect(@request_stub.request_pattern.to_s).to eq(WebMock::RequestPattern.new(:get, "www.example.com", body: "abc").to_s)
22
22
  end
23
23
 
24
24
  it "should assign normalized headers to request pattern" do
25
- @request_stub.with(:headers => {'A' => 'a'})
25
+ @request_stub.with(headers: {'A' => 'a'})
26
26
  expect(@request_stub.request_pattern.to_s).to eq(
27
- WebMock::RequestPattern.new(:get, "www.example.com", :headers => {'A' => 'a'}).to_s
27
+ WebMock::RequestPattern.new(:get, "www.example.com", headers: {'A' => 'a'}).to_s
28
28
  )
29
29
  end
30
30
 
31
31
  it "should assign given block to request profile" do
32
32
  @request_stub.with { |req| req.body == "abc" }
33
- expect(@request_stub.request_pattern.matches?(WebMock::RequestSignature.new(:get, "www.example.com", :body => "abc"))).to be_truthy
33
+ expect(@request_stub.request_pattern.matches?(WebMock::RequestSignature.new(:get, "www.example.com", body: "abc"))).to be_truthy
34
34
  end
35
35
 
36
36
  end
@@ -38,13 +38,13 @@ describe WebMock::RequestStub do
38
38
  describe "to_return" do
39
39
 
40
40
  it "should assign response with provided options" do
41
- @request_stub.to_return(:body => "abc", :status => 500)
41
+ @request_stub.to_return(body: "abc", status: 500)
42
42
  expect(@request_stub.response.body).to eq("abc")
43
43
  expect(@request_stub.response.status).to eq([500, ""])
44
44
  end
45
45
 
46
46
  it "should assign responses with provided options" do
47
- @request_stub.to_return([{:body => "abc"}, {:body => "def"}])
47
+ @request_stub.to_return([{body: "abc"}, {body: "def"}])
48
48
  expect([@request_stub.response.body, @request_stub.response.body]).to eq(["abc", "def"])
49
49
  end
50
50
 
@@ -59,26 +59,26 @@ describe WebMock::RequestStub do
59
59
  describe "response" do
60
60
 
61
61
  it "should return responses in a sequence passed as array" do
62
- @request_stub.to_return([{:body => "abc"}, {:body => "def"}])
62
+ @request_stub.to_return([{body: "abc"}, {body: "def"}])
63
63
  expect(@request_stub.response.body).to eq("abc")
64
64
  expect(@request_stub.response.body).to eq("def")
65
65
  end
66
66
 
67
67
  it "should repeat returning last response" do
68
- @request_stub.to_return([{:body => "abc"}, {:body => "def"}])
68
+ @request_stub.to_return([{body: "abc"}, {body: "def"}])
69
69
  @request_stub.response
70
70
  @request_stub.response
71
71
  expect(@request_stub.response.body).to eq("def")
72
72
  end
73
73
 
74
74
  it "should return responses in a sequence passed as comma separated params" do
75
- @request_stub.to_return({:body => "abc"}, {:body => "def"})
75
+ @request_stub.to_return({body: "abc"}, {body: "def"})
76
76
  expect(@request_stub.response.body).to eq("abc")
77
77
  expect(@request_stub.response.body).to eq("def")
78
78
  end
79
79
 
80
80
  it "should return responses declared in multiple to_return declarations" do
81
- @request_stub.to_return({:body => "abc"}).to_return({:body => "def"})
81
+ @request_stub.to_return({body: "abc"}).to_return({body: "def"})
82
82
  expect(@request_stub.response.body).to eq("abc")
83
83
  expect(@request_stub.response.body).to eq("def")
84
84
  end
@@ -95,7 +95,7 @@ describe WebMock::RequestStub do
95
95
  end
96
96
 
97
97
  it "should assign sequence of responses with response with exception to be thrown" do
98
- @request_stub.to_return(:body => "abc").then.to_raise(ArgumentError)
98
+ @request_stub.to_return(body: "abc").then.to_raise(ArgumentError)
99
99
  expect(@request_stub.response.body).to eq("abc")
100
100
  expect {
101
101
  @request_stub.response.raise_error_if_any
@@ -132,13 +132,13 @@ describe WebMock::RequestStub do
132
132
  end
133
133
 
134
134
  it "should assign sequence of responses with response with timeout" do
135
- @request_stub.to_return(:body => "abc").then.to_timeout
135
+ @request_stub.to_return(body: "abc").then.to_timeout
136
136
  expect(@request_stub.response.body).to eq("abc")
137
137
  expect(@request_stub.response.should_timeout).to be_truthy
138
138
  end
139
139
 
140
140
  it "should allow multiple timeouts to be declared" do
141
- @request_stub.to_timeout.then.to_timeout.then.to_return(:body => "abc")
141
+ @request_stub.to_timeout.then.to_timeout.then.to_return(body: "abc")
142
142
  expect(@request_stub.response.should_timeout).to be_truthy
143
143
  expect(@request_stub.response.should_timeout).to be_truthy
144
144
  expect(@request_stub.response.body).to eq("abc")
@@ -156,21 +156,21 @@ describe WebMock::RequestStub do
156
156
  end
157
157
 
158
158
  it "should repeat returning last declared response declared number of times" do
159
- @request_stub.to_return({:body => "abc"}).times(2).then.to_return({:body => "def"})
159
+ @request_stub.to_return({body: "abc"}).times(2).then.to_return({body: "def"})
160
160
  expect(@request_stub.response.body).to eq("abc")
161
161
  expect(@request_stub.response.body).to eq("abc")
162
162
  expect(@request_stub.response.body).to eq("def")
163
163
  end
164
164
 
165
165
  it "should repeat raising last declared exception declared number of times" do
166
- @request_stub.to_return({:body => "abc"}).times(2).then.to_return({:body => "def"})
166
+ @request_stub.to_return({body: "abc"}).times(2).then.to_return({body: "def"})
167
167
  expect(@request_stub.response.body).to eq("abc")
168
168
  expect(@request_stub.response.body).to eq("abc")
169
169
  expect(@request_stub.response.body).to eq("def")
170
170
  end
171
171
 
172
172
  it "should repeat returning last declared sequence of responses declared number of times" do
173
- @request_stub.to_return({:body => "abc"}, {:body => "def"}).times(2).then.to_return({:body => "ghj"})
173
+ @request_stub.to_return({body: "abc"}, {body: "def"}).times(2).then.to_return({body: "ghj"})
174
174
  expect(@request_stub.response.body).to eq("abc")
175
175
  expect(@request_stub.response.body).to eq("def")
176
176
  expect(@request_stub.response.body).to eq("abc")
@@ -179,18 +179,18 @@ describe WebMock::RequestStub do
179
179
  end
180
180
 
181
181
  it "should return self" do
182
- expect(@request_stub.to_return({:body => "abc"}).times(1)).to eq(@request_stub)
182
+ expect(@request_stub.to_return({body: "abc"}).times(1)).to eq(@request_stub)
183
183
  end
184
184
 
185
185
  it "should raise error if argument is not integer" do
186
186
  expect {
187
- @request_stub.to_return({:body => "abc"}).times("not number")
187
+ @request_stub.to_return({body: "abc"}).times("not number")
188
188
  }.to raise_error("times(N) accepts integers >= 1 only")
189
189
  end
190
190
 
191
191
  it "should raise error if argument is < 1" do
192
192
  expect {
193
- @request_stub.to_return({:body => "abc"}).times(0)
193
+ @request_stub.to_return({body: "abc"}).times(0)
194
194
  }.to raise_error("times(N) accepts integers >= 1 only")
195
195
  end
196
196
 
@@ -5,14 +5,14 @@ describe WebMock::ResponseFactory do
5
5
  describe "response_for" do
6
6
 
7
7
  it "should create response with options passed as arguments" do
8
- options = {:body => "abc", :headers => {:a => :b}}
8
+ options = {body: "abc", headers: {a: :b}}
9
9
  expect(WebMock::Response).to receive(:new).with(options).and_return(@response = double(WebMock::Response))
10
10
  expect(WebMock::ResponseFactory.response_for(options)).to eq(@response)
11
11
  end
12
12
 
13
13
 
14
14
  it "should create dynamic response for argument responding to call" do
15
- callable = double(:call => {:body => "abc"})
15
+ callable = double(call: {body: "abc"})
16
16
  expect(WebMock::DynamicResponse).to receive(:new).with(callable).and_return(@response = double(WebMock::Response))
17
17
  expect(WebMock::ResponseFactory.response_for(callable)).to eq(@response)
18
18
  end
@@ -23,16 +23,16 @@ end
23
23
 
24
24
  describe WebMock::Response do
25
25
  before(:each) do
26
- @response = WebMock::Response.new(:headers => {'A' => 'a'})
26
+ @response = WebMock::Response.new(headers: {'A' => 'a'})
27
27
  end
28
28
 
29
29
  it "should raise an error when initialized with unknown option" do
30
- expect { WebMock::Response.new(:foo => "bar") }.to raise_error('Unknown key: "foo". Valid keys are: "headers", "status", "body", "exception", "should_timeout"')
30
+ expect { WebMock::Response.new(foo: "bar") }.to raise_error('Unknown key: "foo". Valid keys are: "headers", "status", "body", "exception", "should_timeout"')
31
31
  end
32
32
 
33
33
  it "should report normalized headers" do
34
34
  expect(WebMock::Util::Headers).to receive(:normalize_headers).with('A' => 'a').and_return('B' => 'b')
35
- @response = WebMock::Response.new(:headers => {'A' => 'a'})
35
+ @response = WebMock::Response.new(headers: {'A' => 'a'})
36
36
  expect(@response.headers).to eq({'B' => 'b'})
37
37
  end
38
38
 
@@ -42,12 +42,12 @@ describe WebMock::Response do
42
42
  end
43
43
 
44
44
  it "should return assigned status" do
45
- @response = WebMock::Response.new(:status => 500)
45
+ @response = WebMock::Response.new(status: 500)
46
46
  expect(@response.status).to eq([500, ""])
47
47
  end
48
48
 
49
49
  it "should return assigned message" do
50
- @response = WebMock::Response.new(:status => [500, "Internal Server Error"])
50
+ @response = WebMock::Response.new(status: [500, "Internal Server Error"])
51
51
  expect(@response.status).to eq([500, "Internal Server Error"])
52
52
  end
53
53
  end
@@ -55,21 +55,21 @@ describe WebMock::Response do
55
55
  describe "raising error" do
56
56
 
57
57
  it "should raise error if any assigned" do
58
- @response = WebMock::Response.new(:exception => ArgumentError)
58
+ @response = WebMock::Response.new(exception: ArgumentError)
59
59
  expect {
60
60
  @response.raise_error_if_any
61
61
  }.to raise_error(ArgumentError, "Exception from WebMock")
62
62
  end
63
63
 
64
64
  it "should raise error if any assigned as instance" do
65
- @response = WebMock::Response.new(:exception => ArgumentError.new("hello world"))
65
+ @response = WebMock::Response.new(exception: ArgumentError.new("hello world"))
66
66
  expect {
67
67
  @response.raise_error_if_any
68
68
  }.to raise_error(ArgumentError, "hello world")
69
69
  end
70
70
 
71
71
  it "should raise error if any assigned as string" do
72
- @response = WebMock::Response.new(:exception => "hello world")
72
+ @response = WebMock::Response.new(exception: "hello world")
73
73
  expect {
74
74
  @response.raise_error_if_any
75
75
  }.to raise_error("hello world")
@@ -84,7 +84,7 @@ describe WebMock::Response do
84
84
  describe "timeout" do
85
85
 
86
86
  it "should know if it should timeout" do
87
- @response = WebMock::Response.new(:should_timeout => true)
87
+ @response = WebMock::Response.new(should_timeout: true)
88
88
  expect(@response.should_timeout).to be_truthy
89
89
  end
90
90
 
@@ -102,28 +102,28 @@ describe WebMock::Response do
102
102
  end
103
103
 
104
104
  it "should report body if assigned" do
105
- @response = WebMock::Response.new(:body => "abc")
105
+ @response = WebMock::Response.new(body: "abc")
106
106
  expect(@response.body).to eq("abc")
107
107
  end
108
108
 
109
109
  it "should report string even if existing file path was provided" do
110
- @response = WebMock::Response.new(:body => __FILE__)
110
+ @response = WebMock::Response.new(body: __FILE__)
111
111
  expect(@response.body).to eq(__FILE__)
112
112
  end
113
113
 
114
114
  it "should report content of a IO object if provided" do
115
- @response = WebMock::Response.new(:body => File.new(__FILE__))
115
+ @response = WebMock::Response.new(body: File.new(__FILE__))
116
116
  expect(@response.body).to eq(File.read(__FILE__))
117
117
  end
118
118
 
119
119
  it "should report many times content of a IO object if provided" do
120
- @response = WebMock::Response.new(:body => File.new(__FILE__))
120
+ @response = WebMock::Response.new(body: File.new(__FILE__))
121
121
  expect(@response.body).to eq(File.read(__FILE__))
122
122
  expect(@response.body).to eq(File.read(__FILE__))
123
123
  end
124
124
 
125
125
  it "should work with Pathnames" do
126
- @response = WebMock::Response.new(:body => Pathname.new(__FILE__))
126
+ @response = WebMock::Response.new(body: Pathname.new(__FILE__))
127
127
  expect(@response.body).to eq(File.read(__FILE__))
128
128
  end
129
129
 
@@ -131,7 +131,7 @@ describe WebMock::Response do
131
131
  # body to return a hash, to prevent this:
132
132
  #
133
133
  it "should error if not given one of the allowed types" do
134
- expect { WebMock::Response.new(:body => Hash.new) }.to \
134
+ expect { WebMock::Response.new(body: Hash.new) }.to \
135
135
  raise_error(WebMock::Response::InvalidBody)
136
136
  end
137
137
 
@@ -205,21 +205,21 @@ describe WebMock::Response do
205
205
  describe "with dynamically evaluated options" do
206
206
 
207
207
  before(:each) do
208
- @request_signature = WebMock::RequestSignature.new(:post, "www.example.com", :body => "abc", :headers => {'A' => 'a'})
208
+ @request_signature = WebMock::RequestSignature.new(:post, "www.example.com", body: "abc", headers: {'A' => 'a'})
209
209
  end
210
210
 
211
211
  it "should have evaluated body" do
212
- @response = WebMock::Response.new(:body => lambda {|request| request.body})
212
+ @response = WebMock::Response.new(body: lambda {|request| request.body})
213
213
  expect(@response.evaluate(@request_signature).body).to eq("abc")
214
214
  end
215
215
 
216
216
  it "should have evaluated headers" do
217
- @response = WebMock::Response.new(:headers => lambda {|request| request.headers})
217
+ @response = WebMock::Response.new(headers: lambda {|request| request.headers})
218
218
  expect(@response.evaluate(@request_signature).headers).to eq({'A' => 'a'})
219
219
  end
220
220
 
221
221
  it "should have evaluated status" do
222
- @response = WebMock::Response.new(:status => lambda {|request| 302})
222
+ @response = WebMock::Response.new(status: lambda {|request| 302})
223
223
  expect(@response.evaluate(@request_signature).status).to eq([302, ""])
224
224
  end
225
225
 
@@ -232,12 +232,12 @@ describe WebMock::Response do
232
232
  describe "evaluating response options" do
233
233
 
234
234
  it "should evaluate new response with evaluated options" do
235
- request_signature = WebMock::RequestSignature.new(:post, "www.example.com", :body => "abc", :headers => {'A' => 'a'})
235
+ request_signature = WebMock::RequestSignature.new(:post, "www.example.com", body: "abc", headers: {'A' => 'a'})
236
236
  response = WebMock::DynamicResponse.new(lambda {|request|
237
237
  {
238
- :body => request.body,
239
- :headers => request.headers,
240
- :status => 302
238
+ body: request.body,
239
+ headers: request.headers,
240
+ status: 302
241
241
  }
242
242
  })
243
243
  evaluated_response = response.evaluate(request_signature)
@@ -247,10 +247,10 @@ describe WebMock::Response do
247
247
  end
248
248
 
249
249
  it "should be equal to static response after evaluation" do
250
- request_signature = WebMock::RequestSignature.new(:post, "www.example.com", :body => "abc")
251
- response = WebMock::DynamicResponse.new(lambda {|request| {:body => request.body}})
250
+ request_signature = WebMock::RequestSignature.new(:post, "www.example.com", body: "abc")
251
+ response = WebMock::DynamicResponse.new(lambda {|request| {body: request.body}})
252
252
  evaluated_response = response.evaluate(request_signature)
253
- expect(evaluated_response).to eq(WebMock::Response.new(:body => "abc"))
253
+ expect(evaluated_response).to eq(WebMock::Response.new(body: "abc"))
254
254
  end
255
255
 
256
256
  describe "when raw response is evaluated" do
@@ -51,21 +51,21 @@ describe WebMock::StubRegistry do
51
51
  describe "response for request" do
52
52
 
53
53
  it "should report registered evaluated response for request pattern" do
54
- @request_stub.to_return(:body => "abc")
54
+ @request_stub.to_return(body: "abc")
55
55
  WebMock::StubRegistry.instance.register_request_stub(@request_stub)
56
56
  expect(WebMock::StubRegistry.instance.response_for_request(@request_signature)).
57
- to eq(WebMock::Response.new(:body => "abc"))
57
+ to eq(WebMock::Response.new(body: "abc"))
58
58
  end
59
59
 
60
60
  it "should report evaluated response" do
61
- @request_stub.to_return {|request| {:body => request.method.to_s} }
61
+ @request_stub.to_return {|request| {body: request.method.to_s} }
62
62
  WebMock::StubRegistry.instance.register_request_stub(@request_stub)
63
63
  response1 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
64
- expect(response1).to eq(WebMock::Response.new(:body => "get"))
64
+ expect(response1).to eq(WebMock::Response.new(body: "get"))
65
65
  end
66
66
 
67
67
  it "should report clone of the response" do
68
- @request_stub.to_return(:body => lambda{|r| r.method.to_s})
68
+ @request_stub.to_return(body: lambda{|r| r.method.to_s})
69
69
  WebMock::StubRegistry.instance.register_request_stub(@request_stub)
70
70
  response1 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
71
71
  response2 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
@@ -73,7 +73,7 @@ describe WebMock::StubRegistry do
73
73
  end
74
74
 
75
75
  it "should report clone of the dynamic response" do
76
- @request_stub.to_return {|request| {:body => request.method.to_s} }
76
+ @request_stub.to_return {|request| {body: request.method.to_s} }
77
77
  WebMock::StubRegistry.instance.register_request_stub(@request_stub)
78
78
  response1 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
79
79
  response2 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
@@ -86,16 +86,16 @@ describe WebMock::StubRegistry do
86
86
 
87
87
  it "should always return last registered matching response" do
88
88
  @request_stub1 = WebMock::RequestStub.new(:get, "www.example.com")
89
- @request_stub1.to_return(:body => "abc")
89
+ @request_stub1.to_return(body: "abc")
90
90
  @request_stub2 = WebMock::RequestStub.new(:get, "www.example.com")
91
- @request_stub2.to_return(:body => "def")
91
+ @request_stub2.to_return(body: "def")
92
92
  @request_stub3 = WebMock::RequestStub.new(:get, "www.example.org")
93
- @request_stub3.to_return(:body => "ghj")
93
+ @request_stub3.to_return(body: "ghj")
94
94
  WebMock::StubRegistry.instance.register_request_stub(@request_stub1)
95
95
  WebMock::StubRegistry.instance.register_request_stub(@request_stub2)
96
96
  WebMock::StubRegistry.instance.register_request_stub(@request_stub3)
97
97
  expect(WebMock::StubRegistry.instance.response_for_request(@request_signature)).
98
- to eq(WebMock::Response.new(:body => "def"))
98
+ to eq(WebMock::Response.new(body: "def"))
99
99
  end
100
100
 
101
101
  end