guard / guard-spork

Guard::Spork automatically manage Spork DRb servers
https://rubygems.org/gems/guard-spork
MIT License
296 stars 58 forks source link

ERROR: Could not start Spork server for RSpec & Cucumber. Make sure you can use it manually first. #48

Closed belgoros closed 12 years ago

belgoros commented 12 years ago

I can't figure out what's wrong in my configuration as I'am getting the following error:

serge@serge-laptop:~/Development/Ruby/test_projects/timetracking$ guard
Please install libnotify gem for Linux notification support and add it to your Gemfile
Guard is now watching at '/home/serge/Development/Ruby/test_projects/timetracking'
Starting Spork for RSpec & Cucumber 
Using RSpec
Using Cucumber
Preloading Rails environment
/home/serge/Development/Ruby/test_projects/timetracking/features/support/env.rb has not been bootstrapped.  Run spork --bootstrap to do so.
Loading Spork.prefork block...
ERROR: Could not start Spork server for RSpec & Cucumber. Make sure you can use it manually first.
Guard::RSpec is running, with RSpec 2!
Running all features
Disabling profiles...
WARNING: No DRb server is running. Running features locally:
Preloading Rails environment
Spork is ready and listening on 8990!
Spork is ready and listening on 8989!
Feature: Login into the application
...

Here is my Gemfile:

gem 'rails', '3.1.1'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem 'jquery-rails'
gem 'mongrel', '1.2.0.pre2'
gem 'kaminari'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.1.4'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'guard-cucumber', :group => :development

group :test, :development do
  gem "rspec-rails"
end

group :test do
  gem "factory_girl_rails"
  gem "capybara"
  gem "guard-rspec"
  gem 'cucumber-rails'
  gem 'database_cleaner'
  gem "spork", "> 0.9.0.rc"
  gem "guard-spork"
end

Guard file:

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
  watch('config/application.rb')
  watch('config/environment.rb')
  watch(%r{^config/environments/.+\.rb$})
  watch(%r{^config/initializers/.+\.rb$})
  watch('Gemfile')
  watch('Gemfile.lock')
  watch('spec/spec_helper.rb')
  watch('test/test_helper.rb')
end

