vcr 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +3 -0
  3. data/.travis.yml +2 -0
  4. data/CHANGELOG.md +31 -0
  5. data/Gemfile +1 -2
  6. data/Gemfile.lock +63 -46
  7. data/README.md +5 -2
  8. data/features/cassettes/allow_unused_http_interactions.feature +1 -1
  9. data/features/cassettes/automatic_re_recording.feature +1 -1
  10. data/features/cassettes/decompress.feature +3 -3
  11. data/features/cassettes/dynamic_erb.feature +2 -2
  12. data/features/cassettes/exclusive.feature +1 -1
  13. data/features/cassettes/naming.feature +1 -1
  14. data/features/cassettes/no_cassette.feature +6 -3
  15. data/features/cassettes/persistence.feature +1 -1
  16. data/features/cassettes/update_content_length_header.feature +1 -1
  17. data/features/configuration/allow_http_connections_when_no_cassette.feature +1 -1
  18. data/features/configuration/cassette_library_dir.feature +1 -1
  19. data/features/configuration/debug_logging.feature +5 -5
  20. data/features/configuration/filter_sensitive_data.feature +2 -2
  21. data/features/configuration/hook_into.feature +4 -7
  22. data/features/getting_started.md +2 -2
  23. data/features/hooks/before_playback.feature +5 -5
  24. data/features/hooks/before_record.feature +5 -5
  25. data/features/middleware/rack.feature +2 -2
  26. data/features/record_modes/all.feature +1 -1
  27. data/features/record_modes/new_episodes.feature +1 -1
  28. data/features/record_modes/none.feature +1 -1
  29. data/features/record_modes/once.feature +1 -1
  30. data/features/request_matching/custom_matcher.feature +1 -1
  31. data/features/request_matching/headers.feature +0 -2
  32. data/features/request_matching/playback_repeats.feature +1 -1
  33. data/features/request_matching/uri_without_param.feature +1 -1
  34. data/features/support/env.rb +1 -0
  35. data/features/test_frameworks/cucumber.feature +8 -8
  36. data/features/test_frameworks/rspec_macro.feature +2 -2
  37. data/features/test_frameworks/rspec_metadata.feature +1 -1
  38. data/gemfiles/typhoeus_old.gemfile +1 -1
  39. data/gemfiles/typhoeus_old.gemfile.lock +31 -57
  40. data/lib/vcr/cassette/migrator.rb +8 -1
  41. data/lib/vcr/configuration.rb +9 -2
  42. data/lib/vcr/library_hooks/excon.rb +2 -184
  43. data/lib/vcr/library_hooks/typhoeus.rb +1 -1
  44. data/lib/vcr/library_hooks/typhoeus_0.4.rb +4 -0
  45. data/lib/vcr/library_hooks/webmock.rb +1 -1
  46. data/lib/vcr/middleware/excon.rb +226 -0
  47. data/lib/vcr/version.rb +1 -1
  48. data/spec/acceptance/threading_spec.rb +28 -0
  49. data/spec/monkey_patches.rb +3 -7
  50. data/spec/quality_spec.rb +1 -1
  51. data/spec/spec_helper.rb +7 -4
  52. data/spec/support/http_library_adapters.rb +4 -3
  53. data/spec/support/shared_example_groups/excon.rb +22 -0
  54. data/spec/support/shared_example_groups/hook_into_http_library.rb +46 -46
  55. data/spec/support/shared_example_groups/request_hooks.rb +8 -8
  56. data/spec/vcr/cassette/erb_renderer_spec.rb +5 -5
  57. data/spec/vcr/cassette/http_interaction_list_spec.rb +52 -40
  58. data/spec/vcr/cassette/migrator_spec.rb +11 -11
  59. data/spec/vcr/cassette/persisters/file_system_spec.rb +11 -11
  60. data/spec/vcr/cassette/persisters_spec.rb +2 -2
  61. data/spec/vcr/cassette/serializers_spec.rb +13 -12
  62. data/spec/vcr/cassette_spec.rb +58 -58
  63. data/spec/vcr/configuration_spec.rb +43 -31
  64. data/spec/vcr/deprecations_spec.rb +3 -3
  65. data/spec/vcr/errors_spec.rb +25 -25
  66. data/spec/vcr/extensions/net_http_response_spec.rb +7 -7
  67. data/spec/vcr/library_hooks/excon_spec.rb +7 -85
  68. data/spec/vcr/library_hooks/fakeweb_spec.rb +15 -13
  69. data/spec/vcr/library_hooks/faraday_spec.rb +4 -4
  70. data/spec/vcr/library_hooks/typhoeus_0.4_spec.rb +5 -0
  71. data/spec/vcr/library_hooks/typhoeus_spec.rb +3 -3
  72. data/spec/vcr/library_hooks/webmock_spec.rb +13 -5
  73. data/spec/vcr/library_hooks_spec.rb +9 -9
  74. data/spec/vcr/middleware/faraday_spec.rb +10 -10
  75. data/spec/vcr/middleware/rack_spec.rb +20 -15
  76. data/spec/vcr/request_ignorer_spec.rb +3 -3
  77. data/spec/vcr/request_matcher_registry_spec.rb +88 -61
  78. data/spec/vcr/structs_spec.rb +85 -85
  79. data/spec/vcr/test_frameworks/cucumber_spec.rb +7 -7
  80. data/spec/vcr/test_frameworks/rspec_spec.rb +10 -10
  81. data/spec/vcr/util/hooks_spec.rb +20 -20
  82. data/spec/vcr/util/internet_connection_spec.rb +2 -2
  83. data/spec/vcr_spec.rb +50 -48
  84. data/vcr.gemspec +4 -4
  85. metadata +308 -372
