require_relative "../lib/lesson" require "minitest/autorun" class TestLesson < Minitest::Test def setup @lesson = Lesson.new [[0.1 / 60, "test the thing"], [0.1 / 60, "finish testing"]] end def test_start @channel = Minitest::Mock.new @channel.expect(:send_message, nil) { |msg| msg.include? "to test the thing" } @channel.expect(:send_message, nil) { |msg| msg.include? "to finish testing" } @channel.expect(:send_message, nil) { |msg| msg == "Lesson over!" } assert_equal false, @lesson.running @lesson.start!(@channel) sleep(0.5) # gonna be impossible to thread this needle # assert_equal true, @lesson.running sleep(0.5) assert_equal false, @lesson.running end end