1
私はテストを実装し、習得しようとしています(minitestが行く方法です)。私は内部モジュールクラスメソッドをテストするのに惨めに失敗しています。スタブとモックMinitest
私がやろうとしている用途は多かれ少なかれます。
module Zombie
class << self
# This is the method/code I want to test/execute
def intimidate
roar('slardar')
end
# This is the method that is internal, that I want to stub.
# Actual method(not this mocked one) is stateful. So I want to have
# mocked predefined data.
def roar(a)
'rawrger' + a
end
end
end
# Test Thingy
class ZombieTest < Minitest::Test
def test_mr_mock
@mock = Minitest::Mock.new
@mock.expect(:roar, 'rawrgerslardar', ['slardar'])
Zombie.stub :roar, @mock do
Zombie.intimidate
end
@mock.verify
end
end