@@ -6,8 +6,8 @@ shared_examples_for "request hooks" do |library_hook_name, request_type|
6
6
  end
7
7
 
8
8
  def assert_expected_response(response)
9
- response.status.code.should eq(200)
10
- response.body.should eq('FOO!')
9
+ expect(response.status.code).to eq(200)
10
+ expect(response.body).to eq('FOO!')
11
11
  end
12
12
 
13
13
  [:before_http_request, :after_http_request].each do |hook|
@@ -16,7 +16,7 @@ shared_examples_for "request hooks" do |library_hook_name, request_type|
16
16
  VCR.configuration.send(hook) { |r| call_count += 1 }
17
17
 
18
18
  make_request
19
- call_count.should eq(1)
19
+ expect(call_count).to eq(1)
20
20
  end
21
21
 
22
22
  specify "the #{hook} hook yields the request" do
@@ -24,19 +24,19 @@ shared_examples_for "request hooks" do |library_hook_name, request_type|
24
24
  VCR.configuration.send(hook) { |r| request = r }
25
25
 
26
26
  make_request
27
- request.method.should be(:get)
28
- request.uri.should eq(request_url)
27
+ expect(request.method).to be(:get)
28
+ expect(request.uri).to eq(request_url)
29
29
  end
30
30
 
31
31
  specify "the #{hook} hook is not called if the library hook is disabled" do
32
- VCR.library_hooks.should respond_to(:disabled?)
32
+ expect(VCR.library_hooks).to respond_to(:disabled?)
33
33
  VCR.library_hooks.stub(:disabled? => true)
34
34
 
35
35
  hook_called = false
36
36
  VCR.configuration.send(hook) { |r| hook_called = true }
37
37
 
38
38
  make_request(:disabled)
39
- hook_called.should be_false
39
+ expect(hook_called).to be_false
40
40
  end
41
41
 
42
42
  specify "the #type of the yielded request given to the #{hook} hook is #{request_type}" do
@@ -44,7 +44,7 @@ shared_examples_for "request hooks" do |library_hook_name, request_type|
44
44
  VCR.configuration.send(hook) { |r| request = r }
45
45
 
46
46
  make_request
