webmock 3.14.0 → 3.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +124 -2
- data/README.md +46 -18
- data/lib/webmock/api.rb +2 -0
- data/lib/webmock/assertion_failure.rb +2 -0
- data/lib/webmock/callback_registry.rb +2 -0
- data/lib/webmock/config.rb +2 -0
- data/lib/webmock/cucumber.rb +2 -0
- data/lib/webmock/deprecation.rb +2 -0
- data/lib/webmock/errors.rb +2 -0
- data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +8 -1
- data/lib/webmock/http_lib_adapters/curb_adapter.rb +4 -2
- data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +14 -6
- data/lib/webmock/http_lib_adapters/excon_adapter.rb +2 -0
- data/lib/webmock/http_lib_adapters/http_lib_adapter.rb +2 -0
- data/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb +2 -0
- data/lib/webmock/http_lib_adapters/http_rb/client.rb +3 -3
- data/lib/webmock/http_lib_adapters/http_rb/request.rb +3 -1
- data/lib/webmock/http_lib_adapters/http_rb/response.rb +6 -1
- data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +6 -2
- data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +8 -2
- data/lib/webmock/http_lib_adapters/http_rb_adapter.rb +2 -0
- data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +2 -0
- data/lib/webmock/http_lib_adapters/manticore_adapter.rb +2 -0
- data/lib/webmock/http_lib_adapters/net_http.rb +24 -115
- data/lib/webmock/http_lib_adapters/net_http_response.rb +2 -0
- data/lib/webmock/http_lib_adapters/patron_adapter.rb +2 -0
- data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +2 -0
- data/lib/webmock/matchers/any_arg_matcher.rb +2 -0
- data/lib/webmock/matchers/hash_argument_matcher.rb +2 -0
- data/lib/webmock/matchers/hash_excluding_matcher.rb +2 -0
- data/lib/webmock/matchers/hash_including_matcher.rb +2 -0
- data/lib/webmock/minitest.rb +2 -0
- data/lib/webmock/rack_response.rb +2 -0
- data/lib/webmock/request_body_diff.rb +2 -0
- data/lib/webmock/request_execution_verifier.rb +2 -0
- data/lib/webmock/request_pattern.rb +26 -8
- data/lib/webmock/request_registry.rb +2 -0
- data/lib/webmock/request_signature.rb +4 -2
- data/lib/webmock/request_signature_snippet.rb +2 -0
- data/lib/webmock/request_stub.rb +34 -0
- data/lib/webmock/response.rb +10 -8
- data/lib/webmock/responses_sequence.rb +2 -0
- data/lib/webmock/rspec/matchers/request_pattern_matcher.rb +2 -0
- data/lib/webmock/rspec/matchers/webmock_matcher.rb +2 -0
- data/lib/webmock/rspec/matchers.rb +2 -0
- data/lib/webmock/rspec.rb +2 -0
- data/lib/webmock/stub_registry.rb +2 -0
- data/lib/webmock/stub_request_snippet.rb +2 -0
- data/lib/webmock/test_unit.rb +2 -0
- data/lib/webmock/util/hash_counter.rb +12 -6
- data/lib/webmock/util/hash_keys_stringifier.rb +2 -0
- data/lib/webmock/util/hash_validator.rb +2 -0
- data/lib/webmock/util/headers.rb +22 -8
- data/lib/webmock/util/json.rb +2 -0
- data/lib/webmock/util/query_mapper.rb +2 -0
- data/lib/webmock/util/uri.rb +3 -1
- data/lib/webmock/util/values_stringifier.rb +2 -0
- data/lib/webmock/util/version_checker.rb +7 -5
- data/lib/webmock/version.rb +3 -1
- data/lib/webmock/webmock.rb +12 -0
- data/lib/webmock.rb +2 -0
- metadata +51 -183
- data/.gemtest +0 -0
- data/.github/workflows/CI.yml +0 -37
- data/.gitignore +0 -34
- data/.rspec-tm +0 -2
- data/Gemfile +0 -9
- data/Rakefile +0 -38
- data/minitest/test_helper.rb +0 -34
- data/minitest/test_webmock.rb +0 -9
- data/minitest/webmock_spec.rb +0 -60
- data/spec/acceptance/async_http_client/async_http_client_spec.rb +0 -375
- data/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +0 -73
- data/spec/acceptance/curb/curb_spec.rb +0 -499
- data/spec/acceptance/curb/curb_spec_helper.rb +0 -147
- data/spec/acceptance/em_http_request/em_http_request_spec.rb +0 -462
- data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +0 -77
- data/spec/acceptance/excon/excon_spec.rb +0 -77
- data/spec/acceptance/excon/excon_spec_helper.rb +0 -52
- data/spec/acceptance/http_rb/http_rb_spec.rb +0 -93
- data/spec/acceptance/http_rb/http_rb_spec_helper.rb +0 -54
- data/spec/acceptance/httpclient/httpclient_spec.rb +0 -217
- data/spec/acceptance/httpclient/httpclient_spec_helper.rb +0 -57
- data/spec/acceptance/manticore/manticore_spec.rb +0 -107
- data/spec/acceptance/manticore/manticore_spec_helper.rb +0 -35
- data/spec/acceptance/net_http/net_http_shared.rb +0 -153
- data/spec/acceptance/net_http/net_http_spec.rb +0 -369
- data/spec/acceptance/net_http/net_http_spec_helper.rb +0 -64
- data/spec/acceptance/net_http/real_net_http_spec.rb +0 -20
- data/spec/acceptance/patron/patron_spec.rb +0 -125
- data/spec/acceptance/patron/patron_spec_helper.rb +0 -54
- data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +0 -313
- data/spec/acceptance/shared/callbacks.rb +0 -148
- data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +0 -36
- data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +0 -95
- data/spec/acceptance/shared/precedence_of_stubs.rb +0 -15
- data/spec/acceptance/shared/request_expectations.rb +0 -930
- data/spec/acceptance/shared/returning_declared_responses.rb +0 -409
- data/spec/acceptance/shared/stubbing_requests.rb +0 -678
- data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +0 -135
- data/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +0 -60
- data/spec/acceptance/webmock_shared.rb +0 -41
- data/spec/fixtures/test.txt +0 -1
- data/spec/quality_spec.rb +0 -84
- data/spec/spec_helper.rb +0 -48
- data/spec/support/example_curl_output.txt +0 -22
- data/spec/support/failures.rb +0 -9
- data/spec/support/my_rack_app.rb +0 -53
- data/spec/support/network_connection.rb +0 -19
- data/spec/support/webmock_server.rb +0 -70
- data/spec/unit/api_spec.rb +0 -175
- data/spec/unit/errors_spec.rb +0 -129
- data/spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb +0 -17
- data/spec/unit/http_lib_adapters/http_lib_adapter_spec.rb +0 -12
- data/spec/unit/matchers/hash_excluding_matcher_spec.rb +0 -61
- data/spec/unit/matchers/hash_including_matcher_spec.rb +0 -87
- data/spec/unit/rack_response_spec.rb +0 -112
- data/spec/unit/request_body_diff_spec.rb +0 -90
- data/spec/unit/request_execution_verifier_spec.rb +0 -208
- data/spec/unit/request_pattern_spec.rb +0 -736
- data/spec/unit/request_registry_spec.rb +0 -95
- data/spec/unit/request_signature_snippet_spec.rb +0 -89
- data/spec/unit/request_signature_spec.rb +0 -155
- data/spec/unit/request_stub_spec.rb +0 -199
- data/spec/unit/response_spec.rb +0 -286
- data/spec/unit/stub_registry_spec.rb +0 -103
- data/spec/unit/stub_request_snippet_spec.rb +0 -115
- data/spec/unit/util/hash_counter_spec.rb +0 -39
- data/spec/unit/util/hash_keys_stringifier_spec.rb +0 -27
- data/spec/unit/util/headers_spec.rb +0 -28
- data/spec/unit/util/json_spec.rb +0 -33
- data/spec/unit/util/query_mapper_spec.rb +0 -157
- data/spec/unit/util/uri_spec.rb +0 -371
- data/spec/unit/util/version_checker_spec.rb +0 -65
- data/spec/unit/webmock_spec.rb +0 -60
- data/test/http_request.rb +0 -24
- data/test/shared_test.rb +0 -108
- data/test/test_helper.rb +0 -23
- data/test/test_webmock.rb +0 -12
- data/webmock.gemspec +0 -54
@@ -1,95 +0,0 @@
|
|
1
|
-
shared_context "enabled and disabled webmock" do |*adapter_info|
|
2
|
-
describe "when webmock is disabled" do
|
3
|
-
before(:each) do
|
4
|
-
WebMock.disable!
|
5
|
-
end
|
6
|
-
after(:each) do
|
7
|
-
WebMock.enable!
|
8
|
-
end
|
9
|
-
include_context "disabled WebMock"
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "when webmock is enabled again" do
|
13
|
-
before(:each) do
|
14
|
-
WebMock.disable!
|
15
|
-
WebMock.enable!
|
16
|
-
end
|
17
|
-
include_context "enabled WebMock"
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "when webmock is disabled except this lib" do
|
21
|
-
before(:each) do
|
22
|
-
WebMock.disable!(except: [http_library])
|
23
|
-
end
|
24
|
-
after(:each) do
|
25
|
-
WebMock.enable!
|
26
|
-
end
|
27
|
-
include_context "enabled WebMock"
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "when webmock is enabled except this lib" do
|
31
|
-
before(:each) do
|
32
|
-
WebMock.disable!
|
33
|
-
WebMock.enable!(except: [http_library])
|
34
|
-
end
|
35
|
-
after(:each) do
|
36
|
-
WebMock.enable!
|
37
|
-
end
|
38
|
-
include_context "disabled WebMock"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
shared_context "disabled WebMock" do
|
43
|
-
it "should not register executed requests" do
|
44
|
-
http_request(:get, webmock_server_url)
|
45
|
-
expect(a_request(:get, webmock_server_url)).not_to have_been_made
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should not block unstubbed requests" do
|
49
|
-
expect {
|
50
|
-
http_request(:get, webmock_server_url)
|
51
|
-
}.not_to raise_error
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should return real response even if there are stubs" do
|
55
|
-
stub_request(:get, /.*/).to_return(body: "x")
|
56
|
-
expect(http_request(:get, webmock_server_url).body).to eq("hello world")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should not invoke any callbacks" do
|
60
|
-
WebMock.reset_callbacks
|
61
|
-
stub_request(:get, webmock_server_url)
|
62
|
-
@called = nil
|
63
|
-
WebMock.after_request { @called = 1 }
|
64
|
-
http_request(:get, webmock_server_url)
|
65
|
-
expect(@called).to eq(nil)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
shared_context "enabled WebMock" do
|
70
|
-
it "should register executed requests" do
|
71
|
-
WebMock.allow_net_connect!
|
72
|
-
http_request(:get, webmock_server_url)
|
73
|
-
expect(a_request(:get, webmock_server_url)).to have_been_made
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should block unstubbed requests" do
|
77
|
-
expect {
|
78
|
-
http_request(:get, "http://www.example.com/")
|
79
|
-
}.to raise_error(WebMock::NetConnectNotAllowedError)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should return stubbed response" do
|
83
|
-
stub_request(:get, /.*/).to_return(body: "x")
|
84
|
-
expect(http_request(:get, "http://www.example.com/").body).to eq("x")
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should invoke callbacks" do
|
88
|
-
WebMock.allow_net_connect!
|
89
|
-
WebMock.reset_callbacks
|
90
|
-
@called = nil
|
91
|
-
WebMock.after_request { @called = 1 }
|
92
|
-
http_request(:get, webmock_server_url)
|
93
|
-
expect(@called).to eq(1)
|
94
|
-
end
|
95
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
shared_context "precedence of stubs" do |*adapter_info|
|
2
|
-
describe "when choosing a matching request stub" do
|
3
|
-
it "should use the last declared matching request stub" do
|
4
|
-
stub_request(:get, "www.example.com").to_return(body: "abc")
|
5
|
-
stub_request(:get, "www.example.com").to_return(body: "def")
|
6
|
-
expect(http_request(:get, "http://www.example.com/").body).to eq("def")
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should not be affected by the type of uri or request method" do
|
10
|
-
stub_request(:get, "www.example.com").to_return(body: "abc")
|
11
|
-
stub_request(:any, /.*example.*/).to_return(body: "def")
|
12
|
-
expect(http_request(:get, "http://www.example.com/").body).to eq("def")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|