[rspec-users] specing nested models

Nick nick at deadorange.com
Mon Jan 24 15:35:27 EST 2011

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110124/f3ae25d1/attachment.html>

More information about the rspec-users mailing list