Method: VCR#insert_cassette
- Defined in:
- lib/vcr.rb
#insert_cassette(name, options = {}) ⇒ VCR::Cassette
Note:
If you use this method you must call eject_cassette
when you
are done. It is generally recommended that you use #use_cassette
unless your code-under-test cannot be run as a block.
Inserts the named cassette using the given cassette options.
New HTTP interactions, if allowed by the cassette's :record
option, will
be recorded to the cassette. The cassette's existing HTTP interactions
will be used to stub requests, unless prevented by the cassette's
:record
option.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/vcr.rb', line 132 def insert_cassette(name, = {}) if turned_on? if cassettes.any? { |c| c.name == name } raise ArgumentError.new("There is already a cassette with the same name (#{name}). You cannot nest multiple cassettes with the same name.") end cassette = Cassette.new(name, ) context_cassettes.push(cassette) cassette elsif !ignore_cassettes? = "VCR is turned off. You must turn it on before you can insert a cassette. " + "Or you can use the `:ignore_cassettes => true` option to completely ignore cassette insertions." raise TurnedOffError.new() end end |