[rspec-users] Class mocking

Marcus Roberts M.Roberts at NITTYGRITTY.NET
Fri Feb 27 12:36:28 EST 2009

>That's the way Ruby behaves, yes.

>Once you assign the constant MachineInstance to point to your mock,  
>Rails' magic auto-file-loading which normally happens when Ruby fires  
>a 'missing constant error' will never run, so your real class will  
>never get loaded.

>Assigning constants in your tests is a pretty bad idea unless you know  
>exactly what you're doing.

Assuming that assigning a constant was the right thing to do, it means there's different behaviour when running autospec versus running the specs individually.

I'm going to assume that we're doing the wrong thing by assigning a constant, which changes my question to how do we mock/stub the behaviour of our classes without that behaviour passing from spec to spec when running autospec.


-------------- next part --------------

The WatchGuard Firebox that protects your network has detected a message that may not be safe.

Cause : The file type may not be safe.
Content type : application/ms-tnef
File name    : winmail.dat
Virus status : No information.
Action       : The Firebox deleted winmail.dat.

Your network administrator can not restore this attachment.

More information about the rspec-users mailing list