webmock 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -37,10 +37,10 @@ module NetHTTPSpecHelper
37
37
  headers = {}
38
38
  response.each_header {|name, value| headers[name] = value}
39
39
  OpenStruct.new({
40
- :body => response.body,
41
- :headers => WebMock::Util::Headers.normalize_headers(headers),
42
- :status => response.code,
43
- :message => response.message
40
+ body: response.body,
41
+ headers: WebMock::Util::Headers.normalize_headers(headers),
42
+ status: response.code,
43
+ message: response.message
44
44
  })
45
45
  end
46
46
 
@@ -6,7 +6,7 @@ require 'stringio'
6
6
  require 'acceptance/net_http/net_http_shared'
7
7
  require 'support/webmock_server'
8
8
 
9
- describe "Real Net:HTTP without webmock", :without_webmock => true do
9
+ describe "Real Net:HTTP without webmock", without_webmock: true do
10
10
  before(:all) do
11
11
  raise "WebMock has no access here!!!" if defined?(WebMock::NetHTTPUtility)
12
12
  WebMockServer.instance.start
@@ -32,7 +32,7 @@ unless RUBY_PLATFORM =~ /java/
32
32
  end
33
33
 
34
34
  it "should work with get_file" do
35
- stub_request(:get, "www.example.com").to_return(:body => "abc")
35
+ stub_request(:get, "www.example.com").to_return(body: "abc")
36
36
  @sess.get_file("/", @file_path)
37
37
  expect(File.read(@file_path)).to eq("abc")
38
38
  end
@@ -53,18 +53,18 @@ unless RUBY_PLATFORM =~ /java/
53
53
 
54
54
  it "should work with put_file" do
55
55
  File.open(@file_path, "w") {|f| f.write "abc"}
56
- stub_request(:put, "www.example.com").with(:body => "abc")
56
+ stub_request(:put, "www.example.com").with(body: "abc")
57
57
  @sess.put_file("/", @file_path)
58
58
  end
59
59
 
60
60
  it "should work with post_file" do
61
61
  File.open(@file_path, "w") {|f| f.write "abc"}
62
- stub_request(:post, "www.example.com").with(:body => "abc")
62
+ stub_request(:post, "www.example.com").with(body: "abc")
63
63
  @sess.post_file("/", @file_path)
64
64
  end
65
65
 
66
66
  it "should raise same error as Patron if file is not readable for post request" do
67
- stub_request(:post, "www.example.com").with(:body => "abc")
67
+ stub_request(:post, "www.example.com").with(body: "abc")
68
68
  expect {
69
69
  @sess.post_file("/", "/path/to/non/existing/file")
70
70
  }.to raise_error(ArgumentError, "Unable to open specified file.")
@@ -82,7 +82,7 @@ unless RUBY_PLATFORM =~ /java/
82
82
  end
83
83
 
84
84
  it "should work with WebDAV copy request" do
85
- stub_request(:copy, "www.example.com/abc").with(:headers => {'Destination' => "/def"})
85
+ stub_request(:copy, "www.example.com/abc").with(headers: {'Destination' => "/def"})
86
86
  @sess.copy("/abc", "/def")
87
87
  end
88
88
 
@@ -97,22 +97,22 @@ unless RUBY_PLATFORM =~ /java/
97
97
 
98
98
  it "should encode body with default encoding" do
99
99
  stub_request(:get, "www.example.com").
100
- to_return(:body => "Øl")
100
+ to_return(body: "Øl")
101
101
 
102
102
  expect(@sess.get("").body.encoding).to eq(Encoding::UTF_8)
103
103
  end
104
104
 
105
105
  it "should encode body to default internal" do
106
106
  stub_request(:get, "www.example.com").
107
- to_return(:headers => {'Content-Type' => 'text/html; charset=iso-8859-1'},
108
- :body => "Øl".encode("iso-8859-1"))
107
+ to_return(headers: {'Content-Type' => 'text/html; charset=iso-8859-1'},
108
+ body: "Øl".encode("iso-8859-1"))
109
109
 
