Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guard crashing Spork when using guard-spork

I've followd the "How I Test" screencast at RailsCasts, however I ran into a problem with spork

$ guard
Guard is now watching at '/Users/darth/projects/auth-before'
Starting Spork for Test::Unit & RSpec 
Couldn't find a supported test framework that begins with 'testunit'

Supported test frameworks:
( ) Cucumber
(*) RSpec

Legend: ( ) - not detected in project   (*) - detected
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
ERROR: Could not start Spork server for Test::Unit & RSpec. Make sure you can use it manually first.

# here I get growl notification "Test::Unit & RSpec NOT started

Guard::RSpec is running, with RSpec 2!
Running all specs
Running tests with args ["--color", "--format", "progress", "--format", "Guard::RSpec::Formatter::NotificationRSpec", "--out", "/dev/null", "--require", "/Users/darth/.rvm/gems/ruby-1.9.2-p290/gems/guard-rspec-0.5.0/lib/guard/rspec/formatters/notification_rspec.rb", "spec"]...
.

Finished in 14.47 seconds
1 example, 0 failures
Done.

When I try to run spork in a separate terminal window, it doesn't help, as it gets killed instantly once I run guard

$ spork
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Killed: 9

If I just run spork and then try rspec . --drb, it works just fine. Here's link to gist with my Gemfile, Guardfile and spec_helper.rb

like image 910
Jakub Arnold Avatar asked Oct 20 '11 13:10

Jakub Arnold


2 Answers

You should change:

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, 
               :rspec_env => { 'RAILS_ENV' => 'test' }, 
               :wait => 120

to:

guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' }, 
                cucumber: false, 
                test_unit: false 
like image 152
taivn07 Avatar answered Nov 21 '22 15:11

taivn07


This problem is actually caused by guard killing spork before it can even load, which is a problem on my slower MacBook pro.

The solution is to increase the wait time with :wait => 120 in the Guardfile, e.g.

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, 
               :rspec_env => { 'RAILS_ENV' => 'test' }, :wait => 120
    ....
like image 43
Jakub Arnold Avatar answered Nov 21 '22 15:11

Jakub Arnold