进行防护会发出很多警告

进行防护会发出很多警告

本文介绍了在 Rails 4 上使用 RSpec 进行防护会发出很多警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在运行简单测试时关闭所有这些警告:

I'm wondering how I can turn off all these warnings when running a simple test:

[1] guard(main)>
16:59:46 - INFO - Run all
16:59:46 - INFO - Running all specs
/Users/esjd/.rvm/gems/ruby-2.1.2/gems/rspec-rails-3.0.1/lib/rspec/rails/adapters.rb:124: warning: instance variable @example not initialized
/Users/esjd/.rvm/gems/ruby-2.1.2/gems/rspec-rails-3.0.1/lib/rspec/rails/adapters.rb:124: warning: instance variable @example not initialized
.*

Pending:
  HomeHelper add some examples to (or delete) /Users/esjd/ruby/rails/ts3/spec/helpers/home_helper_spec.rb
    # Not yet implemented
    # ./spec/helpers/home_helper_spec.rb:14

Finished in 0.03601 seconds (files took 7 minutes 48 seconds to load)
2 examples, 0 failures, 1 pending
/Users/esjd/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:76: warning: global variable `$CELLULOID_DEBUG' not initialized
/Users/esjd/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:76: warning: global variable `$CELLULOID_DEBUG' not initialized

/Users/esjd/.rvm/gems/ruby-2.1.2/gems/guard-2.6.1/lib/guard/interactor.rb:64: warning: instance variable @enabled not initialized
/Users/esjd/.rvm/gems/ruby-2.1.2/gems/guard-2.6.1/lib/guard/interactor.rb:64: warning: instance variable @enabled not initialized
/Users/esjd/.rvm/gems/ruby-2.1.2/gems/guard-2.6.1/lib/guard/interactor.rb:64: warning: instance variable @enabled not initialized
/Users/esjd/.rvm/gems/ruby-2.1.2/gems/guard-2.6.1/lib/guard/interactor.rb:64: warning: instance variable @enabled not initialized
/Users/esjd/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:76: warning: global variable `$CELLULOID_DEBUG' not initialized
/Users/esjd/.rvm/gems/ruby-2.1.2/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:76: warning: global variable `$CELLULOID_DEBUG' not initialized

我正在运行 Rails 4.1.1、Ruby 2.1.2p95 和...

I'm running Rails 4.1.1, Ruby 2.1.2p95, and...

guard (2.6.1)
rspec (3.0.0)
guard-rspec (4.2.9)

我试过用以下方式跑卫:

I've tried running guard with:

guard :rspec, cmd:"ruby -W0 bin/rspec" do

代替:

guard :rspec, cmd:"spring rspec" do

但它没有做任何事情.

这些警告非常烦人,我很确定不是我造成的.帮助!

These warnings are super annoying, and I'm pretty sure I'm not causing them. Help!

推荐答案

rspec 生成器 rails generate rspec:install 现在将 --warnings 选项放在 >.rspec 文件默认.删除该行,警告就会消失.

The rspec generator rails generate rspec:install now puts the --warnings option in the .rspec file by default. Remove that line, and the warnings will go away.

这篇关于在 Rails 4 上使用 RSpec 进行防护会发出很多警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 04:40