2013-02-21 92 views
1

我有问题:在我看来无法找到链接(水豚:: ElementNotFound)

find_movies_with_same_director_movie GET /movies/:id/find_movies_with_same_director(.:format) {:action=>"find_movies_with_same_director", :controller=>"movies"} 
           movies GET /movies(.:format)          

When I follow "Find Movies With Same Director"       # 
features/step_definitions/web_steps.rb:56 
Unable to find link "Find Movies With Same Director" (Capybara::ElementNotFound) 

在web_steps.rb:

When /^(?:|I)follow "([^"]*)"$/ do |link| 
    click_link(link) 
end 
在我的路线

show.html.haml:

%br 
= link_to 'Find Movies With Same Director', find_movies_with_same_director_movie_path(@movie) 

在控制器movies_controller.rb:

def find_movies_with_same_director 
    # some code 
end 

错了呢?

+0

当您点击此链接时,您是否在正确的页面上? – sevenseacat 2013-02-21 11:05:55

+0

'代码'场景:找同样导演的电影 由于我在“星球大战”的详细信息页面 当我按照“找到与相同导演的电影”代码“ – kotygoroshko 2013-02-21 12:14:26

+1

,不回答问题。在失败步骤之前使用'save_and_open_page'确保您位于正确的页面上。 – sevenseacat 2013-02-21 12:15:19

回答

0

感谢sevenseacat的提示:save_and_open_page

我有情景:

Scenario: find movie with same director 
Given I am on the details page for "Star Wars" 
When I follow "Find Movies With Same Director" 

步骤:鉴于我的详细信息页面上的 “星球大战” 我有错误:

when /^the details page for "(.*)"$/  
    movies_path(Movie.find_by_title($1)) 

正确的路径:

when /^the details page for "(.*)"$/  
    movie_path(Movie.find_by_title($1))