RoR Tutorial Chapter 3 - Guard detects changes but doesn't fully execute tests

178 views Asked by At

I'm currently following the book and the video and in the video, Hartl runs a guardfile so that it automatically runs tests after any changes have been made. So in the videos when he presses return whilst in guard mode, it says:

17:35:31 - INFO - Running: test/controllers/static_pages_controller_test.rb

followed by

Started 

   2/2 [=======] 100% Time: 00:00:00, Time: 00:00:00

Finished in 0.214142s
2 tests, 2 assumptions, 0 failures, 0 errors, 0 skips
[1] guard(main)>

To which I assume that the tests have actually been executed.

But when I make changes to /test/controllers/static_pages_controller_test.rb the guard runs but it runs up until the line where is says and that's it:

INFO - Running: test/controllers/static_pages_controller_test.rb

I've run the guard in debug and this is what has occured:

chocoberry4@sample_app:~/workspace (static-pages) $ bundle exec guard -d
19:39:44 - DEBUG - Notiffany: gntp not available (Please add "gem 'ruby_gntp'" to your Gemfile and run your app with "bundle exec".).
19:39:44 - DEBUG - Notiffany: growl not available (Unsupported platform "linux-gnu").
19:39:44 - DEBUG - Notiffany: terminal_notifier not available (Unsupported platform "linux-gnu").
19:39:44 - DEBUG - Notiffany: libnotify not available (Please add "gem 'libnotify'" to your Gemfile and run your app with "bundle exec".).
19:39:44 - DEBUG - Command execution: which notify-send
19:39:44 - DEBUG - Notiffany: notifysend not available (libnotify-bin package is not installed).
19:39:44 - DEBUG - Notiffany: notifu not available (Unsupported platform "linux-gnu").
19:39:44 - DEBUG - Command execution: emacsclient --eval '1'
19:39:44 - DEBUG - Notiffany: emacs not available (Emacs client failed).
19:39:44 - DEBUG - Command execution: tmux -V
19:39:44 - DEBUG - Notiffany: file not available (No :path option given).
19:39:44 - DEBUG - Command execution: tmux -V
19:39:44 - DEBUG - Notiffany is using Tmux to send notifications.
19:39:44 - DEBUG - Command execution: tmux list-clients -F '#{client_tty}'
19:39:44 - DEBUG - Command execution: tmux show -t /dev/pts/1
19:39:44 - DEBUG - Command execution: tmux show -t /dev/pts/2
19:39:44 - DEBUG - Notiffany is using TerminalTitle to send notifications.
19:39:44 - DEBUG - Command execution: hash stty
19:39:44 - DEBUG - Guard starts all plugins
19:39:44 - DEBUG - Hook :start_begin executed for Guard::Minitest
19:39:44 - INFO - Guard::Minitest 2.3.1 is running, with Minitest::Unit 5.7.0!
19:39:44 - DEBUG - Hook :start_end executed for Guard::Minitest
19:39:44 - INFO - Guard is now watching at '/home/ubuntu/workspace'
19:39:44 - DEBUG - Start interactor
19:39:51 - DEBUG - Interactor was stopped or killed
19:39:51 - DEBUG - Hook :run_on_modifications_begin executed for Guard::Minitest
19:39:51 - INFO - Running: test/controllers/static_pages_controller_test.rb
19:39:51 - DEBUG - Command execution: tmux set -q status-left-bg red

Then I made a change to the file "test/controllers/static_pages_controller_test.rb" here...

19:39:51 - DEBUG - Start interactor
19:39:58 - DEBUG - Interactor was stopped or killed
19:39:58 - DEBUG - Hook :run_on_modifications_begin executed for Guard::Minitest
19:39:58 - INFO - Running: test/controllers/static_pages_controller_test.rb
19:39:58 - DEBUG - Command execution: tmux set -q status-left-bg red

19:39:58 - DEBUG - Start interactor
1

There are 1 answers

12
CryptoPiggy On BEST ANSWER
2 tests, 2 assumptions, 0 failures, 0 errors, 0 skips

means guard successfully ran 2 tests containing two assumptions (assertions).

The messages in the debug log are telling you of missing dependencies. You could save yourself a big headache and use the free cloud 9 and heroku setup Hartl suggests, as it will just work 'out of the box'.

Otherwise you need to go through and add the missing gems the debug is complaining about, ruby_gntp and libnotify. You may get other errors afterwards, but that's where you need to start. Run bundle install after adding them to your gemfile.

Edit: (since OP is using Cloud9)

There's a bug in the spring gem that leaves instances running until all your cloud9 RAM is consumed and Guard fails to complete due to being out of memory. If this is the case your options are to kill spring instances or restart your app and try again. But as your test suite grows with the tutorial killing PIDs or restarting will become too frequent to bother with. The best solution is to not use guard on the limited memory free cloud9 account. Just run bundle exec rake test when the tutorial suggests.

If there are still problems, check your gemfile exactly matches the one from the tutorial.