[rspec-users] Stubbing @instance.association.build
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:
> 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,
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
More information about the rspec-users