On Thu, 2008-01-10 at 18:09 -0600, David Chelimsky wrote: > It has more to do with what I'm looking at in my specs than what lies > under the hood. Why do I care if a visitor has_many(:posts)? Maybe > there is something different about a blogger with no posts vs one with > 50. So I'd have an example: > > describe Blogger, "with no posts" do > it "should be completely lame and banned for eternity" do > @blogger.should be_completely_lame_and_banned_for_eternity > end > end > > describe Blogger, "with 1000 posts" do > it "should be revered by the community" do > (1..1000).each { @blogger.post(:title => "today's thoughts") } > @blogger.should be_revered_by_the_community > end > end > > Now we're talking about behaviour. has_many is implied. No need to > spec it directly - serves no purpose by itself. > > That all make sense?
In principle, yes. But what if your association isn't that interesting. What if it is literally has_many :posts and that's it. You still want to make sure it will work (for instance that the posts.blogger_id column actually exists), but you've got nothing interesting to poke it with... On the other hand maybe it's stupid testing that as you are really testing the database, which is a different layer entirely. But in practise I know it's quite usual to make a database change and inadvertently break an association you had forgotten about... Jon -- Jonathan Leighton http://jonathanleighton.com/ _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users