summaryrefslogtreecommitdiff
path: root/test/plugins/test_rot13.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/plugins/test_rot13.rb')
-rw-r--r--test/plugins/test_rot13.rb53
1 files changed, 5 insertions, 48 deletions
diff --git a/test/plugins/test_rot13.rb b/test/plugins/test_rot13.rb
index aa4bb185..fafb58ba 100644
--- a/test/plugins/test_rot13.rb
+++ b/test/plugins/test_rot13.rb
@@ -1,57 +1,14 @@
-$:.unshift File.join(File.dirname(__FILE__), '../lib')
-
-module Irc
-class Bot
- module Config
- @@datadir = File.expand_path(File.dirname($0) + '/../data/rbot')
- @@coredir = File.expand_path(File.dirname($0) + '/../lib/rbot/core')
- end
-end
-end
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
+$:.unshift File.join(File.dirname(__FILE__), '..', '..')
require 'test/unit'
+require 'test/mock'
+
require 'rbot/ircbot'
require 'rbot/registry'
require 'rbot/plugins'
-class MockBot
- attr_reader :filters
- def initialize
- @filters = {}
- end
-
- def register_filter(name, &block)
- @filters[name] = block
- end
-
- def filter(name, value)
- @filters[name].call({text: value})[:text]
- end
-
- def path
- ''
- end
-
- def registry_factory
- Irc::Bot::Registry.new('tc')
- end
-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
@@ -65,6 +22,6 @@ class PluginTest < Test::Unit::TestCase
assert_equal(@plugin.help(nil), "rot13 <string> => encode <string> to rot13 or back")
m = MockMessage.new
@plugin.rot13(m, {string: 'Hello World'})
- assert_equal(m.messages.first, 'Uryyb Jbeyq')
+ assert_equal(m.replies.first, 'Uryyb Jbeyq')
end
end