Displaying 1 result from an estimated 1 matches for "mock_my_singleton".
2007 Aug 21
7
mocking singletons
...ocking 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(''bar'')
   MySingleton.expects(:instance).returns(m)
   yield
end
Thanks for your help.
-justin
list mods: I sent a previous message to the list but my membership  
was pending so my message is too. This message is...