Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 580
Kleber S. Avatar asked Jun 16 '12 16:06

Kleber S.


People also ask

How do you get rid of warnings in Ruby?

If the deprecations are coming mostly from Rails, it may be time to disable the messages and save yourself from messy terminal output. The TL;DR is that you need to use RUBYOPT='-W:no-deprecated -W:no-experimental' to disable the deprecations. This will also disable experimental feature warnings as well.

Does RSpec clean database?

I use the database_cleaner gem to scrub my test database before each test runs, ensuring a clean slate and stable baseline every time. By default, RSpec will actually do this for you, running every test with a database transaction and then rolling back that transaction after it finishes.

What does RSpec describe do?

RSpec is a testing tool for Ruby, created for behavior-driven development (BDD). It is the most frequently used testing library for Ruby in production applications. Even though it has a very rich and powerful DSL (domain-specific language), at its core it is a simple tool which you can start using rather quickly.


1 Answers

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

like image 111
Noah Clark Avatar answered Oct 22 '22 07:10

Noah Clark