Search code examples
rubyruby-on-rails-4rspec-railsguard

guard doesn't run test for changed file rails 4.1.2


Using guard 2.6.1 with Zeus, guard does not execute specs for any changed file.

I'm using a mac os x 10.9.4 with rails 4.1.2 and ruby 2.1.2

When I make any change on a spec, guard execute it instantly, but in any other file, guard seems to ignore any change.

My bundle is:

    Using capybara (2.4.1)
    Using guard (2.6.1)
    Using guard-rspec (4.3.1)
    Using guard-zeus (2.0.0)
    Using pry (0.10.1)
    Using rails (4.1.2)
    Using rb-fsevent (0.9.4)
    Using rb-inotify (0.9.5)
    Using rspec (3.0.0)
    Using rspec-core (3.0.4)
    Using rspec-expectations (3.0.4)
    Using rspec-mocks (3.0.4)
    Using rspec-rails (3.0.2)
    Using rspec-support (3.0.4)
    Using terminal-notifier-guard (1.5.3)
    Using zeus (0.15.1)

And my Guardfile is:

    guard :rspec, cmd: 'zeus rspec' 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|\.slim)$})          { |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" }
      watch('spec/rails_helper.rb')                       { "spec" }

      # Capybara features specs
      watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$})     { |m| "spec/features/#{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

    guard 'zeus' do
      # uses the .rspec file
      # --colour --fail-fast --format documentation --tag ~slow
      watch(%r{^spec/.+_spec\.rb$})
      watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
      watch(%r{^app/(.+)\.haml$})                         { |m| "spec/#{m[1]}.haml_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/requests/#{m[1]}_spec.rb"] }

      # TestUnit
      # watch(%r|^test/(.*)_test\.rb$|)
      # watch(%r|^lib/(.*)([^/]+)\.rb$|)     { |m| "test/#{m[1]}test_#{m[2]}.rb" }
      # watch(%r|^test/test_helper\.rb$|)    { "test" }
      # watch(%r|^app/controllers/(.*)\.rb$|) { |m| "test/functional/#{m[1]}_test.rb" }
      # watch(%r|^app/models/(.*)\.rb$|)      { |m| "test/unit/#{m[1]}_test.rb" }
    end

Solution

  • This Wiki entry is exactly for debugging problems where file changes don't trigger actions: https://github.com/guard/guard/wiki/Understanding-Guard