]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - test/plugins/test_rot13.rb
77e6fbda822ef23e8c248e49ca18eb8381a4374b
[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('dbm')
34   end
35 end
36
37
38 class PluginTest < Test::Unit::TestCase
39   def setup
40     Irc::Bot::Plugins.manager.bot_associate(MockBot.new)
41
42     # @plugin = RotPlugin.new(MockBot.new)
43     # require ''
44     plugin_module = Module.new
45     fname = './data/rbot/plugins/rot13.rb'
46     bindtextdomain_to(plugin_module, "rbot-#{File.basename(fname, '.rb')}")
47     plugin_string = IO.read(fname)
48     plugin_module.module_eval(plugin_string, fname)
49   end
50
51   def test_rot13
52     plugins = Irc::Bot::Plugins.manager.botmodules[:Plugin]
53     assert_equal(plugins.size, 1)
54     rot13 = plugins.first
55
56     assert_equal(rot13.help(nil), "rot13 <string> => encode <string> to rot13 or back")
57   end
58 end