4

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

当我运行guard并启动并运行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
4

1 回答 1

2

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

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

于 2012-12-07T18:19:32.520 回答