Created
October 16, 2019 15:22
-
-
Save afcapel/40d43893223090e17b4cd86a26605cea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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