Module: MinitestVcr::Spec

Defined in:
lib/minitest-vcr/spec.rb

Class Method Summary collapse

Class Method Details

.configure!Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/minitest-vcr/spec.rb', line 7

def self.configure!
  run_before = lambda do |example|
    if [:vcr]
      options = [:vcr].is_a?(Hash) ? [:vcr] : {}
      VCR.insert_cassette StringHelpers.vcr_path(example), options
    end
  end

  run_after = lambda do |example|
    ::VCR.eject_cassette if [:vcr]
  end

  ::MiniTest::Spec.before :each, &run_before
  ::MiniTest::Spec.after :each, &run_after
end