I am confused by the instance variable @serverand serverin your example, but here is an example that should help you get where you're trying to:
class Runner
def run
fork do
STDERR.reopen("/dev/null")
end
end
end
describe "runner" do
it "#run reopens STDERR at /dev/null" do
runner = Runner.new
runner.should_receive(:fork) do |&block|
STDERR.should_receive(:reopen).with("/dev/null")
block.call
end
runner.run
end
end
The key is that the message is forksent to the object itself Runner, although its implementation is in the module Kernel.
NTN, David
source
share