[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  

@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?



More information about the rspec-users mailing list