Kleber S.
Kleber S.

Reputation: 8240

Rspec: How to suppress warnings and notices when running tests?

I was using Mysql database before and decided to switch to Postgresql and now, when I run my tests using rspec, I getting a lot of warnings and notices.

WARNING:  there is already a transaction in progress
NOTICE:  there is no transaction in progress
      should has link "Suspender"
WARNING:  there is already a transaction in progress
NOTICE:  there is no transaction in progress
      should has css "title" with text "Suspensão de anúncio"
WARNING:  there is already a transaction in progress
NOTICE:  there is no transaction in progress
      should has css "h1" with text "Awesome job!"

How can I suppress that? Is there a way, right?

Upvotes: 11

Views: 4941

Answers (3)

Pablo Cantero
Pablo Cantero

Reputation: 6357

Disabling transactions

If you prefer to manage the data yourself, or using another tool like database_cleaner to do it for you, simply tell RSpec to tell Rails not to manage transactions:

RSpec.configure do |config| config.use_transactional_fixtures = false end

https://www.relishapp.com/rspec/rspec-rails/docs/transactions

Upvotes: 0

skalee
skalee

Reputation: 12665

I had config.use_transactional_fixtures = true set. This was default (spec_helper generated with rails g rspec:install). I am using FactoryGirl instead of fixtures, getting rid of this setting removed warnings.

Upvotes: 4

Noah Clark
Noah Clark

Reputation: 8131

Did you set: config.use_transactional_examples = true to false and see if that breaks anything?

Upvotes: 18

Related Questions