VCR BadAlias error when used with Cucumber tag

梦想的初衷 提交于 2019-12-10 22:23:08

问题


I have to feature steps

@vcr
Given A

@vcr
Given B

and its definitions:

Given /^A$/ do
  a_method_that_makes_a_request
end

Given /^B$/ do
  a_method_that_makes_a_request
end

This fail with:

Unknown alias: 70305756847740 (Psych::BadAlias)

The number changes. But when I did this:

# Feature step
Given B

# Step definition
Given /^B$/ do
  VCR.use_cassette 'a_cassette' do
    a_method_that_makes_a_request
  end
end

It works. Can avoid this patch to use @vcr tag?

This is my config:

# features/support/vcr_setup.rb
require 'vcr'

VCR.configure do |c|
  # c.allow_http_connections_when_no_cassette = true
  c.cassette_library_dir = 'spec/fixtures/cassettes'
  c.hook_into :webmock
  c.ignore_localhost = true
  log_path = File.expand_path('../../../log/vcr.log', __FILE__)
  c.debug_logger = File.open(log_path, 'w')
end

VCR.cucumber_tags do |t|
  t.tag  '@localhost_request' # uses default record mode since no options are given
  t.tags '@disallowed_1', '@disallowed_2', :record => :none
  t.tag  '@vcr', :use_scenario_name => true, record: :new_episodes
end

来源:https://stackoverflow.com/questions/14907347/vcr-badalias-error-when-used-with-cucumber-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!