Forum: RSpec Best approach to spec'ing this

Posted by Matt Riches (Guest)
on 2010-02-22 20:23
(Received via mailing list)
I am hoping that this is an easy question to answer!

I have 2 models, related via an association model, such that models a 
and b
use has_many to refer to each other, and also the association.

(Thats as simple as the code is)

When I try to write a simple spec to access model 2 from model 1 I am
getting a failure "uninitialized constant in Model1::Association

Before I go back to this tomorrow, what is the best way of speccing 
models
that are connected via associations. Should I be Mocking and stubbing 
the
assosciation model and the child model, or requiring the actual models, 
and
pulling some seed data in form the database?

Thanks

Matt
Posted by Andrei Erdoss (cautaro)
on 2010-02-22 20:43
(Received via mailing list)
What I do is to mock and stub the associated models. The current model 
that
I work on is called, usually using a Factory Girl. Hope this helps.
Posted by Scott Taylor (Guest)
on 2010-02-22 21:33
(Received via mailing list)
On Feb 22, 2010, at 1:54 PM, Matt Riches wrote:

> I am hoping that this is an easy question to answer!
> 
> I have 2 models, related via an association model, such that models a and b use has_many to refer to each other, and also the association.

has_many :through with an extra table, or HABTM?

gist the relevant code.

Best,

Scott
Posted by Matt Riches (Guest)
on 2010-02-22 22:11
(Received via mailing list)
>
> > I am hoping that this is an easy question to answer!
> >
> > I have 2 models, related via an association model, such that models a and
> b use has_many to refer to each other, and also the association.
>
> has_many :through with an extra table, or HABTM?
>
> Im home now and dont have the code in front of me, but it was using
:through and the extra table, if that has any bearing?
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.