Permalink
Browse files

Fix VCR.eject_cassette so that it always pops the cassette off the st…

…ack.

Previously, if there was an error while ejecting the cassette, the cassette would remain as the current cassette.

Closes #175.
  • Loading branch information...
1 parent c3ab6af commit 2bff0706d1eb9c16d07980f4c07378d967f351d2 @myronmarston committed Jun 15, 2012
Showing with 17 additions and 1 deletion.
  1. +8 −1 CHANGELOG.md
  2. +2 −0 lib/vcr.rb
  3. +7 −0 spec/vcr_spec.rb
View
@@ -1,6 +1,13 @@
## In git
-[Full Changelog](http://github.com/myronmarston/vcr/compare/v2.2.0...master)
+[Full Changelog](http://github.com/myronmarston/vcr/compare/v2.2.1...master)
+
+Bug Fixes:
+
+* Fix `VCR.eject_cassette` so that it always pops a cassette off the
+ cassette stack even if an error occurs while ejecting the cassette.
+ This is important to keep things consistent, so that a cassette for
+ one test doesn't remain in place for another test.
## 2.2.1 (June 13, 2012)
View
@@ -134,6 +134,8 @@ def insert_cassette(name, options = {})
def eject_cassette
cassette = cassettes.last
cassette.eject if cassette
+ cassette
+ ensure
cassettes.pop
end
View
@@ -52,6 +52,13 @@ def insert_cassette(name = :cassette_test)
current.should be(cassette)
VCR.current_cassette.should_not be(cassette)
end
+
+ it 'properly pops the cassette off the stack even if an error occurs' do
+ cassette = insert_cassette
+ cassette.stub(:eject) { raise "boom" }
+ expect { VCR.eject_cassette }.to raise_error("boom")
+ VCR.current_cassette.should be_nil
+ end
end
describe '.use_cassette' do

0 comments on commit 2bff070

Please sign in to comment.