Re: [rspec-users] specing nested models

2011-01-28 Thread Mike Mazur
Hi, On Mon, Jan 24, 2011 at 19:33, Cezar Halmagean wrote: > So I am trying to spec a nested model / form like say Post has_many Comments > and in order to build a nested form I need to build a new comment in > @posts.comments like so: > @post = Post.new > @post.comments.build > Now, my question i

Re: [rspec-users] specing nested models

2011-01-27 Thread Nick
On Wednesday, January 26, 2011 10:34:14 AM UTC-5, Cezar Halmagean wrote: > > That worked great, thank you. You're welcome, mate! ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

[rspec-users] specing nested models

2011-01-27 Thread Cezar Halmagean
So I am trying to spec a nested model / form like say Post has_many Comments and in order to build a nested form I need to build a new comment in @posts.comments like so: @post = Post.new @post.comments.build Now, my question is: How do you go about correctly testing this ? Thanks

Re: [rspec-users] specing nested models

2011-01-27 Thread Nick
How about: it 'builds a comment in the post' do post = Post.new comments_assoc = mock comment = mock_model Comment post.stub(:comments).and_return comments_assoc comments_assoc.should_receive(:build).with(no_args).and_return comment # invoke something to trigger the action end _

Re: [rspec-users] specing nested models

2011-01-27 Thread Cezar Halmagean
That worked great, thank you.___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users