Displaying 1 result from an estimated 1 matches for "mock_my_global".
2007 Aug 21
7
mocking singletons
How can I safely mock a singleton without the mocked method living on
outside the scope of the test method?
I''ve run into this problem with mocking methods on globals (gasp!) in
the past by doing something like
def mock_my_global
original = $my_global
$my_global.expects(:foo).returns(''bar'')
yield
$my_global = original
end
Is there something similar I can do for a singleton? Right now I have
this:
def mock_my_singleton
m = mock("my singleton")
m.expects(:foo).returns('...