[rspec-users] How to write specification for the *base* class API?

Bart Zonneveld loop at superinfinite.com
Tue Jul 15 08:58:46 EDT 2008

On 15-jul-2008, at 14:47, Pat Maddox wrote:

> On Tue, Jul 15, 2008 at 5:17 AM, Piotr Wlodarek <lists at ruby- 
> forum.com> wrote:
>> For the base class, it seems reasonable to specify public API with
>> RSpec.
>> However, since we deal with a base class, methods are often empty  
>> (put
>> there just to show the API).
> What's the point of that?  This isn't Java.

Exactly. In all of my projects, I only have an inheritance tree of at  
most 3 levels deep. AR::Base -> Generic -> Specific model.
If there are more than three levels, something might not be okay with  
the design of your app. Of course your mileage may vary, but I think  
a lot of developers will agree on this subject.

>> The spec cannot be run against the base class. In consequence, the  
>> spec
>> must be duplicated in every derived class, which seems to be far from
>> DRY.
> Presumably the derived classes have different implementations, so you
> would need to spec them out differently.
> If the implementations are the same, shared behaviors are often  
> useful.

More information about the rspec-users mailing list