JohnHanks
JohnHanks

Reputation: 143

Cucumber: can't convert nil to string TypeError

filter_movie_list.feature

When I check the following ratings: PG, R

movie_steps.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'

I get this error:

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'

What do?

EDIT: Sorry for the n00bishness (formatting errors)

Upvotes: 3

Views: 1213

Answers (1)

nzifnab
nzifnab

Reputation: 16092

Try changing your within to read: within('#ratings_form') and see if that changes anything...

Upvotes: 1

Related Questions