Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Raise an error if VCR::Cassette.new is given invalid options.

  • Loading branch information...
commit 606e32813a6f7c9c189b35f0b3b5f69e03c80f84 1 parent 0289298
@myronmarston authored
Showing with 14 additions and 1 deletion.
  1. +2 −0  CHANGELOG.md
  2. +6 −1 lib/vcr/cassette.rb
  3. +6 −0 spec/cassette_spec.rb
View
2  CHANGELOG.md
@@ -5,6 +5,8 @@
* Removed VCR::TaskRunner and the corresponding rake task definition. The rake task migrated cassettes from the
0.3.1 format to the 0.4+ format. If you are still on 0.3.1 or earlier, I recommend you upgrade to 0.4.1 first,
migrate your cassettes and deal with migration warnings, then upgrade to the current release.
+* Added some code to VCR::Cassette.new to check the options passed to the cassette and raise an error if any
+ invalid options are passed.
## 1.0.3 (August 5, 2010)
View
7 lib/vcr/cassette.rb
@@ -12,6 +12,11 @@ class MissingERBVariableError < NameError; end
def initialize(name, options = {})
options = VCR::Config.default_cassette_options.merge(options)
+ invalid_options = options.keys - [:record, :erb, :allow_real_http]
+
+ if invalid_options.size > 0
+ raise ArgumentError.new("You passed the following invalid options to VCR::Cassette.new: #{invalid_options.inspect}.")
+ end
@name = name
@record_mode = options[:record]
@@ -132,4 +137,4 @@ def write_recorded_interactions_to_disk
end
end
end
-end
+end
View
6 spec/cassette_spec.rb
@@ -45,6 +45,12 @@
lambda { VCR::Cassette.new(:test, :record => :not_a_record_mode) }.should raise_error(ArgumentError)
end
+ it 'raises an error if given invalid options' do
+ expect {
+ VCR::Cassette.new(:test, :invalid => :option)
+ }.to raise_error(ArgumentError)
+ end
+
it 'creates a stubs checkpoint on the http_stubbing_adapter' do
VCR.http_stubbing_adapter.should_receive(:create_stubs_checkpoint).with('example').once
VCR::Cassette.new('example')
Please sign in to comment.
Something went wrong with that request. Please try again.