webmock 2.3.2 → 3.0.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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -6
- data/CHANGELOG.md +24 -0
- data/README.md +11 -5
- data/lib/webmock/http_lib_adapters/net_http.rb +2 -19
- data/lib/webmock/request_registry.rb +2 -2
- data/lib/webmock/rspec/matchers/webmock_matcher.rb +15 -0
- data/lib/webmock/stub_request_snippet.rb +3 -3
- data/lib/webmock/test_unit.rb +1 -1
- data/lib/webmock/util/hash_counter.rb +7 -0
- data/lib/webmock/util/json.rb +5 -15
- data/lib/webmock/util/query_mapper.rb +1 -1
- data/lib/webmock/version.rb +1 -1
- data/spec/acceptance/httpclient/httpclient_spec.rb +3 -2
- data/spec/acceptance/net_http/net_http_shared.rb +11 -0
- data/spec/acceptance/shared/stubbing_requests.rb +1 -1
- data/spec/unit/request_registry_spec.rb +19 -0
- data/spec/unit/request_signature_snippet_spec.rb +2 -2
- data/spec/unit/stub_request_snippet_spec.rb +16 -16
- data/spec/unit/util/query_mapper_spec.rb +6 -0
- data/webmock.gemspec +3 -3
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fa6515a5f5cc32fb13178203cd7005737dae9ed2
|
|
4
|
+
data.tar.gz: 351a2ceeac166e491aa4cff1d7c9db5b052cb96e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 55209329e78df950a0cc9f0dfaaf53e1e0029f64b158962f301d77cad5557f6d4e26c94523f5e0cb99afc0f09eacc0560d99d01928d0f604b45bc87d1c82272a
|
|
7
|
+
data.tar.gz: 200bcf41066c34527ff772e2f89105e6603810abb51724461444436b60484ff33630247f8642a1f3865723e717e9624bf14c7bae414c074cfc22289b04f61e1b
|
data/.travis.yml
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
rvm:
|
|
2
|
-
- 1.9.3
|
|
3
2
|
- 2.0.0
|
|
4
3
|
- 2.1.0
|
|
5
4
|
- 2.2.1
|
|
@@ -8,14 +7,11 @@ rvm:
|
|
|
8
7
|
- 2.4.0
|
|
9
8
|
- rbx-2
|
|
10
9
|
- ruby-head
|
|
11
|
-
- jruby-9.0.
|
|
12
|
-
- jruby-9.
|
|
13
|
-
- jruby-19mode
|
|
14
|
-
- jruby
|
|
10
|
+
- jruby-9.0.5.0
|
|
11
|
+
- jruby-9.1.5.0
|
|
15
12
|
- jruby-head
|
|
16
13
|
matrix:
|
|
17
14
|
allow_failures:
|
|
18
|
-
- rvm: jruby-9.0.0.0
|
|
19
15
|
- rvm: jruby-head
|
|
20
16
|
- rvm: ruby-head
|
|
21
17
|
- rvm: rbx-2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
* Dropped support for Ruby 1.9.3
|
|
6
|
+
|
|
7
|
+
* Using Ruby >= 1.9 hash key syntax in stub suggestions
|
|
8
|
+
|
|
9
|
+
Thanks to [Tarmo Tänav](https://github.com/tarmo)
|
|
10
|
+
|
|
11
|
+
* Add at_least matchers for fakeweb-style expectations
|
|
12
|
+
|
|
13
|
+
Thanks to [Joe Marty](https://github.com/mltsy)
|
|
14
|
+
|
|
15
|
+
* Fix against "can't modify frozen String' error when Ruby option `frozen_string_literal` is enabled.
|
|
16
|
+
|
|
17
|
+
Thanks to [Chris Thomson](https://github.com/christhomson)
|
|
18
|
+
|
|
19
|
+
* Handling `read_timeout` option in Net::HTTP in Ruby >= 2.4
|
|
20
|
+
|
|
21
|
+
Thanks to [Christof Koenig](https://github.com/ckoenig)
|
|
22
|
+
|
|
23
|
+
* `RequestRegistry` fix for `RuntimeError - can't add a new key into hash during iteration`
|
|
24
|
+
|
|
25
|
+
Thanks to [Chung-Yi Chi](https://github.com/starsirius)
|
|
26
|
+
|
|
3
27
|
## 2.3.2
|
|
4
28
|
|
|
5
29
|
* Restored support for Ruby 1.9.3 to comply with semantic versioning.
|
data/README.md
CHANGED
|
@@ -32,8 +32,7 @@ Supported HTTP libraries
|
|
|
32
32
|
Supported Ruby Interpreters
|
|
33
33
|
---------------------------
|
|
34
34
|
|
|
35
|
-
* MRI
|
|
36
|
-
* MRI 2.0.0
|
|
35
|
+
* MRI 2.0
|
|
37
36
|
* MRI 2.1
|
|
38
37
|
* MRI 2.2
|
|
39
38
|
* MRI 2.3
|
|
@@ -132,7 +131,7 @@ end # ===> Success
|
|
|
132
131
|
|
|
133
132
|
```ruby
|
|
134
133
|
stub_request(:post, "www.example.com").
|
|
135
|
-
with(body:
|
|
134
|
+
with(body: /world$/, headers: {"Content-Type" => /image\/.+/}).
|
|
136
135
|
to_return(body: "abc")
|
|
137
136
|
|
|
138
137
|
uri = URI.parse('http://www.example.com/')
|
|
@@ -232,7 +231,7 @@ RestClient.get('user:pass@www.example.com') # ===> Success
|
|
|
232
231
|
### Matching uris using regular expressions
|
|
233
232
|
|
|
234
233
|
```ruby
|
|
235
|
-
stub_request(:any,
|
|
234
|
+
stub_request(:any, /example/)
|
|
236
235
|
|
|
237
236
|
Net::HTTP.get('www.example.com', '/') # ===> Success
|
|
238
237
|
```
|
|
@@ -787,7 +786,7 @@ or these
|
|
|
787
786
|
|
|
788
787
|
If you provide Regexp to match URI, WebMock will try to match it against every valid form of the same url.
|
|
789
788
|
|
|
790
|
-
I.e
|
|
789
|
+
I.e `/my path/` will match `www.example.com/my%20path` because it is equivalent of `www.example.com/my path`
|
|
791
790
|
|
|
792
791
|
## Matching with URI Templates
|
|
793
792
|
|
|
@@ -1029,6 +1028,13 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
|
1029
1028
|
* Ville Lautanala
|
|
1030
1029
|
* Koichi ITO
|
|
1031
1030
|
* Jordan Harband
|
|
1031
|
+
* Tarmo Tänav
|
|
1032
|
+
* Joe Marty
|
|
1033
|
+
* Chris Thomson
|
|
1034
|
+
* Vít Ondruch
|
|
1035
|
+
* George Ulmer
|
|
1036
|
+
* Christof Koenig
|
|
1037
|
+
* Chung-Yi Chi
|
|
1032
1038
|
|
|
1033
1039
|
For a full list of contributors you can visit the
|
|
1034
1040
|
[contributors](https://github.com/bblimke/webmock/contributors) page.
|
|
@@ -183,9 +183,6 @@ module WebMock
|
|
|
183
183
|
if defined?(Net::OpenTimeout)
|
|
184
184
|
# Ruby 2.x
|
|
185
185
|
Net::OpenTimeout
|
|
186
|
-
elsif defined?(Net::HTTP::OpenTimeout)
|
|
187
|
-
# Ruby 1.9
|
|
188
|
-
Net::HTTP::OpenTimeout
|
|
189
186
|
else
|
|
190
187
|
# Fallback, if things change
|
|
191
188
|
Timeout::Error
|
|
@@ -259,22 +256,8 @@ end
|
|
|
259
256
|
module Net #:nodoc: all
|
|
260
257
|
|
|
261
258
|
class WebMockNetBufferedIO < BufferedIO
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
def initialize(io, debug_output = nil)
|
|
265
|
-
common_initialize(io, debug_output)
|
|
266
|
-
end
|
|
267
|
-
DEFINE_METHOD
|
|
268
|
-
else
|
|
269
|
-
class_eval <<-DEFINE_METHOD
|
|
270
|
-
def initialize(io, read_timeout: 60, continue_timeout: nil, debug_output: nil)
|
|
271
|
-
common_initialize(io, debug_output)
|
|
272
|
-
end
|
|
273
|
-
DEFINE_METHOD
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
def common_initialize(io, debug_output = nil)
|
|
277
|
-
@read_timeout = 60
|
|
259
|
+
def initialize(io, read_timeout: 60, continue_timeout: nil, debug_output: nil)
|
|
260
|
+
@read_timeout = read_timeout
|
|
278
261
|
@rbuf = ''
|
|
279
262
|
@debug_output = debug_output
|
|
280
263
|
|
|
@@ -14,9 +14,9 @@ module WebMock
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def times_executed(request_pattern)
|
|
17
|
-
self.requested_signatures.
|
|
17
|
+
self.requested_signatures.select do |request_signature|
|
|
18
18
|
request_pattern.matches?(request_signature)
|
|
19
|
-
|
|
19
|
+
end.inject(0) { |sum, (_, times_executed)| sum + times_executed }
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def to_s
|
|
@@ -16,6 +16,21 @@ module WebMock
|
|
|
16
16
|
self
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def at_least_once
|
|
20
|
+
@request_execution_verifier.at_least_times_executed = 1
|
|
21
|
+
self
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def at_least_twice
|
|
25
|
+
@request_execution_verifier.at_least_times_executed = 2
|
|
26
|
+
self
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def at_least_times(times)
|
|
30
|
+
@request_execution_verifier.at_least_times_executed = times
|
|
31
|
+
self
|
|
32
|
+
end
|
|
33
|
+
|
|
19
34
|
def with(options = {}, &block)
|
|
20
35
|
@request_execution_verifier.request_pattern.with(options, &block)
|
|
21
36
|
self
|
|
@@ -16,17 +16,17 @@ module WebMock
|
|
|
16
16
|
with = ""
|
|
17
17
|
|
|
18
18
|
if (request_pattern.body_pattern)
|
|
19
|
-
with << ":
|
|
19
|
+
with << "body: #{request_pattern.body_pattern.to_s}"
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
if (request_pattern.headers_pattern)
|
|
23
23
|
with << ",\n " unless with.empty?
|
|
24
24
|
|
|
25
|
-
with << ":
|
|
25
|
+
with << "headers: #{request_pattern.headers_pattern.to_s}"
|
|
26
26
|
end
|
|
27
27
|
string << ".\n with(#{with})" unless with.empty?
|
|
28
28
|
if with_response
|
|
29
|
-
string << ".\n to_return(:
|
|
29
|
+
string << ".\n to_return(status: 200, body: \"\", headers: {})"
|
|
30
30
|
end
|
|
31
31
|
string
|
|
32
32
|
end
|
data/lib/webmock/test_unit.rb
CHANGED
|
@@ -22,6 +22,13 @@ module WebMock
|
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
def select(&block)
|
|
26
|
+
return unless block_given?
|
|
27
|
+
@lock.synchronize do
|
|
28
|
+
hash.select &block
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
25
32
|
def each(&block)
|
|
26
33
|
@order.to_a.sort {|a, b| a[1] <=> b[1]}.each do |a|
|
|
27
34
|
block.call(a[0], hash[a[0]])
|
data/lib/webmock/util/json.rb
CHANGED
|
@@ -48,21 +48,11 @@ module WebMock
|
|
|
48
48
|
right_pos = marks << json.bytesize
|
|
49
49
|
output = []
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
output << json[left.succ..right_pos[i]]
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
else
|
|
60
|
-
json_as_binary = json.force_encoding("binary")
|
|
61
|
-
left_pos.each_with_index do |left, i|
|
|
62
|
-
output << json_as_binary[left.succ..right_pos[i]]
|
|
63
|
-
end
|
|
64
|
-
output.map! do |binary_str|
|
|
65
|
-
binary_str.force_encoding("UTF-8")
|
|
51
|
+
left_pos.each_with_index do |left, i|
|
|
52
|
+
if json.respond_to?(:byteslice)
|
|
53
|
+
output << json.byteslice(left.succ..right_pos[i])
|
|
54
|
+
else
|
|
55
|
+
output << json[left.succ..right_pos[i]]
|
|
66
56
|
end
|
|
67
57
|
end
|
|
68
58
|
|
|
@@ -39,7 +39,7 @@ module WebMock::Util
|
|
|
39
39
|
# #=> [['one', 'two'], ['one', 'three']]
|
|
40
40
|
def query_to_values(query, options={})
|
|
41
41
|
return nil if query.nil?
|
|
42
|
-
query.force_encoding('utf-8') if query.respond_to?(:force_encoding)
|
|
42
|
+
query = query.dup.force_encoding('utf-8') if query.respond_to?(:force_encoding)
|
|
43
43
|
|
|
44
44
|
options[:notation] ||= :subscript
|
|
45
45
|
|
data/lib/webmock/version.rb
CHANGED
|
@@ -182,7 +182,7 @@ describe "HTTPClient" do
|
|
|
182
182
|
end
|
|
183
183
|
end
|
|
184
184
|
|
|
185
|
-
context 'httpclient streams response' do
|
|
185
|
+
context 'httpclient streams response', net_connect: true do
|
|
186
186
|
before do
|
|
187
187
|
WebMock.allow_net_connect!
|
|
188
188
|
WebMock.after_request(except: [:other_lib]) do |_, response|
|
|
@@ -201,7 +201,8 @@ describe "HTTPClient" do
|
|
|
201
201
|
|
|
202
202
|
context 'credentials' do
|
|
203
203
|
it 'are detected when manually specifying Authorization header' do
|
|
204
|
-
stub_request(:get,
|
|
204
|
+
stub_request(:get, "http://www.example.com/").with(basic_auth: ['username', 'password']).to_return(status: 200)
|
|
205
|
+
|
|
205
206
|
headers = {'Authorization' => 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='}
|
|
206
207
|
expect(http_request(:get, 'http://www.example.com/', {headers: headers}).status).to eql('200')
|
|
207
208
|
end
|
|
@@ -43,6 +43,17 @@ shared_examples_for "Net::HTTP" do
|
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
it "should pass the read_timeout value on", net_connect: true do
|
|
47
|
+
@http = Net::HTTP.new('localhost', port)
|
|
48
|
+
read_timeout = @http.read_timeout + 1
|
|
49
|
+
@http.read_timeout = read_timeout
|
|
50
|
+
@http.start {|conn|
|
|
51
|
+
conn.request(Net::HTTP::Get.new("/"))
|
|
52
|
+
socket = conn.instance_variable_get(:@socket)
|
|
53
|
+
expect(socket.read_timeout).to eq(read_timeout)
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
|
|
46
57
|
describe "without start" do
|
|
47
58
|
it "should close connection after a real request" do
|
|
48
59
|
@http.get('/') { }
|
|
@@ -18,7 +18,7 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
|
18
18
|
expect(http_request(:get, "http://www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}").body).to eq("abc")
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
it "should return stubbed response for url with non utf query params"
|
|
21
|
+
it "should return stubbed response for url with non utf query params" do
|
|
22
22
|
param = 'aäoöuü'.encode('iso-8859-1')
|
|
23
23
|
param = CGI.escape(param)
|
|
24
24
|
stub_request(:get, "www.example.com/?#{param}").to_return(body: "abc")
|
|
@@ -43,6 +43,25 @@ describe WebMock::RequestRegistry do
|
|
|
43
43
|
it "should report number of times all matching pattern were requested" do
|
|
44
44
|
expect(WebMock::RequestRegistry.instance.times_executed(WebMock::RequestPattern.new(:get, /.*example.*/))).to eq(3)
|
|
45
45
|
end
|
|
46
|
+
|
|
47
|
+
describe "multithreading" do
|
|
48
|
+
let(:request_pattern) { WebMock::RequestPattern.new(:get, "www.example.com") }
|
|
49
|
+
|
|
50
|
+
# Reproduce a multithreading issue that causes a RuntimeError:
|
|
51
|
+
# can't add a new key into hash during iteration.
|
|
52
|
+
it "works normally iterating on the requested signature hash while another thread is setting it" do
|
|
53
|
+
thread_injected = false
|
|
54
|
+
allow(request_pattern).to receive(:matches?).and_wrap_original do |m, *args|
|
|
55
|
+
unless thread_injected
|
|
56
|
+
thread_injected = true
|
|
57
|
+
Thread.new { WebMock::RequestRegistry.instance.requested_signatures.put(:abc) }.join(0.1)
|
|
58
|
+
end
|
|
59
|
+
m.call(*args)
|
|
60
|
+
end
|
|
61
|
+
expect(WebMock::RequestRegistry.instance.times_executed(request_pattern)).to eq(2)
|
|
62
|
+
sleep 0.1 while !WebMock::RequestRegistry.instance.requested_signatures.hash.key?(:abc)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
46
65
|
end
|
|
47
66
|
|
|
48
67
|
describe "request_signatures" do
|
|
@@ -60,7 +60,7 @@ RSpec.describe WebMock::RequestSignatureSnippet do
|
|
|
60
60
|
result = subject.request_stubs
|
|
61
61
|
result.sub!("registered request stubs:\n\n", "")
|
|
62
62
|
expect(result).to eq(
|
|
63
|
-
"stub_request(:get, \"https://www.example.com/\").\n with(:
|
|
63
|
+
"stub_request(:get, \"https://www.example.com/\").\n with(body: {\"a\"=>\"b\"})"
|
|
64
64
|
)
|
|
65
65
|
end
|
|
66
66
|
|
|
@@ -74,7 +74,7 @@ RSpec.describe WebMock::RequestSignatureSnippet do
|
|
|
74
74
|
result = subject.request_stubs
|
|
75
75
|
result.sub!("registered request stubs:\n\n", "")
|
|
76
76
|
expect(result).to eq(
|
|
77
|
-
"stub_request(:get, \"https://www.example.com/\").\n with(:
|
|
77
|
+
"stub_request(:get, \"https://www.example.com/\").\n with(body: {\"a\"=>\"b\"})\n\nBody diff:\n [[\"-\", \"key\", \"different value\"], [\"+\", \"a\", \"b\"]]\n"
|
|
78
78
|
)
|
|
79
79
|
end
|
|
80
80
|
end
|
|
@@ -8,7 +8,7 @@ describe WebMock::StubRequestSnippet do
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it "should print stub request snippet with url with params and method and empty successful response" do
|
|
11
|
-
expected = %Q(stub_request(:get, "http://www.example.com/?a=b&c=d").\n to_return(:
|
|
11
|
+
expected = %Q(stub_request(:get, "http://www.example.com/?a=b&c=d").\n to_return(status: 200, body: "", headers: {}))
|
|
12
12
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
|
13
13
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
|
|
14
14
|
end
|
|
@@ -16,8 +16,8 @@ describe WebMock::StubRequestSnippet do
|
|
|
16
16
|
it "should print stub request snippet with body if available" do
|
|
17
17
|
@request_signature.body = "abcdef"
|
|
18
18
|
expected = %Q(stub_request(:get, "http://www.example.com/?a=b&c=d").)+
|
|
19
|
-
"\n with(:
|
|
20
|
-
"\n to_return(:
|
|
19
|
+
"\n with(body: \"abcdef\")." +
|
|
20
|
+
"\n to_return(status: 200, body: \"\", headers: {})"
|
|
21
21
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
|
22
22
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
|
|
23
23
|
end
|
|
@@ -25,8 +25,8 @@ describe WebMock::StubRequestSnippet do
|
|
|
25
25
|
it "should print stub request snippet with multiline body" do
|
|
26
26
|
@request_signature.body = "abc\ndef"
|
|
27
27
|
expected = %Q(stub_request(:get, "http://www.example.com/?a=b&c=d").)+
|
|
28
|
-
"\n with(:
|
|
29
|
-
"\n to_return(:
|
|
28
|
+
"\n with(body: \"abc\\ndef\")." +
|
|
29
|
+
"\n to_return(status: 200, body: \"\", headers: {})"
|
|
30
30
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
|
31
31
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
|
|
32
32
|
end
|
|
@@ -34,8 +34,8 @@ describe WebMock::StubRequestSnippet do
|
|
|
34
34
|
it "should print stub request snippet with headers if any" do
|
|
35
35
|
@request_signature.headers = {'B' => 'b', 'A' => 'a'}
|
|
36
36
|
expected = 'stub_request(:get, "http://www.example.com/?a=b&c=d").'+
|
|
37
|
-
"\n with(:
|
|
38
|
-
"\n to_return(:
|
|
37
|
+
"\n with(headers: {\'A\'=>\'a\', \'B\'=>\'b\'})." +
|
|
38
|
+
"\n to_return(status: 200, body: \"\", headers: {})"
|
|
39
39
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
|
40
40
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
|
|
41
41
|
end
|
|
@@ -44,15 +44,15 @@ describe WebMock::StubRequestSnippet do
|
|
|
44
44
|
@request_signature.body = "abcdef"
|
|
45
45
|
@request_signature.headers = {'B' => 'b', 'A' => 'a'}
|
|
46
46
|
expected = 'stub_request(:get, "http://www.example.com/?a=b&c=d").'+
|
|
47
|
-
"\n with(:
|
|
48
|
-
"\n to_return(:
|
|
47
|
+
"\n with(body: \"abcdef\",\n headers: {\'A\'=>\'a\', \'B\'=>\'b\'})." +
|
|
48
|
+
"\n to_return(status: 200, body: \"\", headers: {})"
|
|
49
49
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
|
50
50
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it "should not print to_return part if not wanted" do
|
|
54
54
|
expected = 'stub_request(:get, "http://www.example.com/").'+
|
|
55
|
-
"\n with(:
|
|
55
|
+
"\n with(body: \"abcdef\")"
|
|
56
56
|
stub = WebMock::RequestStub.new(:get, "www.example.com").with(body: "abcdef").to_return(body: "hello")
|
|
57
57
|
expect(WebMock::StubRequestSnippet.new(stub).to_s(false)).to eq(expected)
|
|
58
58
|
end
|
|
@@ -68,9 +68,9 @@ describe WebMock::StubRequestSnippet do
|
|
|
68
68
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
|
69
69
|
expected = <<-STUB
|
|
70
70
|
stub_request(:post, "http://www.example.com/").
|
|
71
|
-
with(:
|
|
72
|
-
:
|
|
73
|
-
to_return(:
|
|
71
|
+
with(body: {"user"=>{"first_name"=>"Bartosz"}},
|
|
72
|
+
headers: {'Content-Type'=>'application/x-www-form-urlencoded'}).
|
|
73
|
+
to_return(status: 200, body: \"\", headers: {})
|
|
74
74
|
STUB
|
|
75
75
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected.strip)
|
|
76
76
|
end
|
|
@@ -82,9 +82,9 @@ stub_request(:post, "http://www.example.com/").
|
|
|
82
82
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
|
83
83
|
expected = <<-STUB
|
|
84
84
|
stub_request(:post, "http://www.example.com/").
|
|
85
|
-
with(:
|
|
86
|
-
:
|
|
87
|
-
to_return(:
|
|
85
|
+
with(body: "#{multipart_form_body}",
|
|
86
|
+
headers: {'Content-Type'=>'multipart/form-data; boundary=ABC123'}).
|
|
87
|
+
to_return(status: 200, body: \"\", headers: {})
|
|
88
88
|
STUB
|
|
89
89
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected.strip)
|
|
90
90
|
end
|
|
@@ -64,6 +64,12 @@ describe WebMock::Util::QueryMapper do
|
|
|
64
64
|
expect(hsh['a'][0]['b']).to eq(['one'])
|
|
65
65
|
expect(hsh['a'][0]['c']).to eq(['two'])
|
|
66
66
|
end
|
|
67
|
+
|
|
68
|
+
it 'should not attempt to mutate its query argument' do
|
|
69
|
+
query = "a=foo".freeze
|
|
70
|
+
hsh = subject.query_to_values(query)
|
|
71
|
+
expect(hsh['a']).to eq('foo')
|
|
72
|
+
end
|
|
67
73
|
end
|
|
68
74
|
|
|
69
75
|
context '#to_query' do
|
data/webmock.gemspec
CHANGED
|
@@ -15,9 +15,9 @@ Gem::Specification.new do |s|
|
|
|
15
15
|
|
|
16
16
|
s.rubyforge_project = 'webmock'
|
|
17
17
|
|
|
18
|
-
s.required_ruby_version = '>=
|
|
18
|
+
s.required_ruby_version = '>= 2.0'
|
|
19
19
|
|
|
20
|
-
s.add_dependency 'addressable', '>= 2.3.6'
|
|
20
|
+
s.add_dependency 'addressable', '>= 2.3.6'
|
|
21
21
|
s.add_dependency 'crack', '>= 0.3.2'
|
|
22
22
|
s.add_dependency 'hashdiff'
|
|
23
23
|
|
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
|
27
27
|
s.add_development_dependency 'typhoeus', '>= 0.5.0'
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
s.add_development_dependency 'http',
|
|
30
|
+
s.add_development_dependency 'http', '>= 0.8.0'
|
|
31
31
|
s.add_development_dependency 'manticore', '>= 0.5.1' if RUBY_PLATFORM =~ /java/
|
|
32
32
|
s.add_development_dependency 'rack', ((RUBY_VERSION < '2.2.2') ? '1.6.0' : '> 1.6')
|
|
33
33
|
s.add_development_dependency 'rspec', '>= 3.1.0'
|
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:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bartosz Blimke
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-04-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -112,16 +112,16 @@ dependencies:
|
|
|
112
112
|
name: rack
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
|
-
- -
|
|
115
|
+
- - '='
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version:
|
|
117
|
+
version: 1.6.0
|
|
118
118
|
type: :development
|
|
119
119
|
prerelease: false
|
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
|
122
|
-
- -
|
|
122
|
+
- - '='
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
|
-
version:
|
|
124
|
+
version: 1.6.0
|
|
125
125
|
- !ruby/object:Gem::Dependency
|
|
126
126
|
name: rspec
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -386,7 +386,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
386
386
|
requirements:
|
|
387
387
|
- - ">="
|
|
388
388
|
- !ruby/object:Gem::Version
|
|
389
|
-
version:
|
|
389
|
+
version: '2.0'
|
|
390
390
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
391
391
|
requirements:
|
|
392
392
|
- - ">="
|
|
@@ -394,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
394
394
|
version: '0'
|
|
395
395
|
requirements: []
|
|
396
396
|
rubyforge_project: webmock
|
|
397
|
-
rubygems_version: 2.
|
|
397
|
+
rubygems_version: 2.2.2
|
|
398
398
|
signing_key:
|
|
399
399
|
specification_version: 4
|
|
400
400
|
summary: Library for stubbing HTTP requests in Ruby.
|