[rspec-users] Stubbing @instance.association.build

David Chelimsky dchelimsky at gmail.com
Wed Feb 17 07:53:48 EST 2010

On Wed, Feb 17, 2010 at 5:44 AM, Nickolay Kolev <nmkolev at gmail.com> wrote:
> Hi all,
> I am trying to spec a controller for a nested resource:
> http://gist.github.com/306521
> Running the spec as it is in the gist results in
> undefined method `save' for nil:NilClass (line 66 in the gist)
> So should_receive is interfering with the build message resulting in
> @course ending up nil.
> Is there a way to stub "build" so that the assertion works *and* does
> not result in @course == nil?
> Many thanks in advance,
> Nickolay

I don't see @new_course getting defined anywhere. Try assigning it a
non-nil value in each of the POST examples (or in before(:each) in
that group).

More information about the rspec-users mailing list