我无法让这个简单的摩卡测试工作
免责声明我是摩卡的新手!
我的Factory
班级
# lib/fabtory.rb
class Factory
def self.build klass, *args
klass.new *args
end
end
我的测试代码
# test/test_factory.rb
class FactoryTest < MiniTest::Unit::TestCase
# my fake class
class Fake
def initialize *args
end
end
def test_build_passes_arguments_to_constructor
obj = Factory.build Fake, 1, 2, 3
obj.expects(:initialize).with(1, 2, 3).once
end
end
输出
unsatisfied expectations:
- expected exactly once, not yet invoked: #<Fake:0x7f98d5534740>.initialize(1, 2, 3)