35 lines
841 B
Ruby
35 lines
841 B
Ruby
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
|