webmock 1.20.3 → 1.20.4
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.
- 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
@@ -35,7 +35,7 @@ unless RUBY_PLATFORM =~ /java/
|
|
35
35
|
it "should work with get_file" do
|
36
36
|
stub_request(:get, "www.example.com").to_return(:body => "abc")
|
37
37
|
@sess.get_file("/", @file_path)
|
38
|
-
File.read(@file_path).
|
38
|
+
expect(File.read(@file_path)).to eq("abc")
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should raise same error as Patron if file is not readable for get request" do
|
@@ -44,9 +44,9 @@ unless RUBY_PLATFORM =~ /java/
|
|
44
44
|
tmpfile.chmod(0400)
|
45
45
|
end
|
46
46
|
begin
|
47
|
-
|
47
|
+
expect {
|
48
48
|
@sess.get_file("/", "/tmp/read_only_file")
|
49
|
-
}.
|
49
|
+
}.to raise_error(ArgumentError, "Unable to open specified file.")
|
50
50
|
ensure
|
51
51
|
File.unlink("/tmp/read_only_file")
|
52
52
|
end
|
@@ -66,9 +66,9 @@ unless RUBY_PLATFORM =~ /java/
|
|
66
66
|
|
67
67
|
it "should raise same error as Patron if file is not readable for post request" do
|
68
68
|
stub_request(:post, "www.example.com").with(:body => "abc")
|
69
|
-
|
69
|
+
expect {
|
70
70
|
@sess.post_file("/", "/path/to/non/existing/file")
|
71
|
-
}.
|
71
|
+
}.to raise_error(ArgumentError, "Unable to open specified file.")
|
72
72
|
end
|
73
73
|
|
74
74
|
end
|
@@ -76,9 +76,9 @@ unless RUBY_PLATFORM =~ /java/
|
|
76
76
|
describe "handling errors same way as patron" do
|
77
77
|
it "should raise error if put request has neither upload_data nor file_name" do
|
78
78
|
stub_request(:post, "www.example.com")
|
79
|
-
|
79
|
+
expect {
|
80
80
|
@sess.post("/", nil)
|
81
|
-
}.
|
81
|
+
}.to raise_error(ArgumentError, "Must provide either data or a filename when doing a PUT or POST")
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -100,7 +100,7 @@ unless RUBY_PLATFORM =~ /java/
|
|
100
100
|
stub_request(:get, "www.example.com").
|
101
101
|
to_return(:body => "Øl")
|
102
102
|
|
103
|
-
@sess.get("").body.encoding.
|
103
|
+
expect(@sess.get("").body.encoding).to eq(Encoding::UTF_8)
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should encode body to default internal" do
|
@@ -108,7 +108,7 @@ unless RUBY_PLATFORM =~ /java/
|
|
108
108
|
to_return(:headers => {'Content-Type' => 'text/html; charset=iso-8859-1'},
|
109
109
|
:body => "Øl".encode("iso-8859-1"))
|
110
110
|
|
111
|
-
@sess.get("").body.encoding.
|
111
|
+
expect(@sess.get("").body.encoding).to eq(Encoding.default_internal)
|
112
112
|
end
|
113
113
|
|
114
114
|
it "should encode body based on encoding-attribute in body" do
|
@@ -116,7 +116,7 @@ unless RUBY_PLATFORM =~ /java/
|
|
116
116
|
to_return(:body => "<?xml encoding=\"iso-8859-1\">Øl</xml>".encode("iso-8859-1"))
|
117
117
|
|
118
118
|
|
119
|
-
@sess.get("").body.encoding.
|
119
|
+
expect(@sess.get("").body.encoding).to eq(Encoding::ISO_8859_1)
|
120
120
|
end
|
121
121
|
|
122
122
|
|
@@ -126,7 +126,7 @@ unless RUBY_PLATFORM =~ /java/
|
|
126
126
|
|
127
127
|
@sess.default_response_charset = "iso-8859-1"
|
128
128
|
|
129
|
-
@sess.get("").body.encoding.
|
129
|
+
expect(@sess.get("").body.encoding).to eq(Encoding::ISO_8859_1)
|
130
130
|
end
|
131
131
|
|
132
132
|
end
|
@@ -6,19 +6,19 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should make a real web request if request is not stubbed" do
|
9
|
-
http_request(:get, webmock_server_url).status.
|
9
|
+
expect(http_request(:get, webmock_server_url).status).to eq("200")
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should make a real https request if request is not stubbed" do
|
13
13
|
unless http_library == :httpclient
|
14
|
-
http_request(:get, "https://www.google.com/").
|
15
|
-
body.
|
14
|
+
expect(http_request(:get, "https://www.google.com/").
|
15
|
+
body).to match(/.*google.*/)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should return stubbed response if request was stubbed" do
|
20
20
|
stub_request(:get, "www.example.com").to_return(:body => "abc")
|
21
|
-
http_request(:get, "http://www.example.com/").body.
|
21
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -29,18 +29,18 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
|
|
29
29
|
|
30
30
|
it "should return stubbed response if request was stubbed" do
|
31
31
|
stub_request(:get, "www.example.com").to_return(:body => "abc")
|
32
|
-
http_request(:get, "http://www.example.com/").body.
|
32
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should return stubbed response if request with path was stubbed" do
|
36
36
|
stub_request(:get, "www.example.com/hello_world").to_return(:body => "abc")
|
37
|
-
http_request(:get, "http://www.example.com/hello_world").body.
|
37
|
+
expect(http_request(:get, "http://www.example.com/hello_world").body).to eq("abc")
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should raise exception if request was not stubbed" do
|
41
|
-
|
41
|
+
expect {
|
42
42
|
http_request(:get, "http://www.example.com/")
|
43
|
-
}.
|
43
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/))
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -51,31 +51,31 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
|
|
51
51
|
|
52
52
|
it "should return stubbed response if request was stubbed" do
|
53
53
|
stub_request(:get, "www.example.com").to_return(:body => "abc")
|
54
|
-
http_request(:get, "http://www.example.com/").body.
|
54
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should raise exception if request was not stubbed" do
|
58
|
-
|
58
|
+
expect {
|
59
59
|
http_request(:get, "http://www.example.com/")
|
60
|
-
}.
|
60
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/))
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should make a real request to localhost" do
|
64
|
-
|
64
|
+
expect {
|
65
65
|
http_request(:get, "http://localhost:12345/")
|
66
|
-
}.
|
66
|
+
}.to raise_error(connection_refused_exception_class)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should make a real request to 127.0.0.1" do
|
70
|
-
|
70
|
+
expect {
|
71
71
|
http_request(:get, "http://127.0.0.1:12345/")
|
72
|
-
}.
|
72
|
+
}.to raise_error(connection_refused_exception_class)
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should make a real request to 0.0.0.0" do
|
76
|
-
|
76
|
+
expect {
|
77
77
|
http_request(:get, "http://0.0.0.0:12345/")
|
78
|
-
}.
|
78
|
+
}.to raise_error(connection_refused_exception_class)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -89,52 +89,52 @@ shared_context "allowing and disabling net connect" do |*adapter_info|
|
|
89
89
|
context "when the host is not allowed" do
|
90
90
|
it "should return stubbed response if request was stubbed" do
|
91
91
|
stub_request(:get, "www.example.com").to_return(:body => "abc")
|
92
|
-
http_request(:get, "http://www.example.com/").body.
|
92
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should raise exception if request was not stubbed" do
|
96
|
-
|
96
|
+
expect {
|
97
97
|
http_request(:get, "http://www.example.com/")
|
98
|
-
}.
|
98
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/))
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
context "when the host with port is not allowed" do
|
103
103
|
it "should return stubbed response if request was stubbed" do
|
104
104
|
stub_request(:get, "http://localhost:2345").to_return(:body => "abc")
|
105
|
-
http_request(:get, "http://localhost:2345/").body.
|
105
|
+
expect(http_request(:get, "http://localhost:2345/").body).to eq("abc")
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should raise exception if request was not stubbed" do
|
109
|
-
|
109
|
+
expect {
|
110
110
|
http_request(:get, "http://localhost:2345/")
|
111
|
-
}.
|
111
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://localhost:2345/))
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
115
|
context "when the host is allowed" do
|
116
116
|
it "should raise exception if request was not stubbed" do
|
117
|
-
|
117
|
+
expect {
|
118
118
|
http_request(:get, "http://www.example.com/")
|
119
|
-
}.
|
119
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/))
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should make a real request to allowed host", :net_connect => true do
|
123
|
-
http_request(:get, "http://httpstat.us/200").status.
|
123
|
+
expect(http_request(:get, "http://httpstat.us/200").status).to eq("200")
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
context "when the host with port is allowed" do
|
128
128
|
it "should make a real request to allowed host", :net_connect => true do
|
129
|
-
http_request(:get, "http://#{host_with_port}/").status.
|
129
|
+
expect(http_request(:get, "http://#{host_with_port}/").status).to eq("200")
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
context "when the host is allowed but not port" do
|
134
134
|
it "should make a real request to allowed host", :net_connect => true do
|
135
|
-
|
135
|
+
expect {
|
136
136
|
http_request(:get, "http://localhost:123/")
|
137
|
-
}.
|
137
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://localhost:123/))
|
138
138
|
end
|
139
139
|
end
|
140
140
|
end
|
@@ -9,7 +9,7 @@ shared_context "callbacks" do |*adapter_info|
|
|
9
9
|
WebMock.after_request {
|
10
10
|
@called = true
|
11
11
|
}
|
12
|
-
@called.
|
12
|
+
expect(@called).to eq(nil)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should invoke a callback after request is made" do
|
@@ -17,7 +17,7 @@ shared_context "callbacks" do |*adapter_info|
|
|
17
17
|
@called = true
|
18
18
|
}
|
19
19
|
http_request(:get, "http://www.example.com/")
|
20
|
-
@called.
|
20
|
+
expect(@called).to eq(true)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should not invoke a callback if this http library should be ignored" do
|
@@ -25,7 +25,7 @@ shared_context "callbacks" do |*adapter_info|
|
|
25
25
|
@called = true
|
26
26
|
}
|
27
27
|
http_request(:get, "http://www.example.com/")
|
28
|
-
@called.
|
28
|
+
expect(@called).to eq(nil)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should invoke a callback even if other http libraries should be ignored" do
|
@@ -33,7 +33,7 @@ shared_context "callbacks" do |*adapter_info|
|
|
33
33
|
@called = true
|
34
34
|
}
|
35
35
|
http_request(:get, "http://www.example.com/")
|
36
|
-
@called.
|
36
|
+
expect(@called).to eq(true)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should pass request signature to the callback" do
|
@@ -41,7 +41,7 @@ shared_context "callbacks" do |*adapter_info|
|
|
41
41
|
@request_signature = request_signature
|
42
42
|
end
|
43
43
|
http_request(:get, "http://www.example.com/")
|
44
|
-
@request_signature.uri.to_s.
|
44
|
+
expect(@request_signature.uri.to_s).to eq("http://www.example.com:80/")
|
45
45
|
end
|
46
46
|
|
47
47
|
after(:each) do
|
@@ -60,7 +60,7 @@ shared_context "callbacks" do |*adapter_info|
|
|
60
60
|
end
|
61
61
|
|
62
62
|
http_request(:get, "http://www.example.com/")
|
63
|
-
global_stub_request_sig.
|
63
|
+
expect(global_stub_request_sig).to be(after_request_request_sig)
|
64
64
|
end
|
65
65
|
|
66
66
|
context "passing response to callback" do
|
@@ -79,18 +79,18 @@ shared_context "callbacks" do |*adapter_info|
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should pass response to callback with the status and message" do
|
82
|
-
@response.status.
|
82
|
+
expect(@response.status).to eq([200, "hello"])
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should pass response to callback with headers" do
|
86
|
-
@response.headers.
|
86
|
+
expect(@response.headers).to eq({
|
87
87
|
'Content-Length' => '666',
|
88
88
|
'Hello' => 'World'
|
89
|
-
}
|
89
|
+
})
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should pass response to callback with body" do
|
93
|
-
@response.body.
|
93
|
+
expect(@response.body).to eq("foo bar")
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -105,16 +105,16 @@ shared_context "callbacks" do |*adapter_info|
|
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should pass real response to callback with status and message" do
|
108
|
-
@response.status[0].
|
109
|
-
@response.status[1].
|
108
|
+
expect(@response.status[0]).to eq(201)
|
109
|
+
expect(@response.status[1]).to eq("Created") unless adapter_info.include?(:no_status_message)
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should pass real response to callback with headers" do
|
113
|
-
@response.headers["Content-Length"].
|
113
|
+
expect(@response.headers["Content-Length"]).to eq("11")
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should pass response to callback with body" do
|
117
|
-
@response.body.size.
|
117
|
+
expect(@response.body.size).to eq(11)
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
@@ -123,16 +123,16 @@ shared_context "callbacks" do |*adapter_info|
|
|
123
123
|
WebMock.after_request { @called = 1 }
|
124
124
|
WebMock.after_request { @called += 1 }
|
125
125
|
http_request(:get, "http://www.example.com/")
|
126
|
-
@called.
|
126
|
+
expect(@called).to eq(2)
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should invoke callbacks only for real requests if requested", :net_connect => true do
|
130
130
|
WebMock.after_request(:real_requests_only => true) { @called = true }
|
131
131
|
http_request(:get, "http://www.example.com/")
|
132
|
-
@called.
|
132
|
+
expect(@called).to eq(nil)
|
133
133
|
WebMock.allow_net_connect!
|
134
134
|
http_request(:get, "http://www.example.net/")
|
135
|
-
@called.
|
135
|
+
expect(@called).to eq(true)
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should not invoke any callbacks after callbacks were reset" do
|
@@ -140,7 +140,7 @@ shared_context "callbacks" do |*adapter_info|
|
|
140
140
|
WebMock.reset_callbacks
|
141
141
|
stub_request(:get, "http://www.example.com/")
|
142
142
|
http_request(:get, "http://www.example.com/")
|
143
|
-
@called.
|
143
|
+
expect(@called).to eq(nil)
|
144
144
|
end
|
145
145
|
end
|
146
146
|
end
|
@@ -14,8 +14,8 @@ shared_context "complex cross-concern behaviors" do |*adapter_info|
|
|
14
14
|
|
15
15
|
played_back_response = http_request(:get, webmock_server_url)
|
16
16
|
|
17
|
-
played_back_response.headers.keys.
|
18
|
-
played_back_response.
|
17
|
+
expect(played_back_response.headers.keys).to include('Set-Cookie')
|
18
|
+
expect(played_back_response).to eq(real_response)
|
19
19
|
end
|
20
20
|
|
21
21
|
let(:no_content_url) { 'http://httpstat.us/204' }
|
@@ -28,7 +28,7 @@ shared_context "complex cross-concern behaviors" do |*adapter_info|
|
|
28
28
|
stub_request(:get, no_content_url).to_return(:status => 204, :body => stub_val)
|
29
29
|
stubbed_response = http_request(:get, no_content_url)
|
30
30
|
|
31
|
-
stubbed_response.body.
|
31
|
+
expect(stubbed_response.body).to eq(real_response.body)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -42,18 +42,18 @@ end
|
|
42
42
|
shared_context "disabled WebMock" do
|
43
43
|
it "should not register executed requests" do
|
44
44
|
http_request(:get, webmock_server_url)
|
45
|
-
a_request(:get, webmock_server_url).
|
45
|
+
expect(a_request(:get, webmock_server_url)).not_to have_been_made
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should not block unstubbed requests" do
|
49
|
-
|
49
|
+
expect {
|
50
50
|
http_request(:get, webmock_server_url)
|
51
|
-
}.
|
51
|
+
}.not_to raise_error
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should return real response even if there are stubs" do
|
55
55
|
stub_request(:get, /.*/).to_return(:body => "x")
|
56
|
-
http_request(:get, webmock_server_url).body.
|
56
|
+
expect(http_request(:get, webmock_server_url).body).to eq("hello world")
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should not invoke any callbacks" do
|
@@ -62,7 +62,7 @@ shared_context "disabled WebMock" do
|
|
62
62
|
@called = nil
|
63
63
|
WebMock.after_request { @called = 1 }
|
64
64
|
http_request(:get, webmock_server_url)
|
65
|
-
@called.
|
65
|
+
expect(@called).to eq(nil)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -70,18 +70,18 @@ shared_context "enabled WebMock" do
|
|
70
70
|
it "should register executed requests" do
|
71
71
|
WebMock.allow_net_connect!
|
72
72
|
http_request(:get, webmock_server_url)
|
73
|
-
a_request(:get, webmock_server_url).
|
73
|
+
expect(a_request(:get, webmock_server_url)).to have_been_made
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should block unstubbed requests" do
|
77
|
-
|
77
|
+
expect {
|
78
78
|
http_request(:get, "http://www.example.com/")
|
79
|
-
}.
|
79
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should return stubbed response" do
|
83
83
|
stub_request(:get, /.*/).to_return(:body => "x")
|
84
|
-
http_request(:get, "http://www.example.com/").body.
|
84
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("x")
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should invoke callbacks" do
|
@@ -90,6 +90,6 @@ shared_context "enabled WebMock" do
|
|
90
90
|
@called = nil
|
91
91
|
WebMock.after_request { @called = 1 }
|
92
92
|
http_request(:get, webmock_server_url)
|
93
|
-
@called.
|
93
|
+
expect(@called).to eq(1)
|
94
94
|
end
|
95
95
|
end
|
@@ -3,13 +3,13 @@ shared_context "precedence of stubs" do |*adapter_info|
|
|
3
3
|
it "should use the last declared matching request stub" do
|
4
4
|
stub_request(:get, "www.example.com").to_return(:body => "abc")
|
5
5
|
stub_request(:get, "www.example.com").to_return(:body => "def")
|
6
|
-
http_request(:get, "http://www.example.com/").body.
|
6
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("def")
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should not be affected by the type of uri or request method" do
|
10
10
|
stub_request(:get, "www.example.com").to_return(:body => "abc")
|
11
11
|
stub_request(:any, /.*example.*/).to_return(:body => "def")
|
12
|
-
http_request(:get, "http://www.example.com/").body.
|
12
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("def")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|