webmock 3.18.1 → 3.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/README.md +34 -15
  4. data/lib/webmock/api.rb +2 -0
  5. data/lib/webmock/assertion_failure.rb +2 -0
  6. data/lib/webmock/callback_registry.rb +2 -0
  7. data/lib/webmock/config.rb +2 -0
  8. data/lib/webmock/cucumber.rb +2 -0
  9. data/lib/webmock/deprecation.rb +2 -0
  10. data/lib/webmock/errors.rb +2 -0
  11. data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +2 -0
  12. data/lib/webmock/http_lib_adapters/curb_adapter.rb +2 -0
  13. data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +14 -6
  14. data/lib/webmock/http_lib_adapters/excon_adapter.rb +2 -0
  15. data/lib/webmock/http_lib_adapters/http_lib_adapter.rb +2 -0
  16. data/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb +2 -0
  17. data/lib/webmock/http_lib_adapters/http_rb/client.rb +2 -0
  18. data/lib/webmock/http_lib_adapters/http_rb/request.rb +3 -1
  19. data/lib/webmock/http_lib_adapters/http_rb/response.rb +2 -0
  20. data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +2 -0
  21. data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +2 -0
  22. data/lib/webmock/http_lib_adapters/http_rb_adapter.rb +2 -0
  23. data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +2 -0
  24. data/lib/webmock/http_lib_adapters/manticore_adapter.rb +2 -0
  25. data/lib/webmock/http_lib_adapters/net_http.rb +2 -0
  26. data/lib/webmock/http_lib_adapters/net_http_response.rb +2 -0
  27. data/lib/webmock/http_lib_adapters/patron_adapter.rb +2 -0
  28. data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +2 -0
  29. data/lib/webmock/matchers/any_arg_matcher.rb +2 -0
  30. data/lib/webmock/matchers/hash_argument_matcher.rb +2 -0
  31. data/lib/webmock/matchers/hash_excluding_matcher.rb +2 -0
  32. data/lib/webmock/matchers/hash_including_matcher.rb +2 -0
  33. data/lib/webmock/minitest.rb +2 -0
  34. data/lib/webmock/rack_response.rb +2 -0
  35. data/lib/webmock/request_body_diff.rb +2 -0
  36. data/lib/webmock/request_execution_verifier.rb +2 -0
  37. data/lib/webmock/request_pattern.rb +3 -1
  38. data/lib/webmock/request_registry.rb +2 -0
  39. data/lib/webmock/request_signature.rb +2 -0
  40. data/lib/webmock/request_signature_snippet.rb +2 -0
  41. data/lib/webmock/request_stub.rb +7 -1
  42. data/lib/webmock/response.rb +2 -0
  43. data/lib/webmock/responses_sequence.rb +2 -0
  44. data/lib/webmock/rspec/matchers/request_pattern_matcher.rb +2 -0
  45. data/lib/webmock/rspec/matchers/webmock_matcher.rb +2 -0
  46. data/lib/webmock/rspec/matchers.rb +2 -0
  47. data/lib/webmock/rspec.rb +2 -0
  48. data/lib/webmock/stub_registry.rb +2 -0
  49. data/lib/webmock/stub_request_snippet.rb +2 -0
  50. data/lib/webmock/test_unit.rb +2 -0
  51. data/lib/webmock/util/hash_counter.rb +12 -6
  52. data/lib/webmock/util/hash_keys_stringifier.rb +2 -0
  53. data/lib/webmock/util/hash_validator.rb +2 -0
  54. data/lib/webmock/util/headers.rb +22 -8
  55. data/lib/webmock/util/json.rb +2 -0
  56. data/lib/webmock/util/query_mapper.rb +2 -0
  57. data/lib/webmock/util/uri.rb +3 -1
  58. data/lib/webmock/util/values_stringifier.rb +2 -0
  59. data/lib/webmock/util/version_checker.rb +7 -5
  60. data/lib/webmock/version.rb +3 -1
  61. data/lib/webmock/webmock.rb +2 -0
  62. data/lib/webmock.rb +2 -0
  63. metadata +36 -168
  64. data/.gemtest +0 -0
  65. data/.github/workflows/CI.yml +0 -38
  66. data/.gitignore +0 -34
  67. data/.rspec-tm +0 -2
  68. data/Gemfile +0 -9
  69. data/Rakefile +0 -38
  70. data/minitest/test_helper.rb +0 -34
  71. data/minitest/test_webmock.rb +0 -9
  72. data/minitest/webmock_spec.rb +0 -60
  73. data/spec/acceptance/async_http_client/async_http_client_spec.rb +0 -375
  74. data/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +0 -73
  75. data/spec/acceptance/curb/curb_spec.rb +0 -510
  76. data/spec/acceptance/curb/curb_spec_helper.rb +0 -147
  77. data/spec/acceptance/em_http_request/em_http_request_spec.rb +0 -462
  78. data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +0 -77
  79. data/spec/acceptance/excon/excon_spec.rb +0 -77
  80. data/spec/acceptance/excon/excon_spec_helper.rb +0 -52
  81. data/spec/acceptance/http_rb/http_rb_spec.rb +0 -93
  82. data/spec/acceptance/http_rb/http_rb_spec_helper.rb +0 -54
  83. data/spec/acceptance/httpclient/httpclient_spec.rb +0 -217
  84. data/spec/acceptance/httpclient/httpclient_spec_helper.rb +0 -57
  85. data/spec/acceptance/manticore/manticore_spec.rb +0 -107
  86. data/spec/acceptance/manticore/manticore_spec_helper.rb +0 -35
  87. data/spec/acceptance/net_http/net_http_shared.rb +0 -190
  88. data/spec/acceptance/net_http/net_http_spec.rb +0 -395
  89. data/spec/acceptance/net_http/net_http_spec_helper.rb +0 -64
  90. data/spec/acceptance/net_http/real_net_http_spec.rb +0 -20
  91. data/spec/acceptance/patron/patron_spec.rb +0 -123
  92. data/spec/acceptance/patron/patron_spec_helper.rb +0 -54
  93. data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +0 -313
  94. data/spec/acceptance/shared/callbacks.rb +0 -148
  95. data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +0 -36
  96. data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +0 -95
  97. data/spec/acceptance/shared/precedence_of_stubs.rb +0 -15
  98. data/spec/acceptance/shared/request_expectations.rb +0 -930
  99. data/spec/acceptance/shared/returning_declared_responses.rb +0 -409
  100. data/spec/acceptance/shared/stubbing_requests.rb +0 -678
  101. data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +0 -135
  102. data/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +0 -60
  103. data/spec/acceptance/webmock_shared.rb +0 -41
  104. data/spec/fixtures/test.txt +0 -1
  105. data/spec/quality_spec.rb +0 -84
  106. data/spec/spec_helper.rb +0 -48
  107. data/spec/support/example_curl_output.txt +0 -22
  108. data/spec/support/failures.rb +0 -9
  109. data/spec/support/my_rack_app.rb +0 -53
  110. data/spec/support/network_connection.rb +0 -19
  111. data/spec/support/webmock_server.rb +0 -70
  112. data/spec/unit/api_spec.rb +0 -175
  113. data/spec/unit/errors_spec.rb +0 -129
  114. data/spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb +0 -17
  115. data/spec/unit/http_lib_adapters/http_lib_adapter_spec.rb +0 -12
  116. data/spec/unit/matchers/hash_excluding_matcher_spec.rb +0 -61
  117. data/spec/unit/matchers/hash_including_matcher_spec.rb +0 -87
  118. data/spec/unit/rack_response_spec.rb +0 -112
  119. data/spec/unit/request_body_diff_spec.rb +0 -90
  120. data/spec/unit/request_execution_verifier_spec.rb +0 -208
  121. data/spec/unit/request_pattern_spec.rb +0 -748
  122. data/spec/unit/request_registry_spec.rb +0 -95
  123. data/spec/unit/request_signature_snippet_spec.rb +0 -89
  124. data/spec/unit/request_signature_spec.rb +0 -175
  125. data/spec/unit/request_stub_spec.rb +0 -234
  126. data/spec/unit/response_spec.rb +0 -314
  127. data/spec/unit/stub_registry_spec.rb +0 -103
  128. data/spec/unit/stub_request_snippet_spec.rb +0 -115
  129. data/spec/unit/util/hash_counter_spec.rb +0 -39
  130. data/spec/unit/util/hash_keys_stringifier_spec.rb +0 -27
  131. data/spec/unit/util/headers_spec.rb +0 -28
  132. data/spec/unit/util/json_spec.rb +0 -33
  133. data/spec/unit/util/query_mapper_spec.rb +0 -157
  134. data/spec/unit/util/uri_spec.rb +0 -371
  135. data/spec/unit/util/version_checker_spec.rb +0 -65
  136. data/spec/unit/webmock_spec.rb +0 -114
  137. data/test/http_request.rb +0 -24
  138. data/test/shared_test.rb +0 -108
  139. data/test/test_helper.rb +0 -23
  140. data/test/test_webmock.rb +0 -12
  141. 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