ruby-on-railsunit-testingwarningsdeprecated

Trace source of deprecation warnings in rails tests


When running my functional tests, I'm getting the following warning in one of the test cases but I can't pinpoint where it's coming from:

gems/actionpack-2.3.8/lib/action_controller/record_identifier.rb:76: warning: Object#id will be deprecated; use Object#object_id

Unfortunately that's the only line of the backtrace that's shown, even if I run it with rake test --trace, and there is no more information in log/test.log.

How can I get the full backtrace for this warning or otherwise figure out which line in my code is causing it?


Solution


  • Update: as @Dorian mentions the method is deprecated on recent Rails versions, so you should use:

    Rails.application.deprecators.debug = true
    

    To solve this you could enable the full debugging information. (see the help)

    ActiveSupport::Deprecation.debug = true
    

    As @Eric Anderson says it should be placed after Rails loads (i.e. after require 'rails/all' in application.rb) but before bundler runs to catch deprecation warning in gems (i.e. before Bundler.require(:default, Rails.env) if defined?(Bundler) in application.rb).

    You can add a condition, like if ENV["DEBUG"] or if environment == :test to leave this in your config.