30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/vcr/test_frameworks/rspec.rb', line 30
def configure!
::RSpec.configure do |config|
when_tagged_with_vcr = { :vcr => lambda { |v| !!v } }
config.before(:each, when_tagged_with_vcr) do |ex|
example = ex.respond_to?(:metadata) ? ex : ex.example
cassette_name = nil
options = example.metadata[:vcr]
options = case options
when Hash options.dup
when String cassette_name = options.dup
{}
else {}
end
cassette_name ||= options.delete(:cassette_name) ||
VCR::RSpec::Metadata.vcr_cassette_name_for(example.metadata)
VCR.insert_cassette(cassette_name, options)
end
config.after(:each, when_tagged_with_vcr) do |ex|
example = ex.respond_to?(:metadata) ? ex : ex.example
VCR.eject_cassette(:skip_no_unused_interactions_assertion => !!example.exception)
end
end
end
|