[rspec-users] Common setup code and naming specifications

Tobias Grimm listaccount at e-tobi.net
Thu Jan 4 19:15:38 EST 2007


Thanks for your fast response!

David Chelimsky wrote:
> context "..." do
>   include MyHelpers
>   setup do
>     set_logged_in
>   end
> end
>   

Ok, but this still requires me to call set_logged_in in 99% of my
controller contexts. I can live with it, but it tastes like evil
duplication.

>> specify "should provide the first ten items in @items and three pages in
>> @pages when passing no :page parameter to the :list action"
>>
>> specify "should provide the first ten items and three pages when not
>> selecting a specific page"
>>     
>
> Definitely the latter. These names should be how the customer would
> talk about requirements, not how developers would - UNLESS you're
> writing a framework for developers and developers ARE your customers.
>   

Fine - sounds reasonable! But sometimes it's hard to see, whether you
are working on a framework or not. If I'm at a controller, it's not only
the customer who uses it in some way, it's also the view. And the view
needs to call :list and pass :page and expects to get @items and @pages.
The second of the two specifications above tells nothing about how the
view should interact with the controller.

Tobias



More information about the rspec-users mailing list