cucumber / cucumber-rails

Rails Generators for Cucumber with special support for Capybara and DatabaseCleaner
https://github.com/cucumber/cucumber-rails
MIT License
1.02k stars 327 forks source link

Assert not working? Results in "undefined method `add_assertion' for nil:NilClass" #96

Closed contentfree closed 13 years ago

contentfree commented 13 years ago

I upgraded from the gem version of cucumber-rails to HEAD on the git repo, updated my support files (env.rb et al) and now I'm bombing tests on ol' assert.

My test is a typical assert page.has_css? ... and the resulting error is undefined method 'add_assertion' for nil:NilClass. Stacktrace:

undefined method `add_assertion' for nil:NilClass
/Users/dave/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.3/lib/active_support/whiny_nil.rb:48 :in `method_missing'
/Users/dave/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/testcase.rb:127 :in `add_assertion'
/Users/dave/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/assertions.rb:494 :in `_wrap_assertion'
/Users/dave/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/assertions.rb:61 :in `assert'
/Users/dave/Sites/mysite.com/features/step_definitions/my_steps.rb:122 

Seems very strange... The problem, apparently, is that TestCase#run is never run, so when assert is called, the @_result variable isn't set and add_assertion barfs.

contentfree commented 13 years ago

Also, it doesn't happen with my Ruby 1.9.2 install, just 1.8.7. (It was working fine in 1.8.7 until I switched to HEAD on master at the git repo)