Skip to content

Instantly share code, notes, and snippets.

@kommen
Created December 23, 2008 08:38
Show Gist options
  • Select an option

  • Save kommen/39288 to your computer and use it in GitHub Desktop.

Select an option

Save kommen/39288 to your computer and use it in GitHub Desktop.

Revisions

  1. kommen created this gist Dec 23, 2008.
    17 changes: 17 additions & 0 deletions mocha_stub_path.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    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