110
110
  expect(@sess.get("").body.encoding).to eq(Encoding.default_internal)
111
111
  end
112
112
 
113
113
  it "should encode body based on encoding-attribute in body" do
114
114
  stub_request(:get, "www.example.com").
115
- to_return(:body => "<?xml encoding=\"iso-8859-1\">Øl</xml>".encode("iso-8859-1"))
115
+ to_return(body: "<?xml encoding=\"iso-8859-1\">Øl</xml>".encode("iso-8859-1"))
116
116
 
117
117
  expect(@sess.get("").body.encoding).to eq(Encoding::ISO_8859_1)
118
118
  end
@@ -120,7 +120,7 @@ unless RUBY_PLATFORM =~ /java/
120
120
 
121
121
  it "should encode body based on Session#default_response_charset" do
122
122
  stub_request(:get, "www.example.com").
123
- to_return(:body => "Øl".encode("iso-8859-1"))
123
+ to_return(body: "Øl".encode("iso-8859-1"))
124
124
 
125
125
  @sess.default_response_charset = "iso-8859-1"
126
126
 
@@ -18,7 +18,7 @@ module PatronSpecHelper
18
18
  uri = "#{uri.path}#{uri.query ? '?' : ''}#{uri.query}"
19
19
  uri.gsub!(' ','%20')
20
20
  response = sess.request(method, uri, options[:headers] || {}, {
21
- :data => options[:body]
21
+ data: options[:body]
22
22
  })
23
23
  headers = {}
24
24
  if response.headers
@@ -32,10 +32,10 @@ module PatronSpecHelper
32
32
  message = response.status_line.match(status_line_pattern)[3] || ""
33
33
 
34
34
  OpenStruct.new({
35
- :body => response.body,
36
- :headers => WebMock::Util::Headers.normalize_headers(headers),
37
- :status => response.status.to_s,
38
- :message => message
35
+ body: response.body,
36
+ headers: WebMock::Util::Headers.normalize_headers(headers),
37
+ status: response.status.to_s,
38
+ message: message
39
39
  })
40
40
  end
41
41
 
@@ -1,6 +1,6 @@
1
1
  shared_context "allowing and disabling net connect" do |*adapter_info|
2
2
  describe "when net connect" do
3
- describe "is allowed", :net_connect => true do
3
+ describe "is allowed", net_connect: true do
4
4
  before(:each) do
5
5
  WebMock.allow_net_connect!
6
6
  end
@@ -16,9 +16,9 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
16
16
  result = result.encode(
17
17
  'UTF-8',
18
18
  'binary',
19
- :invalid => :replace,
20
- :undef => :replace,
21
- :replace => ''
19
+ invalid: :replace,
20
+ undef: :replace,
21
+ replace: ''
22
22
  )
23
23
  end
24
24
  expect(result).to match(/.*google.*/)
@@ -26,7 +26,7 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
26
26
  end
27
27
 
28
28
  it "should return stubbed response if request was stubbed" do
29
- stub_request(:get, "www.example.com").to_return(:body => "abc")
29
+ stub_request(:get, "www.example.com").to_return(body: "abc")
30
30
  expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
31
31
  end
32
32
  end
@@ -37,12 +37,12 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
37
37
  end
38
38
 
39
39
  it "should return stubbed response if request was stubbed" do
40
- stub_request(:get, "www.example.com").to_return(:body => "abc")
40
+ stub_request(:get, "www.example.com").to_return(body: "abc")
41
41
  expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
42
42
  end
43
43
 
44
44
  it "should return stubbed response if request with path was stubbed" do
45
- stub_request(:get, "www.example.com/hello_world").to_return(:body => "abc")
45
+ stub_request(:get, "www.example.com/hello_world").to_return(body: "abc")
46
46
  expect(http_request(:get, "http://www.example.com/hello_world").body).to eq("abc")
