2

使用 Ruby on Rails 并且我正在编写步骤定义以便我可以运行 cucumber。但是,我有一个访问页面的一般定义,而黄瓜找不到我给它的路径:

Can't find mapping from "the Brainstormy home index page" to a path.

这是步骤定义:

Given /^(?:|I )am on (.+)$/ do |page_name|
  visit path_to(page_name)
end

这是场景:

Scenario: Sign up for Brainstormy

Given I am on the Brainstormy home index page
When I fill in "firstName" with "John"
And I fill in "lastName" with "Adams"
And I fill in "email" with "jadams@gmail.com"
And I fill in "email2" with "jadams@gmail.com"
And I fill in "password" with "spot1234"
And I fill in "password2" with "spot1234"
And I press "Sign Up"
Then I should be on the profile page

我的路线:

home_index        /home/index(.:format)     home#index
root              /                         home#index

我的路线.rb:

root :to => 'home#index'
resources :ideas
resources :users

#root :to => redirect('/home/index')
match 'home/index' => 'home#index'
match 'users/new' => 'users#new'

问题是,我没有写定义。我从一个工作应用程序中得到它,基本上反映了他们所做的事情。有人可以帮我解决这个问题吗?

4

1 回答 1

2

查看path_to方法内部。这将是从人类可读字符串到 URL 的某种映射。您必须添加一个映射"Brainstormy home index page"以转到您想要的任何 URL。如果您需要其他帮助,path_to请在帖子中包含该方法。

于 2013-04-07T00:20:25.910 回答