In a Rails 5.0.7 app that is about to being upgraded to 5.1, we'd like to capture all the (many) deprecation warnings to a file.
Rspec 3.9 provides a pretty clear example of how to send deprecations to a text file: https://relishapp.com/rspec/rspec-core/v/3-9/docs/configuration/custom-deprecation-stream
But it doesn't work:
# spec/spec_helper.rb
RSpec.configure do |config|
config.deprecation_stream = File.open('deprecations.txt', 'w')
end
When I run a spec that has warnings without the code above, stdout displays a bunch of instances of:
DEPRECATION WARNING: uniq is deprecated and will be removed from Rails 5.1 (use distinct instead) (called from...
If I add the config.deprecation_stream code above, and re-run the same spec:
- the deprecation warnings no longer are shown on stdout as the specs run
- the file deprecations.txt IS created, but
- the file is blank.
How do I configure Rspec's deprecation_stream so it works as expected, eg, sends all deprecation warnings to a file?