在Rails中运行rake测试时排除外部gem警告

时间:2016-03-23 18:01:56

标签: ruby-on-rails testing

我正在尝试设置我的Rails 3.2应用程序的cloud9(https://c9.io)测试安装,以便新开发人员可以快速启动并运行以提交更改和运行测试。我的所有测试都通过了,但是它们与许多与不同宝石相关的警告混合在一起:

Loaded suite /usr/local/rvm/gems/ruby-2.1.2/gems/rake-11.1.1/lib/rake/rake_test_loader
Started
......

Finished in 0.22973343 seconds.
------
6 tests, 10 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
------
26.12 tests/s, 43.53 assertions/s
Loaded suite /usr/local/rvm/gems/ruby-2.1.2/gems/rake-11.1.1/lib/rake/rake_test_loader
Started
............................................

Finished in 4.18306875 seconds.
------
44 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
/usr/local/rvm/gems/ruby-2.1.2/gems/composite_primary_keys-5.0.14/lib/composite_primary_keys/relation.rb:26: warning: previous definition of destroy was here
/usr/local/rvm/gems/ruby-2.1.2/gems/composite_primary_keys-5.0.14/lib/composite_primary_keys/relation.rb:10: warning: method redefined; discarding old delete
/usr/local/rvm/gems/ruby-2.1.2/gems/composite_primary_keys-5.0.14/lib/composite_primary_keys/relation.rb:10: warning: previous definition of delete was here
/usr/local/rvm/gems/ruby-2.1.2/gems/composite_primary_keys-5.0.14/lib/composite_primary_keys/relation.rb:26: warning: method redefined; discarding old destroy

......它继续并为许多其他宝石生成警告。

在我自己的Ubuntu / Debian机器上,我没有看到这些警告,并且很难看到现在穿插在其他几十个警告线中的测试结果。

有没有办法抑制警告或配置我的测试,以便它们不会触发这种级别的冗长?

1 个答案:

答案 0 :(得分:3)

此处有不同环境的选项:Suppress Ruby warnings when running specs

我使用RUBYOPT=W0 rake test,这适用于带有RVM的(crouton,ARM)Ubuntu 14系统。