Rob Sanheim
2007-Sep-06 20:57 UTC
[mocha-developer] any reason we can''t use the concise stubs on Object
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 `method_defined?'' from /opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.4/lib/mocha/mock.rb:148:in `add_expectation'' from /opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.4/lib/mocha/mock.rb:88:in `stubs'' from /opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.4/lib/mocha/auto_verify.rb:65:in `stub'' from /opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.4/lib/mocha/object.rb:57:in `stubs'' from (irb):14 thanks, Rob -- http://robsanheim.com
James Mead
2007-Sep-11 14:31 UTC
[mocha-developer] any reason we can''t use the concise stubs on Object
No specific reason. I''ve been meaning to do it for a while, but not had the time. I''ve added it to the todo list (revision 168). -- James. http://blog.floehopper.org http://tumble.floehopper.org
Apparently Analagous Threads
- Mocking Time, delegating to original object
- Patch: make rdoc of lib/mocha/object.rb instead of lib/stubba/object.rb
- Fwd: [ mocha-Feature Requests-5856 ] Stubbing of private methods should be allowed
- removing Mocha; 'spec spec' fails but the specific model file passes
- how to ensure signature compliance while mocking in ruby