triadaagain.blogg.se

Best webdrive for rails rspec capybara
Best webdrive for rails rspec capybara












best webdrive for rails rspec capybara

I usually create a separate file called spec/support/database_cleaner.rb for this. Without disabling this, none of the following configuration will matter.

best webdrive for rails rspec capybara

This will disable rspec-rails’ implicit wrapping of tests in a database transaction. I just walked a pairing client through the same fix, so in the interests of remembering the steps, and hopefully preventing some other folks from tearing their hair out, here are the steps needed.įirst of all, and this is very important, go into spec/spec_helper.rb and change this line: e_transactional_fixtures = true

#Best webdrive for rails rspec capybara code

The problem is always the same: the tests are being wrapped in database transactions, so any code running outside the actual test process (like, say, a server process servicing a Selenium-driven browser request) does not see the database fixture I’ve so carefully assembled. Eventually, I’ll realize what I did wrong and curse my feeble brain for not remembering the last time I solved the same problem. I’ll set up some records in the test DB, only to have the Selenium-driven browser-based tests act like those records never existed. Periodically I start a new project using Rails, with RSpec, Capybara, and Selenium for acceptance testing, and a short way into it I find myself banging my head against bizarre inconsistencies with the test database. It’s a terrific gem that abstracts away the various ORM APIs for getting the DB into a “blank slate” state. If you write Rails code, or any Ruby code that interacts with a database, and you also write automated tests, chances are you have heard of or used the database_cleaner gem.














Best webdrive for rails rspec capybara