怎么了,伙计们。请帮忙。
当我进行黄瓜测试时,我遇到了这个错误:
No route matches {:action=>"show", :controller=>"accounts"} (ActionController::RoutingError)
./features/support/paths.rb:40:in `path_to'
rake路线显示:
account GET /accounts/:id(.:format) {:action=>"show", :controller=>"accounts"}
cucumber_test.feature
Scenario:
Given...
And...
Then i should be on Show page
特征性/支撑性/ paths.rb
when /^Show page$/
account_path @account
的routes.rb
Myapp::Application.routes.draw do
resources :accounts
答案 0 :(得分:1)
Imho你错误地认为你有@account变量设置。
以下是一些可能的方法。你可以使用:
when /the account page/
account_path(Account.first)
或更好,更干净,可重复使用(我不知道您的帐户架构,因此我使用了通用'名称'):
when /the account page for account named ".*"/
account_name = page_name.scan(/".*"/).first.gsub("\"", '')
account = Account.find_by_name(account_name)
account_path(account)
当然,只要你已经定义了这样的“我在”网站上:
Given /^(?:|I )am on (.+)$/ do |page_name|
visit path_to(page_name)
end