guard 'rspec', :version => 2, :cli => '--drb', :all_on_start => false, :all_after_pass => false do
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb')  { "spec" }

  # Rails example
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.*)(\.erb|\.haml)$})                 { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  watch(%r{^lib/(.+)\.rb$})                           { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
  watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
  watch('spec/spec_helper.rb')                        { "spec" }
  watch('config/routes.rb')                           { "spec/routing" }
  watch('app/controllers/application_controller.rb')  { "spec/controllers" }
  # Capybara request specs
  watch(%r{^app/views/(.+)/.*\.(erb|haml)$})          { |m| "spec/requests/#{m[1]}_spec.rb" }
end

guard 'cucumber', :cli => '--drb --no-profile --color --format pretty --strict' do
  watch(%r{^features/.+\.feature$})
  watch(%r{^features/support/.+$})          { 'features' }
  watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end

And at least, spec_helper.rb:

require 'rubygems'
require 'spork'

Spork.prefork do
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'
  require 'capybara/rspec'

    # Requires supporting ruby files with custom matchers and macros, etc,
  # in spec/support/ and its subdirectories.
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

  RSpec.configure do |config|
    # == Mock Framework
    #
    # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
    #
    # config.mock_with :mocha
    # config.mock_with :flexmock
    # config.mock_with :rr
    config.mock_with :rspec

    # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
    #config.fixture_path = "#{::Rails.root}/spec/fixtures"

    # If you're not using ActiveRecord, or you'd prefer not to run each of your
    # examples within a transaction, remove the following line or assign false
    # instead of true.
    config.use_transactional_fixtures = true

    # If true, the base class of anonymous controllers will be inferred
    # automatically. This will be the default behavior in future versions of
    # rspec-rails.
    config.infer_base_class_for_anonymous_controllers = false
  end
end

Spork.each_run do
  # This code will be run each time you run your specs.

end

I'm on Ruby 1.9.2, Rails 3.1.1, Ubuntu 10.04. THANK YOU.

belgoros commented 12 years ago

Sorry, still can't manage the formatting :(

netzpirat commented 12 years ago

According to the following line in your log you've forgotten to bootstrap Spork:

/home/serge/Development/Ruby/test_projects/timetracking/features/support/env.rb has not been bootstrapped. Run spork --bootstrap to do so.
belgoros commented 12 years ago

I've already seen that message and run the bootstrap, here tis he proof:

serge@serge-laptop:~/Development/Ruby/test_projects/timetracking$ spork --bootstrap
Using RSpec
Already bootstrapped!
serge@serge-laptop:~/Development/Ruby/test_projects/timetracking$ 

Here is what I get after that no changes, unfortunately):

serge@serge-laptop:~/Development/Ruby/test_projects/timetracking$ spork --bootstrap
Using RSpec
Already bootstrapped!
serge@serge-laptop:~/Development/Ruby/test_projects/timetracking$ guard
Please install libnotify gem for Linux notification support and add it to your Gemfile
Guard is now watching at '/home/serge/Development/Ruby/test_projects/timetracking'
Starting Spork for RSpec & Cucumber 
Using RSpec
Using Cucumber
Preloading Rails environment
/home/serge/Development/Ruby/test_projects/timetracking/features/support/env.rb has not been bootstrapped.  Run spork --bootstrap to do so.
Loading Spork.prefork block...
ERROR: Could not start Spork server for RSpec & Cucumber. Make sure you can use it manually first.
Guard::RSpec is running, with RSpec 2!
Running all features
Disabling profiles...
WARNING: No DRb server is running. Running features locally:
Preloading Rails environment
Spork is ready and listening on 8990!
Spork is ready and listening on 8989!
Feature: Login into the application
  To enter the Timetracking application any user should first log in.
giom commented 12 years ago

I had the same issue just now, by default spork --bootstrap only checks and bootstraps rspec and not cucumber. You need to run spork cucumber --bootstrap

Or, if you don't want to use cucumber, you can add cucumber => false to guard 'spork'

Another issue I ran into is that the wait time was too low for my slow machine to finish loading the code, so I added :wait => 50 to guard 'spork'

rymai commented 12 years ago

Thanks @giom, FYI the latest version (0.3.2) of guard-spork should fix the "too long start" issue (details here).

@Javix, does running spork cucumber --bootstrap actually fixes the issue?

belgoros commented 12 years ago

Bootstrap worked witout problems but no changes after all:

serge@serge-laptop:~/Development/Ruby/test_projects/timetracking$ spork cucumber --bootstrap
Using Cucumber
Bootstrapping /home/serge/Development/Ruby/test_projects/timetracking/features/support/env.rb.
Done. Edit /home/serge/Development/Ruby/test_projects/timetracking/features/support/env.rb now with your favorite text editor and follow the instructions.
serge@serge-laptop:~/Development/Ruby/test_projects/timetracking$ guard
Please install libnotify gem for Linux notification support and add it to your Gemfile
Guard is now watching at '/home/serge/Development/Ruby/test_projects/timetracking'
Starting Spork for RSpec & Cucumber 
Using Cucumber
Using RSpec
Preloading Rails environment
Preloading Rails environment
Loading Spork.prefork block...
Loading Spork.prefork block...
ERROR: Could not start Spork server for RSpec & Cucumber. Make sure you can use it manually first.
Guard::RSpec is running, with RSpec 2!
Running all features
Disabling profiles...
WARNING: No DRb server is running. Running features locally:
Spork is ready and listening on 8990!
Spork is ready and listening on 8989!
Feature: Login into the application
  To enter the Timetracking application any user should first log in.

  Scenario: successful login                                      # features/login.feature:4
    Given the email 'admin@example.com'  and the password 'admin' # features/step_definitions/login_steps.rb:1
pauljamesrussell commented 12 years ago

@Javix as mentioned by @rymai above, the latest version (0.3.2) should fix the "Could not start" error you're seeing. Try running bundle update guard-spork?

If you don't want to upgrade, as @glom mentioned, you should be able to manually set the wait time. The readme file contains some information on this.

Do either of these steps fix your issue?

sorens commented 12 years ago

I've updated to 0.3.2 but I am still experiencing the issue.

> guard
Please install growl_notify or growl gem for Mac OS X notification support and add it to your Gemfile
Guard is now watching at '/Users/sorens/Dropbox/workspace/personal/naval_conflict'
Starting Spork for RSpec 
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
ERROR: Could not start Spork server for RSpec after 30 seconds. I will continue waiting for a further 60 seconds.
ERROR: Could not start Spork server for RSpec. Make sure you can use it manually first.
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/sorens/.rvm/gems/ruby-1.9.2-p290@rails3/gems/guard-rspec-0.5.4/lib/guard/rspec/formatters/notification_rspec.rb", "spec"]...
......*...........*......................................

After the wait period has expired, it appears that everything startsup and runs fine. My Guardfile looks like

guard 'spork', :cucumber => false, :rspec_env => { 'RAILS_ENV' => 'test' } do
  # stuff goes here
end

guard 'rspec', :version => 2, :cli => '--drb' do
  # stuff goes here
end

I have run spork manually. I've used --bootstrap as well. If I run spork, everything works fine. Even with those reported errors, spork starts up. I can modify Guardfile and guard-spork reports

Guardfile has been re-evaluated.

If I change a model, again guard-spork reports that my model has changed and re-runs those tests.

Running: spec/models/admin_user_spec.rb

In any event, I figured I would report the problem even though it seems fairly benign.

omnikron commented 12 years ago

I am experiencing the same problem since updating from 0.3.1 to 0.3.2 two days ago. Start-up time has also increased dramatically (my current wait time of 90 seconds is not enough, where previously it took ~10 seconds to load my tiny app). As with @sorens, everything appears to be working fine, so this is more of an annoyance.

Edit: When it does finally start it sends a growl notification Test::Unit & RSpec NOT started although RSpec runs immediately. I have tried using 0.3.1 again and there is no improvement.

rymai commented 12 years ago

Hi,

I'm sorry but if there is no improvement from downgrading to 0.3.1, I don't understand how, by upgrading to 0.3.2, your "Start-up time has also increased dramatically"!

Here is the comparison between 0.3.1 and 0.3.2: https://github.com/guard/guard-spork/compare/v0.3.1...v0.3.2 As you can see, there's no change that can increase the startup time of your app. Maybe the reason is elsewhere, don't you think? Maybe the problem is Spork, did you upgrade it recently?

belgoros commented 12 years ago

After updating to 0.3.2. there still was a problem with time:

RROR: Could not start Spork server for RSpec & Cucumber after 30 seconds. I will continue waiting for a further 60 seconds.

So I added the option ':wait => 50' to guard sprok in the Guardfile and it seems to work now:

serge@serge-laptop:~/Development/Ruby/test_projects/timetracking$ guard
Please install libnotify gem for Linux notification support and add it to your Gemfile
Guard is now watching at '/home/serge/Development/Ruby/test_projects/timetracking'
Starting Spork for RSpec & Cucumber 
Using RSpec
Using Cucumber
Preloading Rails environment
Preloading Rails environment
Loading Spork.prefork block...
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork is ready and listening on 8990!
Spork server for RSpec & Cucumber successfully started
Guard::RSpec is running, with RSpec 2!
Running all features
Disabling profiles...
Running tests with args ["--no-profile", "--color", "--format", "pretty", "--strict", "--require", "/home/serge/.rvm/gems/ruby-1.9.2-head/gems/guard-cucumber-0.7.4/lib/guard/cucumber/notification_formatter.rb", "--format", "Guard::Cucumber::NotificationFormatter", "--out", "/dev/null", "--require", "features", "features"]...
Disabling profiles...
Feature: Login into the application
  To enter the Timetracking application any user should first log in.

  Scenario: successful login                                      # features/login.feature:4
    Given the email 'admin@example.com'  and the password 'admin' # features/step_definitions/login_steps.rb:1
      uninitialized constant User (NameError)
      ./features/step_definitions/login_steps.rb:2:in `/^the email 'admin@example.com'  and the password 'admin'$/'
      features/login.feature:5:in `Given the email 'admin@example.com'  and the password 'admin''
    When the user clicks on 'Log in'                              # features/step_definitions/login_steps.rb:5
    Then the user enters to the application                       # features/step_definitions/login_steps.rb:10

Failing Scenarios:
cucumber features/login.feature:4 # Scenario: successful login

1 scenario (1 failed)
3 steps (1 failed, 2 skipped)
0m3.339s
Done.
pauljamesrussell commented 12 years ago

@Javix, that's behaving as we intended - the error is there because we expected the spork servers to start within 30 seconds. The 60 second wait is intended to help you identify how long it is actually taking. Once spork actually starts, you should get a message saying how long it actually took.

@sorens yours looks more troubling - it should have detected spork was running by the looks of it. I've just run a test against my own config and it looks like it's working for me:

Starting Spork for RSpec & Cucumber 
Using Cucumber
Using RSpec
Preloading Rails environment
Preloading Rails environment
Loading Spork.prefork block...
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork is ready and listening on 8990!
Spork server for RSpec & Cucumber successfully started
Guard::RSpec is running, with RSpec 2!
Pow restarted.

The only obvious difference I can see is that you're only using RSpec, rather than RSpec + cucumber, but I've tried the same thing by running guard-spork against itself (yes, confusing I know, but it was the only non-cucumber project I had handy) which is RSpec only, and it's working there too. I take it this is something that happens every time? I assume your code is from a private project (i.e. it's not floating around on github somewhere?)

