webmock 1.20.3 → 1.20.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.md +21 -22
- data/lib/webmock/matchers/hash_including_matcher.rb +1 -1
- data/lib/webmock/version.rb +1 -1
- data/spec/acceptance/curb/curb_spec.rb +36 -36
- data/spec/acceptance/em_http_request/em_http_request_spec.rb +24 -24
- data/spec/acceptance/excon/excon_spec.rb +11 -11
- data/spec/acceptance/httpclient/httpclient_spec.rb +9 -9
- data/spec/acceptance/net_http/net_http_shared.rb +23 -23
- data/spec/acceptance/net_http/net_http_spec.rb +29 -29
- data/spec/acceptance/patron/patron_spec.rb +11 -11
- data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +29 -29
- data/spec/acceptance/shared/callbacks.rb +18 -18
- data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +3 -3
- data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +10 -10
- data/spec/acceptance/shared/precedence_of_stubs.rb +2 -2
- data/spec/acceptance/shared/request_expectations.rb +302 -302
- data/spec/acceptance/shared/returning_declared_responses.rb +92 -92
- data/spec/acceptance/shared/stubbing_requests.rb +103 -103
- data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +8 -8
- data/spec/quality_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -6
- data/spec/unit/errors_spec.rb +16 -16
- data/spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb +1 -1
- data/spec/unit/http_lib_adapters/http_lib_adapter_spec.rb +2 -2
- data/spec/unit/rack_response_spec.rb +14 -14
- data/spec/unit/request_execution_verifier_spec.rb +31 -31
- data/spec/unit/request_pattern_spec.rb +202 -197
- data/spec/unit/request_registry_spec.rb +10 -9
- data/spec/unit/request_signature_spec.rb +21 -20
- data/spec/unit/request_stub_spec.rb +54 -53
- data/spec/unit/response_spec.rb +44 -44
- data/spec/unit/stub_registry_spec.rb +15 -15
- data/spec/unit/stub_request_snippet_spec.rb +8 -8
- data/spec/unit/util/hash_counter_spec.rb +6 -6
- data/spec/unit/util/hash_keys_stringifier_spec.rb +1 -1
- data/spec/unit/util/headers_spec.rb +4 -4
- data/spec/unit/util/json_spec.rb +1 -1
- data/spec/unit/util/uri_spec.rb +30 -30
- data/spec/unit/util/version_checker_spec.rb +9 -9
- data/spec/unit/webmock_spec.rb +1 -1
- data/webmock.gemspec +1 -1
- metadata +10 -9
@@ -50,7 +50,7 @@ unless RUBY_PLATFORM =~ /java/
|
|
50
50
|
hydra.queue(request)
|
51
51
|
hydra.run
|
52
52
|
|
53
|
-
request.response.
|
53
|
+
expect(request.response).to be_timed_out
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -69,7 +69,7 @@ unless RUBY_PLATFORM =~ /java/
|
|
69
69
|
end
|
70
70
|
hydra.queue @request
|
71
71
|
hydra.run
|
72
|
-
test.
|
72
|
+
expect(test).to eq(body)
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should call on_complete with 5xx response" do
|
@@ -82,7 +82,7 @@ unless RUBY_PLATFORM =~ /java/
|
|
82
82
|
end
|
83
83
|
hydra.queue @request
|
84
84
|
hydra.run
|
85
|
-
test.
|
85
|
+
expect(test).to eq(response_code)
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should call on_body with 2xx response" do
|
@@ -91,7 +91,7 @@ unless RUBY_PLATFORM =~ /java/
|
|
91
91
|
|
92
92
|
test_body = nil
|
93
93
|
test_complete = nil
|
94
|
-
|
94
|
+
skip("This test requires a newer version of Typhoeus") unless @request.respond_to?(:on_body)
|
95
95
|
@request.on_body do |body, response|
|
96
96
|
test_body = body
|
97
97
|
end
|
@@ -100,8 +100,8 @@ unless RUBY_PLATFORM =~ /java/
|
|
100
100
|
end
|
101
101
|
hydra.queue @request
|
102
102
|
hydra.run
|
103
|
-
test_body.
|
104
|
-
test_complete.
|
103
|
+
expect(test_body).to eq(body)
|
104
|
+
expect(test_complete).to eq("")
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should call on_headers with 2xx response" do
|
@@ -109,13 +109,13 @@ unless RUBY_PLATFORM =~ /java/
|
|
109
109
|
stub_request(:any, "example.com").to_return(:body => body, :headers => {'X-Test' => '1'})
|
110
110
|
|
111
111
|
test_headers = nil
|
112
|
-
|
112
|
+
skip("This test requires a newer version of Typhoeus") unless @request.respond_to?(:on_headers)
|
113
113
|
@request.on_headers do |response|
|
114
114
|
test_headers = response.headers
|
115
115
|
end
|
116
116
|
hydra.queue @request
|
117
117
|
hydra.run
|
118
|
-
test_headers.
|
118
|
+
expect(test_headers).to include('X-Test' => '1')
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
data/spec/quality_spec.rb
CHANGED
@@ -51,7 +51,7 @@ describe "The library itself" do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
RSpec::Matchers.define :be_well_formed do
|
54
|
-
|
54
|
+
failure_message do |actual|
|
55
55
|
actual.join("\n")
|
56
56
|
end
|
57
57
|
|
@@ -69,13 +69,13 @@ describe "The library itself" do
|
|
69
69
|
error_messages << check_for_extra_spaces(filename)
|
70
70
|
end
|
71
71
|
end
|
72
|
-
error_messages.compact.
|
72
|
+
expect(error_messages.compact).to be_well_formed
|
73
73
|
end
|
74
74
|
|
75
75
|
it "can still be built" do
|
76
76
|
Dir.chdir(File.expand_path('../../', __FILE__)) do
|
77
77
|
`gem build webmock.gemspec`
|
78
|
-
|
78
|
+
expect($?).to eq(0)
|
79
79
|
|
80
80
|
# clean up the .gem generated
|
81
81
|
system("rm webmock-#{WebMock.version}.gem")
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/errors_spec.rb
CHANGED
@@ -4,8 +4,8 @@ describe "errors" do
|
|
4
4
|
describe WebMock::NetConnectNotAllowedError do
|
5
5
|
describe "message" do
|
6
6
|
it "should have message with request signature and snippet" do
|
7
|
-
WebMock::RequestStub.
|
8
|
-
WebMock::StubRequestSnippet.
|
7
|
+
allow(WebMock::RequestStub).to receive(:from_request_signature).and_return(request_stub)
|
8
|
+
allow(WebMock::StubRequestSnippet).to receive(:new).
|
9
9
|
with(request_stub).and_return(stub_result)
|
10
10
|
|
11
11
|
expected = \
|
@@ -13,13 +13,13 @@ describe "errors" do
|
|
13
13
|
"\n\nYou can stub this request with the following snippet:" \
|
14
14
|
"\n\n#{stub_result}" \
|
15
15
|
"\n\n============================================================"
|
16
|
-
WebMock::NetConnectNotAllowedError.new(request_signature).message.
|
16
|
+
expect(WebMock::NetConnectNotAllowedError.new(request_signature).message).to eq(expected)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should have message with registered stubs if available" do
|
20
|
-
WebMock::StubRegistry.instance.
|
21
|
-
WebMock::RequestStub.
|
22
|
-
WebMock::StubRequestSnippet.
|
20
|
+
allow(WebMock::StubRegistry.instance).to receive(:request_stubs).and_return([request_stub])
|
21
|
+
allow(WebMock::RequestStub).to receive(:from_request_signature).and_return(request_stub)
|
22
|
+
allow(WebMock::StubRequestSnippet).to receive(:new).
|
23
23
|
with(request_stub).and_return(stub_result)
|
24
24
|
|
25
25
|
expected = \
|
@@ -29,12 +29,12 @@ describe "errors" do
|
|
29
29
|
"\n\nregistered request stubs:" \
|
30
30
|
"\n\n#{stub_result}" \
|
31
31
|
"\n\n============================================================"
|
32
|
-
WebMock::NetConnectNotAllowedError.new(request_signature).message.
|
32
|
+
expect(WebMock::NetConnectNotAllowedError.new(request_signature).message).to eq(expected)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should not be caught by a rescue block without arguments" do
|
36
|
-
WebMock::RequestStub.
|
37
|
-
WebMock::StubRequestSnippet.
|
36
|
+
allow(WebMock::RequestStub).to receive(:from_request_signature).and_return(request_stub)
|
37
|
+
allow(WebMock::StubRequestSnippet).to receive(:new).
|
38
38
|
with(request_stub).and_return(stub_result)
|
39
39
|
|
40
40
|
exception = WebMock::NetConnectNotAllowedError.new(request_signature)
|
@@ -54,20 +54,20 @@ describe "errors" do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should have message with request signature and snippet" do
|
57
|
-
WebMock::RequestStub.
|
58
|
-
WebMock::StubRequestSnippet.
|
57
|
+
allow(WebMock::RequestStub).to receive(:from_request_signature).and_return(request_stub)
|
58
|
+
allow(WebMock::StubRequestSnippet).to receive(:new).
|
59
59
|
with(request_stub).and_return(stub_result)
|
60
60
|
|
61
61
|
expected = \
|
62
62
|
"Real HTTP connections are disabled. Unregistered request: #{request_signature}" \
|
63
63
|
"\n\n============================================================"
|
64
|
-
WebMock::NetConnectNotAllowedError.new(request_signature).message.
|
64
|
+
expect(WebMock::NetConnectNotAllowedError.new(request_signature).message).to eq(expected)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should have message with registered stubs if available" do
|
68
|
-
WebMock::StubRegistry.instance.
|
69
|
-
WebMock::RequestStub.
|
70
|
-
WebMock::StubRequestSnippet.
|
68
|
+
allow(WebMock::StubRegistry.instance).to receive(:request_stubs).and_return([request_stub])
|
69
|
+
allow(WebMock::RequestStub).to receive(:from_request_signature).and_return(request_stub)
|
70
|
+
allow(WebMock::StubRequestSnippet).to receive(:new).
|
71
71
|
with(request_stub).and_return(stub_result)
|
72
72
|
|
73
73
|
expected = \
|
@@ -75,7 +75,7 @@ describe "errors" do
|
|
75
75
|
"\n\nregistered request stubs:" \
|
76
76
|
"\n\n#{stub_result}" \
|
77
77
|
"\n\n============================================================"
|
78
|
-
WebMock::NetConnectNotAllowedError.new(request_signature).message.
|
78
|
+
expect(WebMock::NetConnectNotAllowedError.new(request_signature).message).to eq(expected)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -9,7 +9,7 @@ describe WebMock::HttpLibAdapterRegistry do
|
|
9
9
|
WebMock::HttpLibAdapterRegistry.instance.each_adapter {|n,a|
|
10
10
|
adapters << [n, a]
|
11
11
|
}
|
12
|
-
adapters.
|
12
|
+
expect(adapters).to include([:my_lib, MyAdapter])
|
13
13
|
WebMock::HttpLibAdapterRegistry.instance.
|
14
14
|
http_lib_adapters.delete(:my_lib)
|
15
15
|
end
|
@@ -4,8 +4,8 @@ describe WebMock::HttpLibAdapter do
|
|
4
4
|
describe "adapter_for" do
|
5
5
|
it "should add adapter to adapter registry" do
|
6
6
|
class MyAdapter < WebMock::HttpLibAdapter; end
|
7
|
-
WebMock::HttpLibAdapterRegistry.instance.
|
8
|
-
|
7
|
+
expect(WebMock::HttpLibAdapterRegistry.instance).
|
8
|
+
to receive(:register).with(:my_lib, MyAdapter)
|
9
9
|
MyAdapter.adapter_for(:my_lib)
|
10
10
|
end
|
11
11
|
end
|
@@ -10,16 +10,16 @@ describe WebMock::RackResponse do
|
|
10
10
|
request = WebMock::RequestSignature.new(:get, 'www.example.com')
|
11
11
|
response = @rack_response.evaluate(request)
|
12
12
|
|
13
|
-
response.status.first.
|
14
|
-
response.body.
|
13
|
+
expect(response.status.first).to eq(200)
|
14
|
+
expect(response.body).to include('This is my root!')
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should behave correctly when the rack response is not a simple array of strings" do
|
18
18
|
request = WebMock::RequestSignature.new(:get, 'www.example.com/non_array_response')
|
19
19
|
response = @rack_response.evaluate(request)
|
20
20
|
|
21
|
-
response.status.first.
|
22
|
-
response.body.
|
21
|
+
expect(response.status.first).to eq(200)
|
22
|
+
expect(response.body).to include('This is not in an array!')
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should shouldn't blow up when hitting a locked resource twice" do
|
@@ -28,8 +28,8 @@ describe WebMock::RackResponse do
|
|
28
28
|
response = @locked_rack_response.evaluate(request)
|
29
29
|
response2 = @locked_rack_response.evaluate(request)
|
30
30
|
|
31
|
-
response2.body.
|
32
|
-
response2.status.first.
|
31
|
+
expect(response2.body).to include('Single threaded response.')
|
32
|
+
expect(response2.status.first).to eq(200)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should send along params" do
|
@@ -37,8 +37,8 @@ describe WebMock::RackResponse do
|
|
37
37
|
|
38
38
|
response = @rack_response.evaluate(request)
|
39
39
|
|
40
|
-
response.status.first.
|
41
|
-
response.body.
|
40
|
+
expect(response.status.first).to eq(200)
|
41
|
+
expect(response.body).to include('Hello, Johnny')
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should send along POST params" do
|
@@ -47,7 +47,7 @@ describe WebMock::RackResponse do
|
|
47
47
|
)
|
48
48
|
|
49
49
|
response = @rack_response.evaluate(request)
|
50
|
-
response.body.
|
50
|
+
expect(response.body).to include('Good to meet you, Jimmy!')
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should send params with proper content length if params have non-ascii symbols" do
|
@@ -56,7 +56,7 @@ describe WebMock::RackResponse do
|
|
56
56
|
)
|
57
57
|
|
58
58
|
response = @rack_response.evaluate(request)
|
59
|
-
response.body.
|
59
|
+
expect(response.body).to include('Good to meet you, Олег!')
|
60
60
|
end
|
61
61
|
|
62
62
|
describe 'rack error output' do
|
@@ -88,15 +88,15 @@ describe WebMock::RackResponse do
|
|
88
88
|
it 'should be failure when wrong credentials' do
|
89
89
|
request = WebMock::RequestSignature.new(:get, 'foo:bar@www.example.com')
|
90
90
|
response = @rack_response_with_basic_auth.evaluate(request)
|
91
|
-
response.status.first.
|
92
|
-
response.body.
|
91
|
+
expect(response.status.first).to eq(401)
|
92
|
+
expect(response.body).not_to include('This is my root!')
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'should be success when valid credentials' do
|
96
96
|
request = WebMock::RequestSignature.new(:get, 'username:password@www.example.com')
|
97
97
|
response = @rack_response_with_basic_auth.evaluate(request)
|
98
|
-
response.status.first.
|
99
|
-
response.body.
|
98
|
+
expect(response.status.first).to eq(200)
|
99
|
+
expect(response.body).to include('This is my root!')
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -5,7 +5,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
5
5
|
@verifier = WebMock::RequestExecutionVerifier.new
|
6
6
|
@request_pattern = double(WebMock::RequestPattern, :to_s => "www.example.com")
|
7
7
|
@verifier.request_pattern = @request_pattern
|
8
|
-
WebMock::RequestRegistry.instance.
|
8
|
+
allow(WebMock::RequestRegistry.instance).to receive(:to_s).and_return("executed requests")
|
9
9
|
@executed_requests_info = "\n\nThe following requests were made:\n\nexecuted requests\n" + "="*60
|
10
10
|
end
|
11
11
|
|
@@ -17,7 +17,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
17
17
|
@verifier.expected_times_executed = 2
|
18
18
|
expected_text = "The request www.example.com was expected to execute 2 times but it executed 0 times"
|
19
19
|
expected_text << @executed_requests_info
|
20
|
-
@verifier.failure_message.
|
20
|
+
expect(@verifier.failure_message).to eq(expected_text)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should report failure message correctly when executed times is one" do
|
@@ -25,7 +25,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
25
25
|
@verifier.expected_times_executed = 1
|
26
26
|
expected_text = "The request www.example.com was expected to execute 1 time but it executed 1 time"
|
27
27
|
expected_text << @executed_requests_info
|
28
|
-
@verifier.failure_message.
|
28
|
+
expect(@verifier.failure_message).to eq(expected_text)
|
29
29
|
end
|
30
30
|
|
31
31
|
context "at_least_times_executed is set" do
|
@@ -34,7 +34,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
34
34
|
@verifier.at_least_times_executed = 2
|
35
35
|
expected_text = "The request www.example.com was expected to execute at least 2 times but it executed 1 time"
|
36
36
|
expected_text << @executed_requests_info
|
37
|
-
@verifier.failure_message.
|
37
|
+
expect(@verifier.failure_message).to eq(expected_text)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "reports failure message correctly when executed times is two" do
|
@@ -42,7 +42,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
42
42
|
@verifier.at_least_times_executed = 3
|
43
43
|
expected_text = "The request www.example.com was expected to execute at least 3 times but it executed 2 times"
|
44
44
|
expected_text << @executed_requests_info
|
45
|
-
@verifier.failure_message.
|
45
|
+
expect(@verifier.failure_message).to eq(expected_text)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -52,7 +52,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
52
52
|
@verifier.at_most_times_executed = 2
|
53
53
|
expected_text = "The request www.example.com was expected to execute at most 2 times but it executed 3 times"
|
54
54
|
expected_text << @executed_requests_info
|
55
|
-
@verifier.failure_message.
|
55
|
+
expect(@verifier.failure_message).to eq(expected_text)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "reports failure message correctly when executed times is two" do
|
@@ -60,7 +60,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
60
60
|
@verifier.at_most_times_executed = 1
|
61
61
|
expected_text = "The request www.example.com was expected to execute at most 1 time but it executed 2 times"
|
62
62
|
expected_text << @executed_requests_info
|
63
|
-
@verifier.failure_message.
|
63
|
+
expect(@verifier.failure_message).to eq(expected_text)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -72,14 +72,14 @@ describe WebMock::RequestExecutionVerifier do
|
|
72
72
|
@verifier.expected_times_executed = 2
|
73
73
|
expected_text = "The request www.example.com was not expected to execute 2 times but it executed 2 times"
|
74
74
|
expected_text << @executed_requests_info
|
75
|
-
@verifier.failure_message_when_negated.
|
75
|
+
expect(@verifier.failure_message_when_negated).to eq(expected_text)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should report failure message when not expected request but it executed" do
|
79
79
|
@verifier.times_executed = 1
|
80
80
|
expected_text = "The request www.example.com was expected to execute 0 times but it executed 1 time"
|
81
81
|
expected_text << @executed_requests_info
|
82
|
-
@verifier.failure_message_when_negated.
|
82
|
+
expect(@verifier.failure_message_when_negated).to eq(expected_text)
|
83
83
|
end
|
84
84
|
|
85
85
|
context "at_least_times_executed is set" do
|
@@ -88,7 +88,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
88
88
|
@verifier.at_least_times_executed = 2
|
89
89
|
expected_text = "The request www.example.com was not expected to execute at least 2 times but it executed 3 times"
|
90
90
|
expected_text << @executed_requests_info
|
91
|
-
@verifier.failure_message_when_negated.
|
91
|
+
expect(@verifier.failure_message_when_negated).to eq(expected_text)
|
92
92
|
end
|
93
93
|
|
94
94
|
it "reports failure message correctly when executed times is two" do
|
@@ -96,7 +96,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
96
96
|
@verifier.at_least_times_executed = 2
|
97
97
|
expected_text = "The request www.example.com was not expected to execute at least 2 times but it executed 2 times"
|
98
98
|
expected_text << @executed_requests_info
|
99
|
-
@verifier.failure_message_when_negated.
|
99
|
+
expect(@verifier.failure_message_when_negated).to eq(expected_text)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -106,7 +106,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
106
106
|
@verifier.at_most_times_executed = 3
|
107
107
|
expected_text = "The request www.example.com was not expected to execute at most 3 times but it executed 2 times"
|
108
108
|
expected_text << @executed_requests_info
|
109
|
-
@verifier.failure_message_when_negated.
|
109
|
+
expect(@verifier.failure_message_when_negated).to eq(expected_text)
|
110
110
|
end
|
111
111
|
|
112
112
|
it "reports failure message correctly when executed times is one" do
|
@@ -114,7 +114,7 @@ describe WebMock::RequestExecutionVerifier do
|
|
114
114
|
@verifier.at_most_times_executed = 2
|
115
115
|
expected_text = "The request www.example.com was not expected to execute at most 2 times but it executed 1 time"
|
116
116
|
expected_text << @executed_requests_info
|
117
|
-
@verifier.failure_message_when_negated.
|
117
|
+
expect(@verifier.failure_message_when_negated).to eq(expected_text)
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -123,17 +123,17 @@ describe WebMock::RequestExecutionVerifier do
|
|
123
123
|
describe "matches?" do
|
124
124
|
|
125
125
|
it "should succeed if request was executed expected number of times" do
|
126
|
-
WebMock::RequestRegistry.instance.
|
127
|
-
|
126
|
+
expect(WebMock::RequestRegistry.instance).
|
127
|
+
to receive(:times_executed).with(@request_pattern).and_return(10)
|
128
128
|
@verifier.expected_times_executed = 10
|
129
|
-
@verifier.matches
|
129
|
+
expect(@verifier.matches?).to be_truthy
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should fail if request was not executed expected number of times" do
|
133
|
-
WebMock::RequestRegistry.instance.
|
134
|
-
|
133
|
+
expect(WebMock::RequestRegistry.instance).
|
134
|
+
to receive(:times_executed).with(@request_pattern).and_return(10)
|
135
135
|
@verifier.expected_times_executed = 5
|
136
|
-
@verifier.matches
|
136
|
+
expect(@verifier.matches?).to be_falsey
|
137
137
|
end
|
138
138
|
|
139
139
|
end
|
@@ -141,29 +141,29 @@ describe WebMock::RequestExecutionVerifier do
|
|
141
141
|
describe "does_not_match?" do
|
142
142
|
|
143
143
|
it "should fail if request executed expected number of times" do
|
144
|
-
WebMock::RequestRegistry.instance.
|
145
|
-
|
144
|
+
expect(WebMock::RequestRegistry.instance).
|
145
|
+
to receive(:times_executed).with(@request_pattern).and_return(10)
|
146
146
|
@verifier.expected_times_executed = 10
|
147
|
-
@verifier.does_not_match
|
147
|
+
expect(@verifier.does_not_match?).to be_falsey
|
148
148
|
end
|
149
149
|
|
150
150
|
it "should succeed if request was not executed at all and expected number of times was not set" do
|
151
|
-
WebMock::RequestRegistry.instance.
|
152
|
-
|
153
|
-
@verifier.does_not_match
|
151
|
+
expect(WebMock::RequestRegistry.instance).
|
152
|
+
to receive(:times_executed).with(@request_pattern).and_return(0)
|
153
|
+
expect(@verifier.does_not_match?).to be_truthy
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should fail if request was executed and expected number of times was not set" do
|
157
|
-
WebMock::RequestRegistry.instance.
|
158
|
-
|
159
|
-
@verifier.does_not_match
|
157
|
+
expect(WebMock::RequestRegistry.instance).
|
158
|
+
to receive(:times_executed).with(@request_pattern).and_return(1)
|
159
|
+
expect(@verifier.does_not_match?).to be_falsey
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should succeed if request was not executed expected number of times" do
|
163
|
-
WebMock::RequestRegistry.instance.
|
164
|
-
|
163
|
+
expect(WebMock::RequestRegistry.instance).
|
164
|
+
to receive(:times_executed).with(@request_pattern).and_return(10)
|
165
165
|
@verifier.expected_times_executed = 5
|
166
|
-
@verifier.does_not_match
|
166
|
+
expect(@verifier.does_not_match?).to be_truthy
|
167
167
|
end
|
168
168
|
|
169
169
|
end
|