警惕RSpec Rails 4给出了很多警告

我想知道如何在运行简单testing时closures所有这些警告:

[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和…

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

我已经试过跑卫:

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

代替:

 guard :rspec, cmd:"spring rspec" do 

但它没有做任何事情。

这些警告是非常烦人的,我很确定我没有造成他们。 帮帮我!

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

您可以在testing环境中将警告设置为false,以强制Rspec禁用警告消息。

#spec / spec_helper.rb

config.warnings = false