Guard: cmd option doesn't seem to be evaluated

365 Views Asked by At

I try to get Guard running with the Spring gem.

Spring works nicely on the console, and I want Guard to use cmd: 'spring rspec', but Guard doesn't seem to care about the cmd: parameter ind the Guardfile:

guard :rspec, cmd: 'blaaaa' do

This doesn't result in an error, so I think it's simply omitted. How can I debug this?

Gemfile:

group :development do
  gem 'spring'
  gem 'spring-commands-rspec' # Commands for RSpec
  gem 'listen', '~> 1.0'

  gem 'guard-rspec', require: false # Automatically run tests
end

Guardfile:

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

guard :rspec, cmd: 'spring 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" }

  # 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
1

There are 1 best solutions below

0
On

As of guard-rspec version 4.0 you can use the 'cmd' option as you outlined. Errors seem to be swallowed by guard, but if you try using:

.. cmd: 'echo spring spec'

Then restart guard, you will see the command echoed to your terminal. I can confirm that guard works well with Spring.