47
- request.type.should be(request_type)
47
+ expect(request.type).to be(request_type)
48
48
  end
49
49
  end
50
50
 
@@ -11,14 +11,14 @@ describe VCR::Cassette::ERBRenderer do
11
11
 
12
12
  context 'when ERB is disabled' do
13
13
  it 'returns the given template' do
14
- render(no_vars_content, false).should eq(no_vars_content)
15
- render(no_vars_content, nil).should eq(no_vars_content)
14
+ expect(render(no_vars_content, false)).to eq(no_vars_content)
15
+ expect(render(no_vars_content, nil)).to eq(no_vars_content)
16
16
  end
17
17
  end
18
18
 
19
19
  context 'when ERB is enabled but no variables are passed' do
20
20
  it 'renders the file content as ERB' do
21
- render(no_vars_content, true).should eq("7. Some ERB")
21
+ expect(render(no_vars_content, true)).to eq("7. Some ERB")
22
22
  end
23
23
 
24
24
  it 'raises an appropriate error when the ERB template needs variables' do
@@ -31,13 +31,13 @@ describe VCR::Cassette::ERBRenderer do
31
31
  end
32
32
 
33
33
  it 'gracefully handles the template being nil' do
34
- render(nil, true).should be_nil
34
+ expect(render(nil, true)).to be_nil
35
35
  end
36
36
  end
37
37
 
38
38
  context 'when ERB is enabled and variables are passed' do
39
39
  it 'renders the file content as ERB with the passed variables' do
40
- render(vars_content, :var1 => 'foo', :var2 => 'bar').should eq('foo. ERB with Vars! bar')
40
+ expect(render(vars_content, :var1 => 'foo', :var2 => 'bar')).to eq('foo. ERB with Vars! bar')
41
41
  end
42
42
 
43
43
  it 'raises an appropriate error when one or more of the needed variables are not passed' do
@@ -47,41 +47,41 @@ module VCR
47
47
 
48
48
  describe "#has_used_interaction_matching?" do
49
49
  it 'returns false when no interactions have been used' do
50
- list.should_not have_used_interaction_matching(request_with(:method => :put))
50
+ expect(list).not_to have_used_interaction_matching(request_with(:method => :put))
51
51
  end
52
52
 
53
53
  it 'returns true when there is a matching used interaction (even if there is also an unused one that matches)' do
54
54
  list.response_for(request_with(:method => :post))
55
- list.should have_used_interaction_matching(request_with(:method => :post))
55
+ expect(list).to have_used_interaction_matching(request_with(:method => :post))
56
56
  end
57
57
 
58
58
  it 'returns false when none of the used interactions match' do
59
59
  list.response_for(request_with(:method => :put))
60
- list.should_not have_used_interaction_matching(request_with(:method => :post))
60
+ expect(list).not_to have_used_interaction_matching(request_with(:method => :post))
61
61
  end
62
62
  end
63
63
 
64
64
  describe "#remaining_unused_interaction_count" do
65
65
  it 'returns the number of unused interactions' do
66
- list.remaining_unused_interaction_count.should eq(3)
66
+ expect(list.remaining_unused_interaction_count).to eq(3)
67
67
 
68
68
  list.response_for(request_with(:method => :get))
69
- list.remaining_unused_interaction_count.should eq(3)
69
+ expect(list.remaining_unused_interaction_count).to eq(3)
70
70
 
71
71
  list.response_for(request_with(:method => :put))
72
- list.remaining_unused_interaction_count.should eq(2)
72
+ expect(list.remaining_unused_interaction_count).to eq(2)
73
73
 
74
74
  list.response_for(request_with(:method => :put))
75
- list.remaining_unused_interaction_count.should eq(2)
75
+ expect(list.remaining_unused_interaction_count).to eq(2)
76
76
 
77
77
  list.response_for(request_with(:method => :post))
78
- list.remaining_unused_interaction_count.should eq(1)
78
+ expect(list.remaining_unused_interaction_count).to eq(1)
79
79
 
80
80
  list.response_for(request_with(:method => :post))
81
- list.remaining_unused_interaction_count.should eq(0)
81
+ expect(list.remaining_unused_interaction_count).to eq(0)
82
82
 
83
83
  list.response_for(request_with(:method => :post))
84
- list.remaining_unused_interaction_count.should eq(0)
84
+ expect(list.remaining_unused_interaction_count).to eq(0)
85
85
  end
86
86
  end
87
87
 
@@ -102,22 +102,22 @@ module VCR
102
102
 
103
103
  describe "has_interaction_matching?" do
104
104
  it 'returns false when the list is empty' do
105
- HTTPInteractionList.new([], [:method]).should_not have_interaction_matching(stub)
105
+ expect(HTTPInteractionList.new([], [:method])).not_to have_interaction_matching(stub)
106
106
  end
107
107
 
108
108
  it 'returns false when there is no matching interaction' do
109
- list.should_not have_interaction_matching(request_with(:method => :get))
109
+ expect(list).not_to have_interaction_matching(request_with(:method => :get))
110
110
  end
111
111
 
112
112
  it 'returns true when there is a matching interaction' do
113
- list.should have_interaction_matching(request_with(:method => :post))
113
+ expect(list).to have_interaction_matching(request_with(:method => :post))
114
114
  end
115
115
 
116
116
  it 'does not consume the interactions when they match' do
117
- list.should have_interaction_matching(request_with(:method => :post))
118
- list.remaining_unused_interaction_count.should eq(3)
119
- list.should have_interaction_matching(request_with(:method => :post))
120
- list.remaining_unused_interaction_count.should eq(3)
117
+ expect(list).to have_interaction_matching(request_with(:method => :post))
118
+ expect(list.remaining_unused_interaction_count).to eq(3)
119
+ expect(list).to have_interaction_matching(request_with(:method => :post))
120
+ expect(list.remaining_unused_interaction_count).to eq(3)
121
121
  end
122
122
 
123
123
  it 'invokes each matcher block to find the matching interaction' do
@@ -131,15 +131,15 @@ module VCR
131
131
  interaction('response', :method => :put)
132
132
  ], [:foo, :bar, :baz])
133
133
 
134
- list.should_not have_interaction_matching(request_with(:method => :post))
135
- list.should have_interaction_matching(request_with(:method => :post))
134
+ expect(list).not_to have_interaction_matching(request_with(:method => :post))
135
+ expect(list).to have_interaction_matching(request_with(:method => :post))
136
136
  end
137
137
 
138
138
  it "delegates to the parent list when it can't find a matching interaction" do
139
139
  parent_list = mock(:has_interaction_matching? => true)
140
- HTTPInteractionList.new( [], [:method], false, parent_list).should have_interaction_matching(stub)
140
+ expect(HTTPInteractionList.new( [], [:method], false, parent_list)).to have_interaction_matching(stub)
141
141
  parent_list = mock(:has_interaction_matching? => false)
142
- HTTPInteractionList.new( [], [:method], false, parent_list).should_not have_interaction_matching(stub)
142
+ expect(HTTPInteractionList.new( [], [:method], false, parent_list)).not_to have_interaction_matching(stub)
143
143
  end
144
144
 
145
145
  context 'when allow_playback_repeats is set to true' do
@@ -148,9 +148,11 @@ module VCR
148
148
  it 'considers used interactions' do
149
149
  list.response_for(request_with(:method => :put))
150
150
 
151
- 10.times.map {
151
+ results = 10.times.map do
152
152
  list.has_interaction_matching?(request_with(:method => :put))
153
- }.should eq([true] * 10)
153
+ end
154
+
155
+ expect(results).to eq([true] * 10)
154
156
  end
155
157
  end
156
158
 
@@ -160,25 +162,29 @@ module VCR
160
162
  it 'does not consider used interactions' do
161
163
  list.response_for(request_with(:method => :put))
162
164
 
