On 7/3/07, Daniel N <[EMAIL PROTECTED]> wrote:
> Hi,
>
>  I'm very new to rspec, so if this is not the right forum please let me
> know.
>
>  I'm starting to spec my models first in an existing rails app, porting from
> a mix of Test::Unit, and simply_bdd amongst others.
>
>  I'm at the point where I want to test that certain associations are
> present.  What I'm not sure of is should I test the association or the
> method and return object.
>
>  That is, if I wanted to test a has_many should I:
>
>  Confirm the methods exist, and that the return an array etc
>
>  OR
>
>  Check that the model has the named has_many association through it's
> reflections.
>
>  On one hand the second one looks like it will be a bit more robust, since
> if there is a has_many relationship, then all the associated methods may be
> used througout the app.  This would put testing in the one place.
>
>  On the other hand, this would be really testing the implementation of the
> model rather than it's behaviour.   The behaviour is to call
> @article.comments and have an array of comments returned.
>
>  Any thoughts?

I think the jury is still out on this one. Both approaches present
problems, and no better approaches have been proposed. I'd say try it
both ways and report back on experiences.

David

>  Cheers
>  Daniel
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to