2012-11-05 298 views
0

問題我有一些問題,我的黃瓜測試場景,其中不幸的是我有一個錯誤:我黃瓜測試場景

When I follow "More about Star Wars"      # features/step_definitions/web_steps.rb:56 

    no link with title, id or text 'More about Star Wars' found (Capybara::ElementNotFound) 
    (eval):2:in `click_link' 

    ./features/step_definitions/web_steps.rb:57:in `/^(?:|I)follow "([^"]*)"$/' 
    features/find_movie_with_same_director.feature:18:in `When I follow "More about Star Wars"' 

我猜想,這與動態鏈路連接到提取正確的ID。 當然,一切工作都在瀏覽器中,當我測試創建新記錄時也是如此。

細節被添加如下

可能有人幫我找到我的測試場景的妥善解決?

app/views/movies/index.html.haml

%tbody 
- @movies.each do |movie| 

    %tr 
    %td= movie.title 
    %td= movie.rating 
    %td= movie.release_date 
    %td= movie.director 
    %td= link_to "More about #{movie.title}", movie_path(movie) 
    %td= movie_path(movie) 
    =link_to 'Add new movie', new_movie_path 

features/step_definition/web_steps.rb

When /^(?:|I)follow "([^"]*)"$/ do |link| 
    click_link(link) 
end 

在我的特徵文件:

Feature: search for movies by director 

Scenario: find movie with the same director 
As a movie buff 
So that I can find movies with my favorite director 
I want to include and search on director information in movies I enter 

Background: movies in database 
    Given the following movies exist: 
    | title  | rating | director  | release_date | 
    | Star Wars | PG  | George Lucas | 1977-05-25 | 
    | Blade Runner | PG  | Ridley Scott | 1982-06-25 | 
    | Alien  | R  |    | 1979-05-25 | 
    | THX-1138  | R  | George Lucas | 1971-03-11 | 

    Given I am on the home page 
    When I follow "More about Star Wars" 
    Then I should be on the details page for "Star Wars" 

回答

0
Feature: search for movies by director 

    As a movie buff 
    So that I can find movies with my favorite director 
    I want to include and search on director information in movies I enter 

Background: movies in database 
Given the following movies exist: 
    | title  | rating | director  | release_date | 
    | Star Wars | PG  | George Lucas | 1977-05-25 | 
    | Blade Runner | PG  | Ridley Scott | 1982-06-25 | 
    | Alien  | R  |    | 1979-05-25 | 
    | THX-1138  | R  | George Lucas | 1971-03-11 | 
    | THX-1131  | G  | George Lucas | 1971-03-11 | 

Scenario: find movie with same director 
    Given I am on the RottenPotatoes home page 
    And I check "ratings_PG" 
    And I press "Refresh" 
    When I follow "More about Star Wars" 
+0

嗨, 下https://github.com/khunia/hw3_rottenpotatoes.git我把我的最新版本,該項目。 通常在Firefox下一切正常,但測試步驟不 – user1800753

+0

這裏是我的電子郵件:[email protected],給我你的,我會根據我的問題給你發送屏幕 – user1800753

1

When I follow "More about Star Wars" # features/step_definitions/web_steps.rb:56

no link with title, id or text 'More about Star Wars' found (Capybara::ElementNotFound) (eval):2:in `click_link'

./features/step_definitions/web_steps.rb:57:in /^(?:|I)follow "([^"]*)"$/' features/find_movie_with_same_director.feature:18:in When I follow "More about Star Wars"'

似乎Capybara無法找到您的鏈接。 嘗試在那種情況下你的步驟定義這一步點擊鏈接

page.find('tr', text: "#{movie.title}") .click