webmock 3.11.1 → 3.18.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/CI.yml +38 -0
  3. data/CHANGELOG.md +126 -2
  4. data/Gemfile +1 -1
  5. data/README.md +33 -16
  6. data/Rakefile +12 -2
  7. data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +9 -2
  8. data/lib/webmock/http_lib_adapters/curb_adapter.rb +2 -2
  9. data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +6 -3
  10. data/lib/webmock/http_lib_adapters/http_rb/client.rb +1 -3
  11. data/lib/webmock/http_lib_adapters/http_rb/response.rb +17 -3
  12. data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +4 -2
  13. data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +6 -2
  14. data/lib/webmock/http_lib_adapters/manticore_adapter.rb +8 -1
  15. data/lib/webmock/http_lib_adapters/net_http.rb +29 -115
  16. data/lib/webmock/request_pattern.rb +30 -8
  17. data/lib/webmock/request_signature.rb +2 -2
  18. data/lib/webmock/request_stub.rb +15 -0
  19. data/lib/webmock/response.rb +8 -8
  20. data/lib/webmock/version.rb +1 -1
  21. data/lib/webmock/webmock.rb +10 -0
  22. data/minitest/webmock_spec.rb +1 -1
  23. data/spec/acceptance/async_http_client/async_http_client_spec.rb +27 -5
  24. data/spec/acceptance/curb/curb_spec.rb +11 -0
  25. data/spec/acceptance/em_http_request/em_http_request_spec.rb +57 -1
  26. data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +1 -1
  27. data/spec/acceptance/excon/excon_spec.rb +2 -2
  28. data/spec/acceptance/manticore/manticore_spec.rb +32 -0
  29. data/spec/acceptance/net_http/net_http_shared.rb +46 -9
  30. data/spec/acceptance/net_http/net_http_spec.rb +75 -23
  31. data/spec/acceptance/net_http/real_net_http_spec.rb +1 -1
  32. data/spec/acceptance/patron/patron_spec.rb +19 -21
  33. data/spec/acceptance/patron/patron_spec_helper.rb +2 -2
  34. data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +14 -14
  35. data/spec/acceptance/shared/callbacks.rb +2 -2
  36. data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +1 -1
  37. data/spec/unit/request_pattern_spec.rb +82 -46
  38. data/spec/unit/request_signature_spec.rb +21 -1
  39. data/spec/unit/request_stub_spec.rb +35 -0
  40. data/spec/unit/response_spec.rb +29 -1
  41. data/spec/unit/webmock_spec.rb +54 -0
  42. data/webmock.gemspec +6 -5
  43. metadata +46 -32
  44. data/.travis.yml +0 -24
@@ -31,7 +31,7 @@ describe WebMock::Response do
31
31
  end
32
32
 
33
33
  it "should report normalized headers" do
34
- expect(WebMock::Util::Headers).to receive(:normalize_headers).with('A' => 'a').and_return('B' => 'b')
34
+ allow(WebMock::Util::Headers).to receive(:normalize_headers).with({'A' => 'a'}.freeze).and_return('B' => 'b')
35
35
  @response = WebMock::Response.new(headers: {'A' => 'a'})
36
36
  expect(@response.headers).to eq({'B' => 'b'})
37
37
  end
@@ -142,6 +142,34 @@ describe WebMock::Response do
142
142
  end
143
143
 
144
144
  describe "from raw response" do
145
+ describe "when input is a StringIO" do
146
+ before(:each) do
147
+ @io = StringIO.new(File.read(CURL_EXAMPLE_OUTPUT_PATH))
148
+ @response = WebMock::Response.new(@io)
149
+ end
150
+
151
+ it "should read status" do
152
+ expect(@response.status).to eq([202, "OK"])
153
+ end
154
+
155
+ it "should read headers" do
156
+ expect(@response.headers).to eq(
157
+ "Date"=>"Sat, 23 Jan 2010 01:01:05 GMT",
158
+ "Content-Type"=>"text/html; charset=UTF-8",
159
+ "Content-Length"=>"419",
160
+ "Connection"=>"Keep-Alive",
161
+ "Accept"=>"image/jpeg, image/png"
162
+ )
163
+ end
164
+
165
+ it "should read body" do
166
+ expect(@response.body.size).to eq(419)
167
+ end
168
+
169
+ it "should close IO" do
170
+ expect(@io).to be_closed
171
+ end
172
+ end
145
173
 
146
174
  describe "when input is IO" do
147
175
  before(:each) do
@@ -57,4 +57,58 @@ describe "WebMock" do
57
57
  end
58
58
  end
59
59
  end
