I would like to test if a method, in this case 'puts', gets called when I include the Foo module into a 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