Pat Maddox wrote: > On Thu, Feb 5, 2009 at 8:17 AM, Ben Mabey <b...@benmabey.com> wrote: >> Any thoughts? Are Ruby's Object Mothers really Test Data Builders? > > Here's what I think is important: > > * Make fixture setup explicit by inlining it on a per example/group > basis > * Keep fixture setup short by hiding the object graph construction > * Allow concise parameterization of the fixture objects > * Focus 100% on structure (0% on behavior) in methods/objects to build > your data. This minimizes accidental coupling between examples. >
Jay's blog post finally got me inspired in using RSpec. I decided to give a last chance at it, and I wrote my own "Factory framework" after failing at using Machinist effectively and seeing the pain to maintain fixtures. Now I fully enjoy specing my models, and all my tests are straightforward as each test has its own "setup", it's definitely not dry but I don't care, it is so much easier to maintain so much easier to spot any bugs in the specs themselves and it happens a lot. Each model has a dedicated prepopulated before(:each) describe section were setup is "shared" by many examples, it's usually used to test my custom find methods were many models are part of the equation. Specing Models heavily like I now do, also forces me to refactor my app to transfer as much mogic as I can from the controllers to the models. You can't imagine how much code actually fits in the model, it's amazing, some of my controllers wen't down by 50% and it enabled me to spec effectively the models which I couldn't do until now. The next big step will be specing controllers, as it is more painful than models, but now that my controllers are ripped I guess it will be easier. Also I am already seeing some specs that are not efficient, refactoring specs is a compulsory task, so experiment different patterns as Jay proposes in his blog. -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users