I tend to write a fresh description block for every change in the parameters for that specific action, because I hate conditionals in the example describtion, e.g.:<div><br class="webkit-block-placeholder"></div><div>describe SomeController, "handling GET /path/with/param/3" do
</div><div> it "should do this"</div><div> it "should not do this if"</div><div> it "should still do that in both cases" </div><div>end</div><div><br class="webkit-block-placeholder"></div><div>
Seperate description blocks keep things clean, however, there is a big amount of duplication between the two blocks, I do love clarity over cryptic DRY-ed up code (certainly in the examples), but those long blocks make the controller spec file tedious.
</div><div><br> </div><div>Take for instance the code from the following pastie ( <a href="http://pastie.caboo.se/99683">http://pastie.caboo.se/99683</a> ). The only difference between the two examples is that, in the first example a cart is retreived using the cart_id from the session, and in the second a new cart is created. Both then find an item and add this item to the cart.
</div><div><br class="webkit-block-placeholder"></div><div>How would you guys rewrite the examples in the provided pastie? (and don't hesitate to tell me if you have any comments about the way I wrote these examples)</div>