1 $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2 $:.unshift File.join(File.dirname(__FILE__), '..', '..')
8 require 'rbot/registry'
10 require 'rbot/language'
12 class PointsPluginTest < Test::Unit::TestCase
14 manager = Irc::Bot::Plugins.manager
15 manager.bot_associate(MockBot.new)
16 manager.load_botmodule_file('./data/rbot/plugins/points.rb')
17 @plugin = manager.get_plugin('points')
21 assert_not_nil(@plugin)
22 assert_not_empty(@plugin.help(nil))
24 m = MockMessage.new('', 'user')
25 @plugin.points(m, key: 'linux')
26 assert_equal('linux has zero points', m.replies.first)
28 m = MockMessage.new('linux++', 'user')
30 assert_equal('linux now has 1 points!', m.replies.first)
32 m = MockMessage.new('linux++', 'user')
34 assert_equal('linux now has 2 points!', m.replies.first)
36 m = MockMessage.new('linux++', 'linux')
38 assert_empty(m.replies)
40 m = MockMessage.new('', 'user')
41 @plugin.points(m, key: 'linux')
42 assert_equal('points for linux: 2', m.replies.first)
44 m = MockMessage.new('', 'linux')
46 assert_equal('points for linux: 2', m.replies.first)
48 m = MockMessage.new('alice++', 'user')
50 assert_equal('alice now has 1 points!', m.replies.first)
52 # assign to multiple things
53 m = MockMessage.new('hello linux++ hello torvalds++', 'user')
55 assert_equal(m.replies.length, 2)
56 assert_equal('linux now has 3 points!', m.replies[0])
57 assert_equal('torvalds now has 1 points!', m.replies[1])
62 'something something --github',
77 'https://linux.slashdot.org/story/20/04/12/2138205/how-red-hats-new-ceo-handles-life-under-ibm----and-a-global-pandemic'
79 ignored.each do |ignore|
80 m = MockMessage.new(ignore, 'user')
82 assert_empty(m.replies, "message should've been ignored: #{ignore.inspect}")
85 m = MockMessage.new('bob++', 'user')
87 assert_equal('bob now has 1 points!', m.replies.first)
89 m = MockMessage.new('bot++', 'user')
91 assert_equal('thanks :)', m.replies.first)