vcr 2.9.2 → 2.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MWYxNGYxYjZkYmEyZDVmZjA1YmI5NjFhNzNlOWIwNDllMTI2ODNkZg==
5
- data.tar.gz: !binary |-
6
- ODFjNWVlMmIzYzIyMzkzODYyMjkyYTcwZWU0MGY1MWE4YjYxMmI0Mw==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MGQyZDM0NDFlYTQyNjA2NzhjMmU1Mjc4MGFiMTM2NzlmODM4MjBiOGI0ZjMz
10
- OWI0MmYxMTE2N2RjMWMwYTQ4MTFlZjUzYmMyODA0YzJkMmRlYmM3MTgwYTUw
11
- YjhkYWI4NDhkZDRkOWZhM2E1ZGRmZDllMjY5N2JkZDRkMzgyMWM=
12
- data.tar.gz: !binary |-
13
- ZGZkOWJkMWM1ZjQwZDZlZWU1ZGQ5ZDQzMDc1NGVlM2M5M2M4NTMzNTgwNmU1
14
- NjhiYzNhNzI4MzY0ODZiNjNhMzdjZjk3NGIxMTI1M2FlNWNmODBmODQ3ODdi
15
- YWM0MzUzMDgwMjBkMmExZGI4Y2EyYzQ1YTE3ZThjYzZkMzVjOWQ=
2
+ SHA1:
3
+ metadata.gz: 1e6983e0b541695c90b220f62fe9a67357d061c7
4
+ data.tar.gz: dae97ef043b1c5fcc7589dd0f591ce7bb751e3db
5
+ SHA512:
6
+ metadata.gz: 16981e6236478ed88aa82d859e1cfeed50d9d16a44d536a0606c0408c4f17d74147e1ed855a2273a1f0c7aa8521713fdc741333382e181641edf8a30fbbd5d07
7
+ data.tar.gz: de2dd8e386e31e46d500e2faa5daa993df951a2adec43163f325f6bc9d530bce519fe16739c71a8f989daa2015b62cfde4d2369260f2bc50a92630990e509b84
@@ -9,6 +9,7 @@ rvm:
9
9
  - 1.9.2
10
10
  - 1.9.3
11
11
  - 2.0.0
12
+ - 2.1.0
12
13
  - ree
13
14
  - jruby-18mode
14
15
  - jruby-19mode
@@ -1,3 +1,12 @@
1
+ ## 2.9.3 (September 7, 2014)
2
+ [Full Changelog](http://github.com/vcr/vcr/compare/v2.9.2...v2.9.3)
3
+
4
+ Bug Fixes:
5
+
6
+ * Fix `VCR::Cassette#serializable_hash` so that it does not allow
7
+ `before_record` hooks to apply mutations to existing HTTPInteraction
8
+ instances. (Myron Marston)
9
+
1
10
  ## 2.9.2 (May 27, 2014)
2
11
  [Full Changelog](http://github.com/vcr/vcr/compare/v2.9.1...v2.9.2)
3
12
 
data/Gemfile CHANGED
@@ -25,10 +25,7 @@ gem 'rake', '>= 0.9.2'
25
25
 
26
26
  gem 'cucumber', '>= 1.1.4'
27
27
  gem 'aruba', '>= 0.5'
28
-
29
- %w[ core mocks expectations support ].each do |name|
30
- gem "rspec-#{name}", :github => "rspec/rspec-#{name}"
31
- end
28
+ gem 'rspec', '~> 3.1'
32
29
 
33
30
  gem 'fakeweb', '>= 1.3.0'
34
31
  gem 'webmock', '>= 1.14'
@@ -1,35 +1,7 @@
1
- GIT
2
- remote: git://github.com/rspec/rspec-core.git
3
- revision: 5dad09158a9e5d94830dffcacc19f34e3bbc574f
4
- specs:
5
- rspec-core (3.0.0.rc1)
6
- rspec-support (= 3.0.0.rc1)
7
-
8
- GIT
9
- remote: git://github.com/rspec/rspec-expectations.git
10
- revision: 1dce0c78b1a19f0d328d9574d7b3e4201e269b3f
11
- specs:
12
- rspec-expectations (3.0.0.rc1)
13
- diff-lcs (>= 1.2.0, < 2.0)
14
- rspec-support (= 3.0.0.rc1)
15
-
16
- GIT
17
- remote: git://github.com/rspec/rspec-mocks.git
18
- revision: 6176d177121cdb4b83a31fac3b647ff89148a9b5
19
- specs:
20
- rspec-mocks (3.0.0.rc1)
21
- rspec-support (= 3.0.0.rc1)
22
-
23
- GIT
24
- remote: git://github.com/rspec/rspec-support.git
25
- revision: b5f29f2f03ee57f3bbcca092e09fe5a7199b3580
26
- specs:
27
- rspec-support (3.0.0.rc1)
28
-
29
1
  PATH
30
2
  remote: .
31
3
  specs:
32
- vcr (2.9.2)
4
+ vcr (2.9.3)
33
5
 
34
6
  GEM
35
7
  remote: https://rubygems.org/
@@ -113,6 +85,18 @@ GEM
113
85
  rest-client (>= 1.6.1)
114
86
  rest-client (1.6.7)
115
87
  mime-types (>= 1.16)
88
+ rspec (3.1.0)
89
+ rspec-core (~> 3.1.0)
90
+ rspec-expectations (~> 3.1.0)
91
+ rspec-mocks (~> 3.1.0)
92
+ rspec-core (3.1.1)
93
+ rspec-support (~> 3.1.0)
94
+ rspec-expectations (3.1.0)
95
+ diff-lcs (>= 1.2.0, < 2.0)
96
+ rspec-support (~> 3.1.0)
97
+ rspec-mocks (3.1.0)
98
+ rspec-support (~> 3.1.0)
99
+ rspec-support (3.1.0)
116
100
  ruby-debug (0.10.4)
117
101
  columnize (>= 0.1)
118
102
  ruby-debug-base (~> 0.10.4.0)
@@ -163,10 +147,7 @@ DEPENDENCIES
163
147
  redcarpet (~> 1.17.2)
164
148
  redis (>= 2.2.2)
165
149
  relish (~> 0.6)
166
- rspec-core!
167
- rspec-expectations!
168
- rspec-mocks!
169
- rspec-support!
150
+ rspec (~> 3.1)
170
151
  ruby-debug
171
152
  simplecov (>= 0.5.3)
172
153
  sinatra (>= 1.3.2)
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/vcr/vcr.png?branch=master)](http://travis-ci.org/vcr/vcr) [![Code Climate](https://codeclimate.com/github/vcr/vcr.png)](https://codeclimate.com/github/vcr/vcr)
5
+ [![Gem Version](https://img.shields.io/gem/v/vcr.svg)](http://rubygems.org/gems/vcr) [![Build Status](https://img.shields.io/travis/vcr/vcr/master.svg)](https://travis-ci.org/vcr/vcr) [![Code Climate](https://img.shields.io/codeclimate/github/vcr/vcr.svg)](https://codeclimate.com/github/vcr/vcr)
6
6
 
7
7
  ## Synopsis
8
8
 
@@ -161,6 +161,7 @@ Thanks also to the following people who have contributed patches or helpful sugg
161
161
  * [Herman Verschooten](https://github.com/Hermanverschooten)
162
162
  * [Ian Cordasco](https://github.com/sigmavirus24)
163
163
  * [Ingemar](https://github.com/ingemar)
164
+ * [Ilya Scharrenbroich](https://github.com/quidproquo)
164
165
  * [Jacob Green](https://github.com/Jacobkg)
165
166
  * [James Bence](https://github.com/jbence)
166
167
  * [Jay Shepherd](https://github.com/jayshepherd)
@@ -221,6 +222,11 @@ Thanks also to the following people who have contributed patches or helpful sugg
221
222
  * [vcr-clj](https://github.com/ifesdjeen/vcr-clj) (Clojure)
222
223
  * [VHS](https://github.com/diegoeche/vhs) (Erlang)
223
224
 
225
+ ## Related Projects
226
+
227
+ * [Mr. Video](https://github.com/quidproquo/mr_video) (Rails engine for managing VCR cassettes and episodes)
228
+
229
+
224
230
  ## Similar Libraries in Ruby
225
231
 
226
232
  * [Ephemeral Response](https://github.com/sandro/ephemeral_response)
@@ -176,10 +176,11 @@ Then /^the file "([^"]*)" should contain a YAML fragment like:$/ do |file_name,
176
176
  # Normalize by removing leading and trailing whitespace...
177
177
  file_content = file_content.split("\n").map do |line|
178
178
  # Different versions of psych use single vs. double quotes
179
- line.strip.gsub('"', "'")
179
+ # And then 2.1 sometimes adds quotes...
180
+ line.strip.gsub('"', "'").gsub("'", '')
180
181
  end.join("\n")
181
182
 
182
- file_content.should include(fragment)
183
+ file_content.should include(fragment.gsub("'", ''))
183
184
  end
184
185
  end
185
186
 
@@ -244,7 +244,9 @@ module VCR
244
244
  end
245
245
 
246
246
  def interactions_to_record
247
- merged_interactions.tap do |interactions|
247
+ # We deep-dup the interactions by roundtripping them to/from a hash.
248
+ # This is necessary because `before_record` can mutate the interactions.
249
+ merged_interactions.map { |i| HTTPInteraction.from_hash(i.to_hash) }.tap do |interactions|
248
250
  invoke_hook(:before_record, interactions)
249
251
  end
250
252
  end
@@ -10,7 +10,7 @@ module VCR
10
10
  # * `parts` [Array<Integer>] List of the version parts.
11
11
  def version
12
12
  @version ||= begin
13
- string = '2.9.2'
13
+ string = '2.9.3'
14
14
 
15
15
  def string.parts
16
16
  split('.').map { |p| p.to_i }
@@ -73,14 +73,24 @@ describe VCR::Cassette do
73
73
  let(:metadata) { subject.serializable_hash.reject { |k,v| k == "http_interactions" } }
74
74
 
75
75
  it 'includes the hash form of all recorded interactions' do
76
- allow(interaction_1).to receive(:to_hash).and_return({ "i" => 1, 'body' => '' })
77
- allow(interaction_2).to receive(:to_hash).and_return({ "i" => 2, 'body' => '' })
78
- expect(subject.serializable_hash).to include('http_interactions' => [{ "i" => 1, 'body' => '' }, { "i" => 2, 'body' => '' }])
76
+ hash_1 = interaction_1.to_hash
77
+ hash_2 = interaction_2.to_hash
78
+ expect(subject.serializable_hash).to include('http_interactions' => [hash_1, hash_2])
79
79
  end
80
80
 
81
81
  it 'includes additional metadata about the cassette' do
82
82
  expect(metadata).to eq("recorded_with" => "VCR #{VCR.version}")
83
83
  end
84
+
85
+ it 'does not allow the interactions to be mutated by configured hooks' do
86
+ VCR.configure do |c|
87
+ c.define_cassette_placeholder('<BODY>') { 'body' }
88
+ end
89
+
90
+ expect {
91
+ subject.serializable_hash
92
+ }.not_to change { interaction_1.response.body }
93
+ end
84
94
  end
85
95
 
86
96
  describe "#recording?" do
@@ -103,21 +113,21 @@ describe VCR::Cassette do
103
113
 
104
114
  it 'returns false when there is an existing cassette file with content' do
105
115
  cassette = VCR::Cassette.new("example", :record => :once)
106
- expect(File).to exist(cassette.file)
107
- expect(File.size?(cassette.file)).to be_truthy
116
+ expect(::File).to exist(cassette.file)
117
+ expect(::File.size?(cassette.file)).to be_truthy
108
118
  expect(cassette).not_to be_recording
109
119
  end
110
120
 
111
121
  it 'returns true when there is an empty existing cassette file' do
112
122
  cassette = VCR::Cassette.new("empty", :record => :once)
113
- expect(File).to exist(cassette.file)
114
- expect(File.size?(cassette.file)).to be_falsey
123
+ expect(::File).to exist(cassette.file)
124
+ expect(::File.size?(cassette.file)).to be_falsey
115
125
  expect(cassette).to be_recording
116
126
  end
117
127
 
118
128
  it 'returns true when there is no existing cassette file' do
119
129
  cassette = VCR::Cassette.new("non_existant_file", :record => :once)
120
- expect(File).not_to exist(cassette.file)
130
+ expect(::File).not_to exist(cassette.file)
121
131
  expect(cassette).to be_recording
122
132
  end
123
133
  end
@@ -243,11 +253,11 @@ describe VCR::Cassette do
243
253
  end
244
254
 
245
255
  context "and re_record_interval is 7.days" do
246
- let(:file_name) { File.join(VCR.configuration.cassette_library_dir, "cassette_name.yml") }
247
- subject { VCR::Cassette.new(File.basename(file_name).gsub('.yml', ''), :record => record_mode, :re_record_interval => 7.days) }
256
+ let(:file_name) { ::File.join(VCR.configuration.cassette_library_dir, "cassette_name.yml") }
257
+ subject { VCR::Cassette.new(::File.basename(file_name).gsub('.yml', ''), :record => record_mode, :re_record_interval => 7.days) }
248
258
 
249
259
  context 'when the cassette file does not exist' do
250
- before(:each) { allow(File).to receive(:exist?).with(file_name).and_return(false) }
260
+ before(:each) { allow(::File).to receive(:exist?).with(file_name).and_return(false) }
251
261
 
252
262
  it "has :#{record_mode} for the record mode" do
253
263
  expect(subject.record_mode).to eq(record_mode)
@@ -261,9 +271,9 @@ describe VCR::Cassette do
261
271
  end
262
272
  yaml = YAML.dump("http_interactions" => interactions)
263
273
 
264
- allow(File).to receive(:exist?).with(file_name).and_return(true)
265
- allow(File).to receive(:size?).with(file_name).and_return(true)
266
- allow(File).to receive(:read).with(file_name).and_return(yaml)
274
+ allow(::File).to receive(:exist?).with(file_name).and_return(true)
275
+ allow(::File).to receive(:size?).with(file_name).and_return(true)
276
+ allow(::File).to receive(:read).with(file_name).and_return(yaml)
267
277
  end
268
278
 
269
279
  context 'and the earliest recorded interaction was recorded less than 7 days ago' do
@@ -480,7 +490,7 @@ describe VCR::Cassette do
480
490
  expect(cassette).to respond_to(:serializable_hash)
481
491
  allow(cassette).to receive(:serializable_hash).and_return({ "http_interactions" => [1, 3, 5] })
482
492
 
483
- expect { cassette.eject }.to change { File.exist?(cassette.file) }.from(false).to(true)
493
+ expect { cassette.eject }.to change { ::File.exist?(cassette.file) }.from(false).to(true)
484
494
  saved_stuff = YAML.load_file(cassette.file)
485
495
  expect(saved_stuff).to eq("http_interactions" => [1, 3, 5])
486
496
  end
@@ -508,13 +518,13 @@ describe VCR::Cassette do
508
518
  end
509
519
 
510
520
  it 'does not record interactions that have been ignored' do
521
+ VCR.configure do |c|
522
+ c.before_record { |i| i.ignore! if i.request.uri =~ /foo/ }
523
+ end
524
+
511
525
  interaction_1 = http_interaction { |i| i.request.uri = 'http://foo.com/'; i.response.body = 'res 1' }
512
526
  interaction_2 = http_interaction { |i| i.request.uri = 'http://bar.com/'; i.response.body = 'res 2' }
513
527
 
514
- hook_aware_interaction_1 = interaction_1.hook_aware
515
- allow(interaction_1).to receive(:hook_aware).and_return(hook_aware_interaction_1)
516
- hook_aware_interaction_1.ignore!
517
-
518
528
  cassette = VCR::Cassette.new('test_cassette')
519
529
  allow(cassette).to receive(:new_recorded_interactions).and_return([interaction_1, interaction_2])
520
530
  cassette.eject
@@ -524,17 +534,17 @@ describe VCR::Cassette do
524
534
  end
525
535
 
526
536
  it 'does not write the cassette to disk if all interactions have been ignored' do
527
- interaction_1 = http_interaction { |i| i.request.uri = 'http://foo.com/'; i.response.body = 'res 1' }
537
+ VCR.configure do |c|
538
+ c.before_record { |i| i.ignore! }
539
+ end
528
540
 
529
- hook_aware_interaction_1 = interaction_1.hook_aware
530
- allow(interaction_1).to receive(:hook_aware).and_return(hook_aware_interaction_1)
531
- hook_aware_interaction_1.ignore!
541
+ interaction_1 = http_interaction { |i| i.request.uri = 'http://foo.com/'; i.response.body = 'res 1' }
532
542
 
533
543
  cassette = VCR::Cassette.new('test_cassette')
534
544
  allow(cassette).to receive(:new_recorded_interactions).and_return([interaction_1])
535
545
  cassette.eject
536
546
 
537
- expect(File).not_to exist(cassette.file)
547
+ expect(::File).not_to exist(cassette.file)
538
548
  end
539
549
 
540
550
  it "writes the recorded interactions to a subdirectory if the cassette name includes a directory" do
@@ -542,7 +552,7 @@ describe VCR::Cassette do
542
552
  cassette = VCR::Cassette.new('subdirectory/test_cassette')
543
553
  allow(cassette).to receive(:new_recorded_interactions).and_return(recorded_interactions)
544
554
 
545
- expect { cassette.eject }.to change { File.exist?(cassette.file) }.from(false).to(true)
555
+ expect { cassette.eject }.to change { ::File.exist?(cassette.file) }.from(false).to(true)
546
556
  saved_recorded_interactions = YAML.load_file(cassette.file)
547
557
  expect(saved_recorded_interactions["http_interactions"]).to eq(recorded_interactions.map(&:to_hash))
548
558
  end
@@ -558,8 +568,8 @@ describe VCR::Cassette do
558
568
 
559
569
  it "does not re-write to disk the previously recorded interactions if there are no new ones" do
560
570
  yaml_file = subject.file
561
- expect(File).not_to receive(:open).with(subject.file, 'w')
562
- expect { subject.eject }.to_not change { File.mtime(yaml_file) }
571
+ expect(::File).not_to receive(:open).with(subject.file, 'w')
572
+ expect { subject.eject }.to_not change { ::File.mtime(yaml_file) }
563
573
  end
564
574
 
565
575
  context 'when some new interactions have been recorded' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.2
4
+ version: 2.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-28 00:00:00.000000000 Z
11
+ date: 2014-09-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: VCR provides a simple API to record and replay your test suite's HTTP
14
14
  interactions. It works with a variety of HTTP client libraries, HTTP stubbing libraries
@@ -18,12 +18,12 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - .gemtest
22
- - .gitignore
23
- - .gitmodules
24
- - .rspec
25
- - .travis.yml
26
- - .yardopts
21
+ - ".gemtest"
22
+ - ".gitignore"
23
+ - ".gitmodules"
24
+ - ".rspec"
25
+ - ".travis.yml"
26
+ - ".yardopts"
27
27
  - Appraisals
28
28
  - CHANGELOG.md
29
29
  - CONTRIBUTING.md
@@ -200,17 +200,17 @@ require_paths:
200
200
  - lib
201
201
  required_ruby_version: !ruby/object:Gem::Requirement
202
202
  requirements:
203
- - - ! '>='
203
+ - - ">="
204
204
  - !ruby/object:Gem::Version
205
205
  version: 1.8.7
206
206
  required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  requirements:
208
- - - ! '>='
208
+ - - ">="
209
209
  - !ruby/object:Gem::Version
210
210
  version: 1.3.5
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.0.7
213
+ rubygems_version: 2.2.2
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: Record your test suite's HTTP interactions and replay them during future