webmock 3.14.0 → 3.19.1

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 +124 -2
  3. data/README.md +46 -18
  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 +8 -1
  12. data/lib/webmock/http_lib_adapters/curb_adapter.rb +4 -2
  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 +3 -3
  18. data/lib/webmock/http_lib_adapters/http_rb/request.rb +3 -1
  19. data/lib/webmock/http_lib_adapters/http_rb/response.rb +6 -1
  20. data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +6 -2
  21. data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +8 -2
  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 +24 -115
  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 +26 -8
  38. data/lib/webmock/request_registry.rb +2 -0
  39. data/lib/webmock/request_signature.rb +4 -2
  40. data/lib/webmock/request_signature_snippet.rb +2 -0
  41. data/lib/webmock/request_stub.rb +34 -0
  42. data/lib/webmock/response.rb +10 -8
  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 +12 -0
  62. data/lib/webmock.rb +2 -0
  63. metadata +51 -183
  64. data/.gemtest +0 -0
  65. data/.github/workflows/CI.yml +0 -37
  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 -499
  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 -153
  88. data/spec/acceptance/net_http/net_http_spec.rb +0 -369
  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 -125
  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 -736
  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 -155
  125. data/spec/unit/request_stub_spec.rb +0 -199
  126. data/spec/unit/response_spec.rb +0 -286
  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 -60
  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
