From 08cd983415786c83f8661195f2200a35c272b6b1 Mon Sep 17 00:00:00 2001 From: Matthias Hecker Date: Tue, 7 Apr 2020 19:57:49 +0200 Subject: plugin(note): test cases added, closes #24 --- test/plugins/test_note.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/plugins/test_note.rb (limited to 'test/plugins') diff --git a/test/plugins/test_note.rb b/test/plugins/test_note.rb new file mode 100644 index 00000000..b8320965 --- /dev/null +++ b/test/plugins/test_note.rb @@ -0,0 +1,40 @@ +$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') +$:.unshift File.join(File.dirname(__FILE__), '..', '..') + +require 'test/unit' +require 'test/mock' + +require 'rbot/ircbot' +require 'rbot/registry' +require 'rbot/plugins' + + +class NotePluginTest < Test::Unit::TestCase + def setup + @bot = MockBot.new + @bot.config['note.private_message'] = false + manager = Irc::Bot::Plugins.manager + manager.bot_associate(@bot) + manager.load_botmodule_file('./data/rbot/plugins/note.rb') + @plugin = manager.get_plugin('note') + end + + def test_note + assert_not_nil(@plugin) + assert_equal(@plugin.help(nil), 'note => stores a note () for ') + + + m = MockMessage.new + @plugin.note(m, {nick: 'AlIcE', string: 'Hello Alice!'}) + assert_equal(1, m.replies.size) + assert_equal('okay', m.replies.first) + + m = MockMessage.new('', 'Alice') + @plugin.message(m) + assert_equal(1, @bot.messages.size) + to, message = @bot.messages.first + assert_equal('Alice', to) + assert_match(/you have notes!/, message) + assert_match(/ Hello Alice!/, message) + end +end -- cgit v1.2.3