Compare commits
No commits in common. "6612483ac437fc2e548d89255c163bb5ee54b902" and "24b5386b51b2a3ab48732c605521468ad273d3d2" have entirely different histories.
6612483ac4
...
24b5386b51
3
Rakefile
3
Rakefile
@ -1,3 +0,0 @@
|
||||
require "minitest/test_task"
|
||||
|
||||
Minitest::TestTask.create # named test, sensible defaults
|
@ -11,6 +11,7 @@ module Commands
|
||||
|
||||
class Command
|
||||
def self.inherited(klass)
|
||||
p klass
|
||||
Commands.register_command klass
|
||||
end
|
||||
|
||||
|
@ -47,5 +47,11 @@ class Ika
|
||||
end
|
||||
|
||||
return current_session&.respond_to message
|
||||
|
||||
if message.message.content == "!init"
|
||||
return message.respond("There's already a session running") unless current_session.nil?
|
||||
|
||||
return current_session = Session.new(message, event.message.author)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -21,11 +21,11 @@ class KanaKanji
|
||||
@kanji = kanji || kana
|
||||
end
|
||||
|
||||
def [](index)
|
||||
def [] (index)
|
||||
self.class.new kana[index], kanji[index]
|
||||
end
|
||||
|
||||
def +(other)
|
||||
def + (other)
|
||||
case other
|
||||
when String
|
||||
self.class.new kana + other, kanji + other
|
||||
|
@ -1,34 +0,0 @@
|
||||
require_relative "../lib/ika"
|
||||
require "minitest/autorun"
|
||||
|
||||
class TestIka < Minitest::Test
|
||||
def setup
|
||||
@bot = Minitest::Mock.new
|
||||
@ika = Ika.new @bot
|
||||
end
|
||||
|
||||
def test_start
|
||||
@bot.expect(:message, nil)
|
||||
@bot.expect(:run, nil)
|
||||
@ika.start!
|
||||
end
|
||||
|
||||
def test_handle_command_message
|
||||
@command = Minitest::Mock.new
|
||||
@command.expect(:execute, nil)
|
||||
Commands::Command.stub(:for, @command) do |x|
|
||||
@ika.handle_message("msg")
|
||||
end
|
||||
end
|
||||
|
||||
def test_handle_normal_message
|
||||
@ika.current_session = Minitest::Mock.new
|
||||
@command = Commands::Command.new(nil, nil)
|
||||
Commands::Command.stub(:for, nil) do |x|
|
||||
@command.stub(:execute, -> { raise "#execute was called" }) do |x|
|
||||
@ika.current_session.expect(:respond_to, nil) { |x| x == "msg" }
|
||||
@ika.handle_message("msg")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,22 +0,0 @@
|
||||
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
|
Loading…
Reference in New Issue
Block a user