sorens commented 12 years ago

@Javix I created a new rails app which happens to demonstrate the problem, at least on my machine. I pushed it to a new github repo so you can see the disaster that I've created. I posted some of the relevant output to the README.md. The repo is called sporkt. Let me know if you have questions.

omnikron commented 12 years ago

@rymai apologies, I was not clear on my edit - the start-up time issue is not related to the update to 0.3.2. I haven't updated spork, however, so I don't know what is causing it. If you would like to see any particulars of my setup just let me know - I am new to rails/ruby and do not know what you might need, and it is a private repo unfortunately.

pauljamesrussell commented 12 years ago

@sorens, I've just executed your test project, and seeing the following:

Pauls-MacBook-Pro:sporkt paulrussell$ guard
Guard is now watching at '/Users/paulrussell/Documents/Work/3sixty/github/sporkt'
Starting Spork for Test::Unit & RSpec 
Using RSpec
Couldn't find a supported test framework that begins with 'testunit'

Supported test frameworks:
( ) Cucumber
(*) RSpec

Legend: ( ) - not detected in project   (*) - detected
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
ERROR: Could not start Spork server for Test::Unit & RSpec after 30 seconds. I will continue waiting for a further 60 seconds.
ERROR: Could not start Spork server for Test::Unit & RSpec. Make sure you can use it manually first.
[...]

