2013-02-21 88 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))