Skip to content

Instantly share code, notes, and snippets.

@plexus
Forked from ryanb/spec_helper.rb
Created December 5, 2012 15:37
Show Gist options
  • Save plexus/4216654 to your computer and use it in GitHub Desktop.
Save plexus/4216654 to your computer and use it in GitHub Desktop.
Use RSpec tags to add behavior around specs.
# Add this to your spec_helper.rb
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.around(:each, :vcr) do |example|
name = example.metadata[:full_description].downcase.gsub(/\W+/, "_").split("_", 2).join("/")
begin
VCR.use_cassette(name, :record => :new_episodes) do
example.call
end
rescue Errno::ENAMETOOLONG
name = Digest::MD5.hexdigest( name )
retry
end
end
end
it "fetches google.com", :vcr do
# this will automatically use VCR to save the response
Net::HTTP.get(URI.parse("http://www.google.com/"))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment