zeus + guard + rspec"无法找到测试文件' rspec'

时间:2014-07-25 21:13:34

标签: ruby-on-rails rspec rspec-rails guard zeus

我的Rails应用已经安装了guard-zeusrspec-rails宝石。

我的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"]}
        }
      }
    }
  }
}

1 个答案:

答案 0 :(得分: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.jsoncustom_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"]}
        }
      }
    }
  }
}