在此先感謝 - 我正在錄製帶有vcr的控制器規格。VCR重錄盒不會持續
問題:
我第一次運行我的規格,它記錄罰款,然後我刪除my_spec_context_dir,重新運行規範,並沒有錄像帶盒目錄下保存!
的寶石:
gem 'rspec-rails', '~> 3.2.1'
gem 'webmock', '1.22.3', require: false
gem 'vcr'
gem 'capybara', '~> 2.4.3'
該規範:
#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
我已經試過:
所以,我看我的CONFIGS確保VCR每次它應該被記錄運行:
#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
- 是的,我想這就是我想要的
檢查vcr.log,我看到盒記錄:
[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
目錄仍然是空的,所以我清除在測試之前緩存... Rails.cache.clear
並重新運行。
刷新spec/support/cassettes
目錄,我看到它仍然是空的。你認爲保持.yml不被保存是什麼?