163
- 10.times.map {
165
+ result = 10.times.map do
164
166
  list.has_interaction_matching?(request_with(:method => :put))
165
- }.should eq([false] * 10)
167
+ end
168
+
169
+ expect(result).to eq([false] * 10)
166
170
  end
167
171
  end
168
172
  end
169
173
 
170
174
  describe "#response_for" do
171
175
  it 'returns nil when the list is empty' do
172
- HTTPInteractionList.new([], [:method]).response_for(stub).should respond_with(nil)
176
+ expect(HTTPInteractionList.new([], [:method]).response_for(stub)).to respond_with(nil)
173
177
  end
174
178
 
175
179
  it 'returns nil when there is no matching interaction' do
176
- HTTPInteractionList.new([
180
+ response = HTTPInteractionList.new([
177
181
  interaction('foo', :method => :post),
178
182
  interaction('foo', :method => :put)
179
183
  ], [:method]).response_for(
180
184
  request_with(:method => :get)
181
- ).should respond_with(nil)
185
+ )
186
+
187
+ expect(response).to respond_with(nil)
182
188
  end
183
189
 
184
190
  it 'returns the first matching interaction' do
@@ -188,7 +194,7 @@ module VCR
188
194
  interaction('post response 2', :method => :post)
189
195
  ], [:method])
190
196
 
191
- list.response_for(request_with(:method => :post)).should respond_with("post response 1")
197
+ expect(list.response_for(request_with(:method => :post))).to respond_with("post response 1")
192
198
  end
193
199
 
194
200
  it 'invokes each matcher block to find the matching interaction' do
@@ -202,20 +208,22 @@ module VCR
202
208
  interaction('response', :method => :put)
203
209
  ], [:foo, :bar, :baz])
204
210
 
205
- list.response_for(request_with(:method => :post)).should respond_with(nil)
206
- list.response_for(request_with(:method => :post)).should respond_with('response')
211
+ expect(list.response_for(request_with(:method => :post))).to respond_with(nil)
212
+ expect(list.response_for(request_with(:method => :post))).to respond_with('response')
207
213
  end
208
214
 
209
215
  it "delegates to the parent list when it can't find a matching interaction" do
210
216
  parent_list = mock(:response_for => response('parent'))
211
- HTTPInteractionList.new(
217
+ result = HTTPInteractionList.new(
212
218
  [], [:method], false, parent_list
213
- ).response_for(stub).should respond_with('parent')
219
+ ).response_for(stub)
220
+
221
+ expect(result).to respond_with('parent')
214
222
  end
215
223
 
216
224
  it 'consumes the first matching interaction so that it will not be used again' do
217
- list.response_for(request_with(:method => :post)).body.should eq("post response 1")
218
- list.response_for(request_with(:method => :post)).body.should eq("post response 2")
225
+ expect(list.response_for(request_with(:method => :post)).body).to eq("post response 1")
226
+ expect(list.response_for(request_with(:method => :post)).body).to eq("post response 2")
219
227
  end
220
228
 
221
229
  context 'when allow_playback_repeats is set to true' do
@@ -224,10 +232,12 @@ module VCR
224
232
  it 'continues to return the response from the last matching interaction when there are no more' do
225
233
  list.response_for(request_with(:method => :post))
226
234
 
227
- 10.times.map {
235
+ results = 10.times.map do
228
236
  response = list.response_for(request_with(:method => :post))
229
237
  response ? response.body : nil
230
- }.should eq(["post response 2"] * 10)
238
+ end
239
+
240
+ expect(results).to eq(["post response 2"] * 10)
231
241
  end
232
242
  end
233
243
 
@@ -238,16 +248,18 @@ module VCR
238
248
  list.response_for(request_with(:method => :post))
239
249
  list.response_for(request_with(:method => :post))
240
250
 
241
- 10.times.map {
251
+ results = 10.times.map do
242
252
  list.response_for(request_with(:method => :post))
243
- }.should eq([nil] * 10)
253
+ end
254
+
255
+ expect(results).to eq([nil] * 10)
244
256
  end
