Class: ActiveSupport::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest-vcr/spec.rb

Instance Method Summary collapse

Instance Method Details

#after_teardownObject



72
73
74
75
76
77
# File 'lib/minitest-vcr/spec.rb', line 72

def after_teardown
  if self.class.name.match("::vcr::")
    ::VCR.eject_cassette
  end
  super
end

#before_setupObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/minitest-vcr/spec.rb', line 61

def before_setup
  super
  if self.class.name.match("::vcr::")
    base_path = self.class.name.split("::")
      .map {|p| p.underscore.gsub(" ", "_") unless p == "vcr" }.join("/")

    file_name = name.gsub(/^test_.\d+_/, " ").strip.gsub(" ", "_")
    VCR.insert_cassette(base_path + "/" + file_name)
  end
end