Re: [rspec-users] spec'ing models

2008-03-31 Thread Jonathan Linowes
for associations, among other things, i've been using http://rspec-on- rails-matchers.googlecode.com/svn/trunk/README linoj On Mar 31, 2008, at 8:33 PM, Anthony Broad-Crawford wrote: I have been using the following approach. Looking forward to see if anyone else does something better to te

Re: [rspec-users] spec'ing models

2008-03-31 Thread Anthony Broad-Crawford
It looks like my first note didn't go through ... so I apologize if it is delayed and this is a duplicate. My colleagues and I have been testing associations like this ... it "should have one account" do Profile.should_receive(:has_one).with(:account) load "profile.rb" end We li

Re: [rspec-users] spec'ing models

2008-03-31 Thread Tim Haines
And just to argue with myself a little - the spec output is a pretty nice of how a model works. Perhaps I'm thinking that something for the description should be specced so that it appears in the spec output.. Looking forward to taking this newb hat off sometime soon - I'm definitely spending wa

Re: [rspec-users] spec'ing models

2008-03-31 Thread Anthony Broad-Crawford
I have been using the following approach. Looking forward to see if anyone else does something better to test associations ... describe "Profile Associations" do it "should belong to ..." do Profile.should_receive(:belongs_to).with(:account) load "prof

Re: [rspec-users] spec'ing models

2008-03-31 Thread Tim Haines
Hey Matt, Cheers for that. Yeah - I'm not speccing methods like save, valid?, errors etc.. I am writing "belongs_to" though, so figure that should be specced somehow. I guess when I'm adding a "description" field to something, I might be writing a migration for it, but no other model code. I g

Re: [rspec-users] spec'ing models

2008-03-31 Thread Matt Berther
Hi Tim, I'm just a newb too, but as I understand it, you should only spec code you write. In the case of attributes on models, it's ActiveRecord code. You shouldnt need to test that. I have not been doing this. That said, I'd love to get the word from some people that have been doing it f