47
47
  end
48
48
 
@@ -55,11 +55,11 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
55
55
 
56
56
  describe "is not allowed with exception for localhost" do
57
57
  before(:each) do
58
- WebMock.disable_net_connect!(:allow_localhost => true)
58
+ WebMock.disable_net_connect!(allow_localhost: true)
59
59
  end
60
60
 
61
61
  it "should return stubbed response if request was stubbed" do
62
- stub_request(:get, "www.example.com").to_return(:body => "abc")
62
+ stub_request(:get, "www.example.com").to_return(body: "abc")
63
63
  expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
64
64
  end
65
65
 
@@ -91,12 +91,12 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
91
91
  describe "is not allowed, with exceptions" do
92
92
  describe "allowing by host string" do
93
93
  before :each do
94
- WebMock.disable_net_connect!(:allow => 'httpstat.us')
94
+ WebMock.disable_net_connect!(allow: 'httpstat.us')
95
95
  end
96
96
 
97
97
  context "when the host is not allowed" do
98
98
  it "should return stubbed response if request was stubbed" do
99
- stub_request(:get, 'disallowed.example.com/foo').to_return(:body => "abc")
99
+ stub_request(:get, 'disallowed.example.com/foo').to_return(body: "abc")
100
100
  expect(http_request(:get, 'http://disallowed.example.com/foo').body).to eq("abc")
101
101
  end
102
102
 
@@ -109,12 +109,12 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
109
109
 
110
110
  context "when the host is allowed" do
111
111
  it "should return stubbed response if request was stubbed" do
112
- stub_request(:get, 'httpstat.us/200').to_return(:body => "abc")
112
+ stub_request(:get, 'httpstat.us/200').to_return(body: "abc")
113
113
  expect(http_request(:get, "http://httpstat.us/200").body).to eq("abc")
114
114
  end
115
115
 
116
116
  # WARNING: this makes a real HTTP request!
117
- it "should make a real request to allowed host", :net_connect => true do
117
+ it "should make a real request to allowed host", net_connect: true do
118
118
  expect(http_request(:get, "http://httpstat.us/200").status).to eq('200')
119
119
  end
120
120
  end
@@ -129,13 +129,13 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
129
129
  let(:disallowed_host_with_port) { replace_with_different_port(allowed_host_with_port) }
130
130
 
131
131
  before :each do
132
- WebMock.disable_net_connect!(:allow => allowed_host_with_port)
132
+ WebMock.disable_net_connect!(allow: allowed_host_with_port)
133
133
  end
134
134
 
135
135
  context "when the host is not allowed" do
136
136
  it "should return stubbed response if request was stubbed" do
137
137
  request_url = "http://#{disallowed_host_with_port}/foo"
138
- stub_request(:get, request_url).to_return(:body => "abc")
138
+ stub_request(:get, request_url).to_return(body: "abc")
139
139
  expect(http_request(:get, request_url).body).to eq("abc")
140
140
  end
141
141
 
@@ -150,11 +150,11 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
150
150
  context "when the host is allowed" do
151
151
  it "should return stubbed response if request was stubbed" do
152
152
  request_url = "http://#{allowed_host_with_port}/foo"
153
- stub_request(:get, request_url).to_return(:body => "abc")
153
+ stub_request(:get, request_url).to_return(body: "abc")
154
154
  expect(http_request(:get, request_url).body).to eq('abc')
155
155
  end
156
156
 
157
- it "should make a real request to allowed host", :net_connect => true do
157
+ it "should make a real request to allowed host", net_connect: true do
158
158
  request_url = "http://#{allowed_host_with_port}/foo"
159
159
  expect(http_request(:get, request_url).status).to eq('200')
160
160
  end
@@ -163,12 +163,12 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
163
163
 
164
164
  describe "allowing by scheme:host string" do
165
165
  before :each do
166
- WebMock.disable_net_connect!(:allow => 'https://www.google.pl')
166
+ WebMock.disable_net_connect!(allow: 'https://www.google.pl')
167
167
  end
