]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - test/test_registry.rb
test: small changes and fixes to existing tests
[user/henk/code/ruby/rbot.git] / test / test_registry.rb
index c6d68902937157a5c0a3e400093866621c444612..1f25f89d3a087de5bfb0492640deced705602386 100644 (file)
@@ -1,5 +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
+
 require 'test/unit'
 require 'rbot/ircbot'
 require 'rbot/registry'
@@ -293,34 +302,39 @@ class RegistryTCTest < Test::Unit::TestCase
   end
 end
 
-class RegistryDaybreakTest < Test::Unit::TestCase
-  include RegistryTestModule
-  include RegistryHashInterfaceTests
-
-  def initialize(o)
-    super o
-    @format = 'daybreak'
-    Irc::Bot::Registry.new(@format)
-    @registry_class = Irc::Bot::Registry::DaybreakAccessor
-  end
-end
-
-class RegistrySqliteTest < Test::Unit::TestCase
-  include RegistryTestModule
-  include RegistryHashInterfaceTests
-
-  def initialize(o)
-    super o
-    @format = 'sqlite'
-    Irc::Bot::Registry.new(@format)
-    @registry_class = Irc::Bot::Registry::SqliteAccessor
+begin
+  require 'daybreak'
+  class RegistryDaybreakTest < Test::Unit::TestCase
+    include RegistryTestModule
+    include RegistryHashInterfaceTests
+
+    def initialize(o)
+      super o
+      @format = 'daybreak'
+      Irc::Bot::Registry.new(@format)
+      @registry_class = Irc::Bot::Registry::DaybreakAccessor
+    end
   end
+rescue Exception; end
+
+begin
+  require 'sqlite'
+  class RegistrySqliteTest < Test::Unit::TestCase
+    include RegistryTestModule
+    include RegistryHashInterfaceTests
+
+    def initialize(o)
+      super o
+      @format = 'sqlite'
+      Irc::Bot::Registry.new(@format)
+      @registry_class = Irc::Bot::Registry::SqliteAccessor
+    end
 
-  def test_duplicate_keys
-    @reg['foo'] = 1
-    @reg['foo'] = 2
-    res = @reg.registry.execute('select key from data')
-    assert res.length == 1
+    def test_duplicate_keys
+      @reg['foo'] = 1
+      @reg['foo'] = 2
+      res = @reg.registry.execute('select key from data')
+      assert res.length == 1
+    end
   end
-end
-
+rescue Exception; end