webmock 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -7
- data/README.md +54 -53
- data/Rakefile +1 -1
- data/lib/webmock/callback_registry.rb +1 -1
- data/lib/webmock/http_lib_adapters/curb_adapter.rb +68 -6
- data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +4 -4
- data/lib/webmock/http_lib_adapters/excon_adapter.rb +9 -9
- data/lib/webmock/http_lib_adapters/http_rb/request.rb +2 -2
- data/lib/webmock/http_lib_adapters/http_rb/response.rb +5 -5
- data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +3 -3
- data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +5 -5
- data/lib/webmock/http_lib_adapters/manticore_adapter.rb +7 -7
- data/lib/webmock/http_lib_adapters/net_http.rb +3 -3
- data/lib/webmock/http_lib_adapters/patron_adapter.rb +4 -4
- data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +14 -14
- data/lib/webmock/matchers/hash_including_matcher.rb +1 -1
- data/lib/webmock/rack_response.rb +3 -3
- data/lib/webmock/request_pattern.rb +8 -8
- data/lib/webmock/request_stub.rb +5 -5
- data/lib/webmock/util/uri.rb +2 -2
- data/lib/webmock/version.rb +1 -1
- data/minitest/webmock_spec.rb +3 -3
- data/spec/acceptance/curb/curb_spec.rb +64 -47
- data/spec/acceptance/curb/curb_spec_helper.rb +4 -4
- data/spec/acceptance/em_http_request/em_http_request_spec.rb +32 -32
- data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +9 -9
- data/spec/acceptance/excon/excon_spec.rb +14 -14
- data/spec/acceptance/excon/excon_spec_helper.rb +6 -6
- data/spec/acceptance/http_rb/http_rb_spec.rb +1 -1
- data/spec/acceptance/http_rb/http_rb_spec_helper.rb +7 -7
- data/spec/acceptance/httpclient/httpclient_spec.rb +20 -20
- data/spec/acceptance/httpclient/httpclient_spec_helper.rb +5 -5
- data/spec/acceptance/manticore/manticore_spec.rb +11 -11
- data/spec/acceptance/manticore/manticore_spec_helper.rb +3 -3
- data/spec/acceptance/net_http/net_http_shared.rb +4 -4
- data/spec/acceptance/net_http/net_http_spec.rb +25 -25
- data/spec/acceptance/net_http/net_http_spec_helper.rb +4 -4
- data/spec/acceptance/net_http/real_net_http_spec.rb +1 -1
- data/spec/acceptance/patron/patron_spec.rb +10 -10
- data/spec/acceptance/patron/patron_spec_helper.rb +5 -5
- data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +36 -36
- data/spec/acceptance/shared/callbacks.rb +11 -11
- data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +5 -5
- data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +4 -4
- data/spec/acceptance/shared/precedence_of_stubs.rb +4 -4
- data/spec/acceptance/shared/request_expectations.rb +90 -90
- data/spec/acceptance/shared/returning_declared_responses.rb +49 -49
- data/spec/acceptance/shared/stubbing_requests.rb +78 -78
- data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +11 -11
- data/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +8 -8
- data/spec/spec_helper.rb +6 -3
- data/spec/support/webmock_server.rb +1 -1
- data/spec/unit/api_spec.rb +2 -2
- data/spec/unit/errors_spec.rb +3 -3
- data/spec/unit/matchers/hash_including_matcher_spec.rb +16 -16
- data/spec/unit/rack_response_spec.rb +2 -2
- data/spec/unit/request_body_diff_spec.rb +1 -1
- data/spec/unit/request_execution_verifier_spec.rb +1 -1
- data/spec/unit/request_pattern_spec.rb +115 -115
- data/spec/unit/request_signature_snippet_spec.rb +2 -2
- data/spec/unit/request_signature_spec.rb +16 -16
- data/spec/unit/request_stub_spec.rb +20 -20
- data/spec/unit/response_spec.rb +28 -28
- data/spec/unit/stub_registry_spec.rb +10 -10
- data/spec/unit/stub_request_snippet_spec.rb +6 -6
- data/spec/unit/util/hash_keys_stringifier_spec.rb +4 -4
- data/spec/unit/util/query_mapper_spec.rb +2 -2
- data/spec/unit/util/uri_spec.rb +1 -1
- data/test/http_request.rb +3 -3
- data/test/shared_test.rb +6 -6
- data/webmock.gemspec +4 -2
- metadata +32 -4
@@ -4,7 +4,7 @@ describe WebMock::StubRequestSnippet do
|
|
4
4
|
describe "to_s" do
|
5
5
|
describe "GET" do
|
6
6
|
before(:each) do
|
7
|
-
@request_signature = WebMock::RequestSignature.new(:get, "www.example.com/?a=b&c=d", :
|
7
|
+
@request_signature = WebMock::RequestSignature.new(:get, "www.example.com/?a=b&c=d", headers: {})
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should print stub request snippet with url with params and method and empty successful response" do
|
@@ -53,7 +53,7 @@ describe WebMock::StubRequestSnippet do
|
|
53
53
|
it "should not print to_return part if not wanted" do
|
54
54
|
expected = 'stub_request(:get, "http://www.example.com/").'+
|
55
55
|
"\n with(:body => \"abcdef\")"
|
56
|
-
stub = WebMock::RequestStub.new(:get, "www.example.com").with(:
|
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
|
59
59
|
end
|
@@ -63,8 +63,8 @@ describe WebMock::StubRequestSnippet do
|
|
63
63
|
let(:multipart_form_body) { 'complicated stuff--ABC123--goes here' }
|
64
64
|
it "should print stub request snippet with body as a hash using rails conventions on form posts" do
|
65
65
|
@request_signature = WebMock::RequestSignature.new(:post, "www.example.com",
|
66
|
-
:
|
67
|
-
:
|
66
|
+
headers: {'Content-Type' => 'application/x-www-form-urlencoded'},
|
67
|
+
body: form_body)
|
68
68
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
69
69
|
expected = <<-STUB
|
70
70
|
stub_request(:post, "http://www.example.com/").
|
@@ -77,8 +77,8 @@ stub_request(:post, "http://www.example.com/").
|
|
77
77
|
|
78
78
|
it "should print stub request snippet leaving body as string when not a urlencoded form" do
|
79
79
|
@request_signature = WebMock::RequestSignature.new(:post, "www.example.com",
|
80
|
-
:
|
81
|
-
:
|
80
|
+
headers: {'Content-Type' => 'multipart/form-data; boundary=ABC123'},
|
81
|
+
body: multipart_form_body)
|
82
82
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
83
83
|
expected = <<-STUB
|
84
84
|
stub_request(:post, "http://www.example.com/").
|
@@ -4,10 +4,10 @@ describe WebMock::Util::HashKeysStringifier do
|
|
4
4
|
|
5
5
|
it "should recursively stringify all symbol keys" do
|
6
6
|
hash = {
|
7
|
-
:
|
8
|
-
:
|
7
|
+
a: {
|
8
|
+
b: [
|
9
9
|
{
|
10
|
-
:
|
10
|
+
c: [{d: "1"}]
|
11
11
|
}
|
12
12
|
]
|
13
13
|
}
|
@@ -21,7 +21,7 @@ describe WebMock::Util::HashKeysStringifier do
|
|
21
21
|
]
|
22
22
|
}
|
23
23
|
}
|
24
|
-
expect(WebMock::Util::HashKeysStringifier.stringify_keys!(hash, :
|
24
|
+
expect(WebMock::Util::HashKeysStringifier.stringify_keys!(hash, deep: true)).to eq(stringified)
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -6,7 +6,7 @@ describe WebMock::Util::QueryMapper do
|
|
6
6
|
context '#query_to_values' do
|
7
7
|
it 'should raise on invalid notation' do
|
8
8
|
query = 'a=&b=c'
|
9
|
-
expect { subject.query_to_values(query, {:
|
9
|
+
expect { subject.query_to_values(query, {notation: 'foo'}) }.to raise_error(
|
10
10
|
ArgumentError,
|
11
11
|
'Invalid notation. Must be one of: [:flat, :dot, :subscript, :flat_array].'
|
12
12
|
)
|
@@ -77,7 +77,7 @@ describe WebMock::Util::QueryMapper do
|
|
77
77
|
expect(subject.to_query('a', {'key' => 'value'})).to eq('a[key]=value')
|
78
78
|
end
|
79
79
|
it 'should transform hash value with keys that are symbols' do
|
80
|
-
expect(subject.to_query('a', {:
|
80
|
+
expect(subject.to_query('a', {key: 'value'})).to eq('a[key]=value')
|
81
81
|
end
|
82
82
|
it 'should transform array value' do
|
83
83
|
expect(subject.to_query('a', ['b', 'c'])).to eq('a[0]=b&a[1]=c')
|
data/spec/unit/util/uri_spec.rb
CHANGED
@@ -206,7 +206,7 @@ describe WebMock::Util::URI do
|
|
206
206
|
it "should successfully handle repeated paramters" do
|
207
207
|
uri_string = "http://www.example.com:80/path?target=host1&target=host2"
|
208
208
|
uri = WebMock::Util::URI.normalize_uri(uri_string)
|
209
|
-
expect(WebMock::Util::QueryMapper.query_to_values(uri.query, :
|
209
|
+
expect(WebMock::Util::QueryMapper.query_to_values(uri.query, notation: WebMock::Config.instance.query_values_notation)).to eq([['target', 'host1'], ['target', 'host2']])
|
210
210
|
end
|
211
211
|
end
|
212
212
|
end
|
data/test/http_request.rb
CHANGED
@@ -17,8 +17,8 @@ module HttpRequestTestHelper
|
|
17
17
|
http.request(req, options[:body])
|
18
18
|
}
|
19
19
|
OpenStruct.new({
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
20
|
+
body: response.body,
|
21
|
+
headers: response,
|
22
|
+
status: response.code })
|
23
23
|
end
|
24
24
|
end
|
data/test/shared_test.rb
CHANGED
@@ -30,13 +30,13 @@ module SharedTest
|
|
30
30
|
|
31
31
|
def test_verification_that_expected_request_occured
|
32
32
|
http_request(:get, "http://www.example.com/")
|
33
|
-
assert_requested(:get, "http://www.example.com", :
|
33
|
+
assert_requested(:get, "http://www.example.com", times: 1)
|
34
34
|
assert_requested(:get, "http://www.example.com")
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_verification_that_expected_stub_occured
|
38
38
|
http_request(:get, "http://www.example.com/")
|
39
|
-
assert_requested(@stub_http, :
|
39
|
+
assert_requested(@stub_http, times: 1)
|
40
40
|
assert_requested(@stub_http)
|
41
41
|
end
|
42
42
|
|
@@ -58,16 +58,16 @@ module SharedTest
|
|
58
58
|
|
59
59
|
def test_verification_that_expected_request_occured_with_body_and_headers
|
60
60
|
http_request(:get, "http://www.example.com/",
|
61
|
-
:
|
61
|
+
body: "abc", headers: {'A' => 'a'})
|
62
62
|
assert_requested(:get, "http://www.example.com",
|
63
|
-
:
|
63
|
+
body: "abc", headers: {'A' => 'a'})
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_verification_that_expected_request_occured_with_query_params
|
67
|
-
stub_request(:any, "http://www.example.com").with(:
|
67
|
+
stub_request(:any, "http://www.example.com").with(query: hash_including({"a" => ["b", "c"]}))
|
68
68
|
http_request(:get, "http://www.example.com/?a[]=b&a[]=c&x=1")
|
69
69
|
assert_requested(:get, "http://www.example.com",
|
70
|
-
:
|
70
|
+
query: hash_including({"a" => ["b", "c"]}))
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_verification_that_non_expected_request_didnt_occur
|
data/webmock.gemspec
CHANGED
@@ -31,9 +31,11 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_development_dependency 'typhoeus', '>= 0.5.0' unless RUBY_PLATFORM =~ /java/
|
32
32
|
s.add_development_dependency 'manticore', '>= 0.5.1' if RUBY_PLATFORM =~ /java/
|
33
33
|
s.add_development_dependency 'excon', '>= 0.27.5'
|
34
|
-
s.add_development_dependency 'minitest', '
|
35
|
-
s.add_development_dependency '
|
34
|
+
s.add_development_dependency 'minitest', '>= 5.0.0'
|
35
|
+
s.add_development_dependency 'test-unit', '>= 3.0.0'
|
36
|
+
s.add_development_dependency 'rdoc', '> 3.5.0'
|
36
37
|
s.add_development_dependency 'rack'
|
38
|
+
s.add_development_dependency 'simplecov'
|
37
39
|
|
38
40
|
s.files = `git ls-files`.split("\n")
|
39
41
|
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: 2.0
|
4
|
+
version: 2.1.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: 2016-
|
11
|
+
date: 2016-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -182,16 +182,30 @@ dependencies:
|
|
182
182
|
name: minitest
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- - "
|
185
|
+
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: 5.0.0
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- - "
|
192
|
+
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: 5.0.0
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: test-unit
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 3.0.0
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 3.0.0
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: rdoc
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +234,20 @@ dependencies:
|
|
220
234
|
- - ">="
|
221
235
|
- !ruby/object:Gem::Version
|
222
236
|
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: simplecov
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
223
251
|
description: WebMock allows stubbing HTTP requests and setting expectations on HTTP
|
224
252
|
requests.
|
225
253
|
email:
|