data/test/shared_test.rb DELETED
@@ -1,108 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/http_request')
2
-
3
- module SharedTest
4
- include HttpRequestTestHelper
5
-
6
- def setup
7
- super
8
- @stub_http = stub_http_request(:any, "http://www.example.com")
9
- @stub_https = stub_http_request(:any, "https://www.example.com")
10
- end
11
-
12
- def test_assert_requested_with_stub_and_block_raises_error
13
- assert_raises ArgumentError do
14
- assert_requested(@stub_http) {}
15
- end
16
- end
17
-
18
- def test_assert_not_requested_with_stub_and_block_raises_error
19
- assert_raises ArgumentError do
20
- assert_not_requested(@stub_http) {}
21
- end
22
- end
23
-
24
- def test_error_on_non_stubbed_request
25
- assert_raise_with_message(WebMock::NetConnectNotAllowedError, %r{Real HTTP connections are disabled. Unregistered request: GET http://www.example.net/ with headers}) do
26
- http_request(:get, "http://www.example.net/")
27
- end
28
- end
29
-
30
- def test_verification_that_expected_request_occured
31
- http_request(:get, "http://www.example.com/")
32
- assert_requested(:get, "http://www.example.com", times: 1)
33
- assert_requested(:get, "http://www.example.com")
34
- end
35
-
36
- def test_verification_that_expected_stub_occured
37
- http_request(:get, "http://www.example.com/")
38
- assert_requested(@stub_http, times: 1)
39
- assert_requested(@stub_http)
40
- end
41
-
42
- def test_verification_that_expected_request_didnt_occur
43
- expected_message = "The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times"
44
- expected_message += "\n\nThe following requests were made:\n\nNo requests were made.\n============================================================"
45
- assert_fail(expected_message) do
46
- assert_requested(:get, "http://www.example.com")
47
- end
48
- end
49
-
50
- def test_verification_that_expected_stub_didnt_occur
51
- expected_message = "The request ANY http://www.example.com/ was expected to execute 1 time but it executed 0 times"
52
- expected_message += "\n\nThe following requests were made:\n\nNo requests were made.\n============================================================"
53
- assert_fail(expected_message) do
54
- assert_requested(@stub_http)
55
- end
56
- end
57
-
58
- def test_verification_that_expected_request_occured_with_body_and_headers
59
- http_request(:get, "http://www.example.com/",
60
- body: "abc", headers: {'A' => 'a'})
61
- assert_requested(:get, "http://www.example.com",
62
- body: "abc", headers: {'A' => 'a'})
63
- end
64
-
65
- def test_verification_that_expected_request_occured_with_query_params
66
- stub_request(:any, "http://www.example.com").with(query: hash_including({"a" => ["b", "c"]}))
67
- http_request(:get, "http://www.example.com/?a[]=b&a[]=c&x=1")
68
- assert_requested(:get, "http://www.example.com",
69
- query: hash_including({"a" => ["b", "c"]}))
70
- end
71
-
72
- def test_verification_that_expected_request_not_occured_with_query_params
73
- stub_request(:any, 'http://www.example.com').with(query: hash_including(a: ['b', 'c']))
74
- stub_request(:any, 'http://www.example.com').with(query: hash_excluding(a: ['b', 'c']))
75
- http_request(:get, 'http://www.example.com/?a[]=b&a[]=c&x=1')
76
- assert_not_requested(:get, 'http://www.example.com', query: hash_excluding('a' => ['b', 'c']))
77
- end
78
-
79
- def test_verification_that_expected_request_occured_with_excluding_query_params
80
- stub_request(:any, 'http://www.example.com').with(query: hash_excluding('a' => ['b', 'c']))
81
- http_request(:get, 'http://www.example.com/?a[]=x&a[]=y&x=1')
82
- assert_requested(:get, 'http://www.example.com', query: hash_excluding('a' => ['b', 'c']))
83
- end
84
-
85
- def test_verification_that_non_expected_request_didnt_occur
86
- expected_message = %r(The request GET http://www.example.com/ was not expected to execute but it executed 1 time\n\nThe following requests were made:\n\nGET http://www.example.com/ with headers .+ was made 1 time\n\n============================================================)
87
- assert_fail(expected_message) do
88
- http_request(:get, "http://www.example.com/")
89
- assert_not_requested(:get, "http://www.example.com")
90
- end
91
- end
92
-
93
- def test_refute_requested_alias
94
- expected_message = %r(The request GET http://www.example.com/ was not expected to execute but it executed 1 time\n\nThe following requests were made:\n\nGET http://www.example.com/ with headers .+ was made 1 time\n\n============================================================)
95
- assert_fail(expected_message) do
96
- http_request(:get, "http://www.example.com/")
97
- refute_requested(:get, "http://www.example.com")
98
- end
99
- end
100
-
101
- def test_verification_that_non_expected_stub_didnt_occur
102
- expected_message = %r(The request ANY http://www.example.com/ was not expected to execute but it executed 1 time\n\nThe following requests were made:\n\nGET http://www.example.com/ with headers .+ was made 1 time\n\n============================================================)
103
- assert_fail(expected_message) do
104
- http_request(:get, "http://www.example.com/")
105
- assert_not_requested(@stub_http)
106
- end
107
- end
108
- end
data/test/test_helper.rb DELETED
@@ -1,23 +0,0 @@
1
- require 'rubygems'
2
-
3
- $LOAD_PATH.unshift(File.dirname(__FILE__))
4
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
-
6
- require 'webmock/test_unit'
7
- require 'test/unit'
8
-
9
- class Test::Unit::TestCase
10
- AssertionFailedError = Test::Unit::AssertionFailedError rescue MiniTest::Assertion
11
- def assert_raise_with_message(e, message, &block)
12
- e = assert_raises(e, &block)
13
- if message.is_a?(Regexp)
14
- assert_match(message, e.message)
15
- else
16
- assert_equal(message, e.message)
17
- end
18
- end
19
-
20
- def assert_fail(message, &block)
21
- assert_raise_with_message(AssertionFailedError, message, &block)
22
- end
23
- end
data/test/test_webmock.rb DELETED
@@ -1,12 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
- require File.expand_path(File.dirname(__FILE__) + '/shared_test')
3
-
4
- class TestWebMock < Test::Unit::TestCase
5
- include SharedTest
6
-
7
- def teardown
8
- # Ensure global Test::Unit teardown was called
9
- assert_empty WebMock::RequestRegistry.instance.requested_signatures.hash
10
- assert_empty WebMock::StubRegistry.instance.request_stubs
11
- end
12
- end
data/webmock.gemspec DELETED
@@ -1,54 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
3
- require 'webmock/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'webmock'
7
- s.version = WebMock::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ['Bartosz Blimke']
10
- s.email = ['bartosz.blimke@gmail.com']
11
- s.homepage = 'http://github.com/bblimke/webmock'
12
- s.summary = %q{Library for stubbing HTTP requests in Ruby.}
13
- s.description = %q{WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.}
14
- s.license = "MIT"
15
-
16
- s.metadata = {
17
- 'bug_tracker_uri' => 'https://github.com/bblimke/webmock/issues',
18
- 'changelog_uri' => "https://github.com/bblimke/webmock/blob/v#{s.version}/CHANGELOG.md",
19
- 'documentation_uri' => "https://www.rubydoc.info/gems/webmock/#{s.version}",
20
- 'source_code_uri' => "https://github.com/bblimke/webmock/tree/v#{s.version}",
21
- 'wiki_uri' => 'https://github.com/bblimke/webmock/wiki'
22
- }
23
-
24
- s.required_ruby_version = '>= 2.0'
25
-
26
- s.add_dependency 'addressable', '>= 2.8.0'
27
- s.add_dependency 'crack', '>= 0.3.2'
28
- s.add_dependency 'hashdiff', ['>= 0.4.0', '< 2.0.0']
29
-
30
- unless RUBY_PLATFORM =~ /java/
31
- s.add_development_dependency 'patron', '>= 0.4.18'
32
- s.add_development_dependency 'curb', '>= 0.7.16'
33
- s.add_development_dependency 'typhoeus', '>= 0.5.0'
34
- end
35
-
36
- s.add_development_dependency 'http', '>= 0.8.0'
37
- s.add_development_dependency 'manticore', '>= 0.5.1' if RUBY_PLATFORM =~ /java/
38
- s.add_development_dependency 'rack', ((RUBY_VERSION < '2.2.2') ? '1.6.0' : '> 1.6')
39
- s.add_development_dependency 'rspec', '>= 3.1.0'
40
- 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
- s.add_development_dependency 'excon', '>= 0.27.5'
44
- s.add_development_dependency 'async-http', '>= 0.48.0'
45
- s.add_development_dependency 'minitest', '>= 5.0.0'
46
- s.add_development_dependency 'test-unit', '>= 3.0.0'
47
- s.add_development_dependency 'rdoc', '> 3.5.0'
48
- s.add_development_dependency 'webrick'
49
-
50
- s.files = `git ls-files`.split("\n")
51
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
52
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
53
- s.require_paths = ['lib']
54
- end