[rspec-users] To mock or not mock base classes

Scott Taylor mailing_lists at railsnewbie.com
Tue Aug 14 16:15:32 EDT 2007


Just a general opinion question on idioms/common usage.  Is it better  
to mock Ruby's base classes, or to use real instances of those base  
classes?

@string = mock String
@string.stub!(:to_s).and_return "hello"

# or:

@string = "hello"

I was wondering which is generally favored, and if so, for what  
reasons?  Or is it highly dependent on the type of spec which is  
being written?

Regards,

Scott




More information about the rspec-users mailing list