guard / guard-spork

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

Guard-spork fails to make the rails application available to the specs #90

Closed ekampp closed 11 years ago

ekampp commented 11 years ago

I have a some specs (example supplied below) which I can run directly with rspec and guard fine, but when I tried to speed up the process by adding guard-spork, it seems that the specs are now acting up.

The problem that I'm facing is that running controller specs causes this error:

Exception encountered: #<NameError: uninitialized constant MapsController>

when running this piece of spec:

require 'spec_helper'

describe MapsController do
  # let(:model_name) { :map }
  # include_context 'crud actions'

  it "should do something" do
    "bla".should eq "bla"
  end
end

So clearly the MapsController class has become unavailable to rspec after adding spork. Am I doing something wrong, have I forgotten some setting, or is there an actual problem here?

Here is my gem file and my guard file and the trace:

source 'http://rubygems.org'
gem 'rubygems-bundler'

# Rails 4 related
gem 'activerecord-deprecated_finders', github: "rails/activerecord-deprecated_finders", branch: "master"
gem 'journey', github: "rails/journey", branch: "master"
gem 'rails', github: "rails/rails", branch: "master"

# Misc
gem 'inherited_resources'
gem 'paranoia', github: "radar/paranoia", branch: "master"

# Authentication / authorization
gem 'cancan'
gem 'omniauth-facebook'

# Front-end
gem 'simple_form'
gem 'haml-rails'
gem 'jquery-rails'

# Servers
gem "puma"

# Renderers
gem 'redcarpet'
gem 'markdown-rails'

# Database
gem 'bson_ext'
gem 'mongoid', github: "ekampp/mongoid"

# Versioning
gem 'version_bumper'

group :assets do
  gem 'sprockets-rails', github: 'rails/sprockets-rails'
  gem 'sass-rails', github: "rails/sass-rails", branch: "master"
  gem 'coffee-rails', github: "rails/coffee-rails", branch: "master"
  gem 'uglifier-rails', github: "guilleiguaran/uglifier-rails", branch: "master"
  gem 'normalize-rails'
  gem 'bootstrap-sass'
end

group :development, :test do
  gem 'brakeman'
  gem 'capistrano'
  gem 'spinning_cursor'
  gem 'foreman'

  gem 'rspec-rails'
  gem 'capybara'
  gem 'guard-rspec'
  gem 'factory_girl_rails'
  gem 'guard-spork'
end
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'spork', cucumber: false, foreman: true do
  watch('config/application.rb')
  watch('config/environment.rb')
  watch('config/environments/test.rb')
  watch(%r{^config/initializers/.+\.rb$})
  watch('Gemfile')
  watch('Gemfile.lock')
  watch('spec/spec_helper.rb') { :rspec }
end

guard 'rspec', version: 2, cli: "--color --format nested --fail-fast --drb",
               all_after_pass: false, all_on_start: 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{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.*)(\.erb|\.haml)$})                 { |m| "spec/#{m[1]}#{m[2]}_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('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" }

  # Turnip features and steps
  watch(%r{^spec/acceptance/(.+)\.feature$})
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})   { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
Running: spec/controllers/maps_controller_spec.rb
Running tests with args ["--color", "--format", "nested", "--fail-fast", "--drb", "-r", "/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/guard-rspec-1.2.1/lib/guard/rspec/formatters/notification_rspec.rb", "-f", "Guard::RSpec::Formatter::NotificationRSpec", "--out", "/dev/null", "--failure-exit-code", "2", "spec/controllers/maps_controller_spec.rb"]...
Exception encountered: #<NameError: uninitialized constant MapsController>
backtrace:
/Users/emil/code/grid-map/spec/controllers/maps_controller_spec.rb:3:in `<top (required)>'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/test_framework/rspec.rb:11:in `run_tests'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:13:in `block in run'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:21:in `block in initialize'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:18:in `fork'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:18:in `initialize'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `new'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `run'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/server.rb:48:in `run'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/Users/emil/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'
thibaudgg commented 11 years ago

And I think it's the same problem when you are launching Spork manually right? It must be an issue with how you have configured Spork, try to diagnose it: https://github.com/sporkrb/spork#diagnostic-mode

thibaudgg commented 11 years ago

@ekampp is it still an issue?