RSpec加载所有gem文件

时间:2014-07-08 18:11:18

标签: ruby-on-rails rspec rspec-rails

每当我尝试运行我的rspec测试(使用'rspec spec'或'bundle exec rspec spec')时,我会在屏幕上获得大量输出。它似乎遍历我的Gemfile中的每个gem并显示来自它的消息。下面是该输出的示例(还有更多)。

有人可以告诉我这些消息是什么以及如何在每次我想要运行测试时阻止它们显示吗?

C:/Ruby193/lib/ruby/gems/1.9.1/gems/mail-2.5.4/lib/mail/network/delivery_methods
/sendmail.rb:53: warning: shadowing outer local variable - to
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-rails-3.0.1/lib/rspec/rails/matchers/h
ave_http_status.rb:87: warning: assigned but unused variable - _ignored
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-rails-3.0.1/lib/rspec/rails/matchers/h
ave_http_status.rb:142: warning: assigned but unused variable - _ignored
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-rails-3.0.1/lib/rspec/rails/matchers/h
ave_http_status.rb:257: warning: assigned but unused variable - _ignored
C:/Ruby193/lib/ruby/gems/1.9.1/gems/holidays-1.0.6/lib/holidays.rb:361: warning:
 assigned but unused variable - e
C:/Ruby193/lib/ruby/gems/1.9.1/gems/business_time-0.7.3/lib/business_time/config
.rb:76: warning: method redefined; discarding old end_of_workday
C:/Ruby193/lib/ruby/gems/1.9.1/gems/business_time-0.7.3/lib/business_time/config
.rb:31: warning: previous definition of end_of_workday was here
C:/Ruby193/lib/ruby/gems/1.9.1/gems/business_time-0.7.3/lib/business_time/config
.rb:85: warning: method redefined; discarding old beginning_of_workday
C:/Ruby193/lib/ruby/gems/1.9.1/gems/business_time-0.7.3/lib/business_time/config
.rb:31: warning: previous definition of beginning_of_workday was here
C:/Ruby193/lib/ruby/gems/1.9.1/gems/business_time-0.7.3/lib/business_time/config
.rb:94: warning: method redefined; discarding old work_week=
C:/Ruby193/lib/ruby/gems/1.9.1/gems/business_time-0.7.3/lib/business_time/config
.rb:34: warning: previous definition of work_week= was here
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/depen
dencies.rb:247: warning: loading in progress, circular require considered harmfu
l - C:/Ruby193/lib/ruby/gems/1.9.1/gems/haml-4.0.5/lib/haml/template.rb
        from C:/Ruby193/bin/rspec:23:in `<main>'
        from C:/Ruby193/bin/rspec:23:in `load'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.2/exe/rspec:4:in
 `<top (required)>'

1 个答案:

答案 0 :(得分:4)

https://github.com/rspec/rspec-core/issues/1571。基本上,最近的rspec版本默认将--warnings添加到.rspec文件。这导致了很多关于输出宝石中的代码的警告。现在的“修复”是删除--warnings行。