【问题标题】:Guard: cmd option doesn't seem to be evaluatedGuard: cmd 选项似乎没有被评估
【发布时间】:2013-12-02 21:41:36
【问题描述】:

我尝试让 Guard 与 Spring gem 一起运行。

Spring 在控制台上运行良好,我希望 Guard 使用 cmd: 'spring rspec',但 Guard 似乎并不关心 cmd: 参数和 Guardfile

guard :rspec, cmd: 'blaaaa' do

这不会导致错误,所以我认为它只是被省略了。我该如何调试?

宝石文件:

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

保护文件:

# 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

【问题讨论】:

    标签: spring rspec guard


    【解决方案1】:

    从guard-rspec 4.0 版开始,您可以使用您所概述的'cmd' 选项。错误似乎被守卫吞下了,但如果你尝试使用:

    .. cmd: 'echo spring spec'
    

    然后重新启动守卫,您将看到命令回显到您的终端。我可以确认 guard 与 Spring 配合得很好。

    【讨论】:

      猜你喜欢
      • 2018-12-03
      • 2015-10-28
      • 2019-05-05
      • 2014-03-16
      • 2011-03-29
      • 2020-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多