diff options
author | Matthias Hecker <mail@apoc.cc> | 2020-04-06 20:20:32 +0200 |
---|---|---|
committer | Matthias Hecker <mail@apoc.cc> | 2020-04-06 20:20:32 +0200 |
commit | 618df277b7cb7d160ba5c86d1a22298a4741ed5f (patch) | |
tree | 8e709db0e57559a0e1aa06eae886a770c80c17a2 /test/mock.rb | |
parent | 628bf10d8ad8536b98b85c529fe92e8ac56a9c4d (diff) |
tests: mocked bot and messages added, added points tests
Diffstat (limited to 'test/mock.rb')
-rw-r--r-- | test/mock.rb | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/mock.rb b/test/mock.rb new file mode 100644 index 00000000..f1ce92dd --- /dev/null +++ b/test/mock.rb @@ -0,0 +1,71 @@ +$:.unshift File.join(File.dirname(__FILE__), '..', 'lib') +$:.unshift File.join(File.dirname(__FILE__), '..') + + +module Irc +class Bot + module Config + @@datadir = File.expand_path(File.dirname(__FILE__) + '/../data/rbot') + @@coredir = File.expand_path(File.dirname(__FILE__) + '/../lib/rbot/core') + end +end +end + + +class MockBot + attr_reader :filters, :lang + + def initialize + @filters = {} + @lang = Irc::Bot::Language.new(self, 'english') + end + + def register_filter(name, &block) + @filters[name] = block + end + + def filter(name, value) + @filters[name].call({text: value})[:text] + end + + def nick + 'bot' + end + + def path(*components) + File.join('/tmp/rbot-test', *(components.map {|c| c.to_s})) + end + + def plugins + nil + end + + def registry_factory + Irc::Bot::Registry.new('mem') + end +end + + +class MockMessage + attr_reader :message + attr_reader :replies + attr_reader :channel + attr_reader :sourcenick + + def initialize(message='', source='user') + @message = message + @sourcenick = source + @channel = Irc::Channel.new('#test', '', [], server: nil) + @replies = [] + end + + def reply(message) + @replies << message + end + + def public? + true + end +end + + |