Loading Fixture Data
Understand how to efficiently manage test data in Rails by loading fixture data. Explore the benefits and limitations of fixtures, including their speed and suitability for static data, and how transactional behavior affects tests.
Fixtures loading
By default, all our defined fixtures are loaded into the database once at the beginning of our test run. Rails start a database transaction at the beginning of each test. At the end of each test, the transaction is rolled back, restoring the initial state quickly.
The spec_helper.rb file fixtures
The fixtures’ transactional behavior is a problem if we’re trying to test transactional behavior in our application. In that case, the fixture transaction will overwhelm the transaction we’re trying to test. If we need less aggressive transaction behavior, we can go into ...