Testing applications that use databases can be difficult. You have to make sure each scenario starts with a clean slate, but cleaning the slate can have its own pitfalls. In this chapter, we learned about the benefits and drawbacks of two strategies—transaction and truncation. To sum it up:
ActiveRecord is a useful library for quickly connecting to SQL databases.
Resetting state between scenarios is vital; otherwise, you get weird failures.
Transaction-based cleaning is preferred because it is fast, but it works only when there is one single-threaded process.
Truncation-based cleaning is a slower, brute-force technique that works in multiprocess and multithreaded environments.
Find an existing database, ...