在 Rails 应用程序中运行 rake 任务后出现加载消息和测试结果
运行一些 rake 任务后会出现以下输出:
Loaded suite /usr/bin/rake
Started
Finished in 0.00042 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
对于与测试无关的任务,此输出没有用或没有必要。我想阻止它出现。我认为它源于需要某个文件或包含某个模块。
更新:看来我错了,在 Rails 内置的一些任务中确实出现了这种情况。这是使用 --trace
加载的装置的输出。
$ rake db:fixtures:load --trace
** Invoke db:fixtures:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:fixtures:load
Loaded suite /usr/bin/rake
Started
Finished in 0.000255 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
The following output appears after running some rake tasks:
Loaded suite /usr/bin/rake
Started
Finished in 0.00042 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
This output is not useful or necessary for tasks not related to testing. I'd like to prevent it from appearing. I would assume it stems from requiring a certain file or including a certain module.
Updated: It appears that I was wrong and this does come up during some of the tasks built into Rails. Here is the output of fixtures being loaded with --trace
.
$ rake db:fixtures:load --trace
** Invoke db:fixtures:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:fixtures:load
Loaded suite /usr/bin/rake
Started
Finished in 0.000255 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
解决方案可以在这里找到:
http://github.com/thoughtbot/shoulda/issues /#issue/59
基本上不需要 shoulda gem,除非它是测试环境(其中已经需要 test/unit)。
Solution can be found here:
http://github.com/thoughtbot/shoulda/issues/#issue/59
Basically don't require the shoulda gem unless it's the test environment (where test/unit would already be required).
首先检查
Rake::TestTask
的测试模式。应该类似于'test/**/*_test.rb'
。无论出于何种原因,Test::Unit 都会尝试在
/usr/bin/rake
可执行文件中查找测试,这可能意味着您在某处有一个伪造的模式。每当遇到此类问题时,您都需要使用
--trace
运行rake
来查看正在运行哪些任务和任务依赖项以及运行顺序。如果更新模式不起作用,请将打开--trace
的完整运行的输出复制到您的问题中。First check the test pattern for your
Rake::TestTask
. Should be something like'test/**/*_test.rb'
.For whatever reason, Test::Unit is trying to find tests in the
/usr/bin/rake
executable, which probably means you've got a bogus pattern somewhere.Anytime you have problems like this, you want to run
rake
with--trace
to see what tasks and task dependencies are being run, and in which order. If updating the pattern doesn't work, please copy the output of a full run with--trace
switched on into your question.我找到了这个文件: ~/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/minitest/unit.rb
在第 498 行(就在“def self.autorun”之后)我把:
我不认为这个方法会让我觉得想念他......
I got to this file: ~/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/minitest/unit.rb
And at line 498 (just after "def self.autorun") I put:
I don't think this method will make me fell as missing him...