Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress Ruby warnings when running specs

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:

DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, ... warning: already initialized constant SOME_CONSTANT_NAME 

Removing the ActiveSupport warning is quite easy with ActiveSupport::Deprecation.silenced = true.

How do I prevent the already initialized constant warnings as part of my spec command? Or through creating another spec file that can suppress such warnings. Keep in mind that these warnings are from gem files, therefore I cannot go into those files and surround them with Kernel.silence_warnings.

Note: I understand that suppressing warnings are bad. However, when I run a single spec from within vim it would be nice if the warnings didn't clutter my screen.

like image 595
Jey Balachandran Avatar asked Apr 08 '11 06:04

Jey Balachandran


1 Answers

The syntax for RUBYOPT is

RUBYOPT="-W0" rspec 

Tested in ruby 2.1.x and 2.14.x

like image 139
Dingle Avatar answered Sep 24 '22 05:09

Dingle