168
168
 
169
169
  context "when the host and scheme is not allowed" do
170
170
  it "should return stubbed response if request was stubbed" do
171
- stub_request(:get, 'https://disallowed.example.com/foo').to_return(:body => "abc")
171
+ stub_request(:get, 'https://disallowed.example.com/foo').to_return(body: "abc")
172
172
  expect(http_request(:get, 'https://disallowed.example.com/foo').body).to eq("abc")
173
173
  end
174
174
 
@@ -193,16 +193,16 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
193
193
 
194
194
  context "when the host is allowed" do
195
195
  it "should return stubbed response if request was stubbed" do
196
- stub_request(:get, 'https://www.google.pl').to_return(:body => "abc")
196
+ stub_request(:get, 'https://www.google.pl').to_return(body: "abc")
197
197
  expect(http_request(:get, "https://www.google.pl/").body).to eq("abc")
198
198
  end
199
199
 
200
- it "should make a real request to allowed host with scheme", :net_connect => true do
200
+ it "should make a real request to allowed host with scheme", net_connect: true do
201
201
  method = http_library == :httpclient ? :head : :get #https://github.com/nahi/httpclient/issues/299
202
202
  expect(http_request(method, "https://www.google.pl/").status).to eq('200')
203
203
  end
204
204
 
205
- it "should make a real request to allowed host with scheme and port", :net_connect => true do
205
+ it "should make a real request to allowed host with scheme and port", net_connect: true do
206
206
  method = http_library == :httpclient ? :head : :get
207
207
  expect(http_request(method, "https://www.google.pl:443/").status).to eq('200')
208
208
  end
@@ -211,12 +211,12 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
211
211
 
212
212
  describe "allowing by regular expression" do
213
213
  before :each do
214
- WebMock.disable_net_connect!(:allow => %r{httpstat})
214
+ WebMock.disable_net_connect!(allow: %r{httpstat})
215
215
  end
216
216
 
217
217
  context "when the host is not allowed" do
218
218
  it "should return stubbed response if request was stubbed" do
219
- stub_request(:get, 'disallowed.example.com/foo').to_return(:body => "abc")
219
+ stub_request(:get, 'disallowed.example.com/foo').to_return(body: "abc")
220
220
  expect(http_request(:get, 'http://disallowed.example.com/foo').body).to eq("abc")
221
221
  end
222
222
 
@@ -229,17 +229,17 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
229
229
 
230
230
  context "when the host is allowed" do
231
231
  it "should return stubbed response if request was stubbed" do
232
- stub_request(:get, 'httpstat.us/200').to_return(:body => "abc")
232
+ stub_request(:get, 'httpstat.us/200').to_return(body: "abc")
233
233
  expect(http_request(:get, "http://httpstat.us/200").body).to eq("abc")
234
234
  end
235
235
 
236
236
  # WARNING: this makes a real HTTP request!
237
- it "should make a real request to allowed host", :net_connect => true do
237
+ it "should make a real request to allowed host", net_connect: true do
238
238
  expect(http_request(:get, "http://httpstat.us/200").status).to eq('200')
239
239
  end
240
240
 
241
- it "should make a real request if request is allowed by path regexp and url contains default port", :net_connect => true do
242
- WebMock.disable_net_connect!(:allow => %r{www.google.pl/webhp})
241
+ it "should make a real request if request is allowed by path regexp and url contains default port", net_connect: true do
242
+ WebMock.disable_net_connect!(allow: %r{www.google.pl/webhp})
243
243
  method = http_library == :httpclient ? :head : :get
244
244
  expect(http_request(method, 'https://www.google.pl:443/webhp').status).to eq('200')
245
245
  end
@@ -248,12 +248,12 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
248
248
 
249
249
  describe "allowing by a callable" do
250
250
  before :each do
