guard / guard-spork

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

hitting enter to run specs not working after change to rails model #76

Closed baversjo closed 12 years ago

baversjo commented 12 years ago

Hello! If I make a change to a rails model and then hit enter in the terminal to run all specs nothing happens. I've tried waiting for up to a minute. Looks like guard/spork is locked. After waiting, if I save the model file again my previous request to run all specs instantly starts successfully. If I do not change any "rails classes", running specs by hitting enter always works.

I just changed config.cache_classes to false in my test environment, hoping that was the cause but nothing changed in the behavior after restarting guard.

Here's my Guardfile (I followed the railscasts.com screencast on spork):

# 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') { :rspec }
  watch('test/test_helper.rb') { :test_unit }
  watch(%r{features/support/}) { :cucumber }
end

guard 'rspec', :version => 2, :cli => '--drb' 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" }
end

spec_helper.rb:

require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'

Spork.prefork do
  # Loading more in this block will cause your tests to run faster. However,
  # if you change any configuration or code from libraries loaded here, you'll
  # need to restart spork for it take effect.

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

  # 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|
    config.mock_with :rspec
    config.use_transactional_fixtures = true
    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.
  FactoryGirl.reload
end

gem versions: spork (0.9.1) guard (1.0.2) guard-rspec (0.7.0) guard-spork (0.7.1) rails (3.2.3) rb-fsevent (0.9.1)

thibaudgg commented 12 years ago

It seems more to be an issue with the Guard Interactor.

Try to add:

platform :ruby do
  gem 'rb-readline'
end

to your Gemfile or to disable the interactor with the -i/--no-interactions option.

baversjo commented 12 years ago

adding that gem worked great, thanks so much!

thibaudgg commented 12 years ago

Great, you're welcome!