【问题标题】:Why is guard stopping?警卫为什么停下来?
【发布时间】:2012-10-21 15:03:21
【问题描述】:

我有一个 Rails 应用程序,我刚刚扔掉了保护和 minitest,我的 gaurd 文件是

guard 'minitest', :cli => '--drb --format doc --color' do
  # with Minitest::Unit
  watch(%r|^test/(.*)\/?test_(.*)\.rb|)
  watch(%r|^lib/(.*)([^/]+)\.rb|)     { |m| "test/#{m[1]}test_#{m[2]}.rb" }
  watch(%r|^test/test_helper\.rb|)    { "test" }

  # Rails
  watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/functional/#{m[1]}_test.rb" }
  watch(%r|^app/helpers/(.*)\.rb|)     { |m| "test/helpers/#{m[1]}_test.rb" }
  watch(%r|^app/models/(.*)\.rb|)      { |m| "test/unit/#{m[1]}_test.rb" }  
end

但是当我运行守卫时,我得到一个命令提示符

bundle exec guard
22:14:12 - INFO - Guard uses TerminalTitle to send notifications.
22:14:12 - INFO - Guard is now watching at '/Users/trace/Sites/application'
1.9.3 (main):0 > 2 + 2
=> 4

为什么我会收到这个提示。任何想法......这是我正在使用的一些宝石

更新...

当我运行 all minitest 时,测试就会运行...但是为什么我必须运行它...任何想法

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 guard minitest


    【解决方案1】:

    您看到的是使用Pry 的Guard 交互器。通常提示看起来有点不同,所以我假设你有一个带有一些配置的~/.pryrc 文件。在昨天发布的 Guard 1.5.3 中,Guard 忽略了 ~/.pryrc 并且只评估 ~/.guardrc 的 Pry 配置,因此正常的 Pry 配置与 Guard Pry 交互器是分开的。

    当你看到这个提示时,说明Guard正在等待,无事可做。您现在可以开始工作,Guard 会根据您的文件修改和观察程序配置自动开始使用 minitest 测试您的应用,或者您可以手动触发操作。

    您可以使用help guard 获取可用操作的列表。根据Guardfile 中的 Guard 插件和组,会生成一些命令。这是我的一个项目的示例:

    $ bundle exec guard 
    09:58:14 - INFO - Guard uses GNTP to send notifications.
    09:58:14 - INFO - Guard is now watching at '/Users/michi/Repositories/extranett'
    09:58:15 - INFO - Guard::Jasmine starts Unicorn test server on port 8888 in development environment.
    09:58:17 - INFO - Waiting for Jasmine test runner at http://dnndev.me:8888/jasmine
    09:58:23 - INFO - Run all Jasmine suites
    09:58:23 - INFO - Run Jasmine suite at http://dnndev.me:8888/jasmine
    09:58:41 - INFO - Finished in 8.853 seconds
    09:58:41 - INFO - 896 specs, 0 failures
    09:58:41 - INFO - Done.
    09:58:41 - INFO - Guard::RSpec is running
    09:58:41 - INFO - LiveReload 1.6 is waiting for a browser to connect.
    [1] guard(main)> help guard
    Guard
      all                Run all plugins.
      backend            Run all backend
      change             Trigger a file change.
      coffeescript       Run all coffeescript
      frontend           Run all frontend
      jasmine            Run all jasmine
      livereload         Run all livereload
      notification       Toggles the notifications.
      pause              Toggles the file listener.
      reload             Reload all plugins.
      rspec              Run all rspec
      show               Show all Guard plugins.
    [2] guard(main)> exit
    09:59:39 - INFO - Guard::Jasmine stops server.
    09:59:39 - INFO - Bye bye...
    

    【讨论】:

    • 如果您希望guard 使用的特定Pry 实例有自己的提示(独立于.pryrc 中指定的提示)然后在启动pry github.com/pry/pry/wiki/… 时传递:prompt 选项(忽略@987654331 @ 选项,直到下一个版本才可用)
    • @Netxpirat - 有没有办法阻止这种情况,当我像以前一样进行更改时,只需保持警惕
    • @Trace 可以,可以通过-i 选项来保护和禁用交互器:bundle exec guard -i
    • @banister 我使用Pry.config.prompt根据监听器状态动态设置它:github.com/guard/guard/blob/master/lib/guard/…
    猜你喜欢
    • 2016-04-13
    • 1970-01-01
    • 2017-11-27
    • 2014-05-19
    • 1970-01-01
    • 1970-01-01
    • 2013-08-12
    • 2014-01-13
    相关资源
    最近更新 更多