myronmarston/vcr — Issue #95: Enable through RSpec Metadata
Author: ryanb
Created: 2011-10-21 17:12:32+00:00
State: open

The `use_vcr_cassette` RSpec macro is nice, but I prefer to use RSpec metadata/tags for enabling VCR. My usual RSpec config looks like this.

```ruby
RSpec.configure do |c|
c.treat_symbols_as_metadata_keys_with_true_values = true
c.around(:each, :vcr) do |example|
name = example.metadata[:full_description].split(/\s+/, 2).join("/").underscore.gsub(/[^\w\/]+/, "_")
options = example.metadata.slice(:record, :match_requests_on).except(:example_group)
VCR.use_cassette(name, options) { example.call }
end
end
```

So that we can pass a `:vcr` tag with options into RSpec to enable it.

```ruby
it "does something", :vcr, record: :new_episodes
```

The options would better work in a nested hash but I don't know how to do this with RSpec.

```ruby
it "does something", vcr: {record: :new_episodes}
```

Any chance we can get this functionality in 2.0?