I would like to check whether the method, in this case "puts", will be called when I include the Foo module in the class and call "bar".
require 'minitest/autorun' module Foo def bar puts 'bar' end end class FooTest < MiniTest::Unit::TestCase def setup @class = Class.new do extend Foo end end def test_if_bar_method_calls_puts mock = MiniTest::Mock.new mock.expect(:puts, nil, ['bar']) @class.bar assert mock.verify end end
source share