0

我一直在寻找高低尝试实施一系列建议来破解这个建议,但它们似乎都没有奏效。抱歉,如果这已在其他地方得到解答,我只是找不到它!

基本上,我坚持编写一个步骤定义来测试当前视图是否已按某些标准过滤。以下是相关步骤:

  When I check the following ratings: PG, R
  And I uncheck the following ratings: G, PG-13, NC-17
  And I press "Refresh"
  Then I should see movies with the ratings: PG, R

以下是我对后两者的步骤定义:

And /I press "Refresh"/ do
    click_button("Refresh")
end

Then /I should see movies with the ratings: (.*)/ do |ratings|
    page.should have_content ratings
end

第一个直接不起作用(说它不明确),第二个说它在页面上找不到文本 PG, R 。黄瓜对我来说完全陌生,我很迷茫!您能提供的任何建议将不胜感激!

编辑:根据要求,这是 Capybara 正在操作的 Haml:

-#  This file is app/views/movies/index.html.haml
%h1 All Movies

= form_tag movies_path, :method => :get, :id => 'ratings_form' do
  = hidden_field_tag "title_sort", true if @title_header
  = hidden_field_tag ":release_date_sort", true if @date_header
  Include: 
  - @all_ratings.each do |rating|
    = rating
    = check_box_tag "ratings[#{rating}]", 1, @selected_ratings.include?(rating), :id => "ratings_#{rating}"
  = submit_tag 'Refresh', :id => 'ratings_submit'

%table#movies
  %thead
    %tr
      %th{:class => @title_header}= link_to 'Movie Title', movies_path(:sort => 'title', :ratings => @selected_ratings), :id => 'title_header'
      %th Rating
      %th{:class => @date_header}= link_to 'Release Date', movies_path(:sort => 'release_date', :ratings => @selected_ratings), :id => 'release_date_header'
      %th More Info
  %tbody
    - @movies.each do |movie|
      %tr
        %td= movie.title 
        %td= movie.rating
        %td= movie.release_date
        %td= link_to "More about #{movie.title}", movie_path(movie)

= link_to 'Add new movie', new_movie_path
4

2 回答 2

0

您可能已经在step_definitions/browsing_steps.rb.

删除你的定义And /I press "Refresh"/

于 2013-11-15T14:20:55.073 回答
0

歧义意味着您有两个相同的匹配项,因此它不知道要使用哪个匹配项。在 web-steps.rb 你已经有了

When /^(?:|I )press "([^"]*)"$/ do |button|
  click_button(button)
end

所以你不需要指定你自己的。

于 2013-11-09T08:51:31.717 回答