Silencing DB messages during tests
June 21st, 2009
When running tests in Rails, sometimes you need to perform various tasks in the database directly which can lead to a lot of unwanted messages in your test output.
If you’re using Postgresql, simply add the following line to your tests/tests_helper.rb file.
ActiveRecord::Base.connection.execute "set client_min_messages to ERROR"
Now you’ll only see messages of ERROR and above in your test output.
Update
Found a better way to do this. In your database.yml file, simply add the following line to your :test section.
min_messages: ERROR

Sorry, comments are closed for this article.