[mocha-developer] any reason we can't use the concise stubs on Object

Rob Sanheim rsanheim at gmail.com
Thu Sep 6 16:57:59 EDT 2007

I like the concise version of stubs available on true mocks:

=> #<Mock:0x32f76d4>
>> foo.stubs(:one => 'hi', :two => 'again')
=> {:one=>"hi", :two=>"again"}

Why can't we do it on 'real' objects?

>> foo = Object.new
>> foo.stubs(:method1 => 'a', :method2 => 'b')
TypeError: #<Mocha::InstanceMethod:0x32f9100 @method={:foo=>"b",
:again=>"hi"}, @stubbee=#<Object:0x32fc364>> is not a symbol
        from /opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.4/lib/mocha/mock.rb:148:in
        from /opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.4/lib/mocha/mock.rb:148:in
        from /opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.4/lib/mocha/mock.rb:88:in
        from /opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.4/lib/mocha/auto_verify.rb:65:in
        from /opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.4/lib/mocha/object.rb:57:in
        from (irb):14


More information about the mocha-developer mailing list