【问题标题】:Running guard-jasmine from command line doesn't run any specs从命令行运行guard-jasmine 不运行任何规范
【发布时间】:2012-12-06 21:33:22
【问题描述】:

我已经设置了spec/javascripts/spec.js.coffee 并在spec/javascripts 中有一个包含 3 个测试的规范文件。当我在浏览器中运行 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

【问题讨论】:

  • 你能出示你的 Guardfile 吗?
  • 当然可以,但是现在已经修复了! (见我自己的答案)。

标签: guard


【解决方案1】:

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

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

【讨论】:

  • 您能否更具体地说明您添加的位置?那是让它在开发环境中运行,对 - 所以使用 server_env: "development" 应该做同样的事情?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-18
  • 1970-01-01
相关资源
最近更新 更多