3

filter_movie_list.feature

When I check the following ratings: PG, R

电影步骤.rb

When /^I check the following ratings: (.*)/ do |rating_list|
  within(:id => 'ratings_form') do
    rating_list.split(', ').each do |rating|
      check("ratings_#{rating}")
    end
  end
end

index.html.haml

= 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'

我收到此错误:

When I check the following ratings: PG, R          #step_definitions/movie_steps.rb:21
  can't convert nil into String (TypeError)
  (eval):2:in `find'
  ./step_definitions/movie_steps.rb:22:in `/^I check the following ratings: (.*)/'
  filter_movie_list.feature:26:in `When I check the following ratings: PG, R'

做什么?

编辑:对不起n00bishness(格式错误)

4

1 回答 1

1

尝试改变你within的阅读: within('#ratings_form')看看是否会改变任何东西......

于 2012-10-25T18:45:34.730 回答