Thanks in advance - i'm recording a controller spec with vcr.
The problem:
The first time I run my spec, it records fine, then I delete my_spec_context_dir, re-run the spec, and no cassette is saved under the cassettes dir!
The gems:
gem 'rspec-rails', '~> 3.2.1'
gem 'webmock', '1.22.3', require: false
gem 'vcr'
gem 'capybara', '~> 2.4.3'
The spec:
#spec/controllers/my_spec.rb
require 'unit_spec_helper'
describe 'description' do
it 'example_name', :vcr do
@instance_var = table_record.attribute
get 'controller_action'
expect(response.status).to eq(200)
expect(response.content_type).to eq 'image/png'
table_record.delete
end
end
What i've tried:
So I look at my configs to make sure vcr should be recording each time its run:
#spec/unit_spec_helper.rb
require 'vcr'
if Rails.env.test?
VCR.configure do |c|
c.ignore_localhost = false
c.hook_into :webmock
c.cassette_library_dir = "spec/support/cassettes"
c.configure_rspec_metadata!
c.allow_http_connections_when_no_cassette = true
c.default_cassette_options = {
allow_playback_repeats: true,
serialize_with: :json,
record: :all,
match_requests_on: [:method, :uri, :headers]
}
c.debug_logger = File.open(Rails.root.join('log/vcr.log'), 'w')
end
end
allow_playback_repeats: true, record: :all
- yep, I think thats what I want
Checking the vcr.log, I see that the cassette was recorded:
[Cassette: 'MyController/description/example_name'] Initialized with options: {:record=>:new_episodes, :match_requests_on=>[:method, :uri, :headers], :allow_unused_http_interactions=>true, :serialize_with=>:json, :persist_with=>:file_system, :allow_playback_repeats=>true}
spec/support/cassettes
dir is still empty, so i'm clearing the cache before the test... Rails.cache.clear
and re-running.
Refreshing the spec/support/cassettes
directory, I see its still empty. What do you suppose is keeping the .yml from saving?