Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3949098
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:27:12+00:00 2026-05-20T01:27:12+00:00

I am upgrading a Rails 2 to Rails 3 application (code not written by

  • 0

I am upgrading a Rails 2 to Rails 3 application (code not written by me).
The (well tested code) uses shoulda and Test::Unit, and extensively uses the macros should_create and should_change.

I understand from this discussion that the shoulda maintainers want to get rid of both methods but that people using Test::Unit don’t find it necessary (not sure I am grasping the whole discussion though).

Anaway, is there a way to selectively turn of the deprecation warnings for specified macros? I already know from this posting that you can turn off the deprecation warnings in the Rake test output entirely by setting:

ActiveSupport::Deprecation.silenced = true

in your the test environment file and I also know that you can put specific pieces of code in a block to get them silenced:

ActiveSupport::Deprecation.silence do
# no warnings for any use of deprecated methods here
end

The latter is an option but would require me to go over all the tests and enclose the should_create macros in such a block. So I was wondering there was a way to eliminate warnings for specific macros entirely with one configuration setting?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:27:12+00:00Added an answer on May 20, 2026 at 1:27 am

    In fact I stil had lots of other deprecation warnings from code that was in plugins or gems I had installed. In order to avoid most of that, I overwrote the Deprecation::warn method in test_helper.rb. So instead of the previous code, use:

    module ActiveSupport
      module Deprecation
        class << self
          def warn(message = nil, callstack = caller)
            # modif pvh the following lines make sure no deprecation warnings are sent 
            # for code that is
            # not by my but in some gem or plugin...
            return if silenced  || callstack.grep(/myrailsappname/).blank?
            # return if silenced 
            deprecation_message(callstack, message).tap do |m|
              behavior.each { |b| b.call(m, callstack) }
            end
          end
        end
      end
    end  
    

    BTW you need to replace myrailsappname with your app’s name (the name of the folder it resides in). There is probably a more generic way to get that name, but I couldn’t find it right now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting bad performance after upgrading an application to Rails 3. Before upgrading,
I am upgrading an application a rails application to 2.3.2 and I am finding
How hard/complex would upgrading an application from Rails 2.2.2 to the latest build? I
I am upgrading an application to Rails 3.0.0 and am wondering if the standard
I'm uploading files to my public/files folder of a Rails application on a constant
After upgrading a rails 1.2 website to 2.1, the ExceptionNotifier plugin no longer works,
We are currently in the process of upgrading our rails version and I have
I have developed a Ruby on Rails application and successfully deployed on Weblogic using
i was upgrading my Netbeans 6.5 to Netbeans 6.7 and i open my rails
I am upgrading my Rails plugin to be an engine that works with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.