Skip to content

Instantly share code, notes, and snippets.

@sirwolfgang
Last active January 19, 2017 22:39
Show Gist options
  • Save sirwolfgang/34bf202f4e084f8ce5f5 to your computer and use it in GitHub Desktop.
Save sirwolfgang/34bf202f4e084f8ce5f5 to your computer and use it in GitHub Desktop.
RSpec.configure do |config|
# Add VCR to all tests
config.around(:each) do |example|
options = example.metadata[:vcr] || {}
if options[:record] == :skip
VCR.turned_off(&example)
else
name = example
.metadata[:full_description]
.split(/\s+/, 2)
.join('/')
.underscore
.strip
.gsub('!', '_bang')
.gsub(/[\.#]/, '/')
.gsub(%r([^\w/]+), '_')
.gsub(%(/$), '')
.gsub('_/', '/')
VCR.use_cassette(name, options, &example)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment