我一直在努力寻求实施一系列建议来破解这一点,但它们似乎都没有起作用。对不起,如果这已在其他地方得到解答,我就找不到了!
基本上,我很难编写一个步骤定义来测试当前视图是否已按某些条件过滤。以下是相关步骤:
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
答案 0 :(得分:0)
不明确意味着您有两个相同的匹配,因此它不知道使用哪个。 在web-steps.rb中你已经有了
When /^(?:|I )press "([^"]*)"$/ do |button|
click_button(button)
end
所以你不需要指定自己的。
答案 1 :(得分:0)
您可能已在step_definitions/browsing_steps.rb
中定义了此步骤。
删除And /I press "Refresh"/