60
+
61
+ describe ".net_http_connect_on_start?" do
62
+ let(:uri) { Addressable::URI.parse("http://example.org:5432") }
63
+
64
+ it "will not connect on start when false" do
65
+ WebMock.disable_net_connect!
66
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(false)
67
+ end
68
+
69
+ it "will connect on start when true" do
70
+ WebMock.disable_net_connect!(net_http_connect_on_start: true)
71
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(true)
72
+ end
73
+
74
+ it "will connect on start when regexp matches" do
75
+ WebMock.disable_net_connect!(net_http_connect_on_start: /example/)
76
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(true)
77
+ end
78
+
79
+ it "will not connect on start when regexp does not match" do
80
+ WebMock.disable_net_connect!(net_http_connect_on_start: /nope/)
81
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(false)
82
+ end
83
+
84
+ it "will connect on start when host matches" do
85
+ WebMock.disable_net_connect!(net_http_connect_on_start: "example.org")
86
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(true)
87
+ end
88
+
89
+ it "will not connect on start when host does not match" do
90
+ WebMock.disable_net_connect!(net_http_connect_on_start: "localhost")
91
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(false)
92
+ end
93
+
94
+ it "will connect on start when host + port matches" do
95
+ WebMock.disable_net_connect!(net_http_connect_on_start: "example.org:5432")
96
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(true)
97
+ end
98
+
99
+ it "will not connect on start when host + port does not match" do
100
+ WebMock.disable_net_connect!(net_http_connect_on_start: "example.org:80")
101
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(false)
102
+ end
103
+
104
+ it "will connect on start when scheme + host + port matches" do
105
+ WebMock.disable_net_connect!(net_http_connect_on_start: "http://example.org:5432")
106
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(true)
107
+ end
108
+
109
+ it "will not connect on start when scheme + host + port does not match" do
110
+ WebMock.disable_net_connect!(net_http_connect_on_start: "https://example.org:5432")
111
+ expect(WebMock.net_http_connect_on_start?(uri)).to be(false)
112
+ end
113
+ end
60
114
  end
data/webmock.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ['Bartosz Blimke']
10
10
  s.email = ['bartosz.blimke@gmail.com']
11
- s.homepage = 'http://github.com/bblimke/webmock'
11
+ s.homepage = 'https://github.com/bblimke/webmock'
12
12
  s.summary = %q{Library for stubbing HTTP requests in Ruby.}
13
13
  s.description = %q{WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.}
14
14
  s.license = "MIT"
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
21
21
  'wiki_uri' => 'https://github.com/bblimke/webmock/wiki'
22
22
  }
23
23
 
24
- s.required_ruby_version = '>= 2.0'
24
+ s.required_ruby_version = '>= 2.3'
25
25
 
26
- s.add_dependency 'addressable', '>= 2.3.6'
26
+ s.add_dependency 'addressable', '>= 2.8.0'
27
27
  s.add_dependency 'crack', '>= 0.3.2'
28
28
  s.add_dependency 'hashdiff', ['>= 0.4.0', '< 2.0.0']
29
29
 
@@ -31,6 +31,8 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency 'patron', '>= 0.4.18'
32
32
  s.add_development_dependency 'curb', '>= 0.7.16'
33
33
  s.add_development_dependency 'typhoeus', '>= 0.5.0'
34
+ s.add_development_dependency 'em-http-request', '>= 1.0.2'
35
+ s.add_development_dependency 'em-synchrony', '>= 1.0.0'
34
36
  end
35
37
 
36
38
  s.add_development_dependency 'http', '>= 0.8.0'
@@ -38,13 +40,12 @@ Gem::Specification.new do |s|
38
40
  s.add_development_dependency 'rack', ((RUBY_VERSION < '2.2.2') ? '1.6.0' : '> 1.6')
39
41
  s.add_development_dependency 'rspec', '>= 3.1.0'
40
42
  s.add_development_dependency 'httpclient', '>= 2.2.4'
41
- s.add_development_dependency 'em-http-request', '>= 1.0.2'
42
- s.add_development_dependency 'em-synchrony', '>= 1.0.0'
43
43
  s.add_development_dependency 'excon', '>= 0.27.5'
44
44
  s.add_development_dependency 'async-http', '>= 0.48.0'
45
45
  s.add_development_dependency 'minitest', '>= 5.0.0'
46
46
  s.add_development_dependency 'test-unit', '>= 3.0.0'
47
47
  s.add_development_dependency 'rdoc', '> 3.5.0'
48
+ s.add_development_dependency 'webrick'
48
49
 
49
50
  s.files = `git ls-files`.split("\n")
50
51
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.1
4
+ version: 3.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Blimke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-13 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.6
19
+ version: 2.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.6
26
+ version: 2.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: crack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -101,89 +101,89 @@ dependencies:
101
101
  - !ruby/object:Gem::Version
102
102
  version: 0.5.0
103
103
  - !ruby/object:Gem::Dependency
104
- name: http
104
+ name: em-http-request
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: 0.8.0
109
+ version: 1.0.2
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: 0.8.0
116
+ version: 1.0.2
117
117
  - !ruby/object:Gem::Dependency
118
- name: rack
118
+ name: em-synchrony
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - ">"
121
+ - - ">="
122
122
  - !ruby/object:Gem::Version
123
- version: '1.6'
123
+ version: 1.0.0
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - ">"
128
+ - - ">="
129
129
  - !ruby/object:Gem::Version
