ruby-on-rails - 在 Rails 中,我从 Guard 那里收到这个错误,说我必须更新到新的 :cmd syntax

标签 ruby-on-rails ruby rspec ruby-on-rails-4 guard

我刚刚更新了我的 gem,当我尝试运行 Guard 时,出现以下错误:

Guard::RSpec DEPRECATION WARNING: The :cli option is deprecated. Please customize the new :cmd option to fit your need.

这是我的 Guard 文件:

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

  # Custom specs
  watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
    ["spec/routing/#{m[1]}_routing_spec.rb",
     "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb",
     "spec/acceptance/#{m[1]}_spec.rb",
     (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" :
                       "spec/requests/#{m[1].singularize}_pages_spec.rb")]
  end
  watch(%r{^app/views/(.+)/}) do |m|
    (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" :
                      "spec/requests/#{m[1].singularize}_pages_spec.rb")
  end
  watch(%r{^app/controllers/sessions_controller\.rb$}) do |m|
    "spec/requests/authentication_pages_spec.rb"
  end

  # Capybara features specs
  watch(%r{^app/views/(.+)/.*\.(erb|haml)$})          { |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 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } 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 }
  watch('test/test_helper.rb') { :test_unit }
  watch(%r{features/support/}) { :cucumber }
end

那么如何使用 :cmd 命令来替换 '--drb' 呢?

最佳答案

cmd 选项记录在 guard-rspec README .在 cli: 值中使用您喜欢的调用 rspec 的方法作为前缀。

例如,我使用 Zeus,所以除了 cli: 选项外,我还有 zeus: truebundler: false 选项(这三个现在都已弃用):

guard 'rspec', cli: '--color --format nested --fail-fast', zeus: true, bundler: false, all_after_pass: true do
  ...
end

如果我在 guard 之外手动调用 Rspec,我会使用命令行:

zeus rspec [spec/]

所以在我的 Guardfile 中,我删除了已弃用的选项,现在使用:

guard 'rspec', cmd: 'zeus rspec --color --format nested --fail-fast', all_after_pass: true do
  ...
end

关于ruby-on-rails - 在 Rails 中,我从 Guard 那里收到这个错误,说我必须更新到新的 :cmd syntax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19585567/

相关文章:

ruby-on-rails - 为什么 Rails runner shebang 不能在 Debian 上运行但在 OS X 上运行?

ruby-on-rails - Rails 4 混淆了我的一个引擎模型与另一个引擎库模块

ruby-on-rails - 在 rspec 的描述 block 中包含类型有什么作用?

ruby-on-rails - Rails 每天只保存众多记录中的 1 条。保留最后,删除其余

ruby-on-rails - 我可以在 RSpec 测试中实现依赖注入(inject)吗?

ruby-on-rails - 如何在permit + Rails中合并嵌套属性

ruby - `Dir.entries` 中的排序顺序

ruby - 在 ruby​​ 中将 JSON 转换为字符串或哈希

ruby-on-rails-3 - Capybara 无法从 Stripe 中找到表单字段?

ruby-on-rails - 通过 ActiveRecord Create 从文件加载二进制数据