1

我的 Rails 应用程序已经安装了guard-zeusrspec-railsgems。

Guardfile的默认手表代码由guard init zeus

我跑guard。当我保存文件时,该文件中的规范运行正确。

但是,当我在控制台中按回车键时guard,我希望它能够运行整个测试套件。它试图这样做,但抛出Couldn't find test file 'rspec'

如果我zeus自己开始(没有警卫),我可以zeus start然后zeus rake成功。

我无法弄清楚“rspec”文件guard在寻找什么。这是我的 Guardfile:

guard 'zeus' do
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^lib/(.+)\.rb$})                           { |m| "spec/lib/#{m[1]}_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/requests/#{m[1]}_spec.rb"] }
end

我试过cmd: bundle exec rake在保护块中指定 。

附加信息:

custom_plan.rb看起来像这样:

require 'zeus/rails'

class CustomPlan < Zeus::Rails

  # def my_custom_command
  #  # see https://github.com/burke/zeus/blob/master/docs/ruby/modifying.md
  # end

end

Zeus.plan = CustomPlan.new

zeus.json看起来像这样:

{
  "command": "ruby -rubygems -r./custom_plan -eZeus.go",

  "plan": {
    "boot": {
      "default_bundle": {
        "development_environment": {
          "prerake": {"rake": []},
          "console": ["c"],
          "server": ["s"],
          "generate": ["g"],
          "destroy": ["d"],
          "dbconsole": []
        },
        "test_environment": {
          "test_helper": {"test": ["rspec"]}
        }
      }
    }
  }
}
4

1 回答 1

1

你介意试试这个,好吗?

guard 'zeus', :rspec => true, :bundler => true  do
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^lib/(.+)\.rb$})                           { |m| "spec/lib/#{m[1]}_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/requests/#{m[1]}_spec.rb"] }
end

也请粘贴 和 的zeus.json内容custom_plan.rb

如果您缺少其中任何一个文件,请运行zeus init. 这将创建zeus.jsoncustom_plan.rb

然后,编辑 zeus.json 以仅包含您将使用 Zeus 的任务。我的看起来像这样:

{
  "command": "ruby -rubygems -r./custom_plan -eZeus.go",

  "plan": {
    "boot": {
      "default_bundle": {
        "development_environment": {
          "prerake": {"rake": []},
          "runner": ["r"],
          "console": ["c"],
          "server": ["s"],
          "generate": ["g"],
          "destroy": ["d"],
          "dbconsole": []
        },
        "test_environment": {
          "test_helper": {"test": ["rspec"]}
        }
      }
    }
  }
}
于 2014-08-15T07:44:46.207 回答