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

Nickolay Kolev nmkolev at gmail.com
Wed Feb 17 06:44:56 EST 2010


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


More information about the rspec-users mailing list