...which indicates that guard-spork is trying (and failing) to wait for Test::Unit, since it is not in the Gemfile. When I change the project to remove test/test_support.rb, which is how guard-spork detects which frameworks to use, then I get the following successful result:

Pauls-MacBook-Pro:sporkt paulrussell$ guard
Guard is now watching at '/Users/paulrussell/Documents/Work/3sixty/github/sporkt'
Starting Spork for RSpec 
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork server for RSpec successfully started
Guard::RSpec is running, with RSpec 2!
Running all specs
[...]

Sorens: Unless you're still seeing the issue r.e. the upgrade to 0.3.2 failing to detect a /correct/ startup, I'm inlined to suggest we close this issue, since I think the original issue was fixed by 0.3.2. Any objections?

sorens commented 12 years ago

@pauljamesrussell I commented out the watch for test/test_helper.rb and it works just as you said. Thanks for the help! I didn't create the issue, I just hijacked it when I was having the same issue :) but feel free to close.

reidreid46 commented 12 years ago

Hey @pauljamesrussell, I've just started using Spork (it's awesome). I'm running version 0.3.2 with the line 'watch('test/test_helper.rb')' commented out (since I'm not using the relevant gem) and I'm having the same issue. I'll post the project for review within the next 48 hours so, just wanted to give you the heads up before closed the issue.

Also, I'm pretty new with new with giving feedback on other peoples gems, let me know if there's a better process. Thanks!

omnikron commented 12 years ago

Removing the /test folder entirely fixed the issue for me. There was no test_support.rb file, the contents were:

test/test_helper.rb
test/performance/browsing_test.rb

I did have :testunit => false in my Guardfile but it seems that didn't make any difference.

reidreid46 commented 12 years ago

Thanks clearing that up @omnikron, remvoing the /test directory worked for me. Now I can startup Spork without any trouble. Not sure if other people will run into the same confusion, happy to make a note in the readme file or elsewhere if it would be helpful to others.

thibaudgg commented 12 years ago

@reidreid46 feel free to submit a pull request with more info about this problem in the README. Thanks all!

acco commented 12 years ago

@omnikron +1, worked great for me thanks!

medampudi commented 12 years ago

@omnikron +1, thanks for the Help.. but what are the implications of removing it. are anything effected and why is it there in the first place.

acco commented 12 years ago

@medampudi Test::Unit is the default test framework for rails. You don't need what you don't use.

klebershimabuku commented 12 years ago

@omnikron +1, removing the test directory worked for me too. Thank you.

matt-hwy1 commented 12 years ago

I found that I just needed to remove test/test_helper.rb from the test dir, which was otherwise empty, to make this work. rake test was working fine for me (essentially a no-op) so I'm puzzled why it should fail through guard-spork. In any case, that was my workaround. We're using rspec on this project but I'd still like to be able to use test:unit at some point. Cross that bridge at some point I suppose,

tryphoon commented 11 years ago

+1

dtnorris commented 11 years ago

+1

stephanschielke commented 11 years ago

@omnikron +1

kmanicka commented 11 years ago

+1 removing the /test directory did the trick

gabrielspmoreira commented 11 years ago

+1

bhardin commented 11 years ago

Removing /test directory worked for me too.

rebdev commented 11 years ago

+1

h0jeZvgoxFepBQ2C commented 11 years ago

But i need the /test direcotry because i use both rspec and test unit... And i still get the problem:

Spork is ready and listening on 8989! 09:45:28 - ERROR - Could not start Spork server for RSpec, Test::Unit after 30 seconds. I will continue waiting for a further 60 seconds.

09:46:28 - ERROR - Could not start Spork server for RSpec, Test::Unit. Make sure you can use it manually first.

madeonamac commented 11 years ago

+1