Non-rails unit tests don't hit the db but Rails unit tests do

Generally when unit testing in non-Rails apps, we never write unit tests which hit a database. If we're forced to, we keep them to a minimum, treat them as a symptom of bad design and do our best to refactor them away over time. This is because you should be able to create and use models independently of your database - otherwise your code is implicitly tied to your db schema, something you want to avoid.

Thing is, this isn't true for Rails because of the neat one-to-one mapping of a table to a domain object.

Just an observation.
Post a Comment