[rspec-users] a MockExpectationError problem

Patrick J. Collins patrick at collinatorstudios.com
Sun Apr 25 19:58:08 EDT 2010


> 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.


Patrick J. Collins
http://collinatorstudios.com


More information about the rspec-users mailing list