245
257
  end
246
258
 
247
259
  it 'does not modify the original interaction array the list was initialized with' do
248
260
  original_dup = original_list_array.dup
249
261
  list.response_for(request_with(:method => :post))
250
- original_list_array.should == original_dup
262
+ expect(original_list_array).to eq original_dup
251
263
  end
252
264
  end
253
265
  end
@@ -136,36 +136,36 @@ EOF
136
136
  it 'migrates a cassette from the 1.x to 2.x format' do
137
137
  File.open(file_name, 'w') { |f| f.write(original_contents) }
138
138
  subject.migrate!
139
- YAML.load_file(file_name).should eq(YAML.load(updated_contents))
140
- output.should match(/Migrated example.yml/)
139
+ expect(YAML.load_file(file_name)).to eq(YAML.load(updated_contents))
140
+ expect(output).to match(/Migrated example.yml/)
141
141
  end
142
142
 
143
143
  it 'ignores files that do not contain arrays' do
144
144
  File.open(file_name, 'w') { |f| f.write(true.to_yaml) }
145
145
  subject.migrate!
146
- File.read(file_name).should eq(true.to_yaml)
147
- output.should match(/Ignored example.yml since it does not appear to be a valid VCR 1.x cassette/)
146
+ expect(File.read(file_name)).to eq(true.to_yaml)
147
+ expect(output).to match(/Ignored example.yml since it does not appear to be a valid VCR 1.x cassette/)
148
148
  end
149
149
 
150
150
  it 'ignores files that contain YAML arrays of other things' do
151
151
  File.open(file_name, 'w') { |f| f.write([{}, {}].to_yaml) }
152
152
  subject.migrate!
153
- File.read(file_name).should eq([{}, {}].to_yaml)
154
- output.should match(/Ignored example.yml since it does not appear to be a valid VCR 1.x cassette/)
153
+ expect(File.read(file_name)).to eq([{}, {}].to_yaml)
154
+ expect(output).to match(/Ignored example.yml since it does not appear to be a valid VCR 1.x cassette/)
155
155
  end
156
156
 
157
157
  it 'ignores URIs that have sensitive data substitutions' do
158
158
  modified_contents = original_contents.gsub('example.com', '<HOST>')
159
159
  File.open(file_name, 'w') { |f| f.write(modified_contents) }
160
160
  subject.migrate!
161
- YAML.load_file(file_name).should eq(YAML.load(updated_contents.gsub('example.com', '<HOST>:80')))
161
+ expect(YAML.load_file(file_name)).to eq(YAML.load(updated_contents.gsub('example.com', '<HOST>:80')))
162
162
  end
163
163
 
164
164
  it 'ignores files that are empty' do
165
165
  File.open(file_name, 'w') { |f| f.write('') }
166
166
  subject.migrate!
167
- File.read(file_name).should eq('')
168
- output.should match(/Ignored example.yml since it could not be parsed as YAML/)
167
+ expect(File.read(file_name)).to eq('')
168
+ expect(output).to match(/Ignored example.yml since it could not be parsed as YAML/)
169
169
  end
170
170
 
171
171
  shared_examples_for "ignoring invalid YAML" do
@@ -174,8 +174,8 @@ EOF
174
174
  modified_contents = modified_contents.gsub(/\z/, "<% end %>")
175
175
  File.open(file_name, 'w') { |f| f.write(modified_contents) }
176
176
  subject.migrate!
177
- File.read(file_name).should eq(modified_contents)
178
- output.should match(/Ignored example.yml since it could not be parsed as YAML/)
177
+ expect(File.read(file_name)).to eq(modified_contents)
178
+ expect(output).to match(/Ignored example.yml since it could not be parsed as YAML/)
179
179
  end
180
180
  end
181
181
 
@@ -10,51 +10,51 @@ module VCR
10
10
  describe "#[]" do
11
11
  it 'reads from the given file, relative to the configured storage location' do
