vcr 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.rspec +1 -1
- data/.travis.yml +4 -0
- data/CHANGELOG.md +29 -0
- data/CONTRIBUTING.md +0 -13
- data/Gemfile +1 -3
- data/Gemfile.lock +13 -22
- data/README.md +7 -1
- data/Rakefile +10 -6
- data/cucumber.yml +2 -2
- data/features/request_matching/body_as_json.feature +90 -0
- data/features/support/env.rb +1 -1
- data/gemfiles/typhoeus_old.gemfile +2 -3
- data/gemfiles/typhoeus_old.gemfile.lock +32 -38
- data/lib/vcr.rb +1 -1
- data/lib/vcr/errors.rb +22 -2
- data/lib/vcr/library_hooks/excon.rb +16 -1
- data/lib/vcr/library_hooks/webmock.rb +1 -1
- data/lib/vcr/middleware/excon.rb +55 -58
- data/lib/vcr/middleware/excon/legacy_methods.rb +1 -1
- data/lib/vcr/request_matcher_registry.rb +18 -0
- data/lib/vcr/test_frameworks/rspec.rb +2 -2
- data/lib/vcr/version.rb +1 -1
- data/script/ci.sh +1 -2
- data/spec/monkey_patches.rb +3 -2
- data/spec/spec_helper.rb +1 -2
- data/spec/support/shared_example_groups/excon.rb +28 -9
- data/spec/support/shared_example_groups/request_hooks.rb +1 -1
- data/spec/vcr/cassette/persisters/file_system_spec.rb +2 -2
- data/spec/vcr/cassette_spec.rb +7 -7
- data/spec/vcr/configuration_spec.rb +13 -13
- data/spec/vcr/errors_spec.rb +23 -0
- data/spec/vcr/library_hooks/excon_spec.rb +15 -0
- data/spec/vcr/library_hooks/fakeweb_spec.rb +1 -1
- data/spec/vcr/library_hooks_spec.rb +8 -8
- data/spec/vcr/middleware/faraday_spec.rb +1 -1
- data/spec/vcr/middleware/rack_spec.rb +1 -1
- data/spec/vcr/request_ignorer_spec.rb +2 -2
- data/spec/vcr/request_matcher_registry_spec.rb +59 -33
- data/spec/vcr/structs_spec.rb +2 -2
- data/spec/vcr/test_frameworks/cucumber_spec.rb +1 -1
- data/spec/vcr/test_frameworks/rspec_spec.rb +1 -1
- data/spec/vcr/util/hooks_spec.rb +5 -5
- data/spec/vcr/version_spec.rb +20 -4
- data/spec/vcr_spec.rb +7 -7
- metadata +4 -3
- data/.limited_red +0 -1
@@ -62,7 +62,7 @@ describe VCR::Configuration do
|
|
62
62
|
matcher_run = false
|
63
63
|
subject.register_request_matcher(:custom) { |r1, r2| matcher_run = true }
|
64
64
|
VCR.request_matchers[:custom].matches?(:r1, :r2)
|
65
|
-
expect(matcher_run).to
|
65
|
+
expect(matcher_run).to be true
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -83,7 +83,7 @@ describe VCR::Configuration do
|
|
83
83
|
called = false
|
84
84
|
subject.after_library_hooks_loaded { called = true }
|
85
85
|
subject.hook_into :fakeweb
|
86
|
-
expect(called).to
|
86
|
+
expect(called).to be true
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -108,7 +108,7 @@ describe VCR::Configuration do
|
|
108
108
|
block_called = false
|
109
109
|
subject.ignore_request { |r| block_called = true }
|
110
110
|
VCR.request_ignorer.ignore?(double(:parsed_uri => uri))
|
111
|
-
expect(block_called).to
|
111
|
+
expect(block_called).to be true
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -156,9 +156,9 @@ describe VCR::Configuration do
|
|
156
156
|
called = false
|
157
157
|
VCR.configuration.send(hook_type, :my_tag) { called = true }
|
158
158
|
VCR.configuration.invoke_hook(hook_type, double, double(:tags => []))
|
159
|
-
expect(called).to
|
159
|
+
expect(called).to be false
|
160
160
|
VCR.configuration.invoke_hook(hook_type, double, double(:tags => [:my_tag]))
|
161
|
-
expect(called).to
|
161
|
+
expect(called).to be true
|
162
162
|
end
|
163
163
|
end
|
164
164
|
end
|
@@ -218,11 +218,11 @@ describe VCR::Configuration do
|
|
218
218
|
yielded = false
|
219
219
|
subject.after_http_request(:stubbed_by_vcr?) { |req| yielded = true }
|
220
220
|
subject.invoke_hook(:after_http_request, request(:stubbed_by_vcr), response)
|
221
|
-
expect(yielded).to
|
221
|
+
expect(yielded).to be true
|
222
222
|
|
223
223
|
yielded = false
|
224
224
|
subject.invoke_hook(:after_http_request, request(:ignored), response)
|
225
|
-
expect(yielded).to
|
225
|
+
expect(yielded).to be false
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
@@ -271,31 +271,31 @@ describe VCR::Configuration do
|
|
271
271
|
|
272
272
|
context "default hook" do
|
273
273
|
it "returns false when there is no current cassette" do
|
274
|
-
expect(subject.preserve_exact_body_bytes_for?(message_for "string")).to
|
274
|
+
expect(subject.preserve_exact_body_bytes_for?(message_for "string")).to be false
|
275
275
|
end
|
276
276
|
|
277
277
|
it "returns false when the current cassette has been created without the :preserve_exact_body_bytes option" do
|
278
278
|
VCR.insert_cassette('foo')
|
279
|
-
expect(subject.preserve_exact_body_bytes_for?(message_for "string")).to
|
279
|
+
expect(subject.preserve_exact_body_bytes_for?(message_for "string")).to be false
|
280
280
|
end
|
281
281
|
|
282
282
|
it 'returns true when the current cassette has been created with the :preserve_exact_body_bytes option' do
|
283
283
|
VCR.insert_cassette('foo', :preserve_exact_body_bytes => true)
|
284
|
-
expect(subject.preserve_exact_body_bytes_for?(message_for "string")).to
|
284
|
+
expect(subject.preserve_exact_body_bytes_for?(message_for "string")).to be true
|
285
285
|
end
|
286
286
|
end
|
287
287
|
|
288
288
|
it "returns true when the configured block returns true" do
|
289
289
|
subject.preserve_exact_body_bytes { |msg| msg.body == "a" }
|
290
|
-
expect(subject.preserve_exact_body_bytes_for?(message_for "a")).to
|
291
|
-
expect(subject.preserve_exact_body_bytes_for?(message_for "b")).to
|
290
|
+
expect(subject.preserve_exact_body_bytes_for?(message_for "a")).to be true
|
291
|
+
expect(subject.preserve_exact_body_bytes_for?(message_for "b")).to be false
|
292
292
|
end
|
293
293
|
|
294
294
|
it "returns true when any of the registered blocks returns true" do
|
295
295
|
called_hooks = []
|
296
296
|
subject.preserve_exact_body_bytes { called_hooks << :hook_1; false }
|
297
297
|
subject.preserve_exact_body_bytes { called_hooks << :hook_2; true }
|
298
|
-
expect(subject.preserve_exact_body_bytes_for?(message_for "a")).to
|
298
|
+
expect(subject.preserve_exact_body_bytes_for?(message_for "a")).to be true
|
299
299
|
expect(called_hooks).to eq([:hook_1, :hook_2])
|
300
300
|
end
|
301
301
|
|
data/spec/vcr/errors_spec.rb
CHANGED
@@ -23,6 +23,14 @@ module VCR
|
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'when there is no current cassette' do
|
26
|
+
it 'identifies the request by its body when the default_cassette_options include the body in the match_requests_on option' do
|
27
|
+
VCR.configuration.default_cassette_options[:match_requests_on] = [:body]
|
28
|
+
|
29
|
+
expect(message_for(:body => 'param=val1')).to include(
|
30
|
+
"Body: param=val1"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
26
34
|
it 'mentions that there is no current cassette' do
|
27
35
|
expect(message).to include('There is currently no cassette in use.')
|
28
36
|
end
|
@@ -49,6 +57,21 @@ module VCR
|
|
49
57
|
end
|
50
58
|
|
51
59
|
context 'when there is a current cassette' do
|
60
|
+
it 'identifies the request by its body when the match_requests_on option includes the body' do
|
61
|
+
VCR.use_cassette('example', :match_requests_on => [:body]) do
|
62
|
+
expect(message_for(:body => 'param=val1')).to include(
|
63
|
+
"Body: param=val1"
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'does not identify the request by its body when the cassette match_requests_on option does not include the body but the default_cassette_options do' do
|
69
|
+
VCR.configuration.default_cassette_options[:match_requests_on] = [:body]
|
70
|
+
VCR.use_cassette('example', :match_requests_on => [:uri]) do
|
71
|
+
expect(message_for(:body => 'param=val1')).to_not match(/body/i)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
52
75
|
it 'mentions the details about the current casette' do
|
53
76
|
VCR.use_cassette('example') do
|
54
77
|
expect(message).to match(/VCR is currently using the following cassette:.+example.yml/m)
|
@@ -30,6 +30,21 @@ describe "Excon hook", :with_monkey_patches => :excon do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
context "when Excon's expects and idempotent middlewares cause errors to be raised" do
|
34
|
+
let(:excon) { ::Excon.new("http://localhost:#{VCR::SinatraApp.port}/404_not_200") }
|
35
|
+
|
36
|
+
def make_request
|
37
|
+
VCR.use_cassette('with_errors', :record => :once) do
|
38
|
+
excon.request(:method => :get, :expects => [200], :idempotent => true).body
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'records and plays back properly' do
|
43
|
+
expect { make_request }.to raise_error(Excon::Errors::NotFound)
|
44
|
+
expect { make_request }.to raise_error(Excon::Errors::NotFound)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
33
48
|
include_examples "Excon streaming"
|
34
49
|
|
35
50
|
context 'when Excon raises an error due to an unexpected response status' do
|
@@ -111,7 +111,7 @@ describe "FakeWeb hook", :with_monkey_patches => :fakeweb do
|
|
111
111
|
|
112
112
|
context 'when WebMock has been loaded' do
|
113
113
|
before(:each) do
|
114
|
-
expect(defined?(WebMock)).to
|
114
|
+
expect(defined?(WebMock)).to be_truthy
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'raises an error since FakeWeb and WebMock cannot both be used simultaneously' do
|
@@ -4,8 +4,8 @@ module VCR
|
|
4
4
|
describe LibraryHooks do
|
5
5
|
describe '#disabled?' do
|
6
6
|
it 'returns false by default for any argument given' do
|
7
|
-
expect(subject.disabled?(:foo)).to
|
8
|
-
expect(subject.disabled?(:bar)).to
|
7
|
+
expect(subject.disabled?(:foo)).to be false
|
8
|
+
expect(subject.disabled?(:bar)).to be false
|
9
9
|
end
|
10
10
|
|
11
11
|
context 'when a library hook is exclusively enabled' do
|
@@ -27,8 +27,8 @@ module VCR
|
|
27
27
|
bar_disabled = subject.disabled?(:bar)
|
28
28
|
end
|
29
29
|
|
30
|
-
expect(foo_disabled).to
|
31
|
-
expect(bar_disabled).to
|
30
|
+
expect(foo_disabled).to be true
|
31
|
+
expect(bar_disabled).to be true
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -36,14 +36,14 @@ module VCR
|
|
36
36
|
describe '#exclusively_enabled' do
|
37
37
|
it 'restores all hook to being enabled when the block completes' do
|
38
38
|
subject.exclusively_enabled(:faraday) { }
|
39
|
-
expect(subject.disabled?(:foo)).to
|
40
|
-
expect(subject.disabled?(:faraday)).to
|
39
|
+
expect(subject.disabled?(:foo)).to be false
|
40
|
+
expect(subject.disabled?(:faraday)).to be false
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'restores all hooks to being enabled when the block completes, even if there is an error' do
|
44
44
|
subject.exclusively_enabled(:faraday) { raise "boom" } rescue
|
45
|
-
expect(subject.disabled?(:foo)).to
|
46
|
-
expect(subject.disabled?(:faraday)).to
|
45
|
+
expect(subject.disabled?(:foo)).to be false
|
46
|
+
expect(subject.disabled?(:faraday)).to be false
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -58,11 +58,11 @@ module VCR
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'ignores requests for which the block returns true' do
|
61
|
-
expect(subject.ignore?(request('http://foo.com:5/bar'))).to
|
61
|
+
expect(subject.ignore?(request('http://foo.com:5/bar'))).to be true
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'does not ignore requests for which the block returns false' do
|
65
|
-
expect(subject.ignore?(request('http://foo.com:6/bar'))).to
|
65
|
+
expect(subject.ignore?(request('http://foo.com:6/bar'))).to be false
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -26,7 +26,7 @@ module VCR
|
|
26
26
|
matcher_called = false
|
27
27
|
subject.register(:my_matcher) { |*a| matcher_called = true }
|
28
28
|
subject[:my_matcher].matches?(double, double)
|
29
|
-
expect(matcher_called).to
|
29
|
+
expect(matcher_called).to be true
|
30
30
|
end
|
31
31
|
|
32
32
|
context 'when there is already a matcher for the given name' do
|
@@ -37,7 +37,7 @@ module VCR
|
|
37
37
|
|
38
38
|
it 'overrides the existing matcher' do
|
39
39
|
subject.register(:foo) { |*a| true }
|
40
|
-
expect(subject[:foo].matches?(double, double)).to
|
40
|
+
expect(subject[:foo].matches?(double, double)).to be true
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'warns that there is a name collision' do
|
@@ -65,15 +65,15 @@ module VCR
|
|
65
65
|
|
66
66
|
it 'returns an object that calls the named block when #matches? is called on it' do
|
67
67
|
subject.register(:foo) { |r1, r2| r1 == 5 || r2 == 10 }
|
68
|
-
expect(subject[:foo].matches?(5, 0)).to
|
69
|
-
expect(subject[:foo].matches?(0, 10)).to
|
70
|
-
expect(subject[:foo].matches?(7, 7)).to
|
68
|
+
expect(subject[:foo].matches?(5, 0)).to be true
|
69
|
+
expect(subject[:foo].matches?(0, 10)).to be true
|
70
|
+
expect(subject[:foo].matches?(7, 7)).to be false
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'returns an object that calls the given callable when #matches? is called on it' do
|
74
74
|
block_called = false
|
75
75
|
subject[lambda { |r1, r2| block_called = true }].matches?(5, 0)
|
76
|
-
expect(block_called).to
|
76
|
+
expect(block_called).to be true
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -86,7 +86,7 @@ module VCR
|
|
86
86
|
request_with(:uri => 'http://example.com/search?foo=123'),
|
87
87
|
request_with(:uri => 'http://example.com/search?foo=123')
|
88
88
|
)
|
89
|
-
expect(matches).to
|
89
|
+
expect(matches).to be true
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'matches two requests with URIs that are identical' do
|
@@ -94,7 +94,7 @@ module VCR
|
|
94
94
|
request_with(:uri => 'http://example.com/search?foo=123'),
|
95
95
|
request_with(:uri => 'http://example.com/search?foo=123')
|
96
96
|
)
|
97
|
-
expect(matches).to
|
97
|
+
expect(matches).to be true
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'does not match two requests with different path parts' do
|
@@ -102,7 +102,7 @@ module VCR
|
|
102
102
|
request_with(:uri => 'http://example.com/search?foo=123'),
|
103
103
|
request_with(:uri => 'http://example.com/find?foo=123')
|
104
104
|
)
|
105
|
-
expect(matches).to
|
105
|
+
expect(matches).to be false
|
106
106
|
end
|
107
107
|
|
108
108
|
it 'ignores the given query parameters when it is at the start' do
|
@@ -110,7 +110,7 @@ module VCR
|
|
110
110
|
request_with(:uri => 'http://example.com/search?foo=123&bar=r'),
|
111
111
|
request_with(:uri => 'http://example.com/search?foo=124&bar=r')
|
112
112
|
)
|
113
|
-
expect(matches).to
|
113
|
+
expect(matches).to be true
|
114
114
|
end
|
115
115
|
|
116
116
|
it 'ignores the given query parameters when it is at the end' do
|
@@ -118,7 +118,7 @@ module VCR
|
|
118
118
|
request_with(:uri => 'http://example.com/search?foo=124&bar=r'),
|
119
119
|
request_with(:uri => 'http://example.com/search?foo=124&bar=q')
|
120
120
|
)
|
121
|
-
expect(matches).to
|
121
|
+
expect(matches).to be true
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'still takes into account other query params' do
|
@@ -126,7 +126,7 @@ module VCR
|
|
126
126
|
request_with(:uri => 'http://example.com/search?foo=123&bar=r'),
|
127
127
|
request_with(:uri => 'http://example.com/search?foo=124&bar=q')
|
128
128
|
)
|
129
|
-
expect(matches).to
|
129
|
+
expect(matches).to be false
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'handles multiple query params of the same name' do
|
@@ -134,7 +134,7 @@ module VCR
|
|
134
134
|
request_with(:uri => 'http://example.com/search?foo=124&tag[]=a&tag[]=b'),
|
135
135
|
request_with(:uri => 'http://example.com/search?foo=124&tag[]=d&tag[]=e')
|
136
136
|
)
|
137
|
-
expect(matches).to
|
137
|
+
expect(matches).to be true
|
138
138
|
end
|
139
139
|
|
140
140
|
it 'can ignore multiple named parameters' do
|
@@ -142,7 +142,7 @@ module VCR
|
|
142
142
|
request_with(:uri => 'http://example.com/search?foo=123&bar=r&baz=9'),
|
143
143
|
request_with(:uri => 'http://example.com/search?foo=124&baz=9&bar=q')
|
144
144
|
)
|
145
|
-
expect(matches).to
|
145
|
+
expect(matches).to be true
|
146
146
|
end
|
147
147
|
|
148
148
|
it 'matches two requests with URIs that have no params' do
|
@@ -150,7 +150,7 @@ module VCR
|
|
150
150
|
request_with(:uri => 'http://example.com/search'),
|
151
151
|
request_with(:uri => 'http://example.com/search')
|
152
152
|
)
|
153
|
-
expect(matches).to
|
153
|
+
expect(matches).to be true
|
154
154
|
end
|
155
155
|
|
156
156
|
it 'does not match two requests with URIs that have no params but different paths' do
|
@@ -158,7 +158,7 @@ module VCR
|
|
158
158
|
request_with(:uri => 'http://example.com/foo'),
|
159
159
|
request_with(:uri => 'http://example.com/bar')
|
160
160
|
)
|
161
|
-
expect(matches).to
|
161
|
+
expect(matches).to be false
|
162
162
|
end
|
163
163
|
|
164
164
|
it 'matches a second request when all parameters are filtered' do
|
@@ -166,7 +166,7 @@ module VCR
|
|
166
166
|
request_with(:uri => 'http://example.com/search'),
|
167
167
|
request_with(:uri => 'http://example.com/search?q=vcr&oq=vcr')
|
168
168
|
)
|
169
|
-
expect(matches).to
|
169
|
+
expect(matches).to be true
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
@@ -178,7 +178,7 @@ module VCR
|
|
178
178
|
request_with(:method => :get),
|
179
179
|
request_with(:method => :get)
|
180
180
|
)
|
181
|
-
expect(matches).to
|
181
|
+
expect(matches).to be true
|
182
182
|
end
|
183
183
|
|
184
184
|
it 'does not match when it is not the same' do
|
@@ -186,7 +186,7 @@ module VCR
|
|
186
186
|
request_with(:method => :get),
|
187
187
|
request_with(:method => :post)
|
188
188
|
)
|
189
|
-
expect(matches).to
|
189
|
+
expect(matches).to be false
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
@@ -196,7 +196,7 @@ module VCR
|
|
196
196
|
request_with(:uri => 'http://foo.com/bar?baz=7'),
|
197
197
|
request_with(:uri => 'http://foo.com/bar?baz=7')
|
198
198
|
)
|
199
|
-
expect(matches).to
|
199
|
+
expect(matches).to be true
|
200
200
|
end
|
201
201
|
|
202
202
|
it 'does not match when it is different' do
|
@@ -204,7 +204,7 @@ module VCR
|
|
204
204
|
request_with(:uri => 'http://foo1.com/bar?baz=7'),
|
205
205
|
request_with(:uri => 'http://foo2.com/bar?baz=7')
|
206
206
|
)
|
207
|
-
expect(matches).to
|
207
|
+
expect(matches).to be false
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
@@ -214,7 +214,7 @@ module VCR
|
|
214
214
|
request_with(:uri => 'http://foo.com/bar'),
|
215
215
|
request_with(:uri => 'http://foo.com/car')
|
216
216
|
)
|
217
|
-
expect(matches).to
|
217
|
+
expect(matches).to be true
|
218
218
|
end
|
219
219
|
|
220
220
|
it 'does not match when it is not the same' do
|
@@ -222,7 +222,7 @@ module VCR
|
|
222
222
|
request_with(:uri => 'http://foo.com/bar'),
|
223
223
|
request_with(:uri => 'http://goo.com/bar')
|
224
224
|
)
|
225
|
-
expect(matches).to
|
225
|
+
expect(matches).to be false
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
@@ -232,7 +232,7 @@ module VCR
|
|
232
232
|
request_with(:uri => 'http://foo.com/bar?a=8'),
|
233
233
|
request_with(:uri => 'http://goo.com/bar?a=9')
|
234
234
|
)
|
235
|
-
expect(matches).to
|
235
|
+
expect(matches).to be true
|
236
236
|
end
|
237
237
|
|
238
238
|
it 'does not match when it is not the same' do
|
@@ -240,7 +240,7 @@ module VCR
|
|
240
240
|
request_with(:uri => 'http://foo.com/bar?a=8'),
|
241
241
|
request_with(:uri => 'http://foo.com/car?a=8')
|
242
242
|
)
|
243
|
-
expect(matches).to
|
243
|
+
expect(matches).to be false
|
244
244
|
end
|
245
245
|
end
|
246
246
|
|
@@ -250,7 +250,7 @@ module VCR
|
|
250
250
|
request_with(:body => 'foo'),
|
251
251
|
request_with(:body => 'foo')
|
252
252
|
)
|
253
|
-
expect(matches).to
|
253
|
+
expect(matches).to be true
|
254
254
|
end
|
255
255
|
|
256
256
|
it 'does not match when it is not the same' do
|
@@ -258,7 +258,33 @@ module VCR
|
|
258
258
|
request_with(:body => 'foo'),
|
259
259
|
request_with(:body => 'bar')
|
260
260
|
)
|
261
|
-
expect(matches).to
|
261
|
+
expect(matches).to be false
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
describe ":body_as_json" do
|
266
|
+
it 'matches when the body json is reordered' do
|
267
|
+
matches = subject[:body_as_json].matches?(
|
268
|
+
request_with(:body => '{ "a": "1", "b": "2" }'),
|
269
|
+
request_with(:body => '{ "b": "2", "a": "1" }')
|
270
|
+
)
|
271
|
+
expect(matches).to be true
|
272
|
+
end
|
273
|
+
|
274
|
+
it 'does not match when json is not the same' do
|
275
|
+
matches = subject[:body_as_json].matches?(
|
276
|
+
request_with(:body => '{ "a": "1", "b": "2" }'),
|
277
|
+
request_with(:body => '{ "a": "1", "b": "1" }')
|
278
|
+
)
|
279
|
+
expect(matches).to be false
|
280
|
+
end
|
281
|
+
|
282
|
+
it 'does not match when body is not json' do
|
283
|
+
matches = subject[:body_as_json].matches?(
|
284
|
+
request_with(:body => 'a=b'),
|
285
|
+
request_with(:body => 'a=b')
|
286
|
+
)
|
287
|
+
expect(matches).to be false
|
262
288
|
end
|
263
289
|
end
|
264
290
|
|
@@ -268,7 +294,7 @@ module VCR
|
|
268
294
|
request_with(:headers => { 'a' => 1, 'b' => 2 }),
|
269
295
|
request_with(:headers => { 'b' => 2, 'a' => 1 })
|
270
296
|
)
|
271
|
-
expect(matches).to
|
297
|
+
expect(matches).to be true
|
272
298
|
end
|
273
299
|
|
274
300
|
it 'does not match when it is not the same' do
|
@@ -276,7 +302,7 @@ module VCR
|
|
276
302
|
request_with(:headers => { 'a' => 3, 'b' => 2 }),
|
277
303
|
request_with(:headers => { 'b' => 2, 'a' => 1 })
|
278
304
|
)
|
279
|
-
expect(matches).to
|
305
|
+
expect(matches).to be false
|
280
306
|
end
|
281
307
|
end
|
282
308
|
|
@@ -286,7 +312,7 @@ module VCR
|
|
286
312
|
request_with(:uri => 'http://foo.com/bar?a=8'),
|
287
313
|
request_with(:uri => 'http://goo.com/car?a=8')
|
288
314
|
)
|
289
|
-
expect(matches).to
|
315
|
+
expect(matches).to be true
|
290
316
|
end
|
291
317
|
|
292
318
|
it 'matches when empty' do
|
@@ -294,7 +320,7 @@ module VCR
|
|
294
320
|
request_with(:uri => 'http://foo.com/bar'),
|
295
321
|
request_with(:uri => 'http://goo.com/car')
|
296
322
|
)
|
297
|
-
expect(matches).to
|
323
|
+
expect(matches).to be true
|
298
324
|
end
|
299
325
|
|
300
326
|
it 'matches when parameters are reordered' do
|
@@ -302,7 +328,7 @@ module VCR
|
|
302
328
|
request_with(:uri => 'http://foo.com/bar?a=8&b=9'),
|
303
329
|
request_with(:uri => 'http://goo.com/car?b=9&a=8')
|
304
330
|
)
|
305
|
-
expect(matches).to
|
331
|
+
expect(matches).to be true
|
306
332
|
end
|
307
333
|
|
308
334
|
it 'does not match when it is not the same' do
|
@@ -310,7 +336,7 @@ module VCR
|
|
310
336
|
request_with(:uri => 'http://foo.com/bar?a=8'),
|
311
337
|
request_with(:uri => 'http://goo.com/car?b=8')
|
312
338
|
)
|
313
|
-
expect(matches).to
|
339
|
+
expect(matches).to be false
|
314
340
|
end
|
315
341
|
end
|
316
342
|
end
|