用黄瓜和黄瓜设置录像机水豚

时间:2015-08-29 16:57:55

标签: ruby-on-rails cucumber vcr

我安装了vcr和webmock gems。

特征/支持/ vcr_setup.rb:

require 'vcr'

VCR.configure do |c|
  c.cassette_library_dir = 'vcr_cassettes'
  c.hook_into :webmock
end

特征/ step_definitions / user.rb:

VCR.use_cassette('login to shopify') do
  Given /^I am a logged in user$/ do
    @shop = create(:shop)
    visit root_path
    fill_in :shop, :with => @shop.shopify_domain
    click_button 'Install'
    expect(page).to have_content("We'll automatically")
  end
end

当我运行我的套件时,我收到了发出HTTP请求的警报。我错过了哪一步来正确记录第一张录音带,以便我可以重新用于将来的测试?

1 个答案:

答案 0 :(得分:0)

尝试指定cassette_library_dir配置的绝对路径。像这样:

  c.cassette_library_dir = Rails.root.join('test', 'fixtures', 'vcr_cassettes')

(无论申请中vcr_cassettes的正确路径是什么)

所以,你的features/support/vcr_setup.rb变成了这样:

VCR.configure do |c|
  c.cassette_library_dir = Rails.root.join('test', 'fixtures', 'vcr_cassettes')
  c.hook_into :webmock
end