12
12
  File.open(FileSystem.storage_location + '/foo.txt', 'w') { |f| f.write('1234') }
13
- FileSystem["foo.txt"].should eq("1234")
13
+ expect(FileSystem["foo.txt"]).to eq("1234")
14
14
  end
15
15
 
16
16
  it 'handles directories in the given file name' do
17
17
  FileUtils.mkdir_p FileSystem.storage_location + '/a'
18
18
  File.open(FileSystem.storage_location + '/a/b', 'w') { |f| f.write('1234') }
19
- FileSystem["a/b"].should eq("1234")
19
+ expect(FileSystem["a/b"]).to eq("1234")
20
20
  end
21
21
 
22
22
  it 'returns nil if the file does not exist' do
23
- FileSystem["non_existant_file"].should be_nil
23
+ expect(FileSystem["non_existant_file"]).to be_nil
24
24
  end
25
25
  end
26
26
 
27
27
  describe "#[]=" do
28
28
  it 'writes the given file contents to the given file name' do
29
- File.exist?(FileSystem.storage_location + '/foo.txt').should be_false
29
+ expect(File.exist?(FileSystem.storage_location + '/foo.txt')).to be_false
30
30
  FileSystem["foo.txt"] = "bar"
31
- File.read(FileSystem.storage_location + '/foo.txt').should eq("bar")
31
+ expect(File.read(FileSystem.storage_location + '/foo.txt')).to eq("bar")
32
32
  end
33
33
 
34
34
  it 'creates any needed intermediary directories' do
35
- File.exist?(FileSystem.storage_location + '/a').should be_false
35
+ expect(File.exist?(FileSystem.storage_location + '/a')).to be_false
36
36
  FileSystem["a/b"] = "bar"
37
- File.read(FileSystem.storage_location + '/a/b').should eq("bar")
37
+ expect(File.read(FileSystem.storage_location + '/a/b')).to eq("bar")
38
38
  end
39
39
  end
40
40
 
41
41
  describe "#absolute_path_to_file" do
42
42
  it "returns the absolute path to the given relative file based on the storage location" do
43
43
  expected = File.join(FileSystem.storage_location, "bar/bazz.json")
44
- FileSystem.absolute_path_to_file("bar/bazz.json").should eq(expected)
44
+ expect(FileSystem.absolute_path_to_file("bar/bazz.json")).to eq(expected)
45
45
  end
46
46
 
47
47
  it "returns nil if the storage_location is not set" do
48
48
  FileSystem.storage_location = nil
49
- FileSystem.absolute_path_to_file("bar/bazz.json").should be_nil
49
+ expect(FileSystem.absolute_path_to_file("bar/bazz.json")).to be_nil
50
50
  end
51
51
 
52
52
  it "sanitizes the file name" do
53
53
  expected = File.join(FileSystem.storage_location, "_t_i-t_1_2_f_n.json")
54
- FileSystem.absolute_path_to_file("\nt \t! i-t_1.2_f n.json").should eq(expected)
54
+ expect(FileSystem.absolute_path_to_file("\nt \t! i-t_1.2_f n.json")).to eq(expected)
55
55
 
56
56
  expected = File.join(FileSystem.storage_location, "a_1/b")
57
- FileSystem.absolute_path_to_file("a 1/b").should eq(expected)
57
+ expect(FileSystem.absolute_path_to_file("a 1/b")).to eq(expected)
58
58
  end
59
59
  end
60
60
  end
@@ -12,7 +12,7 @@ module VCR
12
12
 
13
13
  it 'overrides the existing persister' do
14
14
  subject[:foo] = :new_persister
15
- subject[:foo].should be(:new_persister)
15
+ expect(subject[:foo]).to be(:new_persister)
16
16
  end
17
17
 
18
18
  it 'warns that there is a name collision' do
@@ -30,7 +30,7 @@ module VCR
30
30
  end
31
31
 
32
32
  it 'returns the named persister' do
