Let me try again.
class CodeIWantToTest
def foo(bar)
f = File.new(@userPath+bar)
#more
f.close
end
end
class Tests < Test::Unit::TestCase
def testFoo
fileNew=MockNew.new(File)
mockFile=FlexMock.new
fileNew.handle { |path| assert_equal('/home/usrname/etc/bob',path);
mockFile }
#more
subj.foo('bob')
fileNew.verify
end
end
I the test above, I want foo to call File.new. If I were to make a
mock class (cl_fake) in my test, I couldn't expect foo to call it,
because foo is not aware of cl_fake. Foo knows about File.
Maybe I'm missing something. Can you write the example above with the
method from your post?
J.