Search code examples
ruby-on-railsruby-on-rails-3rspecguardspork

Problems with Guard, Spork, Rspec & Rails 3


I've followed the spork railscast video and it gives me the following error when I try to run guard:

Guard is now watching at '/Users/m/work/'
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.
Guard::RSpec is running, with RSpec 2!
Running all specs

It looks like The spork server starts up fine and then errors and tries to carry on. I've tried making the :wait option 120 seconds and it still has the same issue.

Spork works fine if I execute the tests without guard & guard-spork

Environment:

  • Mac OSX
  • rails (3.1.1)
  • guard (0.8.8)
  • guard-rspec (0.5.4)
  • spork (0.9.0.rc9)
  • guard-spork (0.3.1)

How would I go about debugging this issue? I have no idea where to start.


Solution

  • I had exactly this issue on Ubuntu. My solution was simple enough:

    1) I stopped guard

    2) I deleted the test folder

    3) started guard

    This time, instead of seeing Starting Spork for Test::Unit & RSpec, I got Starting Spork for RSpec. So spork automatically recognised that my test folder was no longer needed and everything ran sweetly.

    Interestingly enough the

    Supported test frameworks:
    ( ) Cucumber
    (*) RSpec
    

    message also disappeared and I got exactly the expected results as per railscast.

    The only conclusions I can come up with are:

    1) This is not an OS dependant issue.

    2) spork, rspec and test unit don't play nicely on Rails > v3.x apps which makes sense. You don't need both. UPDATE - Please see updated answer below if you want both.

    Obviously I followed the Railscast instructions very closely but I seriously suggest that you look at deleting the test folder.

    UPDATE It should be noted that it is possible to get both to play nicely together as per the comment below from @yuvilio, a quote of which follows:

    I don't think the issue is that they don't get along. I got Cucumber/Rspec/testunit to play nice with each other in spork. In my gemfile, in addition to rspec/cucumber/guard related gems, I added spork-testunit, guard-test, ruby-prof gems and ran bundle install. Then, I bootstrapped testunit: bundle exec spork testunit --bootstrap.Then customized test/test_helper.rb. Then updated the guard file watching for testunit: bundle exec guard init test. When I ran guard, I got output including Spork server for RSpec, Cucumber, Test::Unit successfully started