[rspec-users] a MockExpectationError problem

Patrick J. Collins
Sun, 25 Apr 2010 23:58:08 -0000

> Regarding your original problem of the mocking error, have you debugged
into
> the FlexImage code? In looking at your gist, you have this:
>
>         # @photo = mock_model(Photo, {:image_file_string =>
photo_content})
>
> which says "create a mock object based on the Photo model, and if
> #image_file_string gets called on that object, return photo_content".
Then you
> have
>
>         # Photo.should_receive(:create).and_return(@photo)

...  Well, from what I can tell, the problem is not with
Photo.should_receive...  If I change

@contact.photo = Photo.create(...)

to

Photo.create(...)

then the spec passes...  It''s when that @contact.photo = is there that
it
breaks.