webmock 3.14.0 → 3.25.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/CHANGELOG.md +213 -3
- data/README.md +66 -20
- 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 +16 -4
- data/lib/webmock/http_lib_adapters/curb_adapter.rb +4 -2
- data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +17 -7
- 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 +17 -5
- data/lib/webmock/http_lib_adapters/http_rb/response.rb +32 -9
- data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +10 -2
- data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +8 -2
- data/lib/webmock/http_lib_adapters/http_rb_adapter.rb +7 -5
- data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +26 -25
- data/lib/webmock/http_lib_adapters/manticore_adapter.rb +2 -0
- data/lib/webmock/http_lib_adapters/net_http.rb +46 -121
- data/lib/webmock/http_lib_adapters/net_http_response.rb +2 -0
- data/lib/webmock/http_lib_adapters/patron_adapter.rb +3 -1
- data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +18 -2
- 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 +5 -1
- data/lib/webmock/request_body_diff.rb +2 -0
- data/lib/webmock/request_execution_verifier.rb +2 -0
- data/lib/webmock/request_pattern.rb +35 -12
- 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 +15 -13
- 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 +23 -10
- data/lib/webmock/util/parsers/json.rb +72 -0
- data/lib/webmock/util/parsers/parse_error.rb +7 -0
- data/lib/webmock/util/parsers/xml.rb +16 -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 +4 -2
- metadata +66 -185
- 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/lib/webmock/util/json.rb +0 -67
- 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
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
|