X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=test%2Fplugins%2Ftest_rot13.rb;h=aa4bb18576c11a4f335e679fbeb1e7e468d7b8fa;hb=b22038a43a626915c6f70debf63f732053309a75;hp=a8223532a6b69cf0ead4bc9874a4794ff377fb3a;hpb=201901b959ad7f8b6d30f2867ee06c213c093e4b;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/test/plugins/test_rot13.rb b/test/plugins/test_rot13.rb index a8223532..aa4bb185 100644 --- a/test/plugins/test_rot13.rb +++ b/test/plugins/test_rot13.rb @@ -25,6 +25,10 @@ class MockBot @filters[name] = block end + def filter(name, value) + @filters[name].call({text: value})[:text] + end + def path '' end @@ -35,6 +39,19 @@ class MockBot end +class MockMessage + attr_reader :messages + + def initialize + @messages = [] + end + + def reply(message) + @messages << message + end +end + + class PluginTest < Test::Unit::TestCase def setup manager = Irc::Bot::Plugins.manager @@ -46,5 +63,8 @@ class PluginTest < Test::Unit::TestCase def test_rot13 assert_not_nil(@plugin) assert_equal(@plugin.help(nil), "rot13 => encode to rot13 or back") + m = MockMessage.new + @plugin.rot13(m, {string: 'Hello World'}) + assert_equal(m.messages.first, 'Uryyb Jbeyq') end end