pluginfactory 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/test.rb DELETED
@@ -1,72 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- #
3
- # Tests for the PluginFactory module
4
- #
5
-
6
- BEGIN {
7
- require 'pathname'
8
- basedir = Pathname.new( __FILE__ ).dirname
9
-
10
- $:.unshift( basedir + "lib" )
11
- $:.unshift( basedir + "tests" )
12
- }
13
-
14
- require "pluginfactory"
15
- require "test/unit"
16
- require 'mybase'
17
-
18
- class FactoryTests < Test::Unit::TestCase
19
-
20
- def setup
21
- if $DEBUG
22
- PluginFactory.logger_callback = lambda {|lvl, msg|
23
- $deferr.puts msg
24
- }
25
- end
26
- end
27
-
28
- def test_inclusion_of_mixin_should_add_a_create_class_method
29
- subclass = rval = nil
30
-
31
- assert_nothing_raised do
32
- subclass = Class::new { include PluginFactory }
33
- end
34
-
35
- assert_respond_to subclass, :create
36
- end
37
-
38
-
39
- @@subs = %w{subof OtherSub SubOfMyBase othersubmybase deepsubof}
40
-
41
-
42
- def test_create_should_fetch_search_dirs_from_base_class
43
- subclass = rval = nil
44
-
45
- assert_nothing_raised do
46
- subclass = Class::new {
47
- include PluginFactory
48
- @method_called = false
49
-
50
- class << self
51
- attr_accessor :method_called
52
- end
53
- def self.derivative_dirs
54
- method_called = true
55
- end
56
- }
57
- end
58
-
59
-
60
- end
61
-
62
- def test_creation
63
- @@subs.each do |sub|
64
- result = nil
65
- assert_nothing_raised {result = MyBase.create(sub)}
66
- assert result.kind_of?(MyBase)
67
- assert_match %r[#{sub}]i, result.class.name
68
- end
69
- end
70
-
71
-
72
- end # class FactoryTests
@@ -1,3 +0,0 @@
1
- require 'subofmybase'
2
-
3
- class DeepSubOf < SubOfMyBase; end
data/tests/mybase.rb DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "pluginfactory"
4
-
5
- class MyBase
6
- include PluginFactory
7
- def self::derivativeDirs
8
- testdir = File::expand_path( File.dirname(__FILE__) )
9
- return [ testdir, File::join(testdir, "dir") ]
10
- end
11
- end
data/tests/othersub.rb DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'mybase'
4
-
5
- class OtherSubMyBase < MyBase; end
data/tests/subofmybase.rb DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'mybase'
4
-
5
- class SubOfMyBase < MyBase; end