Rails Test Prescriptions, Hold the Rails

Learn about the isolated tests with the help of an example.

RSpec bypassing Rails for speed

The basic idea of isolation is isolating our objects from each other and isolating our code from Rails functionality that would require Rails to be loaded. Isolation means that different objects interact with each other over as small a set of methods as possible. Ideally, it means objects know nothing about the internal structure of other objects in the system.

This doesn’t have to be very complicated. We’ve been writing tests with reasonably good habits so far. To isolate our Project tests from anything other than ActiveRecord, we must change the header. We’ll remove the require rails_helper call and replace it:

Get hands-on with 1200+ tech skills courses.