Warren's spot on. You're testing Rails, not your own code. These days I don't 
bother checking whether associations exist - that's something integration tests 
will pick up.

-- 
Pat

On 10/09/2011, at 4:04 PM, Warren Seen wrote:

> There's not really anything wrong with your specs, but the general wisdom is 
> that there's not a lot of point testing what's essentially part of rails 
> itself. 
> 
> In the past, I've used rspec matchers to confirm that models have the correct 
> associations defined, eg: https://github.com/thoughtbot/shoulda-matchers but 
> that's about as far as I'd usually go in testing associations themselves.
> 
> Cheers,
> 
> Warren. 
> 
> On 10/09/2011, at 3:53 PM, Stuart Liston wrote:
> 
>> Hi ladies and gents
>> 
>> I joined this group a few week ago and keep an eye on it but am a little too 
>> 'green' to help out a lot of the time. Instead, my first mail will be to 
>> look for advice!
>> 
>> I'm looking to test some model (HABTM) relationships in a small application 
>> I'm building, and I'm keen to show some more experienced developers how I'm 
>> going about it so that I don't start to get into bad habits.
>> 
>> So with that in mind, does anyone fancy having a quick gander over the 
>> following gist and telling me if I'm approaching the problem in a reasonable 
>> way? My specs are green, it's more a 'best practice'  thing...
>> 
>> https://gist.github.com/1207931
>> 
>> (The assumption would be that I have rspec and factorygirl set up correctly)
>> 
>> Thanks for your time in advance!
>> Stu
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby or Rails Oceania" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to 
>> [email protected].
>> For more options, visit this group at 
>> http://groups.google.com/group/rails-oceania?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rails-oceania?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to