]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - test/plugins/test_note.rb
chucknorris: fix loading
[user/henk/code/ruby/rbot.git] / test / plugins / test_note.rb
1 $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2 $:.unshift File.join(File.dirname(__FILE__), '..', '..')
3
4 require 'test/unit'
5 require 'test/mock'
6
7 require 'rbot/ircbot'
8 require 'rbot/registry'
9 require 'rbot/plugins'
10
11
12 class NotePluginTest < Test::Unit::TestCase
13   def setup
14     @bot = MockBot.new
15     @bot.config['note.private_message'] = false
16     manager = Irc::Bot::Plugins.manager
17     manager.bot_associate(@bot)
18     manager.load_botmodule_file('./data/rbot/plugins/note.rb')
19     @plugin = manager.get_plugin('note')
20   end
21
22   def test_note
23     assert_not_nil(@plugin)
24     assert_equal(@plugin.help(nil), 'note <nick> <string> => stores a note (<string>) for <nick>')
25
26
27     m = MockMessage.new
28     @plugin.note(m, {nick: 'AlIcE', string: 'Hello Alice!'})
29     assert_equal(1, m.replies.size)
30     assert_equal('okay', m.replies.first)
31
32     m = MockMessage.new('', 'Alice')
33     @plugin.message(m)
34     assert_equal(1, @bot.messages.size)
35     to, message = @bot.messages.first
36     assert_equal('Alice', to)
37     assert_match(/you have notes!/, message)
38     assert_match(/<user> Hello Alice!/, message)
39   end
40 end