2012-11-05 246 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