Search code examples
ruby-on-railsunit-testingrake

rake test:units is printing style/deprecation check errors


I am using the builtin rails rake task test:units to run a series of unit tests in my rails app. When I do this, however, I'm getting a ton of warnings related to style issues both in my own code and in code embedded in gems that I am using.

For example:

/home/steve/.rvm/gems/ruby-2.1.2/gems/activesupport-3.2.19/lib/active_support/file_update_checker.rb:98: warning: File.exists? is a deprecated name, use File.exist? instead
/home/steve/workspace/project/app/models/model.rb:73: warning: mismatched indentations at 'end' with 'def' at 67

I'd like to suppress these warnings, but after a lot of searching around, I can't find anyone talking about this, and the keywords involved are turning up a lot of irrelevant results.

Can anyone tell me how to disable this feature?

It's possible that my entire unit-test running strategy is flawed, and I'm open to that possibility as well.

Possibly relevant:

  • Ruby version: 2.1.2
  • Rake version: 11.1.2
  • Rails version: 3.2.19

I realize these are not fully up to date, but for various reasons, upgrading at this point in time is not an option.


Solution

  • RUBYOPT=W0 rake test:units
    

    Fixes my issue. Strangely, putting the RUBYOPT directive after the rake test:units call doesn't work, in spite of the fact that you can usually put environment directives anywhere on the command line. This lead me to thinking that RUBYOPT wasn't the answer, though in the end, it was.