On Thu, Apr 10, 2008 at 10:30 AM, Anthony Broad-Crawford <[EMAIL PROTECTED]> wrote: > 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.
mock_model does a little bit of stuff for you. It generates a unique ID for the object, sets new_record? to false, and gives it an empty errors array. Not much else though. stub_model, available in RSpec trunk, may be more to your liking. You can read about it at http://rubyforge.org/pipermail/rspec-devel/2008-March/004782.html Pat _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users