I'm upgrading a rather large app from Rails 3.0 to 3.2, and trying to get rid of all the deprecation warnings. My question isn't what to change to resolve particular warnings, but how to get Rails to treat them like exceptions so it will dump a stack trace in dev mode, so I'll have the full stack trace to see where the offending code is coming from. That way I can just use my test suite to find them all, and verify that they're all cleaned up. If there's a way to get rspec to fail a test if it logs a deprecation warning, that would work as well.
(In case anyone wonders, the reason I'm not upgrading all the way to rails 4.0 is that the app depends on some gems that AFAIK aren't fully ready for rails 4 yet, especially activerecord-oracle_enhanced-adapter.)
In Rails 4 you can configure using
config.active_support.deprecation = :raise
in your test.rb
or development.rb
file.
Other available methods can be found in ActiveSupport::Deprecation::Behaviour
The deprecation warning is handled by ActiveSupport::Deprecation, when some code want to show such warning, it calls
ActiveSupport::Deprecation.warn("some message")
There is no error thrown. To answer your question, I'm afraid you have to use dark tool of monkey patching :) Anyway the solution is for temp usage and will get removed later.
Update:
OP pointed out a quick and legit method in comment, so monkey patching is no longer a choice.
Here is his code:
# config/environments/test.rb
ActiveSupport::Deprecation.debug = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With