From: David Chelimsky Date: 2006-09-03T04:07:45+09:00 Subject: yielding a block to another block Hi all, The mocking framework in rspec uses method_missing to capture all the messages sent to it, comparing the message to a list of expected messages. For various reasons I'm trying to rework this so that instead of using method_missing, we define the expected message on the mock on the fly. For that to happen, setting expectations on the mock ends up invoking this: def define_expected_method(sym) (class << self; self; end).__send__(:define_method, sym, lambda {|*args| message_received(sym, *args)}) end The Proc yields *args, which are then passed to message_received. How can I get the Proc to yield a block that is passed in with the call to :sym? I tried this: lambda {|*args, &block| .... but it throws an error. Any other ideas? Let me know if the question is not clear. Thanks, David