aquarium 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Aquarium.ipr +253 -0
- data/Aquarium.iws +629 -0
- data/CHANGES +43 -0
- data/UPGRADE +13 -7
- data/examples/method_tracing_example_spec.rb +4 -1
- data/lib/aquarium/aspects/aspect.rb +28 -11
- data/lib/aquarium/aspects/exclusion_handler.rb +1 -1
- data/lib/aquarium/aspects/join_point.rb +58 -14
- data/lib/aquarium/aspects/pointcut.rb +5 -6
- data/lib/aquarium/extras/design_by_contract.rb +1 -1
- data/lib/aquarium/finders/method_finder.rb +1 -4
- data/lib/aquarium/finders/type_finder.rb +8 -1
- data/lib/aquarium/utils.rb +1 -0
- data/lib/aquarium/utils/default_logger.rb +20 -0
- data/lib/aquarium/utils/options_utils.rb +74 -12
- data/lib/aquarium/utils/type_utils.rb +1 -7
- data/lib/aquarium/version.rb +1 -1
- data/spec/aquarium/aspects/advice_chain_node_spec.rb +1 -1
- data/spec/aquarium/aspects/advice_spec.rb +1 -1
- data/spec/aquarium/aspects/aspect_invocation_spec.rb +1531 -1465
- data/spec/aquarium/aspects/aspect_spec.rb +22 -27
- data/spec/aquarium/aspects/aspect_with_nested_types_spec.rb +1 -1
- data/spec/aquarium/aspects/aspect_with_subtypes_spec.rb +1 -1
- data/spec/aquarium/aspects/concurrent_aspects_spec.rb +1 -1
- data/spec/aquarium/aspects/concurrent_aspects_with_objects_and_types_spec.rb +1 -1
- data/spec/aquarium/aspects/dsl/aspect_dsl_spec.rb +434 -424
- data/spec/aquarium/aspects/join_point_spec.rb +27 -4
- data/spec/aquarium/aspects/pointcut_and_composition_spec.rb +98 -102
- data/spec/aquarium/aspects/pointcut_or_composition_spec.rb +95 -107
- data/spec/aquarium/aspects/pointcut_spec.rb +1365 -1382
- data/spec/aquarium/extensions/hash_spec.rb +1 -1
- data/spec/aquarium/extensions/set_spec.rb +1 -1
- data/spec/aquarium/finders/finder_result_spec.rb +1 -1
- data/spec/aquarium/finders/method_finder_spec.rb +1 -1
- data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +63 -145
- data/spec/aquarium/{spec_example_classes.rb → spec_example_types.rb} +35 -0
- data/spec/aquarium/utils/default_logger_spec.rb +28 -0
- data/spec/aquarium/utils/hash_utils_spec.rb +1 -1
- data/spec/aquarium/utils/logic_error_spec.rb +1 -1
- data/spec/aquarium/utils/name_utils_spec.rb +1 -1
- data/spec/aquarium/utils/nil_object_spec.rb +1 -1
- data/spec/aquarium/utils/options_utils_spec.rb +122 -0
- data/spec/aquarium/utils/set_utils_spec.rb +1 -1
- metadata +9 -4
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/../
|
2
|
+
require File.dirname(__FILE__) + '/../spec_example_types'
|
3
3
|
require 'aquarium/extensions/hash'
|
4
4
|
require 'aquarium/utils/array_utils'
|
5
5
|
require 'aquarium/utils/hash_utils'
|
@@ -2,220 +2,138 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
2
|
require File.dirname(__FILE__) + '/../utils/type_utils_sample_classes'
|
3
3
|
require 'aquarium/finders/type_finder'
|
4
4
|
|
5
|
-
|
5
|
+
include Aquarium::Utils
|
6
6
|
|
7
7
|
def purge_actuals actuals
|
8
8
|
# Remove extra stuff inserted by RSpec, Aquarium, and "pretty printer" (rake?), possibly in other specs! (TODO undo those when finished...)
|
9
9
|
actuals.matched_keys.reject do |t2|
|
10
|
-
t2.name.include?("Spec::") or t2.name =~ /Aquarium::(Utils|Extras|Examples|Aspects)/
|
10
|
+
t2.name.include?("Spec::") or t2.name =~ /Aquarium::(Utils|Extras|Examples|Aspects)/ or t2.name =~ /^PP/
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
describe "#find with types, including descendents", :shared => true do
|
14
|
+
describe "#find types and their descendents, using :types_and_descendents" do
|
16
15
|
it "should find the matching types and their descendent subclasses, even in different nested modules." do
|
17
|
-
|
18
|
-
|
19
|
-
actual = Aquarium::Finders::TypeFinder.new.find option => (t.name)
|
16
|
+
TypeUtils.sample_types.each do |t|
|
17
|
+
actual = Aquarium::Finders::TypeFinder.new.find :types_and_descendents => (t.name)
|
20
18
|
actual_keys = purge_actuals actual
|
21
|
-
actual_keys.sort{|x,y| x.name <=> y.name}.should ==
|
19
|
+
actual_keys.sort{|x,y| x.name <=> y.name}.should == TypeUtils.sample_types_descendents[t].sort{|x,y| x.name <=> y.name}
|
22
20
|
actual.not_matched_keys.should == []
|
23
21
|
end
|
24
22
|
end
|
25
|
-
end
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
variant = "#{n}"
|
31
|
-
it_should_behave_like "#find with types, including descendents"
|
24
|
+
Aquarium::Finders::TypeFinder::TYPES_SYNONYMS.reject{|t| t == :types}.each do |n|
|
25
|
+
it "should accept :#{n}_and_descendents as a synonym for :types_and_descendents" do
|
26
|
+
lambda {Aquarium::Finders::TypeFinder.new.find "#{n}_and_descendents".intern => TypeUtils.sample_types, :noop => true}.should_not raise_error(InvalidOptions)
|
32
27
|
end
|
33
|
-
|
28
|
+
end
|
34
29
|
end
|
35
30
|
|
36
|
-
describe "#find
|
31
|
+
describe "#find types subtracting out excluded types and descendents, using :exclude_types_and_descendents" do
|
37
32
|
it "should find the matching types and their descendent subclasses, minus the excluded type hierarchies." do
|
38
|
-
|
39
|
-
exclude_option = "exclude_#{variant}_and_descendents".intern
|
40
|
-
actual = Aquarium::Finders::TypeFinder.new.find option => ModuleForDescendents, exclude_option => D1ForDescendents
|
33
|
+
actual = Aquarium::Finders::TypeFinder.new.find :types_and_descendents => ModuleForDescendents, :exclude_types_and_descendents => D1ForDescendents
|
41
34
|
actual_keys = purge_actuals actual
|
42
|
-
expected =
|
43
|
-
|
35
|
+
expected = TypeUtils.sample_types_descendents[ModuleForDescendents].reject do |c|
|
36
|
+
TypeUtils.sample_types_descendents[D1ForDescendents].include? c
|
44
37
|
end
|
38
|
+
actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}
|
45
39
|
actual.not_matched_keys.should == []
|
46
40
|
end
|
47
|
-
end
|
48
41
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
variant = "#{n}"
|
53
|
-
it_should_behave_like "#find with excluded types, including descendents"
|
42
|
+
Aquarium::Finders::TypeFinder::TYPES_SYNONYMS.reject{|t| t == :types}.each do |n|
|
43
|
+
it "should accept :exclude_#{n}_and_descendents as a synonym for :exclude_types_and_descendents" do
|
44
|
+
lambda {Aquarium::Finders::TypeFinder.new.find :types_and_descendents => ModuleForDescendents, "exclude_#{n}_and_descendents".intern => D1ForDescendents, :noop => true}.should_not raise_error(InvalidOptions)
|
54
45
|
end
|
55
|
-
|
46
|
+
end
|
56
47
|
end
|
57
48
|
|
58
49
|
|
59
|
-
describe "#find
|
50
|
+
describe "#find types and their ancestors, using :types_and_ancestors" do
|
60
51
|
it "should find the matching types and their ancestors, even in different nested modules." do
|
61
|
-
|
62
|
-
|
63
|
-
actual = Aquarium::Finders::TypeFinder.new.find option => (t.name)
|
52
|
+
TypeUtils.sample_types.each do |t|
|
53
|
+
actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => (t.name)
|
64
54
|
actual_keys = purge_actuals actual
|
65
|
-
actual_keys.sort{|x,y| x.name <=> y.name}.should ==
|
55
|
+
actual_keys.sort{|x,y| x.name <=> y.name}.should == TypeUtils.sample_types_ancestors[t].sort{|x,y| x.name <=> y.name}
|
66
56
|
actual.not_matched_keys.should == []
|
67
57
|
end
|
68
58
|
end
|
69
|
-
end
|
70
59
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
variant = "#{n}"
|
75
|
-
it_should_behave_like "#find with types, including ancestors"
|
60
|
+
Aquarium::Finders::TypeFinder::TYPES_SYNONYMS.reject{|t| t == :types}.each do |n|
|
61
|
+
it "should accept :#{n}_and_ancestors as a synonym for :types_and_ancestors" do
|
62
|
+
lambda {Aquarium::Finders::TypeFinder.new.find "#{n}_and_ancestors".intern => TypeUtils.sample_types, :noop => true}.should_not raise_error(InvalidOptions)
|
76
63
|
end
|
77
|
-
|
64
|
+
end
|
78
65
|
end
|
79
66
|
|
80
67
|
|
81
|
-
describe "#find
|
68
|
+
describe "#find types subtracting out excluded types and ancestors, using :exclude_types_and_ancestors" do
|
82
69
|
it "should find the matching types and their ancestors, minus the excluded types and ancestors." do
|
83
|
-
|
84
|
-
exclude_option = "exclude_#{variant}_and_ancestors".intern
|
85
|
-
actual = Aquarium::Finders::TypeFinder.new.find option => D1ForDescendents, exclude_option => ModuleForDescendents
|
70
|
+
actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => D1ForDescendents, :exclude_types_and_ancestors => ModuleForDescendents
|
86
71
|
actual_keys = purge_actuals actual
|
87
|
-
expected =
|
88
|
-
|
72
|
+
expected = TypeUtils.sample_types_ancestors[D1ForDescendents].reject do |c|
|
73
|
+
TypeUtils.sample_types_ancestors[ModuleForDescendents].include? c
|
89
74
|
end
|
75
|
+
actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}
|
90
76
|
actual.not_matched_keys.should == []
|
91
77
|
end
|
92
|
-
end
|
93
78
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
variant = "#{n}"
|
98
|
-
it_should_behave_like "#find with excluded types, including ancestors"
|
79
|
+
Aquarium::Finders::TypeFinder::TYPES_SYNONYMS.reject{|t| t == :types}.each do |n|
|
80
|
+
it "should accept :exclude_#{n}_and_ancestors as a synonym for :exclude_types_and_ancestors" do
|
81
|
+
lambda {Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => D1ForDescendents, "exclude_#{n}_and_ancestors".intern => ModuleForDescendents, :noop => true}.should_not raise_error(InvalidOptions)
|
99
82
|
end
|
100
|
-
|
83
|
+
end
|
101
84
|
end
|
102
85
|
|
103
86
|
|
104
|
-
describe "#find
|
105
|
-
it "should find the matching types
|
106
|
-
|
107
|
-
|
108
|
-
Aquarium::Utils::TypeUtils.sample_types.each do |t|
|
109
|
-
actual = Aquarium::Finders::TypeFinder.new.find aoption => (t.name), doption => (t.name)
|
87
|
+
describe "#find types and their descendents and ancestors" do
|
88
|
+
it "should find the matching types and their descendents and ancestors, even in different nested modules." do
|
89
|
+
TypeUtils.sample_types.each do |t|
|
90
|
+
actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => (t.name), :types_and_descendents => (t.name)
|
110
91
|
actual_keys = purge_actuals actual
|
111
|
-
expected =
|
92
|
+
expected = TypeUtils.sample_types_ancestors[t] + TypeUtils.sample_types_descendents[t]
|
112
93
|
actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}.uniq
|
113
94
|
actual.not_matched_keys.should == []
|
114
95
|
end
|
115
96
|
end
|
116
97
|
end
|
117
98
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
describe "#find with excluded types, including descendents and ancestors", :shared => true do
|
128
|
-
it "should find the matching types, their descendents and ancestors, minus the excluded types, descendents and ancestors." do
|
129
|
-
doption = "#{variant}_and_descendents".intern
|
130
|
-
aoption = "#{variant}_and_ancestors".intern
|
131
|
-
exclude_doption = "exclude_#{variant}_and_descendents".intern
|
132
|
-
exclude_aoption = "exclude_#{variant}_and_ancestors".intern
|
133
|
-
actual = Aquarium::Finders::TypeFinder.new.find aoption => Aquarium::ForDescendents::NestedD1ForDescendents,
|
134
|
-
doption => Aquarium::ForDescendents::NestedD1ForDescendents,
|
135
|
-
exclude_aoption => Aquarium::ForDescendents::NestedD2ForDescendents,
|
136
|
-
exclude_doption => Aquarium::ForDescendents::NestedD2ForDescendents
|
99
|
+
describe "#find types subtracting out excluded types and their descendents and ancestors" do
|
100
|
+
it "should find the matching types and their descendents and ancestors, minus the excluded types and their descendents and ancestors." do
|
101
|
+
actual = Aquarium::Finders::TypeFinder.new.find \
|
102
|
+
:types_and_ancestors => Aquarium::ForDescendents::NestedD1ForDescendents,
|
103
|
+
:types_and_descendents => Aquarium::ForDescendents::NestedD1ForDescendents,
|
104
|
+
:exclude_types_and_ancestors => Aquarium::ForDescendents::NestedD2ForDescendents,
|
105
|
+
:exclude_types_and_descendents => Aquarium::ForDescendents::NestedD2ForDescendents
|
137
106
|
actual_keys = purge_actuals actual
|
138
|
-
expected = Aquarium::
|
139
|
-
|
140
|
-
end
|
107
|
+
expected = [Aquarium::ForDescendents::NestedD1ForDescendents, Aquarium::ForDescendents::NestedD11ForDescendents, Aquarium::ForDescendents::NestedModuleForDescendents]
|
108
|
+
actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}.uniq
|
141
109
|
actual.not_matched_keys.should == []
|
142
110
|
end
|
143
111
|
end
|
144
112
|
|
145
|
-
|
146
|
-
|
147
|
-
describe Aquarium::Finders::TypeFinder, "#find with :exclude_#{n}_and_ancestors and :exclude_#{n}_and_descendents used to specify one or more names" do
|
148
|
-
variant = "#{n}"
|
149
|
-
it_should_behave_like "#find with excluded types, including descendents and ancestors"
|
150
|
-
end
|
151
|
-
EOF
|
152
|
-
end
|
153
|
-
|
154
|
-
describe "#find with regular expressions, including descendents and ancestors" do
|
155
|
-
it "should find the matching types, including their descendents and ancestors, even in different nested modules." do
|
156
|
-
doption = "types_and_descendents".intern
|
157
|
-
aoption = "types_and_ancestors".intern
|
113
|
+
describe "#find types and their descendents and ancestors, specified with regular expressions" do
|
114
|
+
it "should find the matching types and their descendents and ancestors, even in different nested modules." do
|
158
115
|
regexs = [/ForDescendents$/, /Aquarium::ForDescendents::.*ForDescendents/]
|
159
|
-
actual = Aquarium::Finders::TypeFinder.new.find
|
116
|
+
actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => regexs, :types_and_descendents => regexs
|
160
117
|
actual_keys = purge_actuals actual
|
161
|
-
expected =
|
118
|
+
expected = TypeUtils.sample_types_descendents_and_ancestors.keys + [Kernel, Object]
|
162
119
|
actual_keys.size.should == expected.size
|
163
120
|
expected.each do |t|
|
164
121
|
actual_keys.should include(t)
|
165
122
|
end
|
123
|
+
actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}
|
166
124
|
actual.not_matched_keys.should == []
|
167
125
|
end
|
168
126
|
end
|
169
127
|
|
170
|
-
describe "#find
|
171
|
-
it "should find the matching types
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
128
|
+
describe "#find types and their descendents and ancestors, subtracting out excluded types and their descendents and ancestors, specified using regular expressions" do
|
129
|
+
it "should find the matching types and their descendents and ancestors, minus the excluded types and their descendents and ancestors." do
|
130
|
+
actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => /Aquarium::ForDescendents::.*D1ForDescendents/,
|
131
|
+
:types_and_descendents => /Aquarium::ForDescendents::.*D1ForDescendents/,
|
132
|
+
:exclude_types_and_ancestors => /Aquarium::ForDescendents::.*D2ForDescendents/,
|
133
|
+
:exclude_types_and_descendents => /Aquarium::ForDescendents::.*D2ForDescendents/
|
176
134
|
actual_keys = purge_actuals actual
|
177
|
-
expected = Aquarium::
|
178
|
-
actual_keys.
|
179
|
-
expected.each do |t|
|
180
|
-
actual_keys.should include(t)
|
181
|
-
end
|
182
|
-
actual.not_matched_keys.should == []
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
%w[type types name names].each do |n|
|
187
|
-
instance_eval <<-EOF
|
188
|
-
describe Aquarium::Finders::TypeFinder, "#find regexps with :#{n}_and_ancestors and :#{n}_and_descendents used to specify one or more names" do
|
189
|
-
variant = "#{n}"
|
190
|
-
it_should_behave_like "#find with regular expressions, including descendents and ancestors"
|
191
|
-
end
|
192
|
-
EOF
|
193
|
-
end
|
194
|
-
|
195
|
-
|
196
|
-
describe "#find with excluded regular expressions, including descendents and ancestors", :shared => true do
|
197
|
-
it "should find the matching types, their descendents and ancestors, minus the excluded types, descendents and ancestors." do
|
198
|
-
doption = "#{variant}_and_descendents".intern
|
199
|
-
aoption = "#{variant}_and_ancestors".intern
|
200
|
-
exclude_doption = "exclude_#{variant}_and_descendents".intern
|
201
|
-
exclude_aoption = "exclude_#{variant}_and_ancestors".intern
|
202
|
-
actual = Aquarium::Finders::TypeFinder.new.find aoption => /Aquarium::ForDescendents::.*D1ForDescendents/,
|
203
|
-
doption => /Aquarium::ForDescendents::.*D1ForDescendents/,
|
204
|
-
exclude_aoption => /Aquarium::ForDescendents::.*D2ForDescendents/,
|
205
|
-
exclude_doption => /Aquarium::ForDescendents::.*D2ForDescendents/
|
206
|
-
actual_keys = purge_actuals actual
|
207
|
-
expected = Aquarium::Utils::TypeUtils.sample_types_ancestors[D1ForDescendents].reject do |c|
|
208
|
-
Aquarium::Utils::TypeUtils.sample_types_ancestors[ModuleForDescendents].include? c
|
209
|
-
end
|
135
|
+
expected = [Aquarium::ForDescendents::NestedD1ForDescendents, Aquarium::ForDescendents::NestedD11ForDescendents, Aquarium::ForDescendents::NestedModuleForDescendents]
|
136
|
+
actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}
|
210
137
|
actual.not_matched_keys.should == []
|
211
138
|
end
|
212
139
|
end
|
213
|
-
|
214
|
-
%w[type types name names].each do |n|
|
215
|
-
instance_eval <<-EOF
|
216
|
-
describe Aquarium::Finders::TypeFinder, "#find regexps with :exclude_#{n}_and_ancestors and :exclude_#{n}_and_descendents used to specify one or more names" do
|
217
|
-
variant = "#{n}"
|
218
|
-
it_should_behave_like "#find with excluded regular expressions, including descendents and ancestors"
|
219
|
-
end
|
220
|
-
EOF
|
221
|
-
end
|
@@ -198,4 +198,39 @@ end
|
|
198
198
|
class TestableClassIncludingTestableModule1
|
199
199
|
include TestableModule1
|
200
200
|
def instance_method1; end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Used to mock the expensive computation of descendents in some examples.
|
204
|
+
module Aquarium
|
205
|
+
module SpecExampleTypes
|
206
|
+
def descendents
|
207
|
+
{Watchful => [Watchful, WatchfulChild],
|
208
|
+
TestableModule2 => [TestableModule2, TestableModule1],
|
209
|
+
ExampleParentClass => [ExampleParentClass, ClassWithAttribs,
|
210
|
+
ClassWithPublicInstanceMethod, ClassWithPublicInstanceMethod2, ClassWithProtectedInstanceMethod,
|
211
|
+
ClassWithPrivateInstanceMethod, ClassWithPublicClassMethod, ClassWithPrivateClassMethod],
|
212
|
+
ModuleWithPublicInstanceMethod => [ModuleWithPublicInstanceMethod, ModuleIncludingModuleWithPublicInstanceMethod,
|
213
|
+
ClassIncludingModuleWithPublicInstanceMethod, ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod],
|
214
|
+
ModuleWithProtectedInstanceMethod => [ModuleWithProtectedInstanceMethod, ClassIncludingModuleWithProtectedInstanceMethod],
|
215
|
+
ModuleWithPrivateInstanceMethod => [ModuleWithPrivateInstanceMethod, ClassIncludingModuleWithPrivateInstanceMethod],
|
216
|
+
ModuleWithPublicClassMethod => [ModuleWithPublicClassMethod, ClassIncludingModuleWithPublicClassMethod],
|
217
|
+
ModuleWithPrivateClassMethod => [ModuleWithPrivateClassMethod, ClassIncludingModuleWithPrivateClassMethod],
|
218
|
+
ClassIncludingModuleWithPublicInstanceMethod => [ClassIncludingModuleWithPublicInstanceMethod, ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod],
|
219
|
+
ModuleIncludingModuleWithPublicInstanceMethod => [ModuleIncludingModuleWithPublicInstanceMethod, ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod]
|
220
|
+
}
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
module TypeUtilsStub
|
225
|
+
include SpecExampleTypes
|
226
|
+
|
227
|
+
def stub_type_utils_descendents
|
228
|
+
@stubbed_type_utils_descendents = Aspect.new :around, :calls_to => :descendents, :on_type => Aquarium::Utils::TypeUtils, :restricting_methods_to => :class_methods do |jp, object, *args|
|
229
|
+
descendents[args[0]]
|
230
|
+
end
|
231
|
+
end
|
232
|
+
def unstub_type_utils_descendents
|
233
|
+
@stubbed_type_utils_descendents.unadvise
|
234
|
+
end
|
235
|
+
end
|
201
236
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'aquarium/utils/default_logger'
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
include Aquarium::Utils
|
6
|
+
|
7
|
+
describe DefaultLogger, ".logger=" do
|
8
|
+
before :each do
|
9
|
+
@saved_logger = DefaultLogger.logger
|
10
|
+
end
|
11
|
+
after :each do
|
12
|
+
DefaultLogger.logger= @saved_logger # restore the original!
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should set the global logger." do
|
16
|
+
test_logger = Logger.new STDOUT
|
17
|
+
DefaultLogger.logger = test_logger
|
18
|
+
DefaultLogger.logger.should be_eql(test_logger)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe DefaultLogger, ".logger" do
|
23
|
+
it "should get the global logger." do
|
24
|
+
test_logger = Logger.new STDOUT
|
25
|
+
DefaultLogger.logger = test_logger
|
26
|
+
DefaultLogger.logger.should be_eql(test_logger)
|
27
|
+
end
|
28
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/../
|
2
|
+
require File.dirname(__FILE__) + '/../spec_example_types'
|
3
3
|
require 'aquarium/utils/logic_error'
|
4
4
|
|
5
5
|
# This doesn't do much..., except make rcov happy, since this exception is essentially for catching bugs.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/../
|
2
|
+
require File.dirname(__FILE__) + '/../spec_example_types'
|
3
3
|
require 'aquarium/utils/name_utils'
|
4
4
|
|
5
5
|
describe Aquarium::Utils::NameUtils, ".make_valid_attr_name_from_method_name" do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/../
|
2
|
+
require File.dirname(__FILE__) + '/../spec_example_types'
|
3
3
|
require 'aquarium/utils/nil_object'
|
4
4
|
|
5
5
|
describe Aquarium::Utils::NilObject, " (when a message is sent to it)" do
|
@@ -0,0 +1,122 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
3
|
+
require 'aquarium/utils'
|
4
|
+
|
5
|
+
include Aquarium::Utils
|
6
|
+
|
7
|
+
module Aquarium
|
8
|
+
class OptionsUtilsUser
|
9
|
+
include OptionsUtils
|
10
|
+
def initialize hash = {}
|
11
|
+
init_specification hash, {}
|
12
|
+
end
|
13
|
+
def all_allowed_option_symbols
|
14
|
+
[]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe OptionsUtils, "with no 'universal' options specified" do
|
20
|
+
it "should use the default logger." do
|
21
|
+
object = Aquarium::OptionsUtilsUser.new
|
22
|
+
object.logger.should == DefaultLogger.logger
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set noop to false." do
|
26
|
+
object = Aquarium::OptionsUtilsUser.new
|
27
|
+
object.noop.should be_false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe OptionsUtils, ":logger option" do
|
32
|
+
it "should set the object's logger to the specified logger." do
|
33
|
+
logger = Logger.new STDOUT
|
34
|
+
object = Aquarium::OptionsUtilsUser.new :logger => logger
|
35
|
+
object.logger.should == logger
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe OptionsUtils, ":severity option" do
|
40
|
+
it "should set the level on the object's logger to the :severity value." do
|
41
|
+
logger = Logger.new STDOUT
|
42
|
+
object = Aquarium::OptionsUtilsUser.new :logger => logger, :severity => Logger::Severity::WARN
|
43
|
+
object.logger.level.should == Logger::Severity::WARN
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should cause the creation of a unique logger if one was not specified." do
|
47
|
+
object = Aquarium::OptionsUtilsUser.new :severity => Logger::Severity::WARN
|
48
|
+
object.logger.should_not eql(DefaultLogger.logger)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe OptionsUtils, ":logger_stream option" do
|
53
|
+
it "should set the output stream on the object's logger to the :logger_stream value." do
|
54
|
+
stringio = StringIO.new
|
55
|
+
object = Aquarium::OptionsUtilsUser.new :logger_stream => stringio
|
56
|
+
object.logger << "message"
|
57
|
+
stringio.string.should eql("message")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should cause the creation of a unique logger if one was not specified." do
|
61
|
+
stringio = StringIO.new
|
62
|
+
object = Aquarium::OptionsUtilsUser.new :logger_stream => stringio
|
63
|
+
object.logger.should_not eql(DefaultLogger.logger)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe OptionsUtils, ":logger_stream option" do
|
68
|
+
it "should set the output stream on the object's logger to the :logger_stream value." do
|
69
|
+
logger = Logger.new STDOUT
|
70
|
+
object = Aquarium::OptionsUtilsUser.new :logger => logger, :severity => Logger::Severity::WARN
|
71
|
+
object.logger.level.should == Logger::Severity::WARN
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should cause the creation of a unique logger if one was not specified." do
|
75
|
+
object = Aquarium::OptionsUtilsUser.new :severity => Logger::Severity::WARN
|
76
|
+
object.logger.should_not eql(DefaultLogger.logger)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe OptionsUtils, "#logger" do
|
81
|
+
it "should return the logger specified with the :logger => ... option." do
|
82
|
+
logger = Logger.new STDOUT
|
83
|
+
object = Aquarium::OptionsUtilsUser.new :logger => logger
|
84
|
+
object.logger.should == logger
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return the default logger if no :logger => ... option was specified." do
|
88
|
+
logger = Logger.new STDOUT
|
89
|
+
object = Aquarium::OptionsUtilsUser.new
|
90
|
+
object.logger.should == DefaultLogger.logger
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe OptionsUtils, "#logger=" do
|
95
|
+
it "should set a new logger." do
|
96
|
+
logger1 = Logger.new STDOUT
|
97
|
+
logger2 = Logger.new STDERR
|
98
|
+
object = Aquarium::OptionsUtilsUser.new :logger => logger1
|
99
|
+
object.logger = logger2
|
100
|
+
object.logger.should == logger2
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe OptionsUtils, "#noop" do
|
105
|
+
it "should return false if :noop was not specified." do
|
106
|
+
object = Aquarium::OptionsUtilsUser.new
|
107
|
+
object.noop.should be_false
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should return the value specified with :noop." do
|
111
|
+
object = Aquarium::OptionsUtilsUser.new :noop => true
|
112
|
+
object.noop.should be_true
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe OptionsUtils, "#noop=" do
|
117
|
+
it "should set the noop value." do
|
118
|
+
object = Aquarium::OptionsUtilsUser.new :noop => true
|
119
|
+
object.noop = false
|
120
|
+
object.noop.should be_false
|
121
|
+
end
|
122
|
+
end
|