33
- subject[:file_system].should be(VCR::Cassette::Persisters::FileSystem)
33
+ expect(subject[:file_system]).to be(VCR::Cassette::Persisters::FileSystem)
34
34
  end
35
35
  end
36
36
  end
@@ -1,6 +1,7 @@
1
1
  require 'support/ruby_interpreter'
2
2
  require 'vcr/cassette/serializers'
3
3
  require 'multi_json'
4
+
4
5
  begin
5
6
  require 'psych' # ensure psych is loaded for these tests if its available
6
7
  rescue LoadError
@@ -26,22 +27,22 @@ module VCR
26
27
  context "the #{name} serializer" do
27
28
  it 'lazily loads the serializer' do
28
29
  serializers = subject.instance_variable_get(:@serializers)
29
- serializers.should_not have_key(name)
30
- subject[name].should_not be_nil
31
- serializers.should have_key(name)
30
+ expect(serializers).not_to have_key(name)
31
+ expect(subject[name]).not_to be_nil
32
+ expect(serializers).to have_key(name)
32
33
  end if lazily_loaded
33
34
 
34
35
  it "returns '#{file_extension}' as the file extension" do
35
- serializer.file_extension.should eq(file_extension)
36
+ expect(serializer.file_extension).to eq(file_extension)
36
37
  end
37
38
 
38
39
  it "can serialize and deserialize a hash" do
39
40
  hash = { "a" => 7, "nested" => { "hash" => [1, 2, 3] }}
40
41
  serialized = serializer.serialize(hash)
41
- serialized.should_not eq(hash)
42
- serialized.should be_a(String)
42
+ expect(serialized).not_to eq(hash)
43
+ expect(serialized).to be_a(String)
43
44
  deserialized = serializer.deserialize(serialized)
44
- deserialized.should eq(hash)
45
+ expect(deserialized).to eq(hash)
45
46
  end
46
47
  end
47
48
  end
@@ -118,7 +119,7 @@ module VCR
118
119
 
119
120
  it 'overrides the existing serializer' do
120
121
  subject[:foo] = :new_serializer
121
- subject[:foo].should be(:new_serializer)
122
+ expect(subject[:foo]).to be(:new_serializer)
122
123
  end
123
124
 
124
125
  it 'warns that there is a name collision' do
@@ -136,7 +137,7 @@ module VCR
136
137
  end
137
138
 
138
139
  it 'returns the named serializer' do
139
- subject[:yaml].should be(VCR::Cassette::Serializers::YAML)
140
+ expect(subject[:yaml]).to be(VCR::Cassette::Serializers::YAML)
140
141
  end
141
142
  end
142
143
 
@@ -147,7 +148,7 @@ module VCR
147
148
  it 'serializes things using pysch even if syck is configured as the default YAML engine' do
148
149
  ::YAML::ENGINE.yamler = 'syck'
149
150
  serialized = subject[:psych].serialize(problematic_syck_string)
150
- subject[:psych].deserialize(serialized).should eq(problematic_syck_string)
151
+ expect(subject[:psych].deserialize(serialized)).to eq(problematic_syck_string)
151
152
  end if defined?(::Psych)
152
153
 
153
154
  it 'raises an error if psych cannot be loaded' do
@@ -159,8 +160,8 @@ module VCR
159
160
  it 'forcibly serializes things using syck even if psych is the currently configured YAML engine' do
160
161
  ::YAML::ENGINE.yamler = 'psych'
161
162
  serialized = subject[:syck].serialize(problematic_syck_string)
162
- subject[:syck].deserialize(serialized).should_not eq(problematic_syck_string)
163
- end if defined?(::Psych) && (RUBY_INTERPRETER != :jruby)
163
+ expect(subject[:syck].deserialize(serialized)).not_to eq(problematic_syck_string)
164
+ end if defined?(::Psych) && (RUBY_INTERPRETER != :jruby) && (RUBY_VERSION.to_f < 2.0)
164
165
  end
165
166
  end
166
167
  end