Skip to content

Instantly share code, notes, and snippets.

@kommen
Created December 23, 2008 08:38
Show Gist options
  • Save kommen/39288 to your computer and use it in GitHub Desktop.
Save kommen/39288 to your computer and use it in GitHub Desktop.
module Mocha
module ObjectMethods
def stub_path(path)
path = path.split('.') if path.is_a? String
raise "Invalid Argument" if path.empty?
part = path.shift
mock = Mocha::Mockery.instance.named_mock(part)
exp = self.stubs(part)
if path.length > 0
exp.returns(mock)
return mock.stub_path(path)
else
return exp
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment