不支持:Rails 上 Cucumber 中的符号
unsupported: Symbol in Cucumber on Rails
我正尝试在 RoR 中的 ActiveRecord
object/list 上调用 each
,如以下代码块所示。
41 Then /I should (not )?see movies with ratings: (.*)/ do |not_see, rating_li>
42 @movies = Movie.where(:rating, rating_list.split(", "))
43 rating_list.split(",").map do |x|
44 x.strip
45 end.each do |rating|
46 if not_see
47 @movies.each do |movie|
48 @movie.title
49 end
50 else
51 puts "hello"
52 end
53 end
54 end
这会产生以下错误消息:
And I should not see movies with ratings: G, PG-13, NC-17 # features/step_definitions/movie_steps.rb:41
unsupported: Symbol (RuntimeError)
./features/step_definitions/movie_steps.rb:47:in `block (2 levels) in <top (required)>'
./features/step_definitions/movie_steps.rb:45:in `each'
./features/step_definitions/movie_steps.rb:45:in `/I should (not )?see movies with ratings: (.*)/'
features/filter_movie_list.feature:33:in `And I should not see movies with ratings: G, PG-13, NC-17'
删除上面代码中的第 47
行可以消除错误。这是为什么?据我所知,所有这些都是有效的 Ruby 代码。我错过了什么?
谢谢大家!
导致错误的代码行是第 42
行。对 where
的调用应该是:
Movie.where(:rating => rating_list.split(","))
"=>"
而不是 ","
我正尝试在 RoR 中的 ActiveRecord
object/list 上调用 each
,如以下代码块所示。
41 Then /I should (not )?see movies with ratings: (.*)/ do |not_see, rating_li>
42 @movies = Movie.where(:rating, rating_list.split(", "))
43 rating_list.split(",").map do |x|
44 x.strip
45 end.each do |rating|
46 if not_see
47 @movies.each do |movie|
48 @movie.title
49 end
50 else
51 puts "hello"
52 end
53 end
54 end
这会产生以下错误消息:
And I should not see movies with ratings: G, PG-13, NC-17 # features/step_definitions/movie_steps.rb:41
unsupported: Symbol (RuntimeError)
./features/step_definitions/movie_steps.rb:47:in `block (2 levels) in <top (required)>'
./features/step_definitions/movie_steps.rb:45:in `each'
./features/step_definitions/movie_steps.rb:45:in `/I should (not )?see movies with ratings: (.*)/'
features/filter_movie_list.feature:33:in `And I should not see movies with ratings: G, PG-13, NC-17'
删除上面代码中的第 47
行可以消除错误。这是为什么?据我所知,所有这些都是有效的 Ruby 代码。我错过了什么?
谢谢大家!
导致错误的代码行是第 42
行。对 where
的调用应该是:
Movie.where(:rating => rating_list.split(","))
"=>"
而不是 ","