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

Nickolay Kolev nmkolev at gmail.com
Wed Feb 17 09:31:48 EST 2010

> This is not working for the reason that I think you think it's
> working. and_return is not an expectation - it is a command telling
> @teacher to return @new_course when it receives :build. You have to
> define @new_course in the spec.

I did the following:


and it works as expected. make_unsaved is a class method added by

What is the scope of instance variables defined in a before(:each)
block? They are available to all it-blocks, yet changes made to an
instance variable in one it-block are reverted before the next one,


More information about the rspec-users mailing list