[rspec-users] Specifying mixins

Tom Stuart tom at experthuman.com
Tue Nov 6 10:30:46 EST 2007

On 6 Nov 2007, at 14:40, Jim Lindley wrote:
> Tom, there is likely a better path then the one I'm going down, and I
> would love to hear it. I am no RSpec expert.

Neither am I! From David's response it sounds as though there isn't a  
particularly tidy way to solve this problem at the moment, so I guess  
we just need to muddle along in whatever way works.

> How big are the modules you're including?
> For the modules I do this with it doesn't seem to get out of hand.
> If it's getting too complicated to spec out maybe the module is doing
> too much and should be split up?

Possibly, but the proliferation of behaviours is mostly due to  
following Dave Astels' "one expectation per example" guideline (http://daveastels.com/2006/08/26/one-expectation-per-example-a-remake-of-one-assertion-per-test/ 
), which actually works out really well for regular specs, making them  
easier to write and understand. It's just the impedance mismatch  
between this particular practice (i.e. split up big behaviours into  
lots of smaller ones) and RSpec's limited support for sharing  
behaviours (i.e. you can't group them together or supply parameters  
when referencing them) that causes the hassle, rather than  
(necessarily) a large or complicated mixin module.


More information about the rspec-users mailing list