Skip to content

Instantly share code, notes, and snippets.

@afcapel
Created October 16, 2019 15:22
Show Gist options
  • Save afcapel/40d43893223090e17b4cd86a26605cea to your computer and use it in GitHub Desktop.
Save afcapel/40d43893223090e17b4cd86a26605cea to your computer and use it in GitHub Desktop.
VCR.configure do |config|
config.cassette_library_dir = "test/support/vcr_cassettes"
config.hook_into :webmock
config.ignore_localhost = true
end
module RecordedVCR
extend ActiveSupport::Concern
included do
setup do
VCR.insert_cassette cassete
end
teardown do
VCR.eject_cassette
end
end
private
def swith_cassete(name)
VCR.eject_cassette
VCR.insert_cassette cassete_with(name)
end
def cassete_with(name)
"#{cassete_dir_name}/#{name.underscore}"
end
def cassete
"#{cassete_dir_name}/#{cassete_name}"
end
def cassete_dir_name
self.class.name.underscore
end
def cassete_name
name.underscore
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment