I'm working my way through the Hartl Ruby on Rails Tutorial (4th Edition) and I've come across a problem with some tests I'm trying to run - specifically the exercise in section 11.2.3. All of my tests are green up to this point.
I test the new piece of code:
vagrant@ubuntu-18:/vagrant/sample_app/test$ rails test:mailers
Started with run options --seed 59483
1/1: [======================================================================] 100% Time: 00:00:00, Time: 00:00:00
Finished in 0.33304s
1 tests, 9 assertions, 0 failures, 0 errors, 0 skips
Everything is groovy.
I attempt to run the full test suite:
vagrant@ubuntu-18:/vagrant/sample_app/test$ rails test
Running via Spring preloader in process 11914
Started with run options --seed 56533
ERROR["test_account_activation", UserMailerTest, 1.2505091589991935]
test_account_activation#UserMailerTest (1.25s)
ActionView::Template::Error: ActionView::Template::Error: undefined method `merge' for nil:NilClass
app/views/user_mailer/account_activation.html.erb:6:in `_app_views_user_mailer_account_activation_html_erb__2910351700178259135_47130470135880'
app/mailers/user_mailer.rb:10:in `account_activation'
test/mailers/user_mailer_test.rb:9:in `block in <class:UserMailerTest>'
48/48: [========================================================================] 100% Time: 00:00:01, Time: 00:00:01
Finished in 1.71036s
48 tests, 206 assertions, 0 failures, 1 errors, 0 skips
Bugger. It's definitely the same piece of code that's failing in one place, and working in the other.
However, if instead of running rails test
I run rails test:run
, then this happens:
vagrant@ubuntu-18:/vagrant/sample_app/test$ rails test:run
Started with run options --seed 50303
48/48: [========================================================================] 100% Time: 00:00:01, Time: 00:00:01
Finished in 1.72194s
48 tests, 215 assertions, 0 failures, 0 errors, 0 skips
And similarly, if I use rake test
or rake test:run
, then everything is fine.
vagrant@ubuntu-18:/vagrant/sample_app/test$ rake test
(in /vagrant/sample_app)
Started with run options --seed 9429
48/48: [========================================================================] 100% Time: 00:00:01, Time: 00:00:01
Finished in 1.70475s
48 tests, 215 assertions, 0 failures, 0 errors, 0 skips
vagrant@ubuntu-18:/vagrant/sample_app/test$ rake test:run
(in /vagrant/sample_app)
Started with run options --seed 50280
48/48: [========================================================================] 100% Time: 00:00:01, Time: 00:00:01
Finished in 1.73529s
48 tests, 215 assertions, 0 failures, 0 errors, 0 skips
Can anyone explain what's going on here? And ideally how to make just a rails test
call work again?
Aucun commentaire:
Enregistrer un commentaire