Lesson test

This commit is contained in:
Bill Rossi 2025-08-16 15:57:52 -04:00
parent 6a2a00541c
commit 9df060a124

22
test/test_lesson.rb Normal file
View File

@ -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