diff --git a/test/test_lesson.rb b/test/test_lesson.rb new file mode 100644 index 0000000..fcde514 --- /dev/null +++ b/test/test_lesson.rb @@ -0,0 +1,22 @@ +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