从命令行运行guard-jasmine不会运行任何规范

时间:2012-12-06 21:33:22

标签: guard

我已设置spec/javascripts/spec.js.coffee并在spec/javascripts中有一个包含3个测试的spec文件。当我在浏览器中运行jasmine时,运行3个测试。

当我跑卫并且开始并运行guard-jasmine时,它会找到并运行我的所有测试,如下所示:

$ bundle exec guard
Guard uses GNTP to send notifications.
Guard is now watching at '/workpath'
Guard::Jasmine starts Unicorn test server on port 52512 in development environment.
Waiting for Jasmine test runner at http://localhost:52512/jasmine
Run all Jasmine suites
Run Jasmine suite at http://localhost:52512/jasmine

Finished in 0.013 seconds
3 specs, 0 failures
Done.

但是,当我从终端运行guard-jasmine时,没有找到任何规格:

$ guard-jasmine
Guard::Jasmine starts Unicorn test server on port 53307 in test environment.
Waiting for Jasmine test runner at http://localhost:53307/jasmine
Run all Jasmine suites
Run Jasmine suite at http://localhost:53307/jasmine

Finished in 0.001 seconds
0 specs, 0 failures
Done.

Guard::Jasmine stops server.

我是否需要更改以帮助CLI转轮找到我的规格?

感谢。

编辑:添加相关的Guardfile信息:

guard :jasmine, timeout: 120, server_timeout: 120, server_env: "test" do
  watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { 'spec/javascripts' }
  watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$})
  watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{ m[1] }_spec.#{ m[2] }" }
end

1 个答案:

答案 0 :(得分:2)

问题是默认情况下guard在开发环境中运行,而rake任务和可执行文件guard-jasmine在测试时运行。

我通过将config.assets.debug = true添加到测试环境配置来修复它。