问题
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?
回答1:
Did you set: config.use_transactional_examples = true
to false and see if that breaks anything?
回答2:
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.
回答3:
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
来源:https://stackoverflow.com/questions/11065328/rspec-how-to-suppress-warnings-and-notices-when-running-tests