From: Brian Candler Date: 2010-08-02T23:31:17+09:00 Subject: Re: Mocking a method with a block Fernando Guillen wrote: > But instead of using the .yields method, that I didn't know about, I > tried to mock directly the Net::POP3.start method and this didn't work. It would be really useful if you could attach arbitrary behaviour to a mocked method - perhaps 'returns' with a block: m = [1,2,3] Net::POP3.expects(:start).returns { m.each { puts m }; m.size } This is something I've missed badly in the past, and I've ended up mocking directly using Object.new and defining singleton methods. -- Posted via http://www.ruby-forum.com/.