From b22038a43a626915c6f70debf63f732053309a75 Mon Sep 17 00:00:00 2001 From: Matthias Hecker Date: Wed, 1 Apr 2020 15:48:02 +0200 Subject: plugin(rot13): test assert added --- test/plugins/test_rot13.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') 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 -- cgit v1.2.3