[rspec-users] mock_model

Anthony Broad-Crawford abroad-crawford at within3.com
Thu Apr 10 13:30:51 EDT 2008

Our company just had an interesting conversation around mock_model and  
I want to ask the same question to this audience.  When creating  
mock_models what is the purpose of passing in the class constant?

user = mock_model(User)

To the best that we can tell the method mock_model doesn't actually  
use the class for anything.  Please correct us if we are wrong.   
Secondly, we also typically after a mock_model stub the necessary  
properties (attributes) that are accessed off of the model.  For  
example ....

user = mock_model(User)

user.stub!(:username) ...
user.stub!(:password) ....

Why doesn't mock model interrogate the attributes and generate these  
mocks for me?  Thanks for taking the time to answer.

Anthony Broad-Crawford

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080410/c79ea9ae/attachment-0001.html 

More information about the rspec-users mailing list