Suppress Ruby warnings when running specs

前端 未结 10 2250
野趣味
野趣味 2020-11-27 14:46

I\'m looking for a way to suppress Ruby warnings when I run my specs.

spec spec/models/account_spec.rb

I receive warnings such as:

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 15:34

    Putting Warning[:deprecated] = false after require "rails/all" in config/application.rb works very well to suppress those warnings everywhere. You can do

    Warning[:deprecated] = false if Rails.env.test?
    

    for your particular case, or better yet - put it in config/environments/test.rb, but I'm not sure how well it is going to work since I belive some stuff is loaded before that.

提交回复
热议问题