Redline Software Inc. - Winnipeg's Leader in Ruby on Rails Development

Silencing DB Messages During Tests

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.

1
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.

1
  min_messages: ERROR

Comments