如何参考rspec-capybara特征测试的路线?

时间:2015-11-04 15:39:26

标签: rspec capybara

我的测试有

 scenario 'with all required fields entered' do
   fill_out_form zip.zip_code
   click_button(page_object.eqv_continue_button)
   expect(page).to have_css(page_object.css_vehicle1_ownership)
   expect(current_path).to eq(landings_path)
 end

但我得到

/Users/pengo/eq/lynx/spec/features/full_flows/3_step_minimal_foundation_spec.rb:23:
in `block (2 levels) in <top (required)>': undefined local variable or method `landings_path' for #<Class:0x007fe320eba310> (NameError)

1 个答案:

答案 0 :(得分:0)

如果您使用的是rspec-rails,并且您的测试标记为:type =&gt; :特征 然后应自动包含url助手。如果没有,您可以尝试通过RSpec配置包含它们

RSpec.configure do |config|
  config.include Rails.application.routes.url_helpers
  ...
end