[rspec-devel] rspec_on_rails, speccing models, adding it helpers...

Zach Dennis zach.dennis at gmail.com
Tue Apr 1 19:20:08 EDT 2008


On Tue, Apr 1, 2008 at 6:38 PM, Pat Maddox <pergesu at gmail.com> wrote:
> On Tue, Apr 1, 2008 at 3:09 PM, David Chelimsky <dchelimsky at gmail.com> wrote:
>  >  >  Example:
>  >  >
>  >  >  describe SomeModel do
>  >  >   it_has_many :widgets, :destroy => :null, :class_name => "BaseWidget"
>  >  >   it_has_one :fuzzbucket
>  >  >   it_belongs_to :another_model
>  >  >  end
>  >
>  >  I see more and more structures appearing like this. I have very mixed
>  >  feelings about them. This is about structure, not behaviour. Even if
>  >  the underlying code is actually approaching this in a more behavioural
>  >  way, it's still expressing structure at the high level.
>
>  I don't have mixed feelings about this.  I think this type of spec is
>  terrible.  It completely duplicates the implementation.  It's not even
>  testing anything.
>
>  This is not a value judgment against you though, Zach.  I think when
>  people do stuff like this they genuinely have good intentions.  It's
>  just that it seems to be quite difficult to test highly declarative
>  stuff like AR associations.
>
>  Now that I've given my rather harsh opinion, I have to get back to
>  work :)  I'll try follow up later with something more helpful like
>  thoughts on how to write better specs.
>

I don't like the fact that it tests the structure of the association
(as opposed to testing the behavior), but I do like that it tests the
conceptual relationship between models. I find value in this. Even
though it is declarative it is very clear and meaningful to the next
guy looking at the code, and if someone changes something incidentally
they are quickly pointed to the fact that they broke a conceptual
relationship between two models.

Please do respond with more thoughts, as this is a topic I'd like to
get hammered out as it will provide value to every developer on this
list,


-- 
Zach Dennis
http://www.continuousthinking.com


More information about the rspec-devel mailing list