about summary refs log tree commit homepage
path: root/projects/gem_plugin/test/test_plugins.rb
diff options
context:
space:
mode:
Diffstat (limited to 'projects/gem_plugin/test/test_plugins.rb')
-rw-r--r--projects/gem_plugin/test/test_plugins.rb73
1 files changed, 73 insertions, 0 deletions
diff --git a/projects/gem_plugin/test/test_plugins.rb b/projects/gem_plugin/test/test_plugins.rb
new file mode 100644
index 0000000..39a12e6
--- /dev/null
+++ b/projects/gem_plugin/test/test_plugins.rb
@@ -0,0 +1,73 @@
+require 'test/unit'
+require 'gem_plugin'
+
+include GemPlugin
+
+class ATestPlugin < GemPlugin::Plugin "/stuff"
+end
+
+class First < GemPlugin::Plugin "/commands"
+  def initialize(options = {})
+    puts "First with options: #{options.inspect}"
+  end
+end
+
+class Second < GemPlugin::Plugin "/commands"
+  def initialize(options = {})
+    puts "Second with options: #{options.inspect}"
+  end
+end
+
+class Last < GemPlugin::Plugin "/commands"
+  def initialize(options = {})
+    puts "Last with options: #{options.inspect}"
+  end
+end
+
+
+class PluginTest < Test::Unit::TestCase
+
+  def setup
+    @pmgr = Manager.instance
+    @pmgr.load({"rails" => EXCLUDE})
+    @categories = ["/commands"]
+    @names = ["/first", "/second", "/last", "/atestplugin"]
+  end
+
+  def test_load_plugins
+    puts "#{@pmgr.available.inspect}"
+    @pmgr.available.each {|cat,plugins|
+      plugins.each do |n,p|
+        puts "TEST: #{cat}#{n}"
+        assert @names.include?(n)
+      end
+    }
+
+    @pmgr.load
+    @pmgr.available.each do |cat,plugins|
+      plugins.each do |n,p|
+        STDERR.puts "#{cat}#{n}"
+        plugin = @pmgr.create("#{cat}#{n}", options={"name" => p})
+      end
+    end
+  end
+
+  def test_similar_uris
+
+    @pmgr.register("/test", "/testme", ATestPlugin)
+    @pmgr.register("/test2", "/testme", ATestPlugin)
+
+    assert_equal @pmgr.create("/test/testme").class, ATestPlugin
+    assert_equal @pmgr.create("/test2/testme").class, ATestPlugin
+
+  end
+
+
+  def test_create
+    last = @pmgr.create("/commands/last", "test" => "stuff")
+    assert last != nil, "Didn't make the right plugin"
+    first = @pmgr.create("/commands/last")
+    assert first != nil, "Didn't make the right plugin"
+  end
+
+end