[rspec-users] some fun functionality for all your specs

Courtenay court3nay at gmail.com
Sun Feb 18 00:52:07 EST 2007


On 2/17/07, Courtenay <court3nay at gmail.com> wrote:
> On 2/17/07, Graeme Nelson <graeme.nelson at gmail.com> wrote:
> > Hi.
> >
> > I am not sure what the have_valid_associations is really testing.  If
> > I have a model, like so:
> >
> > class Address < ActiveRecord::Base
> >    belongs_to :order
> > end
> >
>
> try this
>
> class Address < ActiveRecord::Base
>   belongs_to :fooxl
> end
>
> make sure there's no Fooxl model.
>
> the 'valid associations' there means that your association actually
> would work, were you to call it.  It's surprising how many
> associations don't get tested at the model level.
>

you could also try

belongs_to :order, :foreign_key => 'monkey_id'

and it'll fail the spec.


More information about the rspec-users mailing list