130
- version: '1.6'
130
+ version: 1.0.0
131
131
  - !ruby/object:Gem::Dependency
132
- name: rspec
132
+ name: http
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - ">="
136
136
  - !ruby/object:Gem::Version
137
- version: 3.1.0
137
+ version: 0.8.0
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - ">="
143
143
  - !ruby/object:Gem::Version
144
- version: 3.1.0
144
+ version: 0.8.0
145
145
  - !ruby/object:Gem::Dependency
146
- name: httpclient
146
+ name: rack
147
147
  requirement: !ruby/object:Gem::Requirement
148
148
  requirements:
149
- - - ">="
149
+ - - ">"
150
150
  - !ruby/object:Gem::Version
151
- version: 2.2.4
151
+ version: '1.6'
152
152
  type: :development
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
- - - ">="
156
+ - - ">"
157
157
  - !ruby/object:Gem::Version
158
- version: 2.2.4
158
+ version: '1.6'
159
159
  - !ruby/object:Gem::Dependency
160
- name: em-http-request
160
+ name: rspec
161
161
  requirement: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: 1.0.2
165
+ version: 3.1.0
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - ">="
171
171
  - !ruby/object:Gem::Version
172
- version: 1.0.2
172
+ version: 3.1.0
173
173
  - !ruby/object:Gem::Dependency
174
- name: em-synchrony
174
+ name: httpclient
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
177
  - - ">="
178
178
  - !ruby/object:Gem::Version
179
- version: 1.0.0
179
+ version: 2.2.4
180
180
  type: :development
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
184
  - - ">="
185
185
  - !ruby/object:Gem::Version
186
- version: 1.0.0
186
+ version: 2.2.4
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: excon
189
189
  requirement: !ruby/object:Gem::Requirement
@@ -254,6 +254,20 @@ dependencies:
254
254
  - - ">"
255
255
  - !ruby/object:Gem::Version
256
256
  version: 3.5.0
257
+ - !ruby/object:Gem::Dependency
258
+ name: webrick
259
+ requirement: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - ">="
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
264
+ type: :development
265
+ prerelease: false
266
+ version_requirements: !ruby/object:Gem::Requirement
267
+ requirements:
268
+ - - ">="
269
+ - !ruby/object:Gem::Version
270
+ version: '0'
257
271
  description: WebMock allows stubbing HTTP requests and setting expectations on HTTP
258
272
  requests.
259
273
  email:
@@ -263,9 +277,9 @@ extensions: []
263
277
  extra_rdoc_files: []
264
278
  files:
265
279
  - ".gemtest"
280
+ - ".github/workflows/CI.yml"
266
281
  - ".gitignore"
267
282
  - ".rspec-tm"
268
- - ".travis.yml"
269
283
  - CHANGELOG.md
270
284
  - Gemfile
271
285
  - LICENSE
@@ -402,14 +416,14 @@ files:
402
416
  - test/test_helper.rb
403
417
  - test/test_webmock.rb
404
418
  - webmock.gemspec
405
- homepage: http://github.com/bblimke/webmock
419
+ homepage: https://github.com/bblimke/webmock
406
420
  licenses:
407
421
  - MIT
408
422
  metadata:
409
423
  bug_tracker_uri: https://github.com/bblimke/webmock/issues
410
- changelog_uri: https://github.com/bblimke/webmock/blob/v3.11.1/CHANGELOG.md
411
- documentation_uri: https://www.rubydoc.info/gems/webmock/3.11.1
412
- source_code_uri: https://github.com/bblimke/webmock/tree/v3.11.1
424
+ changelog_uri: https://github.com/bblimke/webmock/blob/v3.18.1/CHANGELOG.md
425
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.18.1
426
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.18.1
413
427
  wiki_uri: https://github.com/bblimke/webmock/wiki
414
428
  post_install_message:
415
429
  rdoc_options: []
@@ -419,7 +433,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
419
433
  requirements:
420
434
  - - ">="
421
435
  - !ruby/object:Gem::Version
422
- version: '2.0'
436
+ version: '2.3'
423
437
  required_rubygems_version: !ruby/object:Gem::Requirement
424
438
  requirements:
425
439
  - - ">="
data/.travis.yml DELETED
@@ -1,24 +0,0 @@
1
- before_install:
2
- - gem update --system -N
3
- rvm:
4
- - 2.5.5
5
- - 2.6.3
6
- - 2.7.0
7
- - rbx-2
8
- - ruby-head
9
- matrix:
10
- include:
11
- - rvm: jruby-9.1.17.0
12
- jdk: openjdk8
13
- - rvm: jruby-9.2.11.1
14
- jdk: openjdk11
15
- - rvm: jruby-head
16
- jdk: openjdk11
17
- allow_failures:
18
- - rvm: jruby-head
19
- - rvm: ruby-head
20
- - rvm: rbx-2
21
- env:
22
- global:
23
- JRUBY_OPTS: "--debug"
24
-