ghaki-registry 2011.11.30.1
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/LICENSE +19 -0
- data/README +23 -0
- data/VERSION +1 -0
- data/lib/ghaki/registry/app.rb +8 -0
- data/lib/ghaki/registry/engine.rb +99 -0
- data/lib/ghaki/registry/errors.rb +60 -0
- data/lib/ghaki/registry/factory.rb +65 -0
- data/lib/ghaki/registry/feature.rb +95 -0
- data/lib/ghaki/registry/plugin.rb +23 -0
- data/lib/ghaki/registry/service.rb +57 -0
- data/spec/ghaki/registry/app_spec.rb +22 -0
- data/spec/ghaki/registry/engine_spec.rb +243 -0
- data/spec/ghaki/registry/factory_spec.rb +174 -0
- data/spec/ghaki/registry/feature_spec.rb +209 -0
- data/spec/ghaki/registry/plugin_spec.rb +80 -0
- data/spec/ghaki/registry/service_spec.rb +106 -0
- data/spec/spec_helper.rb +6 -0
- metadata +113 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
############################################################################
|
2
|
+
require 'ghaki/registry/plugin'
|
3
|
+
require 'ghaki/registry/engine'
|
4
|
+
|
5
|
+
############################################################################
|
6
|
+
module Ghaki module Registry module PluginTesting
|
7
|
+
describe Ghaki::Registry::Plugin do
|
8
|
+
|
9
|
+
before(:all) do @reg = Ghaki::Registry::Engine.instance end
|
10
|
+
after(:each) do @reg.clear_features end
|
11
|
+
|
12
|
+
##########################################################################
|
13
|
+
##########################################################################
|
14
|
+
context 'with simple naming' do
|
15
|
+
|
16
|
+
########################################################################
|
17
|
+
class DogBase
|
18
|
+
extend Ghaki::Registry::Plugin
|
19
|
+
set_plugin_registry :dog
|
20
|
+
end
|
21
|
+
class DogCollie < DogBase
|
22
|
+
register_plugin :collie
|
23
|
+
end
|
24
|
+
|
25
|
+
########################################################################
|
26
|
+
context 'base object' do
|
27
|
+
subject { DogBase }
|
28
|
+
it { should respond_to :set_plugin_registry }
|
29
|
+
it { should respond_to :register_plugin }
|
30
|
+
end
|
31
|
+
|
32
|
+
########################################################################
|
33
|
+
context 'child object' do
|
34
|
+
subject { DogCollie }
|
35
|
+
it { should respond_to :set_plugin_registry }
|
36
|
+
it { should respond_to :register_plugin }
|
37
|
+
end
|
38
|
+
|
39
|
+
########################################################################
|
40
|
+
context 'methods' do
|
41
|
+
end # simple methods
|
42
|
+
|
43
|
+
end # simple
|
44
|
+
|
45
|
+
##########################################################################
|
46
|
+
##########################################################################
|
47
|
+
context 'complex' do
|
48
|
+
|
49
|
+
########################################################################
|
50
|
+
class CatBase
|
51
|
+
extend Ghaki::Registry::Plugin
|
52
|
+
set_plugin_registry :cat, :simple_naming => false
|
53
|
+
end
|
54
|
+
class CatTabby < CatBase
|
55
|
+
register_cat_plugin :tabby
|
56
|
+
end
|
57
|
+
|
58
|
+
########################################################################
|
59
|
+
context 'base object' do
|
60
|
+
subject { CatBase }
|
61
|
+
it { should respond_to :set_plugin_registry }
|
62
|
+
it { should respond_to :register_cat_plugin }
|
63
|
+
end
|
64
|
+
|
65
|
+
########################################################################
|
66
|
+
context 'child object' do
|
67
|
+
subject { CatTabby }
|
68
|
+
it { should respond_to :set_plugin_registry }
|
69
|
+
it { should respond_to :register_cat_plugin }
|
70
|
+
end
|
71
|
+
|
72
|
+
########################################################################
|
73
|
+
context 'methods' do
|
74
|
+
end # complex methods
|
75
|
+
|
76
|
+
end # complex
|
77
|
+
|
78
|
+
end
|
79
|
+
end end end
|
80
|
+
############################################################################
|
@@ -0,0 +1,106 @@
|
|
1
|
+
############################################################################
|
2
|
+
require 'ghaki/registry/errors'
|
3
|
+
require 'ghaki/registry/service'
|
4
|
+
|
5
|
+
############################################################################
|
6
|
+
module Ghaki module Registry module ServiceTesting
|
7
|
+
describe Ghaki::Registry::Service do
|
8
|
+
|
9
|
+
class TestPlugin; end
|
10
|
+
class FakeFeature; end
|
11
|
+
|
12
|
+
##########################################################################
|
13
|
+
before (:each) do
|
14
|
+
@service = Ghaki::Registry::Service.new(FakeFeature.new,:my_plugin,TestPlugin)
|
15
|
+
end
|
16
|
+
|
17
|
+
##########################################################################
|
18
|
+
subject { @service }
|
19
|
+
|
20
|
+
##########################################################################
|
21
|
+
context 'object' do
|
22
|
+
MY_METHODS = [
|
23
|
+
:enabled?, :enable, :disable, :assert_enabled!,
|
24
|
+
:to_s,
|
25
|
+
:failure, :failure=, :failed?, :assert_not_failed!,
|
26
|
+
:create, :assert_can_create!,
|
27
|
+
]
|
28
|
+
MY_METHODS.each do |token| it { should respond_to token } end
|
29
|
+
end
|
30
|
+
|
31
|
+
##########################################################################
|
32
|
+
##########################################################################
|
33
|
+
context 'initial state' do
|
34
|
+
it 'should be enabled' do
|
35
|
+
subject.enabled?.should == true
|
36
|
+
end
|
37
|
+
it 'should stringify properly as name' do
|
38
|
+
subject.to_s.should == subject.name.to_s
|
39
|
+
end
|
40
|
+
it 'should not be failed' do
|
41
|
+
subject.failure.should == nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
##########################################################################
|
46
|
+
##########################################################################
|
47
|
+
context 'methods' do
|
48
|
+
|
49
|
+
########################################################################
|
50
|
+
describe '#disable' do
|
51
|
+
it 'should disable' do
|
52
|
+
subject.disable
|
53
|
+
subject.enabled?.should == false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
########################################################################
|
58
|
+
describe '#enable' do
|
59
|
+
it 'should enable' do
|
60
|
+
subject.disable
|
61
|
+
subject.enable
|
62
|
+
subject.enabled?.should == true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
########################################################################
|
67
|
+
describe '#assert_enabled!' do
|
68
|
+
it 'should complain when disabled' do
|
69
|
+
lambda do
|
70
|
+
subject.disable
|
71
|
+
subject.assert_enabled!
|
72
|
+
end.should raise_error(Ghaki::PluginDisabledError)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def make_loader_failure
|
77
|
+
Ghaki::PluginLoadingError.new( :my_feature, :my_plugin,
|
78
|
+
'bad/mojo', RuntimeError.new('Bad Mojo') )
|
79
|
+
end
|
80
|
+
|
81
|
+
########################################################################
|
82
|
+
describe '#failed?' do
|
83
|
+
it 'should recognize failure' do
|
84
|
+
subject.failure = make_loader_failure
|
85
|
+
subject.failed?.should == true
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
########################################################################
|
90
|
+
describe '#create_plugin' do
|
91
|
+
it 'should create plugin when present' do
|
92
|
+
subject.create.should be_an_instance_of(TestPlugin)
|
93
|
+
end
|
94
|
+
it 'should complain when plugin is disabled' do
|
95
|
+
lambda do
|
96
|
+
subject.disable
|
97
|
+
subject.create
|
98
|
+
end.should raise_error(Ghaki::PluginDisabledError)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end # meths
|
103
|
+
|
104
|
+
end
|
105
|
+
end end end
|
106
|
+
############################################################################
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ghaki-registry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2011.11.30.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gerald Kalafut
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-30 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ghaki-app
|
16
|
+
requirement: &75945950 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2011.11.29.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *75945950
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &75945730 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.4.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *75945730
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: mocha
|
38
|
+
requirement: &75945500 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.9.12
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *75945500
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rdoc
|
49
|
+
requirement: &75945270 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.9.4
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *75945270
|
58
|
+
description: Ghaki Registry is a helper library for registering and loading features.
|
59
|
+
email: gerald@kalafut.org
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files:
|
63
|
+
- README
|
64
|
+
files:
|
65
|
+
- lib/ghaki/registry/engine.rb
|
66
|
+
- lib/ghaki/registry/service.rb
|
67
|
+
- lib/ghaki/registry/feature.rb
|
68
|
+
- lib/ghaki/registry/plugin.rb
|
69
|
+
- lib/ghaki/registry/factory.rb
|
70
|
+
- lib/ghaki/registry/errors.rb
|
71
|
+
- lib/ghaki/registry/app.rb
|
72
|
+
- README
|
73
|
+
- LICENSE
|
74
|
+
- VERSION
|
75
|
+
- spec/ghaki/registry/plugin_spec.rb
|
76
|
+
- spec/ghaki/registry/feature_spec.rb
|
77
|
+
- spec/ghaki/registry/app_spec.rb
|
78
|
+
- spec/ghaki/registry/service_spec.rb
|
79
|
+
- spec/ghaki/registry/factory_spec.rb
|
80
|
+
- spec/ghaki/registry/engine_spec.rb
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
homepage: http://github.com/ghaki
|
83
|
+
licenses: []
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.3.6
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project: ghaki-registry
|
102
|
+
rubygems_version: 1.8.10
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: Register and autoload packages
|
106
|
+
test_files:
|
107
|
+
- spec/ghaki/registry/plugin_spec.rb
|
108
|
+
- spec/ghaki/registry/feature_spec.rb
|
109
|
+
- spec/ghaki/registry/app_spec.rb
|
110
|
+
- spec/ghaki/registry/service_spec.rb
|
111
|
+
- spec/ghaki/registry/factory_spec.rb
|
112
|
+
- spec/ghaki/registry/engine_spec.rb
|
113
|
+
- spec/spec_helper.rb
|