Created
September 12, 2011 21:37
-
-
Save ryanb/1212530 to your computer and use it in GitHub Desktop.
Use RSpec tags to add behavior around specs.
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
# 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("/") | |
VCR.use_cassette(name, :record => :new_episodes) do | |
example.call | |
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 |
Thanks, fixed!
I ran into a problem where the filename became too long for my file system. See my fork for a fix.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FWIW,
config.around(:each, :vcr => true) do |example|
can be simplified toconfig.around(:each, :vcr) do |example|
since you've set thetreat_symbols...
option.