myronmarston/vcr — Issue #128: Using the wrong cassettes with RSpec when supplied a name
Author: Retistic
Created: 2012-01-25 03:42:53+00:00
State: open

In the example below, two files are created. One is "register/subscribe_with_unsupported_number" as intended and the other is "Phone/method/subscribe/with_unsupported_phone_number" which is unintended. I don't believe it should be resorting to the default naming scheme if wrapped in the same describe block and supplied a cassette_name.

The first example is executing properly, but it seems that the second is malfunctioning. Various combinations of examples and nesting yield different files being created and there is no pattern that I can recognize. This is the closest I have gotten to pinpointing the exact issue.

## phone_spec.rb
```ruby
# == Schema Information
#
# Table name: phones
#
# id :integer not null, primary key
# number :string(255)
# subscribed :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
#

require 'spec_helper'

describe Phone do

describe "method" do

describe "subscribe" do

describe "with unsupported phone number", :vcr => {cassette_name: "register/subscribe_with_unsupported_number"} do
it "returns an error" do
phone = Phone.create( number: CONFIG['unsupported_number'] )
phone.subscribe.should eql( { status: "error" } )
end
it "doesn't change subscribed to true" do
phone = Phone.create( number: CONFIG['unsupported_number'] )
phone.subscribe
phone.subscribed?.should eql(false)
end
end # describe "with unsupported phone number"

end # describe "subscribe"
end # describe "method"
end
```

# Below is my vcr configuration
## vcr.rb
```ruby
VCR.configure do |c|
c.cassette_library_dir = Rails.root.join("spec", "vcr")
c.hook_into :webmock
c.configure_rspec_metadata!

c.filter_sensitive_data('') { CONFIG['locaid_login'] }
c.filter_sensitive_data('') { CONFIG['locaid_password'] }
c.filter_sensitive_data('') { CONFIG['locaid_class_id'] }
c.filter_sensitive_data('') { CONFIG['locaid_registrar_wsdl'] }
c.filter_sensitive_data('') { CONFIG['locaid_locator_wsdl'] }

c.filter_sensitive_data('') { CONFIG['locaid_registered_number'] }
c.filter_sensitive_data('') { CONFIG['locaid_unregistered_number'] }
c.filter_sensitive_data('') { CONFIG['locaid_unsupported_number'] }

end

RSpec.configure do |c|
c.treat_symbols_as_metadata_keys_with_true_values = true
end
```