251
- WebMock.disable_net_connect!(:allow => lambda{|url| url.to_str.include?('httpstat') })
251
+ WebMock.disable_net_connect!(allow: lambda{|url| url.to_str.include?('httpstat') })
252
252
  end
253
253
 
254
254
  context "when the host is not allowed" do
255
255
  it "should return stubbed response if request was stubbed" do
256
- stub_request(:get, 'disallowed.example.com/foo').to_return(:body => "abc")
256
+ stub_request(:get, 'disallowed.example.com/foo').to_return(body: "abc")
257
257
  expect(http_request(:get, 'http://disallowed.example.com/foo').body).to eq("abc")
258
258
  end
259
259
 
@@ -266,12 +266,12 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
266
266
 
267
267
  context "when the host is allowed" do
268
268
  it "should return stubbed response if request was stubbed" do
269
- stub_request(:get, 'httpstat.us/200').to_return(:body => "abc")
269
+ stub_request(:get, 'httpstat.us/200').to_return(body: "abc")
270
270
  expect(http_request(:get, "http://httpstat.us/200").body).to eq("abc")
271
271
  end
272
272
 
273
273
  # WARNING: this makes a real HTTP request!
274
- it "should make a real request to allowed host", :net_connect => true do
274
+ it "should make a real request to allowed host", net_connect: true do
275
275
  expect(http_request(:get, "http://httpstat.us/200").status).to eq('200')
276
276
  end
277
277
  end
@@ -279,12 +279,12 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
279
279
 
280
280
  describe "allowing by a list of the above" do
281
281
  before :each do
282
- WebMock.disable_net_connect!(:allow => [lambda{|_| false }, %r{foobar}, 'httpstat.us'])
282
+ WebMock.disable_net_connect!(allow: [lambda{|_| false }, %r{foobar}, 'httpstat.us'])
283
283
  end
284
284
 
285
285
  context "when the host is not allowed" do
286
286
  it "should return stubbed response if request was stubbed" do
287
- stub_request(:get, 'disallowed.example.com/foo').to_return(:body => "abc")
287
+ stub_request(:get, 'disallowed.example.com/foo').to_return(body: "abc")
288
288
  expect(http_request(:get, 'http://disallowed.example.com/foo').body).to eq("abc")
289
289
  end
290
290
 
@@ -297,12 +297,12 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
297
297
 
298
298
  context "when the host is allowed" do
299
299
  it "should return stubbed response if request was stubbed" do
300
- stub_request(:get, 'httpstat.us/200').to_return(:body => "abc")
300
+ stub_request(:get, 'httpstat.us/200').to_return(body: "abc")
301
301
  expect(http_request(:get, "http://httpstat.us/200").body).to eq("abc")
302
302
  end
303
303
 
304
304
  # WARNING: this makes a real HTTP request!
305
- it "should make a real request to allowed host", :net_connect => true do
305
+ it "should make a real request to allowed host", net_connect: true do
306
306
  expect(http_request(:get, "http://httpstat.us/200").status).to eq('200')
307
307
  end
308
308
  end
@@ -22,7 +22,7 @@ shared_context "callbacks" do |*adapter_info|
22
22
  end
23
23
 
24
24
  it "should not invoke a callback if this http library should be ignored" do
