Browse files

Raise an argument error when `VCR.turn_off!` is passed invalid options.

  • Loading branch information...
1 parent 7613284 commit 660267f15b4d2a061530a409dc8c79a45b4f48a1 @myronmarston committed May 11, 2011
Showing with 12 additions and 1 deletion.
  1. +6 −1 lib/vcr.rb
  2. +6 −0 spec/vcr_spec.rb
View
7 lib/vcr.rb
@@ -125,9 +125,14 @@ def turn_off!(options = {})
raise CassetteInUseError.new("A VCR cassette is currently in use. You must eject it before you can turn VCR off.")
end
+ @ignore_cassettes = options[:ignore_cassettes]
+ invalid_options = options.keys - [:ignore_cassettes]
+ if invalid_options.any?
+ raise ArgumentError.new("You passed some invalid options: #{invalid_options.inspect}")
+ end
+
VCR.http_stubbing_adapter.http_connections_allowed = true
@turned_off = true
- @ignore_cassettes = options[:ignore_cassettes]
end
def turn_on!
View
6 spec/vcr_spec.rb
@@ -238,6 +238,12 @@ def insert_cassette(name = :cassette_test)
}.to raise_error(VCR::TurnedOffError)
end
+ it 'raises an ArgumentError when given an invalid option' do
+ expect {
+ VCR.turn_off!(:invalid_option => true)
+ }.to raise_error(ArgumentError)
+ end
+
context 'when `:ignore_cassettes => true` is passed' do
before(:each) { VCR.turn_off!(:ignore_cassettes => true) }

0 comments on commit 660267f

Please sign in to comment.