3 ms·
While DHH has remarkably good taste—and he has, in fact, helped make code more beautiful throughout our industry—his taste is not necessarily perfect. Exhibit
by ekidd 16y ago
While DHH has remarkably good taste—and he has, in fact, helped make code more beautiful throughout our industry—his taste is not necessarily perfect.
Exhibit A: Rails fixtures.
When using fixtures, you end share a single set of objects between all your tests. And sooner or later, your tests will become tightly coupled via the fixtures: To add a new test, you must add some new records. But when you add those records, some other tests break.
If you instead use an object factory like machinist or factory_girl, you can create objects at the start of each test, and fill in random values for any fields you don't care about. This makes each test independent of the others, and it keeps the code and data in one place.
So if we admit that DHH's taste in testing is potentially imperfect, what does that mean for the Test::Unit versus RSpec debate? Not much.
Some people like Test::Unit. It's a fine library. I prefer RSpec, because it's a better match to how I think. And many of the testing libraries I want to use are actually work better with RSpec.
Oh, and if Cucumber is a bad match for your project, try Steak. It's easier to set up, and you write ordinary Ruby code.