25
- WebMock.after_request(:except => [http_library()]) {
25
+ WebMock.after_request(except: [http_library()]) {
26
26
  @called = true
27
27
  }
28
28
  http_request(:get, "http://www.example.com/")
@@ -30,7 +30,7 @@ shared_context "callbacks" do |*adapter_info|
30
30
  end
31
31
 
32
32
  it "should invoke a callback even if other http libraries should be ignored" do
33
- WebMock.after_request(:except => [:other_lib]) {
33
+ WebMock.after_request(except: [:other_lib]) {
34
34
  @called = true
35
35
  }
36
36
  http_request(:get, "http://www.example.com/")
@@ -38,7 +38,7 @@ shared_context "callbacks" do |*adapter_info|
38
38
  end
39
39
 
40
40
  it "should pass request signature to the callback" do
41
- WebMock.after_request(:except => [:other_lib]) do |request_signature, _|
41
+ WebMock.after_request(except: [:other_lib]) do |request_signature, _|
42
42
  @request_signature = request_signature
43
43
  end
44
44
  http_request(:get, "http://www.example.com/")
@@ -69,11 +69,11 @@ shared_context "callbacks" do |*adapter_info|
69
69
  before(:each) do
70
70
  stub_request(:get, "http://www.example.com").
71
71
  to_return(
72
- :status => [200, "hello"],
73
- :headers => {'Content-Length' => '666', 'Hello' => 'World'},
74
- :body => "foo bar"
72
+ status: [200, "hello"],
73
+ headers: {'Content-Length' => '666', 'Hello' => 'World'},
74
+ body: "foo bar"
75
75
  )
76
- WebMock.after_request(:except => [:other_lib]) do |_, response|
76
+ WebMock.after_request(except: [:other_lib]) do |_, response|
77
77
  @response = response
78
78
  end
79
79
  http_request(:get, "http://www.example.com/")
@@ -95,11 +95,11 @@ shared_context "callbacks" do |*adapter_info|
95
95
  end
96
96
  end
97
97
 
98
- describe "when request is not stubbed", :net_connect => true do
98
+ describe "when request is not stubbed", net_connect: true do
99
99
  before(:each) do
100
100
  WebMock.reset!
101
101
  WebMock.allow_net_connect!
102
- WebMock.after_request(:except => [:other_lib]) do |_, response|
102
+ WebMock.after_request(except: [:other_lib]) do |_, response|
103
103
  @response = response
104
104
  end
105
105
  http_request(:get, "http://httpstat.us/201")
@@ -127,8 +127,8 @@ shared_context "callbacks" do |*adapter_info|
127
127
  expect(@called).to eq(2)
128
128
  end
129
129
 
130
- it "should invoke callbacks only for real requests if requested", :net_connect => true do
131
- WebMock.after_request(:real_requests_only => true) { @called = true }
130
+ it "should invoke callbacks only for real requests if requested", net_connect: true do
131
+ WebMock.after_request(real_requests_only: true) { @called = true }
132
132
  http_request(:get, "http://www.example.com/")
133
133
  expect(@called).to eq(nil)
134
134
  WebMock.allow_net_connect!
@@ -7,9 +7,9 @@ shared_context "complex cross-concern behaviors" do |*adapter_info|
7
7
  real_response = http_request(:get, webmock_server_url)
8
8
 
9
9
  stub_request(:get, webmock_server_url).to_return(
10
- :status => recorded_response.status,
11
- :body => recorded_response.body,
12
- :headers => recorded_response.headers
10
+ status: recorded_response.status,
11
+ body: recorded_response.body,
12
+ headers: recorded_response.headers
13
13
  )
14
14
 
15
15
  played_back_response = http_request(:get, webmock_server_url)
@@ -20,12 +20,12 @@ shared_context "complex cross-concern behaviors" do |*adapter_info|
20
20
 
21
21
  let(:no_content_url) { 'http://httpstat.us/204' }
22
22
  [nil, ''].each do |stub_val|
23
- it "returns the same value (nil or "") for a request stubbed as #{stub_val.inspect} that a real empty response has", :net_connect => true do
23
+ it "returns the same value (nil or "") for a request stubbed as #{stub_val.inspect} that a real empty response has", net_connect: true do
24
24
  unless http_library == :curb
25
25
  WebMock.allow_net_connect!
26
26
 
27
27
  real_response = http_request(:get, no_content_url)
28
- stub_request(:get, no_content_url).to_return(:status => 204, :body => stub_val)
28
+ stub_request(:get, no_content_url).to_return(status: 204, body: stub_val)
29
29
  stubbed_response = http_request(:get, no_content_url)
30
30
 
31
31
  expect(stubbed_response.body).to eq(real_response.body)