Ruby on Rails中,为何不推荐用Guard Rspec的cli选项,而应改用cmd选项?

更新于
2026-10-03 21:44:50
1阅读来源:SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计507个文字,预计阅读时间需要3分钟。

在Rails应用中使用Guardfile监控rspec:

rubyGuardfileguard :rspec, cmd: '+drb'

或使用all_after_pass: false:

rubyGuardfileguard :rspec, all_after_pass: false, cmd: '+drb'

在我的rails应用程序中使用Guardfile

警卫’rspec’,all_after_pass:false,cli:’ – drb’做

不工作Guardfile

guard’rspec’,all_after_pass:false,cmd:’ – drb’可以

我已经多次用捆绑执行警卫打开警卫,但我发现即使我收到此消息
Guard :: RSpec DEPRECATION警告:不推荐使用:cli选项.请自定义新的:cmd选项以满足您的需求.
并且我做了适当的改变:cli是唯一一个使用rspec的人.

终端输出:cli

01:49:14 - WARN - Guard::RSpec DEPRECATION WARNING: The :cli option is deprecated. Please customize the new :cmd option to fit your need. 01:49:15 - INFO - Guard is using Growl to send notifications. 01:49:15 - INFO - Guard is using Emacs to send notifications. 01:49:15 - INFO - Guard is using TerminalTitle to send notifications. 01:49:15 - INFO - Starting Spork for RSpec Using RSpec, Rails Preloading Rails environment Loading Spork.prefork block... Spork is ready and listening on 8989! 01:49:17 - INFO - Spork server for RSpec successfully started 01:49:17 - INFO - Guard::RSpec is running 01:49:17 - INFO - Guard is now watching at '/Users/me/rails_projects/mvp' [1] guard(main)> 01:49:18 - INFO - Run all 01:49:18 - INFO - Running all specs Running tests with args ["--color", "--failure-exit-code", "2", "--format", "progress", "--format", "Guard::RSpec::Formatter", "--require", "/Users/me/.rvm/gems/ruby-2.1.0@rails40/gems/guard-rspec-4.2.4/lib/guard/rspec/formatter.rb", "spec"]... ...................................................................... Finished in 0.76464 seconds 70 examples, 0 failures Randomized with seed 47137 Done.

终端输出:cmd

bundle exec guard 01:58:55 - INFO - Guard is using Growl to send notifications. 01:58:55 - INFO - Guard is using Emacs to send notifications. 01:58:55 - INFO - Guard is using TerminalTitle to send notifications. 01:58:55 - INFO - Starting Spork for RSpec Using RSpec, Rails Preloading Rails environment Loading Spork.prefork block... Spork is ready and listening on 8989! 01:58:57 - INFO - Spork server for RSpec successfully started 01:58:57 - INFO - Guard::RSpec is running 01:58:57 - INFO - Guard is now watching at '/Users/me/rails_projects/mvp' [1] guard(main)> 01:58:59 - INFO - Run all 01:58:59 - INFO - Running all specs [2] guard(main)>

离开:cli还是有解决方案?

:cmd需要执行自定义的内容以满足我的需求.正如@sevenseacat所说,“你没有根据自己的需要定制它 – 你只是将cli复制到cmd并期望它能够工作”

我正在运行Spork,Guard和Rspec进行测试.而不是只写–drb我应该在它前面添加rspec

固定Guardfile有

guard’rspec’,all_after_pass:false,cmd:’rspec –drb’do

本文共计507个文字,预计阅读时间需要3分钟。

在Rails应用中使用Guardfile监控rspec:

rubyGuardfileguard :rspec, cmd: '+drb'

或使用all_after_pass: false:

rubyGuardfileguard :rspec, all_after_pass: false, cmd: '+drb'

在我的rails应用程序中使用Guardfile

警卫’rspec’,all_after_pass:false,cli:’ – drb’做

不工作Guardfile

guard’rspec’,all_after_pass:false,cmd:’ – drb’可以

我已经多次用捆绑执行警卫打开警卫,但我发现即使我收到此消息
Guard :: RSpec DEPRECATION警告:不推荐使用:cli选项.请自定义新的:cmd选项以满足您的需求.
并且我做了适当的改变:cli是唯一一个使用rspec的人.

终端输出:cli

01:49:14 - WARN - Guard::RSpec DEPRECATION WARNING: The :cli option is deprecated. Please customize the new :cmd option to fit your need. 01:49:15 - INFO - Guard is using Growl to send notifications. 01:49:15 - INFO - Guard is using Emacs to send notifications. 01:49:15 - INFO - Guard is using TerminalTitle to send notifications. 01:49:15 - INFO - Starting Spork for RSpec Using RSpec, Rails Preloading Rails environment Loading Spork.prefork block... Spork is ready and listening on 8989! 01:49:17 - INFO - Spork server for RSpec successfully started 01:49:17 - INFO - Guard::RSpec is running 01:49:17 - INFO - Guard is now watching at '/Users/me/rails_projects/mvp' [1] guard(main)> 01:49:18 - INFO - Run all 01:49:18 - INFO - Running all specs Running tests with args ["--color", "--failure-exit-code", "2", "--format", "progress", "--format", "Guard::RSpec::Formatter", "--require", "/Users/me/.rvm/gems/ruby-2.1.0@rails40/gems/guard-rspec-4.2.4/lib/guard/rspec/formatter.rb", "spec"]... ...................................................................... Finished in 0.76464 seconds 70 examples, 0 failures Randomized with seed 47137 Done.

终端输出:cmd

bundle exec guard 01:58:55 - INFO - Guard is using Growl to send notifications. 01:58:55 - INFO - Guard is using Emacs to send notifications. 01:58:55 - INFO - Guard is using TerminalTitle to send notifications. 01:58:55 - INFO - Starting Spork for RSpec Using RSpec, Rails Preloading Rails environment Loading Spork.prefork block... Spork is ready and listening on 8989! 01:58:57 - INFO - Spork server for RSpec successfully started 01:58:57 - INFO - Guard::RSpec is running 01:58:57 - INFO - Guard is now watching at '/Users/me/rails_projects/mvp' [1] guard(main)> 01:58:59 - INFO - Run all 01:58:59 - INFO - Running all specs [2] guard(main)>

离开:cli还是有解决方案?

:cmd需要执行自定义的内容以满足我的需求.正如@sevenseacat所说,“你没有根据自己的需要定制它 – 你只是将cli复制到cmd并期望它能够工作”

我正在运行Spork,Guard和Rspec进行测试.而不是只写–drb我应该在它前面添加rspec

固定Guardfile有

guard’rspec’,all_after_pass:false,cmd:’rspec –drb’do