]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - test/plugins/test_rot13.rb
test: rot13 simplified
[user/henk/code/ruby/rbot.git] / test / plugins / test_rot13.rb
1 $:.unshift File.join(File.dirname(__FILE__), '../lib')
2
3 module Irc
4 class Bot
5   module Config
6     @@datadir = File.expand_path(File.dirname($0) + '/../data/rbot')
7     @@coredir = File.expand_path(File.dirname($0) + '/../lib/rbot/core')
8   end
9 end
10 end
11
12 require 'test/unit'
13 require 'rbot/ircbot'
14 require 'rbot/registry'
15 require 'rbot/plugins'
16
17
18 class MockBot
19   attr_reader :filters
20   def initialize
21     @filters = {}
22   end
23
24   def register_filter(name, &block)
25     @filters[name] = block
26   end
27
28   def path
29     ''
30   end
31
32   def registry_factory
33     Irc::Bot::Registry.new('tc')
34   end
35 end
36
37
38 class PluginTest < Test::Unit::TestCase
39   def setup
40     manager = Irc::Bot::Plugins.manager
41     manager.bot_associate(MockBot.new)
42     manager.load_botmodule_file('./data/rbot/plugins/rot13.rb')
43     @plugin = manager.get_plugin('rot')
44   end
45
46   def test_rot13
47     assert_not_nil(@plugin)
48     assert_equal(@plugin.help(nil), "rot13 <string> => encode <string> to rot13 or back")
49   end
50 end