Created
December 11, 2009 19:44
-
-
Save pjb3/254456 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'rubygems' | |
require 'mocha' | |
class Class1 | |
def foo | |
c2 = Class2.new | |
x = c2.bar | |
c2.baz(x) | |
end | |
end | |
class Class2 | |
def bar | |
21 | |
end | |
def baz(x) | |
x * 2 | |
end | |
end | |
class MyTest < Test::Unit::TestCase | |
def test_foo | |
n = 99 | |
c2 = mock() | |
Class2.expects(:new).returns(c2) | |
c2.expects(:bar).returns(n) | |
c2.expects(:baz).with(n).returns(1) | |
assert_equal 1, Class1.new.foo | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment