pluginfactory 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +70 -319
- data/LICENSE +1 -1
- data/README +0 -4
- data/Rakefile +90 -68
- data/lib/pluginfactory.rb +7 -11
- data/rake/dependencies.rb +1 -1
- data/rake/helpers.rb +75 -48
- data/rake/hg.rb +261 -0
- data/rake/manual.rb +74 -76
- data/rake/packaging.rb +40 -8
- data/rake/publishing.rb +70 -69
- data/rake/rdoc.rb +11 -26
- data/rake/style.rb +1 -1
- data/rake/svn.rb +582 -516
- data/rake/testing.rb +6 -21
- data/rake/win32.rb +119 -23
- data/spec/pluginfactory_spec.rb +112 -124
- metadata +18 -129
data/rake/testing.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Rake tasklib for testing tasks
|
3
|
-
|
3
|
+
|
4
4
|
#
|
5
5
|
# Authors:
|
6
6
|
# * Michael Granger <ged@FaerieMUD.org>
|
@@ -16,7 +16,7 @@ end
|
|
16
16
|
SPEC_FILES = [] unless defined?( SPEC_FILES )
|
17
17
|
TEST_FILES = [] unless defined?( TEST_FILES )
|
18
18
|
|
19
|
-
COMMON_SPEC_OPTS = ['-Du'
|
19
|
+
COMMON_SPEC_OPTS = ['-Du'] unless defined?( COMMON_SPEC_OPTS )
|
20
20
|
|
21
21
|
COVERAGE_TARGETDIR = BASEDIR + 'coverage' unless defined?( COVERAGE_TARGETDIR )
|
22
22
|
RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib' unless
|
@@ -29,7 +29,7 @@ task :test do
|
|
29
29
|
log "Running specs"
|
30
30
|
Rake::Task['spec:quiet'].invoke
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
unless TEST_FILES.empty?
|
34
34
|
log "Running unit tests"
|
35
35
|
Rake::Task[:unittests].invoke
|
@@ -45,6 +45,7 @@ begin
|
|
45
45
|
require 'spec/rake/spectask'
|
46
46
|
|
47
47
|
### Task: spec
|
48
|
+
desc "Run specs"
|
48
49
|
task :spec => 'spec:doc'
|
49
50
|
|
50
51
|
namespace :spec do
|
@@ -100,7 +101,7 @@ end
|
|
100
101
|
### Test::Unit tests
|
101
102
|
begin
|
102
103
|
require 'rake/testtask'
|
103
|
-
|
104
|
+
|
104
105
|
Rake::TestTask.new( :unittests ) do |task|
|
105
106
|
task.libs += [LIBDIR]
|
106
107
|
task.test_files = TEST_FILES
|
@@ -115,7 +116,7 @@ rescue LoadError => err
|
|
115
116
|
task :unittests => :no_rspec
|
116
117
|
end
|
117
118
|
|
118
|
-
|
119
|
+
|
119
120
|
### RCov (via RSpec) tasks
|
120
121
|
begin
|
121
122
|
gem 'rcov'
|
@@ -135,16 +136,6 @@ begin
|
|
135
136
|
task.rcov = true
|
136
137
|
end
|
137
138
|
end
|
138
|
-
# unless TEST_FILES.empty?
|
139
|
-
# require 'rcov/rcovtask'
|
140
|
-
|
141
|
-
# Rcov::RcovTask.new do |task|
|
142
|
-
# task.libs += [LIBDIR]
|
143
|
-
# task.test_files = TEST_FILES
|
144
|
-
# task.verbose = true
|
145
|
-
# task.rcov_opts = RCOV_OPTS
|
146
|
-
# end
|
147
|
-
# end
|
148
139
|
|
149
140
|
|
150
141
|
### Task: rcov
|
@@ -167,12 +158,6 @@ begin
|
|
167
158
|
task.rcov = true
|
168
159
|
end
|
169
160
|
|
170
|
-
### Task: verify coverage
|
171
|
-
desc "Build coverage statistics"
|
172
|
-
VerifyTask.new( :verify => :rcov ) do |task|
|
173
|
-
task.threshold = COVERAGE_MINIMUM
|
174
|
-
end
|
175
|
-
|
176
161
|
desc "Run RCov in 'spec-only' mode to check coverage from specs"
|
177
162
|
Spec::Rake::SpecTask.new( :speconly ) do |task|
|
178
163
|
task.spec_files = SPEC_FILES
|
data/rake/win32.rb
CHANGED
@@ -13,13 +13,20 @@
|
|
13
13
|
# * Aaron Patterson
|
14
14
|
# http://tenderlovemaking.com/2008/11/21/cross-compiling-ruby-gems-for-win32/
|
15
15
|
|
16
|
+
require 'rubygems'
|
17
|
+
require 'rake'
|
16
18
|
require 'pathname'
|
19
|
+
require 'rubygems/platform'
|
17
20
|
require 'rbconfig'
|
21
|
+
require 'uri'
|
22
|
+
require 'net/ftp'
|
18
23
|
|
19
24
|
HOMEDIR = Pathname( '~' ).expand_path
|
20
25
|
RUBYVERSION = '1.8.6-p287'
|
21
|
-
|
22
|
-
|
26
|
+
RUBYVERSION_MAJORMINOR = RUBYVERSION[/^\d+\.\d+/]
|
27
|
+
|
28
|
+
RUBY_DL_BASE = "ftp://ftp.ruby-lang.org/pub/ruby/#{RUBYVERSION_MAJORMINOR}/"
|
29
|
+
RUBY_DL_URI = URI( RUBY_DL_BASE + "ruby-#{RUBYVERSION}.tar.gz" )
|
23
30
|
|
24
31
|
XCOMPILER_DIR = HOMEDIR + '.ruby_mingw32'
|
25
32
|
|
@@ -27,11 +34,20 @@ XCOMPILER_DL = XCOMPILER_DIR + "ruby-#{RUBYVERSION}.tar.gz"
|
|
27
34
|
XCOMPILER_SRC = XCOMPILER_DIR + "ruby-#{RUBYVERSION}"
|
28
35
|
|
29
36
|
XCOMPILER_BIN = XCOMPILER_DIR + 'bin'
|
37
|
+
XCOMPILER_LIB = XCOMPILER_DIR + 'lib'
|
30
38
|
XCOMPILER_RUBY = XCOMPILER_BIN + 'ruby.exe'
|
31
39
|
|
32
|
-
|
40
|
+
XCOMPILER_LOAD_PATH = XCOMPILER_LIB + "ruby/#{RUBYVERSION_MAJORMINOR}/i386-mingw32"
|
41
|
+
|
42
|
+
TAR_OPTS = { :compression => :gzip }
|
43
|
+
|
44
|
+
WIN32_GEMSPEC = GEMSPEC.dup
|
45
|
+
WIN32_GEMSPEC.files += FileList[ EXTDIR + '**.{dll,so}' ]
|
46
|
+
WIN32_GEMSPEC.platform = Gem::Platform.new( 'i386-mingw32' )
|
47
|
+
WIN32_GEMSPEC.extensions = []
|
48
|
+
|
33
49
|
|
34
|
-
CONFIGURE_CMD = %
|
50
|
+
CONFIGURE_CMD = %W[
|
35
51
|
env
|
36
52
|
ac_cv_func_getpgrp_void=no
|
37
53
|
ac_cv_func_setpgrp_void=yes
|
@@ -41,54 +57,134 @@ CONFIGURE_CMD = %w[
|
|
41
57
|
./configure
|
42
58
|
--host=i386-mingw32
|
43
59
|
--target=i386-mingw32
|
44
|
-
--build=#{
|
60
|
+
--build=#{Config::CONFIG['build']}
|
45
61
|
--prefix=#{XCOMPILER_DIR}
|
46
62
|
]
|
47
63
|
|
64
|
+
### Archive::Tar::Reader#extract (as of 0.9.0) is broken w.r.t.
|
65
|
+
### permissions, so we have to do this ourselves.
|
66
|
+
def untar( tarfile, targetdir )
|
67
|
+
targetdir = Pathname( targetdir )
|
68
|
+
raise "No such directory: #{targetdir}" unless targetdir.directory?
|
69
|
+
|
70
|
+
reader = Archive::Tar::Reader.new( tarfile.to_s, TAR_OPTS )
|
71
|
+
|
72
|
+
mkdir_p( targetdir )
|
73
|
+
reader.each( true ) do |header, body|
|
74
|
+
path = targetdir + header[:path]
|
75
|
+
# trace "Header is: %p" % [ header ]
|
76
|
+
|
77
|
+
case header[:type]
|
78
|
+
when :file
|
79
|
+
trace " #{path}"
|
80
|
+
path.open( File::WRONLY|File::EXCL|File::CREAT|File::TRUNC, header[:mode] ) do |fio|
|
81
|
+
bytesize = header[:size]
|
82
|
+
fio.write( body[0,bytesize] )
|
83
|
+
end
|
84
|
+
|
85
|
+
when :directory
|
86
|
+
trace " #{path}"
|
87
|
+
path.mkpath
|
88
|
+
|
89
|
+
when :link
|
90
|
+
linktarget = targetdir + header[:dest]
|
91
|
+
trace " #{path} => #{linktarget}"
|
92
|
+
path.make_link( linktarget.to_s )
|
93
|
+
|
94
|
+
when :symlink
|
95
|
+
linktarget = targetdir + header[:dest]
|
96
|
+
trace " #{path} -> #{linktarget}"
|
97
|
+
path.make_symlink( linktarget )
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
|
48
104
|
begin
|
49
105
|
require 'archive/tar'
|
50
|
-
|
106
|
+
|
51
107
|
namespace :win32 do
|
52
|
-
directory XCOMPILER_DIR
|
53
|
-
|
108
|
+
directory XCOMPILER_DIR.to_s
|
109
|
+
|
54
110
|
file XCOMPILER_DL => XCOMPILER_DIR do
|
55
|
-
|
111
|
+
# openuri can't handle this -- passive ftp required?
|
112
|
+
# run 'wget', '-O', XCOMPILER_DL, RUBY_DL_URI
|
113
|
+
log "Downloading ruby distro from %s" % [ RUBY_DL_URI ]
|
114
|
+
ftp = Net::FTP.new( RUBY_DL_URI.host )
|
115
|
+
ftp.login
|
116
|
+
ftp.getbinaryfile( RUBY_DL_URI.path, XCOMPILER_DL, 4096 )
|
117
|
+
ftp.close
|
56
118
|
end
|
57
119
|
|
58
|
-
directory XCOMPILER_SRC
|
120
|
+
directory XCOMPILER_SRC.to_s
|
59
121
|
task XCOMPILER_SRC => [ XCOMPILER_DIR, XCOMPILER_DL ] do
|
60
|
-
|
61
|
-
|
122
|
+
if XCOMPILER_SRC.exist?
|
123
|
+
trace "Rake fails. #{XCOMPILER_SRC} already exists."
|
124
|
+
else
|
125
|
+
untar( XCOMPILER_DL, XCOMPILER_DIR )
|
126
|
+
end
|
62
127
|
end
|
63
128
|
|
64
129
|
file XCOMPILER_RUBY => XCOMPILER_SRC do
|
65
130
|
Dir.chdir( XCOMPILER_SRC ) do
|
66
|
-
File.
|
67
|
-
File.
|
68
|
-
|
69
|
-
|
131
|
+
unless File.exist?( 'Makefile.in.orig' )
|
132
|
+
File.open( 'Makefile.in.new', IO::CREAT|IO::WRONLY|IO::EXCL ) do |ofh|
|
133
|
+
IO.readlines( 'Makefile.in' ).each do |line|
|
134
|
+
next if line.include?( 0.chr )
|
135
|
+
trace " copying line: %p" % [ line ]
|
136
|
+
line.sub!( /ALT_SEPARATOR = ".*?"/, "ALT_SEPARATOR = 92.chr" )
|
137
|
+
ofh.write( line )
|
138
|
+
end
|
70
139
|
end
|
140
|
+
|
141
|
+
mv 'Makefile.in', 'Makefile.in.orig'
|
142
|
+
mv 'Makefile.in.new', 'Makefile.in'
|
71
143
|
end
|
72
144
|
|
73
|
-
mv 'Makefile.in.new', 'Makefile.in'
|
74
|
-
|
75
145
|
run *CONFIGURE_CMD
|
146
|
+
run 'make', 'ruby'
|
147
|
+
run 'make', 'rubyw.exe'
|
148
|
+
run 'make', 'install'
|
76
149
|
end
|
77
150
|
end
|
78
151
|
|
79
|
-
|
80
|
-
|
152
|
+
file XCOMPILER_LOAD_PATH => XCOMPILER_RUBY
|
153
|
+
|
154
|
+
desc "Cross-compile the library for Win32 systems, installing a cross-" +
|
155
|
+
"compiled Ruby if necessary"
|
156
|
+
task :build => [ EXTDIR, XCOMPILER_LOAD_PATH.to_s ] do
|
157
|
+
in_subdirectory( EXTDIR ) do
|
158
|
+
ruby "-I#{XCOMPILER_LOAD_PATH}", 'extconf.rb'
|
159
|
+
sh 'make'
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
desc "Build a binary gem for win32 systems"
|
164
|
+
task :gem => ['win32:build', PKGDIR.to_s] + WIN32_GEMSPEC.files do
|
165
|
+
when_writing( "Creating win32 GEM" ) do
|
166
|
+
pkgname = WIN32_GEMSPEC.file_name
|
167
|
+
builder = Gem::Builder.new( WIN32_GEMSPEC )
|
168
|
+
builder.build
|
169
|
+
mv pkgname, PKGDIR + pkgname, :verbose => $trace
|
170
|
+
end
|
81
171
|
end
|
82
172
|
end
|
83
173
|
|
84
174
|
rescue LoadError => err
|
175
|
+
trace "Couldn't load the win32 tasks: %s: %s" % [ err.class.name, err.message ]
|
176
|
+
|
85
177
|
task :no_win32_build do
|
86
|
-
|
178
|
+
abort "No win32 build: %s: %s" % [ err.class.name, err.message ]
|
87
179
|
end
|
88
|
-
|
180
|
+
|
89
181
|
namespace :win32 do
|
182
|
+
desc "Build a binary Gem for Win32 systems, installing a cross " +
|
183
|
+
"compiled Ruby if necessary"
|
184
|
+
task :gem => :no_win32_build
|
90
185
|
task :build => :no_win32_build
|
91
186
|
end
|
92
|
-
|
187
|
+
|
93
188
|
end
|
94
189
|
|
190
|
+
|
data/spec/pluginfactory_spec.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
BEGIN {
|
4
4
|
require 'pathname'
|
5
5
|
basedir = Pathname.new( __FILE__ ).dirname.parent
|
6
|
-
|
6
|
+
|
7
7
|
libdir = basedir + "lib"
|
8
|
-
|
8
|
+
|
9
9
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
10
10
|
}
|
11
11
|
|
@@ -22,176 +22,164 @@ class Plugin
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
class SubPlugin < Plugin; end
|
26
|
+
class TestingPlugin < Plugin; end
|
27
|
+
class BlackSheep < Plugin; end
|
28
|
+
module Test
|
29
|
+
class LoadablePlugin < Plugin; end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
25
33
|
describe PluginFactory do
|
26
34
|
include PluginFactory::SpecHelpers
|
27
35
|
|
28
36
|
before( :each ) do
|
29
37
|
setup_logging( :fatal )
|
30
38
|
end
|
31
|
-
|
39
|
+
|
40
|
+
after( :each ) do
|
41
|
+
reset_logging()
|
42
|
+
end
|
43
|
+
|
32
44
|
|
33
45
|
it "calls its logging callback with the level and joined message if set" do
|
34
46
|
level = nil; msg = nil
|
35
47
|
PluginFactory.logger_callback = lambda {|l, m| level = l; msg = m }
|
36
48
|
PluginFactory.logger.level = Logger::DEBUG
|
37
|
-
|
49
|
+
|
38
50
|
PluginFactory.log.debug( 'message' )
|
39
51
|
level.should == :debug
|
40
52
|
msg.should == 'message'
|
41
53
|
end
|
42
|
-
|
54
|
+
|
43
55
|
it "doesn't error when its log method is called if no logging callback is set" do
|
44
56
|
PluginFactory.logger_callback = nil
|
45
57
|
lambda { PluginFactory.log.debug("msg") }.should_not raise_error()
|
46
58
|
end
|
47
59
|
|
48
|
-
end
|
49
60
|
|
61
|
+
describe "-extended class" do
|
50
62
|
|
51
|
-
|
63
|
+
it "knows about all of its derivatives" do
|
64
|
+
Plugin.derivatives.keys.should include( 'sub' )
|
65
|
+
Plugin.derivatives.keys.should include( 'subplugin' )
|
66
|
+
Plugin.derivatives.keys.should include( 'SubPlugin' )
|
67
|
+
Plugin.derivatives.keys.should include( SubPlugin )
|
68
|
+
end
|
52
69
|
|
53
|
-
|
54
|
-
|
70
|
+
it "returns derivatives directly if they're already loaded" do
|
71
|
+
class AlreadyLoadedPlugin < Plugin; end
|
72
|
+
Kernel.should_not_receive( :require )
|
73
|
+
Plugin.create( 'alreadyloaded' ).should be_an_instance_of( AlreadyLoadedPlugin )
|
74
|
+
Plugin.create( 'AlreadyLoaded' ).should be_an_instance_of( AlreadyLoadedPlugin )
|
75
|
+
Plugin.create( 'AlreadyLoadedPlugin' ).should be_an_instance_of( AlreadyLoadedPlugin )
|
76
|
+
Plugin.create( AlreadyLoadedPlugin ).should be_an_instance_of( AlreadyLoadedPlugin )
|
77
|
+
end
|
55
78
|
|
56
|
-
|
57
|
-
|
58
|
-
|
79
|
+
it "filters errors that happen when creating an instance of derivatives so they " +
|
80
|
+
"point to the right place" do
|
81
|
+
class PugilistPlugin < Plugin
|
82
|
+
def initialize
|
83
|
+
raise "Oh noes -- an error!"
|
84
|
+
end
|
85
|
+
end
|
59
86
|
|
60
|
-
|
61
|
-
|
62
|
-
|
87
|
+
begin
|
88
|
+
Plugin.create('pugilist')
|
89
|
+
rescue ::Exception => err
|
90
|
+
err.backtrace.first.should =~ /#{__FILE__}/
|
91
|
+
else
|
92
|
+
fail "Expected an exception to be raised"
|
93
|
+
end
|
94
|
+
end
|
63
95
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
it "knows about all of its derivatives" do
|
70
|
-
Plugin.derivatives.keys.should include( 'sub' )
|
71
|
-
Plugin.derivatives.keys.should include( 'subplugin' )
|
72
|
-
Plugin.derivatives.keys.should include( 'SubPlugin' )
|
73
|
-
Plugin.derivatives.keys.should include( SubPlugin )
|
74
|
-
end
|
75
|
-
|
76
|
-
it "returns derivatives directly if they're already loaded" do
|
77
|
-
class AlreadyLoadedPlugin < Plugin; end
|
78
|
-
Kernel.should_not_receive( :require )
|
79
|
-
Plugin.create( 'alreadyloaded' ).should be_an_instance_of( AlreadyLoadedPlugin )
|
80
|
-
Plugin.create( 'AlreadyLoaded' ).should be_an_instance_of( AlreadyLoadedPlugin )
|
81
|
-
Plugin.create( 'AlreadyLoadedPlugin' ).should be_an_instance_of( AlreadyLoadedPlugin )
|
82
|
-
Plugin.create( AlreadyLoadedPlugin ).should be_an_instance_of( AlreadyLoadedPlugin )
|
83
|
-
end
|
96
|
+
it "will refuse to create an object other than one of its derivatives" do
|
97
|
+
class Doppelgaenger; end
|
98
|
+
lambda { Plugin.create(Doppelgaenger) }.
|
99
|
+
should raise_error( ArgumentError, /is not a descendent of/ )
|
100
|
+
end
|
84
101
|
|
85
|
-
|
86
|
-
"
|
87
|
-
|
88
|
-
|
89
|
-
|
102
|
+
|
103
|
+
it "will load new plugins from the require path if they're not loaded yet" do
|
104
|
+
loaded_class = nil
|
105
|
+
|
106
|
+
Plugin.should_receive( :require ).with( 'plugins/dazzle_plugin' ).and_return do |*args|
|
107
|
+
loaded_class = Class.new( Plugin )
|
108
|
+
# Simulate a named class, since we're not really requiring
|
109
|
+
Plugin.derivatives['dazzle'] = loaded_class
|
110
|
+
true
|
90
111
|
end
|
112
|
+
|
113
|
+
Plugin.create( 'dazzle' ).should be_an_instance_of( loaded_class )
|
91
114
|
end
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
115
|
+
|
116
|
+
|
117
|
+
it "will output a sensible description of what it tried to load if requiring a " +
|
118
|
+
"derivative fails" do
|
119
|
+
|
120
|
+
# at least 6 -> 3 variants * 2 paths
|
121
|
+
Plugin.should_receive( :require ).
|
122
|
+
at_least(6).times.
|
123
|
+
and_return {|path| raise LoadError, "path" }
|
124
|
+
|
125
|
+
lambda { Plugin.create('scintillating') }.
|
126
|
+
should raise_error( FactoryError, /couldn't find a \S+ named \S+.*tried \[/i )
|
99
127
|
end
|
100
|
-
end
|
101
|
-
|
102
|
-
it "will refuse to create an object other than one of its derivatives" do
|
103
|
-
class Doppelgaenger; end
|
104
|
-
lambda { Plugin.create(Doppelgaenger) }.
|
105
|
-
should raise_error( ArgumentError, /is not a descendent of/ )
|
106
|
-
end
|
107
|
-
|
108
128
|
|
109
|
-
it "will load new plugins from the require path if they're not loaded yet" do
|
110
|
-
loaded_class = nil
|
111
129
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
130
|
+
it "will output a sensible description when a require succeeds, but it loads something unintended" do
|
131
|
+
# at least 6 -> 3 variants * 2 paths
|
132
|
+
Plugin.should_receive( :require ).and_return( true )
|
133
|
+
|
134
|
+
lambda { Plugin.create('corruscating') }.
|
135
|
+
should raise_error( FactoryError, /Require of '\S+' succeeded, but didn't load a Plugin/i )
|
117
136
|
end
|
118
|
-
|
119
|
-
Plugin.create( 'dazzle' ).should be_an_instance_of( loaded_class )
|
120
|
-
end
|
121
|
-
|
122
|
-
|
123
|
-
it "will output a sensible description of what it tried to load if requiring a " +
|
124
|
-
"derivative fails" do
|
125
|
-
|
126
|
-
# at least 6 -> 3 variants * 2 paths
|
127
|
-
Plugin.should_receive( :require ).
|
128
|
-
at_least(6).times.
|
129
|
-
and_return {|path| raise LoadError, "path" }
|
130
|
-
|
131
|
-
lambda { Plugin.create('scintillating') }.
|
132
|
-
should raise_error( FactoryError, /couldn't find a \S+ named \S+.*tried \[/i )
|
133
|
-
end
|
134
137
|
|
135
138
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
# at least 6 -> 3 variants * 2 paths
|
149
|
-
Plugin.should_receive( :require ).at_least(6).times.and_return {|path|
|
150
|
-
raise ScriptError, "error while parsing #{path}"
|
151
|
-
}
|
152
|
-
|
153
|
-
lambda { Plugin.create('portable') }.
|
154
|
-
should raise_error( ScriptError, /error while parsing/ )
|
139
|
+
it "will re-raise the first exception raised when attempting to load a " +
|
140
|
+
"derivative if none of the paths work" do
|
141
|
+
|
142
|
+
# at least 6 -> 3 variants * 2 paths
|
143
|
+
Plugin.should_receive( :require ).at_least(6).times.and_return {|path|
|
144
|
+
raise ScriptError, "error while parsing #{path}"
|
145
|
+
}
|
146
|
+
|
147
|
+
lambda { Plugin.create('portable') }.
|
148
|
+
should raise_error( ScriptError, /error while parsing/ )
|
149
|
+
end
|
155
150
|
end
|
156
|
-
end
|
157
151
|
|
158
152
|
|
159
|
-
|
153
|
+
describe "derivative of an extended class" do
|
160
154
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
TestingPlugin.factory_type.should == 'Plugin'
|
165
|
-
end
|
155
|
+
it "knows what type of factory loads it" do
|
156
|
+
TestingPlugin.factory_type.should == 'Plugin'
|
157
|
+
end
|
166
158
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
159
|
+
it "raises a FactoryError if it can't figure out what type of factory loads it" do
|
160
|
+
TestingPlugin.stub!( :ancestors ).and_return( [] )
|
161
|
+
lambda { TestingPlugin.factory_type }.
|
162
|
+
should raise_error( FactoryError, /couldn't find factory base/i )
|
163
|
+
end
|
171
164
|
end
|
172
|
-
end
|
173
165
|
|
174
166
|
|
175
|
-
class
|
167
|
+
describe "derivative of an extended class that isn't named <Something>Plugin" do
|
168
|
+
|
169
|
+
it "is still creatable via its full name" do
|
170
|
+
Plugin.create( 'blacksheep' ).should be_an_instance_of( BlackSheep )
|
171
|
+
end
|
176
172
|
|
177
|
-
describe "A derivative of a class extended with PluginFactory that isn't named <Something>Plugin" do
|
178
|
-
|
179
|
-
it "is still creatable via its full name" do
|
180
|
-
Plugin.create( 'blacksheep' ).should be_an_instance_of( BlackSheep )
|
181
173
|
end
|
182
|
-
|
183
|
-
end
|
184
174
|
|
185
175
|
|
186
|
-
|
187
|
-
|
188
|
-
|
176
|
+
describe "derivative of an extended class in another namespace" do
|
177
|
+
|
178
|
+
it "is still creatable via its derivative name" do
|
179
|
+
Plugin.create( 'loadable' ).should be_an_instance_of( Test::LoadablePlugin )
|
180
|
+
end
|
189
181
|
|
190
|
-
describe "A derivative of a class extended with PluginFactory in another namespace" do
|
191
|
-
|
192
|
-
it "is still creatable via its derivative name" do
|
193
|
-
Plugin.create( 'loadable' ).should be_an_instance_of( Test::LoadablePlugin )
|
194
182
|
end
|
195
|
-
|
183
|
+
|
196
184
|
end
|
197
185
|
|