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/utils/invalid_options'
|
4
4
|
require 'aquarium/extensions/hash'
|
5
5
|
require 'aquarium/aspects/join_point'
|
@@ -98,1674 +98,1657 @@ def ignored_join_point jp
|
|
98
98
|
jp.target_type.name =~ /^Spec/ or jp.target_type.name =~ /^Aquarium::(Aspects|Extras|Utils)/ or jp.target_type.name =~ /^PP/
|
99
99
|
end
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
describe Pointcut, "methods" do
|
102
|
+
include Aquarium::TypeUtilsStub
|
103
|
+
|
104
|
+
before :all do
|
105
|
+
stub_type_utils_descendents
|
105
106
|
end
|
106
|
-
|
107
|
-
|
108
|
-
describe Pointcut, ".new (empty)" do
|
109
|
-
it "should match no join points by default." do
|
110
|
-
pc = Pointcut.new
|
111
|
-
pc.should be_empty
|
107
|
+
after :all do
|
108
|
+
unstub_type_utils_descendents
|
112
109
|
end
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
110
|
+
|
111
|
+
describe Pointcut, ".new (invalid arguments)" do
|
112
|
+
it "should raise if an unknown argument is specified" do
|
113
|
+
lambda { Pointcut.new :foo => :bar }.should raise_error(Aquarium::Utils::InvalidOptions)
|
114
|
+
end
|
117
115
|
end
|
118
116
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
117
|
+
describe Pointcut, ".new (empty)" do
|
118
|
+
it "should match no join points by default." do
|
119
|
+
pc = Pointcut.new
|
120
|
+
pc.should be_empty
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should match no join points if nil is the only argument specified." do
|
124
|
+
pc = Pointcut.new nil
|
125
|
+
pc.should be_empty
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should match no join points if types = [] specified." do
|
129
|
+
pc = Pointcut.new :types => []
|
130
|
+
pc.should be_empty
|
131
|
+
end
|
123
132
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
133
|
+
it "should match no join points if types = nil specified." do
|
134
|
+
pc = Pointcut.new :types => nil
|
135
|
+
pc.should be_empty
|
136
|
+
end
|
128
137
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
138
|
+
it "should match no join points if objects = [] specified." do
|
139
|
+
pc = Pointcut.new :objects => []
|
140
|
+
pc.should be_empty
|
141
|
+
end
|
133
142
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
143
|
+
it "should match no join points if objects = nil specified." do
|
144
|
+
pc = Pointcut.new :objects => nil
|
145
|
+
pc.should be_empty
|
146
|
+
end
|
138
147
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
148
|
+
it "should match no join points if join_points = nil specified." do
|
149
|
+
pc = Pointcut.new :join_points => nil
|
150
|
+
pc.should be_empty
|
151
|
+
end
|
143
152
|
|
144
|
-
|
145
|
-
|
146
|
-
|
153
|
+
it "should match no join points if join_points = [] specified." do
|
154
|
+
pc = Pointcut.new :join_points => []
|
155
|
+
pc.should be_empty
|
156
|
+
end
|
147
157
|
end
|
148
|
-
end
|
149
158
|
|
150
|
-
describe Pointcut, ".new (classes specified using regular expressions)" do
|
151
|
-
|
152
|
-
|
153
|
-
|
159
|
+
describe Pointcut, ".new (classes specified using regular expressions)" do
|
160
|
+
before(:each) do
|
161
|
+
before_pointcut_class_spec
|
162
|
+
end
|
154
163
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
164
|
+
it "should match multiple classes using regular expressions that cover the full class names." do
|
165
|
+
pc = Pointcut.new :types => /\AClass(?!IncludingModule).*Method\Z/, :method_options => :exclude_ancestor_methods
|
166
|
+
pc.join_points_matched.should == (@expected_classes_matched_jps + [@cdcimpub_jp])
|
167
|
+
pc.join_points_not_matched.should == @expected_classes_not_matched_jps
|
168
|
+
end
|
160
169
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
170
|
+
it "should match clases using regular expressions that only cover partial class names." do
|
171
|
+
pc = Pointcut.new :types => /lass(?!IncludingModule).*Pro.*Inst.*Met/, :method_options => [:public, :protected, :exclude_ancestor_methods]
|
172
|
+
pc.join_points_matched.should == Set.new([@pro_jp])
|
173
|
+
pc.join_points_not_matched.size.should == 0
|
174
|
+
end
|
165
175
|
end
|
166
|
-
end
|
167
176
|
|
168
|
-
describe Pointcut, ".new (classes specified using names)" do
|
169
|
-
|
170
|
-
|
171
|
-
|
177
|
+
describe Pointcut, ".new (classes specified using names)" do
|
178
|
+
before(:each) do
|
179
|
+
before_pointcut_class_spec
|
180
|
+
end
|
172
181
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
182
|
+
it "should match multiple classes using names." do
|
183
|
+
pc = Pointcut.new :types => @example_classes.map {|t| t.to_s}, :method_options => :exclude_ancestor_methods
|
184
|
+
pc.join_points_matched.should == @expected_classes_matched_jps
|
185
|
+
pc.join_points_not_matched.should == @expected_classes_not_matched_jps
|
186
|
+
end
|
178
187
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
188
|
+
it "should match multiple classes using classes themselves." do
|
189
|
+
pc = Pointcut.new :types => @example_classes, :method_options => :exclude_ancestor_methods
|
190
|
+
pc.join_points_matched.should == @expected_classes_matched_jps
|
191
|
+
pc.join_points_not_matched.should == @expected_classes_not_matched_jps
|
192
|
+
end
|
184
193
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
it "should match all public instance methods for classes if :methods => :all specified." do
|
192
|
-
pc = Pointcut.new :types => @example_classes, :methods => :all, :method_options => :exclude_ancestor_methods
|
193
|
-
pc.join_points_matched.should == @expected_classes_matched_jps
|
194
|
-
pc.join_points_not_matched.should == @expected_classes_not_matched_jps
|
195
|
-
end
|
196
|
-
|
197
|
-
it "should match all public instance methods for classes if :methods => :all_methods specified." do
|
198
|
-
pc = Pointcut.new :types => @example_classes, :methods => :all_methods, :method_options => :exclude_ancestor_methods
|
199
|
-
pc.join_points_matched.should == @expected_classes_matched_jps
|
200
|
-
pc.join_points_not_matched.should == @expected_classes_not_matched_jps
|
201
|
-
end
|
194
|
+
it "should match :all public instance methods for classes by default." do
|
195
|
+
pc = Pointcut.new :types => @example_classes, :method_options => :exclude_ancestor_methods
|
196
|
+
pc.join_points_matched.should == @expected_classes_matched_jps
|
197
|
+
pc.join_points_not_matched.should == @expected_classes_not_matched_jps
|
198
|
+
end
|
202
199
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
200
|
+
it "should match all public instance methods for classes if :methods => :all specified." do
|
201
|
+
pc = Pointcut.new :types => @example_classes, :methods => :all, :method_options => :exclude_ancestor_methods
|
202
|
+
pc.join_points_matched.should == @expected_classes_matched_jps
|
203
|
+
pc.join_points_not_matched.should == @expected_classes_not_matched_jps
|
204
|
+
end
|
208
205
|
|
209
|
-
|
210
|
-
|
211
|
-
pc = Pointcut.new key.intern => @example_classes, :method_options => :exclude_ancestor_methods
|
206
|
+
it "should match all public instance methods for classes if :methods => :all_methods specified." do
|
207
|
+
pc = Pointcut.new :types => @example_classes, :methods => :all_methods, :method_options => :exclude_ancestor_methods
|
212
208
|
pc.join_points_matched.should == @expected_classes_matched_jps
|
213
209
|
pc.join_points_not_matched.should == @expected_classes_not_matched_jps
|
214
210
|
end
|
215
|
-
end
|
216
|
-
end
|
217
211
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
pc.join_points_matched.each do |jp|
|
223
|
-
[ModuleIncludingModuleWithPublicInstanceMethod, ModuleWithPublicInstanceMethod].should include(jp.target_type)
|
212
|
+
it "should support MethodFinder's :exclude_ancestor_methods option when using classes." do
|
213
|
+
pc = Pointcut.new :types => @example_classes, :method_options => :exclude_ancestor_methods
|
214
|
+
pc.join_points_matched.should == @expected_classes_matched_jps
|
215
|
+
pc.join_points_not_matched.should == @expected_classes_not_matched_jps
|
224
216
|
end
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
217
|
+
|
218
|
+
Pointcut::CANONICAL_OPTIONS["types"].each do |key|
|
219
|
+
it "should accept :#{key} as a synonym for :types." do
|
220
|
+
pc = Pointcut.new key.intern => @example_classes, :method_options => :exclude_ancestor_methods
|
221
|
+
pc.join_points_matched.should == @expected_classes_matched_jps
|
222
|
+
pc.join_points_not_matched.should == @expected_classes_not_matched_jps
|
223
|
+
end
|
229
224
|
end
|
230
225
|
end
|
231
|
-
end
|
232
226
|
|
233
|
-
describe Pointcut, ".new (modules specified using
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
227
|
+
describe Pointcut, ".new (modules specified using regular expressions)" do
|
228
|
+
it "should match multiple types using regular expressions that cover the full module names." do
|
229
|
+
pc = Pointcut.new :types => /\AModule.*Method\Z/, :method_options => :exclude_ancestor_methods
|
230
|
+
pc.join_points_matched.size.should == 2
|
231
|
+
pc.join_points_matched.each do |jp|
|
232
|
+
[ModuleIncludingModuleWithPublicInstanceMethod, ModuleWithPublicInstanceMethod].should include(jp.target_type)
|
233
|
+
end
|
234
|
+
pc.join_points_not_matched.size.should == 4
|
235
|
+
pc.join_points_not_matched.each do |jp|
|
236
|
+
[ModuleWithPrivateInstanceMethod, ModuleWithProtectedInstanceMethod,
|
237
|
+
ModuleWithPublicClassMethod, ModuleWithPrivateClassMethod].should include(jp.target_type)
|
238
|
+
end
|
245
239
|
end
|
246
240
|
end
|
241
|
+
|
242
|
+
describe Pointcut, ".new (modules specified using names)" do
|
243
|
+
def do_module type_spec
|
244
|
+
pc = Pointcut.new :types => type_spec, :method_options => :exclude_ancestor_methods
|
245
|
+
pc.join_points_matched.size.should == 1
|
246
|
+
pc.join_points_matched.each do |jp|
|
247
|
+
jp.target_type.should == ModuleWithPublicInstanceMethod
|
248
|
+
jp.method_name.should == :public_instance_module_test_method
|
249
|
+
end
|
250
|
+
pc.join_points_not_matched.size.should == 1
|
251
|
+
pc.join_points_not_matched.each do |jp|
|
252
|
+
jp.target_type.should == ModuleWithPublicClassMethod
|
253
|
+
jp.method_name.should == :all
|
254
|
+
end
|
255
|
+
end
|
247
256
|
|
248
|
-
|
249
|
-
|
250
|
-
|
257
|
+
it "should match multiple types using module names." do
|
258
|
+
do_module ["ModuleWithPublicInstanceMethod", "ModuleWithPublicClassMethod"]
|
259
|
+
end
|
251
260
|
|
252
|
-
|
253
|
-
|
254
|
-
|
261
|
+
it "should match multiple types using module-name regular expressions." do
|
262
|
+
do_module /^ModuleWithPublic.*Method/
|
263
|
+
end
|
255
264
|
|
256
|
-
|
257
|
-
|
258
|
-
|
265
|
+
it "should match multiple types using modules themselves." do
|
266
|
+
do_module [ModuleWithPublicInstanceMethod, ModuleWithPublicClassMethod]
|
267
|
+
end
|
259
268
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
it "should support MethodFinder's :exclude_ancestor_methods option when using modules." do
|
265
|
-
do_module [ModuleWithPublicInstanceMethod, ModuleWithPublicClassMethod]
|
266
|
-
end
|
267
|
-
end
|
269
|
+
it "should match :all public instance methods for modules by default." do
|
270
|
+
do_module [ModuleWithPublicInstanceMethod, ModuleWithPublicClassMethod]
|
271
|
+
end
|
268
272
|
|
269
|
-
|
270
|
-
|
271
|
-
|
273
|
+
it "should support MethodFinder's :exclude_ancestor_methods option when using modules." do
|
274
|
+
do_module [ModuleWithPublicInstanceMethod, ModuleWithPublicClassMethod]
|
275
|
+
end
|
272
276
|
end
|
273
277
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
pc.join_points_matched.each do |jp|
|
278
|
-
next if ignored_join_point(jp)
|
279
|
-
expected_types.should include(jp.target_type)
|
278
|
+
describe Pointcut, ".new (types and their ancestors and descendents)" do
|
279
|
+
before(:each) do
|
280
|
+
before_pointcut_module_spec
|
280
281
|
end
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
282
|
+
|
283
|
+
it "should match classes specified and their ancestor and descendent modules and classes." do
|
284
|
+
pc = Pointcut.new :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/, :types_and_descendents => /^Class(Including|DerivedFrom).*Method/, :methods => :all, :method_options => :exclude_ancestor_methods
|
285
|
+
expected_types = @example_modules_with_public_instance_method + [Kernel, Module, Object]
|
286
|
+
pc.join_points_matched.each do |jp|
|
287
|
+
next if ignored_join_point(jp)
|
288
|
+
expected_types.should include(jp.target_type)
|
289
|
+
end
|
290
|
+
not_expected_types = @expected_modules_not_matched_jps.map {|jp| jp.target_type}
|
291
|
+
pc.join_points_not_matched.each do |jp|
|
292
|
+
next if ignored_join_point(jp)
|
293
|
+
not_expected_types.should include(jp.target_type)
|
294
|
+
end
|
285
295
|
end
|
286
|
-
end
|
287
296
|
|
288
|
-
|
289
|
-
|
290
|
-
pc.join_points_matched.should == (@expected_modules_matched_jps + [@mimpub_jp])
|
291
|
-
pc.join_points_not_matched.should == @expected_modules_not_matched_jps
|
292
|
-
end
|
293
|
-
|
294
|
-
Aspect::CANONICAL_OPTIONS["types_and_ancestors"].each do |key|
|
295
|
-
it "should accept :#{key} as a synonym for :types_and_ancestors." do
|
296
|
-
pc = Pointcut.new key.intern => /^Module.*Method/, :types_and_descendents => /^Module.*Method/, :methods => :all, :method_options => :exclude_ancestor_methods
|
297
|
+
it "should match modules specified, their ancestor and descendent modules, and including classes." do
|
298
|
+
pc = Pointcut.new :types_and_ancestors => /^Module.*Method/, :types_and_descendents => /^Module.*Method/, :methods => :all, :method_options => :exclude_ancestor_methods
|
297
299
|
pc.join_points_matched.should == (@expected_modules_matched_jps + [@mimpub_jp])
|
298
300
|
pc.join_points_not_matched.should == @expected_modules_not_matched_jps
|
299
301
|
end
|
300
|
-
|
302
|
+
|
303
|
+
Aspect::CANONICAL_OPTIONS["types_and_ancestors"].each do |key|
|
304
|
+
it "should accept :#{key} as a synonym for :types_and_ancestors." do
|
305
|
+
lambda {Pointcut.new key.intern => /^Module.*Method/, :methods => :all, :noop => true}.should_not raise_error(Aquarium::Utils::InvalidOptions)
|
306
|
+
end
|
307
|
+
end
|
301
308
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
pc.join_points_not_matched.should == @expected_modules_not_matched_jps
|
309
|
+
Aspect::CANONICAL_OPTIONS["types_and_descendents"].each do |key|
|
310
|
+
it "should accept :#{key} as a synonym for :types_and_descendents." do
|
311
|
+
lambda {Pointcut.new key.intern => /^Module.*Method/, :methods => :all, :noop => true}.should_not raise_error(Aquarium::Utils::InvalidOptions)
|
312
|
+
end
|
307
313
|
end
|
308
314
|
end
|
309
|
-
end
|
310
315
|
|
311
|
-
describe Pointcut, ".new (objects specified)" do
|
312
|
-
|
313
|
-
|
314
|
-
|
316
|
+
describe Pointcut, ".new (objects specified)" do
|
317
|
+
before(:each) do
|
318
|
+
before_pointcut_class_spec
|
319
|
+
end
|
315
320
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
321
|
+
it "should match :all public instance methods for objects by default." do
|
322
|
+
pub, pro = ClassWithPublicInstanceMethod.new, ClassWithProtectedInstanceMethod.new
|
323
|
+
pc = Pointcut.new :objects => [pub, pro], :method_options => :exclude_ancestor_methods
|
324
|
+
pc.join_points_matched.should == Set.new([JoinPoint.new(:object => pub, :method_name => :public_instance_test_method)])
|
325
|
+
pc.join_points_not_matched.should == Set.new([JoinPoint.new(:object => pro, :method_name => :all)])
|
326
|
+
end
|
322
327
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
328
|
+
it "should support MethodFinder's :exclude_ancestor_methods option when using objects." do
|
329
|
+
pub, pro = ClassWithPublicInstanceMethod.new, ClassWithProtectedInstanceMethod.new
|
330
|
+
pc = Pointcut.new :objects => [pub, pro], :method_options => :exclude_ancestor_methods
|
331
|
+
pc.join_points_matched.should == Set.new([JoinPoint.new(:object => pub, :method_name => :public_instance_test_method)])
|
332
|
+
pc.join_points_not_matched.should == Set.new([JoinPoint.new(:object => pro, :method_name => :all)])
|
333
|
+
end
|
329
334
|
|
330
|
-
|
331
|
-
pub, pro = ClassWithPublicInstanceMethod.new, ClassWithProtectedInstanceMethod.new
|
332
|
-
pc = Pointcut.new :objects => [pub, pro], :methods => :all, :method_options => [:public, :protected, :exclude_ancestor_methods]
|
333
|
-
pc.join_points_matched.size.should == 2
|
334
|
-
pc.join_points_not_matched.size.should == 0
|
335
|
-
pc.join_points_matched.should == Set.new([
|
336
|
-
JoinPoint.new(:object => pro, :method_name => :protected_instance_test_method),
|
337
|
-
JoinPoint.new(:object => pub, :method_name => :public_instance_test_method)])
|
338
|
-
end
|
339
|
-
|
340
|
-
Aspect::CANONICAL_OPTIONS["objects"].each do |key|
|
341
|
-
it "should accept :#{key} as a synonym for :objects." do
|
335
|
+
it "should match all possible methods on the specified objects." do
|
342
336
|
pub, pro = ClassWithPublicInstanceMethod.new, ClassWithProtectedInstanceMethod.new
|
343
|
-
pc = Pointcut.new
|
337
|
+
pc = Pointcut.new :objects => [pub, pro], :methods => :all, :method_options => [:public, :protected, :exclude_ancestor_methods]
|
344
338
|
pc.join_points_matched.size.should == 2
|
345
339
|
pc.join_points_not_matched.size.should == 0
|
346
340
|
pc.join_points_matched.should == Set.new([
|
347
341
|
JoinPoint.new(:object => pro, :method_name => :protected_instance_test_method),
|
348
342
|
JoinPoint.new(:object => pub, :method_name => :public_instance_test_method)])
|
349
343
|
end
|
350
|
-
end
|
351
344
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
end
|
362
|
-
|
363
|
-
describe Pointcut, ".new (:exclude_types => types specified)" do
|
364
|
-
before(:each) do
|
365
|
-
before_exclude_spec
|
366
|
-
end
|
345
|
+
Aspect::CANONICAL_OPTIONS["objects"].each do |key|
|
346
|
+
it "should accept :#{key} as a synonym for :objects." do
|
347
|
+
pub, pro = ClassWithPublicInstanceMethod.new, ClassWithProtectedInstanceMethod.new
|
348
|
+
pc = Pointcut.new key.intern => [pub, pro], :methods => :all, :method_options => [:public, :protected, :exclude_ancestor_methods]
|
349
|
+
pc.join_points_matched.size.should == 2
|
350
|
+
pc.join_points_not_matched.size.should == 0
|
351
|
+
pc.join_points_matched.should == Set.new([
|
352
|
+
JoinPoint.new(:object => pro, :method_name => :protected_instance_test_method),
|
353
|
+
JoinPoint.new(:object => pub, :method_name => :public_instance_test_method)])
|
354
|
+
end
|
355
|
+
end
|
367
356
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
actual.should include(ExcludeTestOne)
|
373
|
-
actual.should include(ExcludeTestThree)
|
374
|
-
pc.join_points_not_matched.size.should == 0
|
375
|
-
end
|
357
|
+
it "does confuse strings specified with :objects as type names." do
|
358
|
+
string = "mystring"
|
359
|
+
lambda { Pointcut.new :object => string, :methods => :capitalize }.should raise_error(NameError)
|
360
|
+
end
|
376
361
|
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
actual.should include(ExcludeTestOne)
|
382
|
-
actual.should include(ExcludeTestThree)
|
383
|
-
pc.join_points_not_matched.size.should == 0
|
362
|
+
it "does confuse symbols specified with :objects as type names." do
|
363
|
+
symbol = :mystring
|
364
|
+
lambda { Pointcut.new :object => symbol, :methods => :capitalize }.should raise_error(NameError)
|
365
|
+
end
|
384
366
|
end
|
367
|
+
|
368
|
+
describe Pointcut, ".new (:exclude_types => types specified)" do
|
369
|
+
before(:each) do
|
370
|
+
before_exclude_spec
|
371
|
+
end
|
385
372
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
373
|
+
it "should remove from a list of explicitly-specified types the set of explicitly-specified excluded types." do
|
374
|
+
pc = Pointcut.new :types => [ExcludeTestOne, ExcludeTestTwo, ExcludeTestThree], :exclude_type => ExcludeTestTwo, :method_options => :exclude_ancestor_methods
|
375
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
376
|
+
actual.size.should == 2
|
377
|
+
actual.should include(ExcludeTestOne)
|
378
|
+
actual.should include(ExcludeTestThree)
|
379
|
+
pc.join_points_not_matched.size.should == 0
|
380
|
+
end
|
394
381
|
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
382
|
+
it "should remove from a list of explicitly-specified types the set of excluded types specified by regular expression." do
|
383
|
+
pc = Pointcut.new :types => [ExcludeTestOne, ExcludeTestTwo, ExcludeTestThree], :exclude_types => /Two$/, :method_options => :exclude_ancestor_methods
|
384
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
385
|
+
actual.size.should == 2
|
386
|
+
actual.should include(ExcludeTestOne)
|
387
|
+
actual.should include(ExcludeTestThree)
|
388
|
+
pc.join_points_not_matched.size.should == 0
|
389
|
+
end
|
403
390
|
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
391
|
+
it "should remove from a list of explicitly-specified types the set of excluded types specified by name." do
|
392
|
+
pc = Pointcut.new :types => [ExcludeTestOne, ExcludeTestTwo, ExcludeTestThree], :exclude_type => "ExcludeTestTwo", :method_options => :exclude_ancestor_methods
|
393
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
394
|
+
actual.size.should == 2
|
395
|
+
actual.should include(ExcludeTestOne)
|
396
|
+
actual.should include(ExcludeTestThree)
|
397
|
+
pc.join_points_not_matched.size.should == 0
|
398
|
+
end
|
412
399
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
400
|
+
it "should remove from the types specified by regular expression the explicitly-specified excluded types." do
|
401
|
+
pc = Pointcut.new :types => /ExcludeTest/, :exclude_type => ExcludeTestTwo, :method_options => :exclude_ancestor_methods
|
402
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
403
|
+
actual.size.should == 2
|
404
|
+
actual.should include(ExcludeTestOne)
|
405
|
+
actual.should include(ExcludeTestThree)
|
406
|
+
pc.join_points_not_matched.size.should == 0
|
407
|
+
end
|
421
408
|
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
409
|
+
it "should remove from the types specified by regular expression the excluded types specified by regular expression." do
|
410
|
+
pc = Pointcut.new :types => /ExcludeTest/, :exclude_type => /Two$/, :method_options => :exclude_ancestor_methods
|
411
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
412
|
+
actual.size.should == 2
|
413
|
+
actual.should include(ExcludeTestOne)
|
414
|
+
actual.should include(ExcludeTestThree)
|
415
|
+
pc.join_points_not_matched.size.should == 0
|
416
|
+
end
|
430
417
|
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
418
|
+
it "should remove from the types specified by regular expression the excluded types specified by name." do
|
419
|
+
pc = Pointcut.new :types => /ExcludeTest/, :exclude_type => "ExcludeTestTwo", :method_options => :exclude_ancestor_methods
|
420
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
421
|
+
actual.size.should == 2
|
422
|
+
actual.should include(ExcludeTestOne)
|
423
|
+
actual.should include(ExcludeTestThree)
|
424
|
+
pc.join_points_not_matched.size.should == 0
|
425
|
+
end
|
439
426
|
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
427
|
+
it "should remove from the join points corresponding to the excluded types, specified by name." do
|
428
|
+
pc = Pointcut.new :join_points => @all_type_jps, :exclude_type => "ExcludeTestTwo", :method_options => :exclude_ancestor_methods
|
429
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
430
|
+
actual.size.should == 2
|
431
|
+
actual.should include(ExcludeTestOne)
|
432
|
+
actual.should include(ExcludeTestThree)
|
433
|
+
pc.join_points_not_matched.size.should == 0
|
434
|
+
end
|
445
435
|
|
446
|
-
|
447
|
-
|
448
|
-
pc = Pointcut.new :types => /ExcludeTest/, key.intern => [ExcludeTestTwo, ExcludeTestThree], :method_options => :exclude_ancestor_methods
|
436
|
+
it "should remove the specified join points corresponding to the excluded types, specified by regular expression." do
|
437
|
+
pc = Pointcut.new :join_points => @all_type_jps, :exclude_type => /Exclude.*Two/, :method_options => :exclude_ancestor_methods
|
449
438
|
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
450
|
-
actual.size.should ==
|
439
|
+
actual.size.should == 2
|
451
440
|
actual.should include(ExcludeTestOne)
|
441
|
+
actual.should include(ExcludeTestThree)
|
452
442
|
pc.join_points_not_matched.size.should == 0
|
453
443
|
end
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
before_pointcut_module_spec
|
460
|
-
end
|
461
|
-
|
462
|
-
def check_module_ancestors pc
|
463
|
-
expected_types = [
|
464
|
-
ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod,
|
465
|
-
ClassIncludingModuleWithPublicInstanceMethod,
|
466
|
-
Kernel,
|
467
|
-
Object]
|
468
|
-
found_types = {}
|
469
|
-
pc.join_points_matched.each do |jp|
|
470
|
-
next if ignored_join_point(jp)
|
471
|
-
expected_types.should include(jp.target_type)
|
472
|
-
found_types[jp.target_type] = true
|
473
|
-
end
|
474
|
-
found_types.size.should == 4
|
475
|
-
not_expected_types = @expected_modules_not_matched_jps.map {|jp| jp.target_type}
|
476
|
-
pc.join_points_not_matched.each do |jp|
|
477
|
-
next if ignored_join_point(jp)
|
478
|
-
not_expected_types.should include(jp.target_type)
|
444
|
+
|
445
|
+
it "should not add excluded types to the #not_matched results." do
|
446
|
+
pc = Pointcut.new :types => /ExcludeTest/, :exclude_type => ExcludeTestTwo, :method_options => :exclude_ancestor_methods
|
447
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
448
|
+
pc.join_points_not_matched.size.should == 0
|
479
449
|
end
|
480
|
-
end
|
481
450
|
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
451
|
+
Aspect::CANONICAL_OPTIONS["exclude_types"].each do |key|
|
452
|
+
it "should accept :#{key} as a synonym for :exclude_types." do
|
453
|
+
pc = Pointcut.new :types => /ExcludeTest/, key.intern => [ExcludeTestTwo, ExcludeTestThree], :method_options => :exclude_ancestor_methods
|
454
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
455
|
+
actual.size.should == 1
|
456
|
+
actual.should include(ExcludeTestOne)
|
457
|
+
pc.join_points_not_matched.size.should == 0
|
458
|
+
end
|
459
|
+
end
|
491
460
|
end
|
492
461
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
pc.join_points_matched.each do |jp|
|
497
|
-
next if ignored_join_point(jp)
|
498
|
-
expected_types.should include(jp.target_type)
|
499
|
-
found_types[jp.target_type] = true
|
462
|
+
describe Pointcut, ".new (exclude types and their descendents and ancestors)" do
|
463
|
+
before(:each) do
|
464
|
+
before_pointcut_module_spec
|
500
465
|
end
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
466
|
+
|
467
|
+
def check_module_ancestors pc
|
468
|
+
expected_types = [
|
469
|
+
ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod,
|
470
|
+
ClassIncludingModuleWithPublicInstanceMethod,
|
471
|
+
Kernel,
|
472
|
+
Object]
|
473
|
+
found_types = {}
|
474
|
+
pc.join_points_matched.each do |jp|
|
475
|
+
next if ignored_join_point(jp)
|
476
|
+
expected_types.should include(jp.target_type)
|
477
|
+
found_types[jp.target_type] = true
|
478
|
+
end
|
479
|
+
found_types.size.should == 4
|
480
|
+
not_expected_types = @expected_modules_not_matched_jps.map {|jp| jp.target_type}
|
481
|
+
pc.join_points_not_matched.each do |jp|
|
482
|
+
next if ignored_join_point(jp)
|
483
|
+
not_expected_types.should include(jp.target_type)
|
484
|
+
end
|
506
485
|
end
|
507
|
-
end
|
508
486
|
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
end
|
514
|
-
it "should exclude join_points whose types match an excluded descendent modules." do
|
515
|
-
pc = Pointcut.new :join_point => @mpub_jp, :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
|
516
|
-
:exclude_types_and_descendents => ModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
|
517
|
-
check_module_descendents pc
|
518
|
-
end
|
519
|
-
|
520
|
-
def check_class_ancestors pc
|
521
|
-
expected_types = [ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod, ModuleIncludingModuleWithPublicInstanceMethod]
|
522
|
-
found_types = {}
|
523
|
-
pc.join_points_matched.each do |jp|
|
524
|
-
next if ignored_join_point(jp)
|
525
|
-
expected_types.should include(jp.target_type)
|
526
|
-
found_types[jp.target_type] = true
|
487
|
+
it "should exclude modules specified and their included modules when excluding ancestors." do
|
488
|
+
pc = Pointcut.new :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
|
489
|
+
:exclude_types_and_ancestors => ModuleIncludingModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
|
490
|
+
check_module_ancestors pc
|
527
491
|
end
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
492
|
+
it "should exclude join_points whose types match an excluded ancestor modules." do
|
493
|
+
pc = Pointcut.new :join_point => @mimpub_jp, :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
|
494
|
+
:exclude_types_and_ancestors => ModuleIncludingModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
|
495
|
+
check_module_ancestors pc
|
496
|
+
end
|
497
|
+
|
498
|
+
def check_module_descendents pc
|
499
|
+
expected_types = [Kernel, Object]
|
500
|
+
found_types = {}
|
501
|
+
pc.join_points_matched.each do |jp|
|
502
|
+
next if ignored_join_point(jp)
|
503
|
+
expected_types.should include(jp.target_type)
|
504
|
+
found_types[jp.target_type] = true
|
505
|
+
end
|
506
|
+
found_types.size.should == 2
|
507
|
+
not_expected_types = @expected_modules_not_matched_jps.map {|jp| jp.target_type}
|
508
|
+
pc.join_points_not_matched.each do |jp|
|
509
|
+
next if ignored_join_point(jp)
|
510
|
+
not_expected_types.should include(jp.target_type)
|
511
|
+
end
|
533
512
|
end
|
534
|
-
end
|
535
513
|
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
514
|
+
it "should exclude modules specified and their including modules and classes when excluding descendents." do
|
515
|
+
pc = Pointcut.new :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
|
516
|
+
:exclude_types_and_descendents => ModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
|
517
|
+
check_module_descendents pc
|
518
|
+
end
|
519
|
+
it "should exclude join_points whose types match an excluded descendent modules." do
|
520
|
+
pc = Pointcut.new :join_point => @mpub_jp, :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
|
521
|
+
:exclude_types_and_descendents => ModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
|
522
|
+
check_module_descendents pc
|
523
|
+
end
|
524
|
+
|
525
|
+
def check_class_ancestors pc
|
526
|
+
expected_types = [ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod, ModuleIncludingModuleWithPublicInstanceMethod]
|
527
|
+
found_types = {}
|
528
|
+
pc.join_points_matched.each do |jp|
|
529
|
+
next if ignored_join_point(jp)
|
530
|
+
expected_types.should include(jp.target_type)
|
531
|
+
found_types[jp.target_type] = true
|
532
|
+
end
|
533
|
+
found_types.size.should == 2
|
534
|
+
not_expected_types = @expected_modules_not_matched_jps.map {|jp| jp.target_type}
|
535
|
+
pc.join_points_not_matched.each do |jp|
|
536
|
+
next if ignored_join_point(jp)
|
537
|
+
not_expected_types.should include(jp.target_type)
|
538
|
+
end
|
539
|
+
end
|
546
540
|
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
next if ignored_join_point(jp)
|
552
|
-
expected_types.should include(jp.target_type)
|
553
|
-
found_types[jp.target_type] = true
|
541
|
+
it "should exclude classes specified and their included modules and ancestor classes when excluding ancestors." do
|
542
|
+
pc = Pointcut.new :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
|
543
|
+
:exclude_types_and_ancestors => ClassIncludingModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
|
544
|
+
check_class_ancestors pc
|
554
545
|
end
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
not_expected_types.should include(jp.target_type)
|
546
|
+
it "should exclude join_points whose types match an excluded ancestor classes." do
|
547
|
+
pc = Pointcut.new :join_point => @cimpub_jp, :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
|
548
|
+
:exclude_types_and_ancestors => ClassIncludingModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
|
549
|
+
check_class_ancestors pc
|
560
550
|
end
|
561
|
-
end
|
562
551
|
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
552
|
+
def check_class_descendents pc
|
553
|
+
expected_types = [Kernel, ModuleIncludingModuleWithPublicInstanceMethod, ModuleWithPublicInstanceMethod, Object]
|
554
|
+
found_types = {}
|
555
|
+
pc.join_points_matched.each do |jp|
|
556
|
+
next if ignored_join_point(jp)
|
557
|
+
expected_types.should include(jp.target_type)
|
558
|
+
found_types[jp.target_type] = true
|
559
|
+
end
|
560
|
+
found_types.size.should == 4
|
561
|
+
not_expected_types = @expected_modules_not_matched_jps.map {|jp| jp.target_type}
|
562
|
+
pc.join_points_not_matched.each do |jp|
|
563
|
+
next if ignored_join_point(jp)
|
564
|
+
not_expected_types.should include(jp.target_type)
|
565
|
+
end
|
566
|
+
end
|
574
567
|
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
568
|
+
it "should exclude classes specified and their including modules and descendent classes when excluding descendents." do
|
569
|
+
pc = Pointcut.new :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
|
570
|
+
:exclude_types_and_descendents => ClassIncludingModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
|
571
|
+
check_class_descendents pc
|
572
|
+
end
|
573
|
+
it "should exclude join_points whose types match an excluded descendent types." do
|
574
|
+
pc = Pointcut.new :join_point => @cimpub_jp, :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
|
575
|
+
:exclude_types_and_descendents => ClassIncludingModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
|
576
|
+
check_class_descendents pc
|
577
|
+
end
|
584
578
|
end
|
585
579
|
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
580
|
+
describe Pointcut, ".new (:exclude_objects => objects specified)" do
|
581
|
+
before(:each) do
|
582
|
+
@e11 = ExcludeTestOne.new
|
583
|
+
@e12 = ExcludeTestOne.new
|
584
|
+
@e21 = ExcludeTestTwo.new
|
585
|
+
@e22 = ExcludeTestTwo.new
|
586
|
+
@e31 = ExcludeTestThree.new
|
587
|
+
@e32 = ExcludeTestThree.new
|
588
|
+
@objects = [@e11, @e12, @e21, @e22, @e31, @e32]
|
589
|
+
end
|
593
590
|
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
pc.join_points_matched.size.should == 2
|
602
|
-
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
603
|
-
[@e11, @e21].each {|e| actual.should include(e)}
|
604
|
-
pc.join_points_not_matched.size.should == 0
|
605
|
-
end
|
591
|
+
it "should remove from the matched objects the excluded objects." do
|
592
|
+
pc = Pointcut.new :objects => @objects, :exclude_objects => [@e22, @e31], :method_options => :exclude_ancestor_methods
|
593
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
594
|
+
actual.size.should == 4
|
595
|
+
[@e11, @e12, @e21, @e32].each {|e| actual.should include(e)}
|
596
|
+
pc.join_points_not_matched.size.should == 0
|
597
|
+
end
|
606
598
|
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
599
|
+
it "should remove the specified join points corresponding to the excluded objects." do
|
600
|
+
jps11 = JoinPoint.new :object => @e11, :method => :method11
|
601
|
+
jps21 = JoinPoint.new :object => @e21, :method => :method21
|
602
|
+
jps22 = JoinPoint.new :object => @e22, :method => :method22
|
603
|
+
jps31 = JoinPoint.new :object => @e31, :method => :method31
|
604
|
+
jps = [jps11, jps21, jps22, jps31]
|
605
|
+
pc = Pointcut.new :join_points => jps, :exclude_objects => [@e22, @e31], :method_options => :exclude_ancestor_methods
|
606
|
+
pc.join_points_matched.size.should == 2
|
607
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
608
|
+
[@e11, @e21].each {|e| actual.should include(e)}
|
609
|
+
pc.join_points_not_matched.size.should == 0
|
610
|
+
end
|
612
611
|
|
613
|
-
|
614
|
-
|
615
|
-
pc = Pointcut.new :objects => @objects, key.intern => @e22, :method_options => :exclude_ancestor_methods
|
612
|
+
it "should not add excluded objects to the #not_matched results." do
|
613
|
+
pc = Pointcut.new :objects => @objects, :exclude_objects => [@e22, @e31], :method_options => :exclude_ancestor_methods
|
616
614
|
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
617
|
-
actual.size.should == 5
|
618
|
-
[@e11, @e12, @e21, @e31, @e32].each {|e| actual.should include(e)}
|
619
615
|
pc.join_points_not_matched.size.should == 0
|
620
616
|
end
|
621
|
-
end
|
622
|
-
end
|
623
|
-
|
624
|
-
describe Pointcut, ".new (:exclude_join_points => join_points specified)" do
|
625
|
-
before(:each) do
|
626
|
-
before_exclude_spec
|
627
|
-
end
|
628
|
-
|
629
|
-
it "should remove from a list of explicitly-specified join points the set of explicitly-specified excluded join points." do
|
630
|
-
excluded = [@jp12, @jp33, @ojp11, @ojp13, @ojp23]
|
631
|
-
expected = [@jp11, @jp13, @jp21, @jp22, @jp23, @jp31, @jp32, @ojp12, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33]
|
632
|
-
pc = Pointcut.new :join_points => @all_jps, :exclude_join_points => excluded
|
633
|
-
pc.join_points_matched.should == Set.new(expected)
|
634
|
-
pc.join_points_not_matched.size.should == 0
|
635
|
-
end
|
636
617
|
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
618
|
+
Aspect::CANONICAL_OPTIONS["exclude_objects"].each do |key|
|
619
|
+
it "should accept :#{key} as a synonym for :exclude_objects." do
|
620
|
+
pc = Pointcut.new :objects => @objects, key.intern => @e22, :method_options => :exclude_ancestor_methods
|
621
|
+
actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
|
622
|
+
actual.size.should == 5
|
623
|
+
[@e11, @e12, @e21, @e31, @e32].each {|e| actual.should include(e)}
|
624
|
+
pc.join_points_not_matched.size.should == 0
|
625
|
+
end
|
626
|
+
end
|
643
627
|
end
|
644
628
|
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
end
|
652
|
-
|
653
|
-
it "should not add excluded types to the #not_matched results." do
|
654
|
-
excluded = [@jp12, @jp33, @ojp11, @ojp13, @ojp23]
|
655
|
-
pc = Pointcut.new :join_points => @all_jps, :exclude_join_points => excluded
|
656
|
-
pc.join_points_not_matched.size.should == 0
|
657
|
-
end
|
658
|
-
|
659
|
-
Aspect::CANONICAL_OPTIONS["exclude_join_points"].each do |key|
|
660
|
-
it "should accept :#{key} as a synonym for :exclude_join_points." do
|
629
|
+
describe Pointcut, ".new (:exclude_join_points => join_points specified)" do
|
630
|
+
before(:each) do
|
631
|
+
before_exclude_spec
|
632
|
+
end
|
633
|
+
|
634
|
+
it "should remove from a list of explicitly-specified join points the set of explicitly-specified excluded join points." do
|
661
635
|
excluded = [@jp12, @jp33, @ojp11, @ojp13, @ojp23]
|
662
636
|
expected = [@jp11, @jp13, @jp21, @jp22, @jp23, @jp31, @jp32, @ojp12, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33]
|
663
|
-
pc = Pointcut.new :join_points => @all_jps,
|
637
|
+
pc = Pointcut.new :join_points => @all_jps, :exclude_join_points => excluded
|
638
|
+
pc.join_points_matched.should == Set.new(expected)
|
639
|
+
pc.join_points_not_matched.size.should == 0
|
640
|
+
end
|
641
|
+
|
642
|
+
it "should remove from the list of generated, type-based join points the set of explicitly-specified excluded join points." do
|
643
|
+
excluded = [@jp11, @jp22, @jp33]
|
644
|
+
expected = [@jp12, @jp13, @jp21, @jp23, @jp31, @jp32]
|
645
|
+
pc = Pointcut.new :types => /ExcludeTest/, :exclude_join_points => excluded, :method_options => :exclude_ancestor_methods
|
664
646
|
pc.join_points_matched.should == Set.new(expected)
|
665
647
|
pc.join_points_not_matched.size.should == 0
|
666
648
|
end
|
667
|
-
end
|
668
|
-
end
|
669
|
-
|
670
|
-
describe Pointcut, ".new (:exclude_pointcuts => pointcuts specified)" do
|
671
|
-
before(:each) do
|
672
|
-
before_exclude_spec
|
673
|
-
end
|
674
649
|
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
end
|
650
|
+
it "should remove from the list of generated, object-based join points the set of explicitly-specified excluded join points." do
|
651
|
+
excluded = [@ojp12, @ojp23, @ojp31]
|
652
|
+
expected = [@ojp11, @ojp13, @ojp21, @ojp22, @ojp32, @ojp33]
|
653
|
+
pc = Pointcut.new :objects => [@et1, @et2, @et3], :exclude_join_points => excluded, :method_options => :exclude_ancestor_methods
|
654
|
+
pc.join_points_matched.should == Set.new(expected)
|
655
|
+
pc.join_points_not_matched.size.should == 0
|
656
|
+
end
|
683
657
|
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
pc.join_points_matched.should == Set.new(expected)
|
690
|
-
pc.join_points_not_matched.size.should == 0
|
691
|
-
end
|
658
|
+
it "should not add excluded types to the #not_matched results." do
|
659
|
+
excluded = [@jp12, @jp33, @ojp11, @ojp13, @ojp23]
|
660
|
+
pc = Pointcut.new :join_points => @all_jps, :exclude_join_points => excluded
|
661
|
+
pc.join_points_not_matched.size.should == 0
|
662
|
+
end
|
692
663
|
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
664
|
+
Aspect::CANONICAL_OPTIONS["exclude_join_points"].each do |key|
|
665
|
+
it "should accept :#{key} as a synonym for :exclude_join_points." do
|
666
|
+
excluded = [@jp12, @jp33, @ojp11, @ojp13, @ojp23]
|
667
|
+
expected = [@jp11, @jp13, @jp21, @jp22, @jp23, @jp31, @jp32, @ojp12, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33]
|
668
|
+
pc = Pointcut.new :join_points => @all_jps, key.intern => excluded
|
669
|
+
pc.join_points_matched.should == Set.new(expected)
|
670
|
+
pc.join_points_not_matched.size.should == 0
|
671
|
+
end
|
672
|
+
end
|
700
673
|
end
|
674
|
+
|
675
|
+
describe Pointcut, ".new (:exclude_pointcuts => pointcuts specified)" do
|
676
|
+
before(:each) do
|
677
|
+
before_exclude_spec
|
678
|
+
end
|
679
|
+
|
680
|
+
it "should remove from a list of explicitly-specified join points the set of explicitly-specified excluded pointcuts." do
|
681
|
+
excluded_jps = [@jp12, @jp33, @ojp11, @ojp13, @ojp23]
|
682
|
+
excluded = Pointcut.new :join_points => excluded_jps
|
683
|
+
expected = [@jp11, @jp13, @jp21, @jp22, @jp23, @jp31, @jp32, @ojp12, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33]
|
684
|
+
pc = Pointcut.new :join_points => @all_jps, :exclude_pointcuts => excluded
|
685
|
+
pc.join_points_matched.should == Set.new(expected)
|
686
|
+
pc.join_points_not_matched.size.should == 0
|
687
|
+
end
|
701
688
|
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
689
|
+
it "should remove from the list of generated, type-based join points the set of explicitly-specified excluded pointcuts." do
|
690
|
+
excluded_jps = [@jp11, @jp22, @jp33]
|
691
|
+
excluded = Pointcut.new :join_points => excluded_jps
|
692
|
+
expected = [@jp12, @jp13, @jp21, @jp23, @jp31, @jp32]
|
693
|
+
pc = Pointcut.new :types => /ExcludeTest/, :exclude_pointcuts => excluded, :method_options => :exclude_ancestor_methods
|
694
|
+
pc.join_points_matched.should == Set.new(expected)
|
695
|
+
pc.join_points_not_matched.size.should == 0
|
696
|
+
end
|
708
697
|
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
698
|
+
it "should remove from the list of generated, object-based join points the set of explicitly-specified excluded pointcuts." do
|
699
|
+
excluded_jps = [@ojp12, @ojp23, @ojp31]
|
700
|
+
excluded = Pointcut.new :join_points => excluded_jps
|
701
|
+
expected = [@ojp11, @ojp13, @ojp21, @ojp22, @ojp32, @ojp33]
|
702
|
+
pc = Pointcut.new :objects => [@et1, @et2, @et3], :exclude_pointcuts => excluded, :method_options => :exclude_ancestor_methods
|
703
|
+
pc.join_points_matched.should == Set.new(expected)
|
704
|
+
pc.join_points_not_matched.size.should == 0
|
705
|
+
end
|
715
706
|
|
716
|
-
|
717
|
-
it "should accept :#{key} as a synonym for :exclude_pointcuts." do
|
707
|
+
it "should not add excluded types to the #not_matched results." do
|
718
708
|
excluded_jps = [@jp12, @jp33, @ojp11, @ojp13, @ojp23]
|
719
709
|
excluded = Pointcut.new :join_points => excluded_jps
|
720
|
-
|
721
|
-
pc
|
722
|
-
|
710
|
+
pc = Pointcut.new :join_points => @all_jps, :exclude_pointcuts => excluded
|
711
|
+
pc.join_points_not_matched.size.should == 0
|
712
|
+
end
|
713
|
+
|
714
|
+
it "should result in an empty pointcut if the join points in the :exclude_pointcuts are a superset of the matched join points." do
|
715
|
+
excluded = Pointcut.new :join_points => @all_jps
|
716
|
+
pc = Pointcut.new :join_points => @all_jps, :exclude_pointcut => excluded
|
717
|
+
pc.join_points_matched.size.should == 0
|
723
718
|
pc.join_points_not_matched.size.should == 0
|
724
719
|
end
|
720
|
+
|
721
|
+
Aspect::CANONICAL_OPTIONS["exclude_pointcuts"].each do |key|
|
722
|
+
it "should accept :#{key} as a synonym for :exclude_pointcuts." do
|
723
|
+
excluded_jps = [@jp12, @jp33, @ojp11, @ojp13, @ojp23]
|
724
|
+
excluded = Pointcut.new :join_points => excluded_jps
|
725
|
+
expected = [@jp11, @jp13, @jp21, @jp22, @jp23, @jp31, @jp32, @ojp12, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33]
|
726
|
+
pc = Pointcut.new :join_points => @all_jps, key.intern => excluded
|
727
|
+
pc.join_points_matched.should == Set.new(expected)
|
728
|
+
pc.join_points_not_matched.size.should == 0
|
729
|
+
end
|
730
|
+
end
|
725
731
|
end
|
726
|
-
end
|
727
732
|
|
728
|
-
describe Pointcut, ".new (:method_options synonyms)" do
|
729
|
-
|
730
|
-
|
733
|
+
describe Pointcut, ".new (:method_options synonyms)" do
|
734
|
+
before(:each) do
|
735
|
+
before_pointcut_class_spec
|
736
|
+
end
|
737
|
+
|
738
|
+
Aspect::CANONICAL_OPTIONS["method_options"].each do |key|
|
739
|
+
it "should accept :#{key} as a synonym for :method_options." do
|
740
|
+
pc = Pointcut.new :types => ClassWithPublicInstanceMethod, key.intern => [:public, :instance, :exclude_ancestor_methods]
|
741
|
+
pc.join_points_matched.should be_eql(Set.new([@pub_jp]))
|
742
|
+
pc.join_points_not_matched.size.should == 0
|
743
|
+
end
|
744
|
+
end
|
731
745
|
end
|
732
746
|
|
733
|
-
|
734
|
-
|
735
|
-
|
747
|
+
describe Pointcut, ".new (types or objects specified with public instance methods)" do
|
748
|
+
before(:each) do
|
749
|
+
before_pointcut_class_spec
|
750
|
+
end
|
751
|
+
|
752
|
+
it "should support MethodFinder's :public and :instance options for the specified types." do
|
753
|
+
pc = Pointcut.new :types => ClassWithPublicInstanceMethod, :method_options => [:public, :instance, :exclude_ancestor_methods]
|
736
754
|
pc.join_points_matched.should be_eql(Set.new([@pub_jp]))
|
737
755
|
pc.join_points_not_matched.size.should == 0
|
738
756
|
end
|
739
|
-
end
|
740
|
-
end
|
741
|
-
|
742
|
-
describe Pointcut, ".new (types or objects specified with public instance methods)" do
|
743
|
-
before(:each) do
|
744
|
-
before_pointcut_class_spec
|
745
|
-
end
|
746
|
-
|
747
|
-
it "should support MethodFinder's :public and :instance options for the specified types." do
|
748
|
-
pc = Pointcut.new :types => ClassWithPublicInstanceMethod, :method_options => [:public, :instance, :exclude_ancestor_methods]
|
749
|
-
pc.join_points_matched.should be_eql(Set.new([@pub_jp]))
|
750
|
-
pc.join_points_not_matched.size.should == 0
|
751
|
-
end
|
752
757
|
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
+
it "should support MethodFinder's :public and :instance options for the specified objects." do
|
759
|
+
pub = ClassWithPublicInstanceMethod.new
|
760
|
+
pc = Pointcut.new :objects => pub, :method_options => [:public, :instance, :exclude_ancestor_methods]
|
761
|
+
pc.join_points_matched.should be_eql(Set.new([JoinPoint.new(:object => pub, :method_name => :public_instance_test_method)]))
|
762
|
+
pc.join_points_not_matched.size.should == 0
|
763
|
+
end
|
758
764
|
end
|
759
|
-
end
|
760
765
|
|
761
|
-
describe Pointcut, ".new (types or objects specified with protected instance methods)" do
|
762
|
-
|
763
|
-
|
764
|
-
|
766
|
+
describe Pointcut, ".new (types or objects specified with protected instance methods)" do
|
767
|
+
before(:each) do
|
768
|
+
before_pointcut_class_spec
|
769
|
+
end
|
765
770
|
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
+
it "should support MethodFinder's :protected and :instance options for the specified types." do
|
772
|
+
pc = Pointcut.new :types => ClassWithProtectedInstanceMethod, :method_options => [:protected, :instance, :exclude_ancestor_methods]
|
773
|
+
pc.join_points_matched.should be_eql(Set.new([@pro_jp]))
|
774
|
+
pc.join_points_not_matched.size.should == 0
|
775
|
+
end
|
771
776
|
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
+
it "should support MethodFinder's :protected and :instance options for the specified objects." do
|
778
|
+
pro = ClassWithProtectedInstanceMethod.new
|
779
|
+
pc = Pointcut.new :objects => pro, :method_options => [:protected, :instance, :exclude_ancestor_methods]
|
780
|
+
pc.join_points_matched.should be_eql(Set.new([JoinPoint.new(:object => pro, :method_name => :protected_instance_test_method)]))
|
781
|
+
pc.join_points_not_matched.size.should == 0
|
782
|
+
end
|
777
783
|
end
|
778
|
-
end
|
779
784
|
|
780
|
-
describe Pointcut, ".new (types or objects specified with private instance methods)" do
|
781
|
-
|
782
|
-
|
783
|
-
|
785
|
+
describe Pointcut, ".new (types or objects specified with private instance methods)" do
|
786
|
+
before(:each) do
|
787
|
+
before_pointcut_class_spec
|
788
|
+
end
|
784
789
|
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
+
it "should support MethodFinder's :private and :instance options for the specified types." do
|
791
|
+
pc = Pointcut.new :types => ClassWithPrivateInstanceMethod, :method_options => [:private, :instance, :exclude_ancestor_methods]
|
792
|
+
pc.join_points_matched.should be_eql(Set.new([@pri_jp]))
|
793
|
+
pc.join_points_not_matched.size.should == 0
|
794
|
+
end
|
790
795
|
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
+
it "should support MethodFinder's :private and :instance options for the specified objects." do
|
797
|
+
pro = ClassWithPrivateInstanceMethod.new
|
798
|
+
pc = Pointcut.new :objects => pro, :method_options => [:private, :instance, :exclude_ancestor_methods]
|
799
|
+
pc.join_points_matched.should be_eql(Set.new([JoinPoint.new(:object => pro, :method_name => :private_instance_test_method)]))
|
800
|
+
pc.join_points_not_matched.size.should == 0
|
801
|
+
end
|
796
802
|
end
|
797
|
-
end
|
798
803
|
|
799
|
-
describe Pointcut, ".new (types or objects specified with public class methods)" do
|
800
|
-
|
801
|
-
|
802
|
-
|
804
|
+
describe Pointcut, ".new (types or objects specified with public class methods)" do
|
805
|
+
before(:each) do
|
806
|
+
before_pointcut_class_spec
|
807
|
+
end
|
803
808
|
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
+
it "should support MethodFinder's :public and :class options for the specified types." do
|
810
|
+
pc = Pointcut.new :types => ClassWithPublicClassMethod, :method_options => [:public, :class, :exclude_ancestor_methods]
|
811
|
+
pc.join_points_matched.should be_eql(Set.new([@cpub_jp]))
|
812
|
+
pc.join_points_not_matched.size.should == 0
|
813
|
+
end
|
809
814
|
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
815
|
+
it "should support MethodFinder's :public and :class options for the specified objects, which will return no methods." do
|
816
|
+
pub = ClassWithPublicInstanceMethod.new
|
817
|
+
pc = Pointcut.new :objects => pub, :method_options => [:public, :class, :exclude_ancestor_methods]
|
818
|
+
pc.join_points_matched.size.should == 0
|
819
|
+
pc.join_points_not_matched.size.should == 1
|
820
|
+
pc.join_points_not_matched.should be_eql(Set.new([JoinPoint.new(:object => pub, :method_name => :all, :class_method => true)]))
|
821
|
+
end
|
816
822
|
end
|
817
|
-
end
|
818
823
|
|
819
|
-
describe Pointcut, ".new (types or objects specified with private class methods)" do
|
820
|
-
|
821
|
-
|
822
|
-
|
824
|
+
describe Pointcut, ".new (types or objects specified with private class methods)" do
|
825
|
+
before(:each) do
|
826
|
+
before_pointcut_class_spec
|
827
|
+
end
|
823
828
|
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
+
it "should support MethodFinder's :private and :class options for the specified types." do
|
830
|
+
pc = Pointcut.new :types => ClassWithPrivateClassMethod, :method_options => [:private, :class, :exclude_ancestor_methods]
|
831
|
+
pc.join_points_matched.should be_eql(Set.new([@cpri_jp]))
|
832
|
+
pc.join_points_not_matched.size.should == 0
|
833
|
+
end
|
829
834
|
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
+
it "should support MethodFinder's :private and :class options for the specified objects, which will return no methods." do
|
836
|
+
pri = ClassWithPrivateInstanceMethod.new
|
837
|
+
pc = Pointcut.new :objects => pri, :method_options => [:private, :class, :exclude_ancestor_methods]
|
838
|
+
pc.join_points_not_matched.should be_eql(Set.new([JoinPoint.new(:object => pri, :method_name => :all, :class_method => true)]))
|
839
|
+
pc.join_points_not_matched.size.should == 1
|
840
|
+
end
|
835
841
|
end
|
836
|
-
end
|
837
842
|
|
838
|
-
describe Pointcut, ".new (types or objects specified with method regular expressions)" do
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
843
|
+
describe Pointcut, ".new (types or objects specified with method regular expressions)" do
|
844
|
+
before(:each) do
|
845
|
+
before_pointcut_class_spec
|
846
|
+
@jp_rwe = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
847
|
+
@jp_rw = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
848
|
+
@jp_we = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
849
|
+
@jp_r = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
850
|
+
@expected_for_types = Set.new([@jp_rw, @jp_rwe, @jp_r, @jp_we])
|
851
|
+
@object_of_ClassWithAttribs = ClassWithAttribs.new
|
852
|
+
@jp_rwe_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
853
|
+
@jp_rw_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
854
|
+
@jp_we_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
855
|
+
@jp_r_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
856
|
+
@expected_for_objects = Set.new([@jp_rw_o, @jp_rwe_o, @jp_r_o, @jp_we_o])
|
857
|
+
end
|
853
858
|
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
859
|
+
it "should match on public method readers and writers for type names by default." do
|
860
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :methods => [/^attr/]
|
861
|
+
pc.join_points_matched.should == @expected_for_types
|
862
|
+
end
|
858
863
|
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
864
|
+
it "should match on public method readers and writers for types by default." do
|
865
|
+
pc = Pointcut.new :types => ClassWithAttribs, :methods => [/^attr/]
|
866
|
+
pc.join_points_matched.should == @expected_for_types
|
867
|
+
end
|
863
868
|
|
864
|
-
|
865
|
-
|
866
|
-
|
869
|
+
it "should match on public method readers and writers for objects by default." do
|
870
|
+
pc = Pointcut.new :object => @object_of_ClassWithAttribs, :methods => [/^attr/]
|
871
|
+
pc.join_points_matched.should == @expected_for_objects
|
872
|
+
end
|
867
873
|
end
|
868
|
-
end
|
869
874
|
|
870
|
-
describe Pointcut, ".new (synonyms of :methods)" do
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
875
|
+
describe Pointcut, ".new (synonyms of :methods)" do
|
876
|
+
before(:each) do
|
877
|
+
before_pointcut_class_spec
|
878
|
+
@jp_rwe = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
879
|
+
@jp_rw = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
880
|
+
@jp_we = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
881
|
+
@jp_r = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
882
|
+
@expected_for_types = Set.new([@jp_rw, @jp_rwe, @jp_r, @jp_we])
|
883
|
+
@object_of_ClassWithAttribs = ClassWithAttribs.new
|
884
|
+
@jp_rwe_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
885
|
+
@jp_rw_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
886
|
+
@jp_we_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
887
|
+
@jp_r_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
888
|
+
@expected_for_objects = Set.new([@jp_rw_o, @jp_rwe_o, @jp_r_o, @jp_we_o])
|
889
|
+
end
|
890
|
+
|
891
|
+
Aspect::CANONICAL_OPTIONS["methods"].each do |key|
|
892
|
+
it "should accept :#{key} as a synonym for :methods." do
|
893
|
+
pc = Pointcut.new :types => "ClassWithAttribs", key.intern => [/^attr/]
|
894
|
+
pc.join_points_matched.should == @expected_for_types
|
895
|
+
end
|
896
|
+
end
|
884
897
|
end
|
898
|
+
|
899
|
+
describe Pointcut, ".new (:exclude_methods => methods specified)" do
|
900
|
+
before(:each) do
|
901
|
+
before_exclude_spec
|
902
|
+
end
|
885
903
|
|
886
|
-
|
887
|
-
|
888
|
-
pc
|
889
|
-
pc.join_points_matched.should == @
|
904
|
+
it "should remove type-specified JoinPoints matching the excluded methods specified by name." do
|
905
|
+
pc = Pointcut.new :types => [ExcludeTestOne, ExcludeTestTwo, ExcludeTestThree], :exclude_methods => [:method11, :method23], :method_options => :exclude_ancestor_methods
|
906
|
+
pc.join_points_matched.size.should == 7
|
907
|
+
pc.join_points_matched.should == Set.new([@jp12, @jp13, @jp21, @jp22, @jp31, @jp32, @jp33])
|
908
|
+
pc.join_points_not_matched.size.should == 0
|
890
909
|
end
|
891
|
-
end
|
892
|
-
end
|
893
|
-
|
894
|
-
describe Pointcut, ".new (:exclude_methods => methods specified)" do
|
895
|
-
before(:each) do
|
896
|
-
before_exclude_spec
|
897
|
-
end
|
898
910
|
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
911
|
+
it "should remove type-specified JoinPoints matching the excluded methods specified by regular expression." do
|
912
|
+
pc = Pointcut.new :types => [ExcludeTestOne, ExcludeTestTwo, ExcludeTestThree], :exclude_methods => /method[12][13]/, :method_options => :exclude_ancestor_methods
|
913
|
+
pc.join_points_matched.size.should == 5
|
914
|
+
pc.join_points_matched.should == Set.new([@jp12, @jp22, @jp31, @jp32, @jp33])
|
915
|
+
pc.join_points_not_matched.size.should == 0
|
916
|
+
end
|
905
917
|
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
918
|
+
it "should remove object-specified JoinPoints matching the excluded methods specified by name." do
|
919
|
+
pc = Pointcut.new :objects => [@et1, @et2, @et3], :exclude_methods => [:method11, :method23], :method_options => :exclude_ancestor_methods
|
920
|
+
pc.join_points_matched.size.should == 7
|
921
|
+
pc.join_points_matched.should == Set.new([@ojp12, @ojp13, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33])
|
922
|
+
pc.join_points_not_matched.size.should == 0
|
923
|
+
end
|
912
924
|
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
925
|
+
it "should remove object-specified JoinPoints matching the excluded methods specified by regular expression." do
|
926
|
+
pc = Pointcut.new :objects => [@et1, @et2, @et3], :exclude_methods => /method[12][13]/, :method_options => :exclude_ancestor_methods
|
927
|
+
pc.join_points_matched.size.should == 5
|
928
|
+
pc.join_points_matched.should == Set.new([@ojp12, @ojp22, @ojp31, @ojp32, @ojp33])
|
929
|
+
pc.join_points_not_matched.size.should == 0
|
930
|
+
end
|
919
931
|
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
932
|
+
it "should remove join-point-specified JoinPoints matching the excluded methods specified by name." do
|
933
|
+
pc = Pointcut.new :join_points => @all_jps, :exclude_methods => [:method11, :method23], :method_options => :exclude_ancestor_methods
|
934
|
+
pc.join_points_matched.size.should == 14
|
935
|
+
pc.join_points_matched.should == Set.new([@jp12, @jp13, @jp21, @jp22, @jp31, @jp32, @jp33, @ojp12, @ojp13, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33])
|
936
|
+
pc.join_points_not_matched.size.should == 0
|
937
|
+
end
|
926
938
|
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
939
|
+
it "should remove join-point-specified JoinPoints matching the excluded methods specified by regular expression." do
|
940
|
+
pc = Pointcut.new :join_points => @all_jps, :exclude_methods => /method[12][13]/, :method_options => :exclude_ancestor_methods
|
941
|
+
pc.join_points_matched.size.should == 10
|
942
|
+
pc.join_points_matched.should == Set.new([@jp12, @jp22, @jp31, @jp32, @jp33, @ojp12, @ojp22, @ojp31, @ojp32, @ojp33])
|
943
|
+
pc.join_points_not_matched.size.should == 0
|
944
|
+
end
|
933
945
|
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
946
|
+
Aspect::CANONICAL_OPTIONS["exclude_methods"].each do |key|
|
947
|
+
it "should accept :#{key} as a synonym for :exclude_methods." do
|
948
|
+
pc = Pointcut.new :join_points => @all_jps, key.intern => /method[12][13]/, :method_options => :exclude_ancestor_methods
|
949
|
+
pc.join_points_matched.size.should == 10
|
950
|
+
pc.join_points_matched.should == Set.new([@jp12, @jp22, @jp31, @jp32, @jp33, @ojp12, @ojp22, @ojp31, @ojp32, @ojp33])
|
951
|
+
pc.join_points_not_matched.size.should == 0
|
952
|
+
end
|
953
|
+
end
|
939
954
|
end
|
940
955
|
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
956
|
+
describe Pointcut, ".new (types or objects specified with attribute regular expressions)" do
|
957
|
+
before(:each) do
|
958
|
+
before_pointcut_class_spec
|
959
|
+
@jp_rwe = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
960
|
+
@jp_rw = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
961
|
+
@jp_we = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
962
|
+
@jp_r = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
963
|
+
@expected_for_types = Set.new([@jp_rw, @jp_rwe, @jp_r, @jp_we])
|
964
|
+
@object_of_ClassWithAttribs = ClassWithAttribs.new
|
965
|
+
@jp_rwe_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
966
|
+
@jp_rw_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
967
|
+
@jp_we_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
968
|
+
@jp_r_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
969
|
+
@expected_for_objects = Set.new([@jp_rw_o, @jp_rwe_o, @jp_r_o, @jp_we_o])
|
947
970
|
end
|
948
|
-
end
|
949
|
-
end
|
950
971
|
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
@jp_we = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
957
|
-
@jp_r = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
958
|
-
@expected_for_types = Set.new([@jp_rw, @jp_rwe, @jp_r, @jp_we])
|
959
|
-
@object_of_ClassWithAttribs = ClassWithAttribs.new
|
960
|
-
@jp_rwe_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
961
|
-
@jp_rw_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
962
|
-
@jp_we_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
963
|
-
@jp_r_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
964
|
-
@expected_for_objects = Set.new([@jp_rw_o, @jp_rwe_o, @jp_r_o, @jp_we_o])
|
965
|
-
end
|
972
|
+
it "should match on public attribute readers and writers for type names by default." do
|
973
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^attr/]
|
974
|
+
pc.join_points_matched.size.should == 4
|
975
|
+
pc.join_points_matched.should == @expected_for_types
|
976
|
+
end
|
966
977
|
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
end
|
978
|
+
it "should match on public attribute readers and writers for types by default." do
|
979
|
+
pc = Pointcut.new :types => ClassWithAttribs, :attributes => [/^attr/]
|
980
|
+
pc.join_points_matched.should == @expected_for_types
|
981
|
+
end
|
972
982
|
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
983
|
+
it "should match on public attribute readers and writers for objects by default." do
|
984
|
+
pc = Pointcut.new :object => @object_of_ClassWithAttribs, :attributes => [/^attr/]
|
985
|
+
pc.join_points_matched.should == @expected_for_objects
|
986
|
+
end
|
977
987
|
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
988
|
+
it "should match attribute specifications for types that are prefixed with @." do
|
989
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^@attr.*ClassWithAttribs/]
|
990
|
+
pc.join_points_matched.should == @expected_for_types
|
991
|
+
end
|
982
992
|
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
993
|
+
it "should match attribute specifications for objects that are prefixed with @." do
|
994
|
+
pc = Pointcut.new :object => @object_of_ClassWithAttribs, :attributes => [/^@attr.*ClassWithAttribs/]
|
995
|
+
pc.join_points_matched.should == @expected_for_objects
|
996
|
+
end
|
987
997
|
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
998
|
+
it "should match attribute specifications that are regular expressions of symbols." do
|
999
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^:attr.*ClassWithAttribs/]
|
1000
|
+
pc.join_points_matched.should == @expected_for_types
|
1001
|
+
end
|
992
1002
|
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
1003
|
+
it "should match attribute specifications for objects that are regular expressions of symbols." do
|
1004
|
+
object = ClassWithAttribs.new
|
1005
|
+
pc = Pointcut.new :object => object, :attributes => [/^:attr.*ClassWithAttribs/]
|
1006
|
+
pc.join_points_matched.should == Set.new([
|
1007
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1008
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1009
|
+
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs),
|
1010
|
+
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1011
|
+
end
|
997
1012
|
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1003
|
-
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1004
|
-
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs),
|
1005
|
-
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1006
|
-
end
|
1013
|
+
it "should match public attribute readers and writers for types when both the :readers and :writers options are specified." do
|
1014
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^attr.*ClassWithAttribs/], :attribute_options => [:readers, :writers]
|
1015
|
+
pc.join_points_matched.should == @expected_for_types
|
1016
|
+
end
|
1007
1017
|
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1018
|
+
it "should match public attribute readers and writers for objects when both the :readers and :writers options are specified." do
|
1019
|
+
object = ClassWithAttribs.new
|
1020
|
+
pc = Pointcut.new :object => object, :attributes => [/^:attr.*ClassWithAttribs/], :attribute_options => [:readers, :writers]
|
1021
|
+
pc.join_points_matched.should == Set.new([
|
1022
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1023
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1024
|
+
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs),
|
1025
|
+
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1026
|
+
end
|
1012
1027
|
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs),
|
1020
|
-
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1021
|
-
end
|
1028
|
+
it "should match public attribute readers for types only when the :readers option is specified." do
|
1029
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^attr.*ClassWithAttribs/], :attribute_options => [:readers]
|
1030
|
+
pc.join_points_matched.should == Set.new([
|
1031
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
|
1032
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
|
1033
|
+
end
|
1022
1034
|
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1035
|
+
it "should match public attribute readers for objects only when the :readers option is specified." do
|
1036
|
+
object = ClassWithAttribs.new
|
1037
|
+
pc = Pointcut.new :object => object, :attributes => [/^:attr.*ClassWithAttribs/], :attribute_options => [:readers]
|
1038
|
+
pc.join_points_matched.should == Set.new([
|
1039
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1040
|
+
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
|
1041
|
+
end
|
1029
1042
|
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
end
|
1043
|
+
it "should match public attribute writers for types only when the :writers option is specified." do
|
1044
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^attr.*ClassWithAttribs/], :attribute_options => [:writers]
|
1045
|
+
pc.join_points_matched.should == Set.new([
|
1046
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
|
1047
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
|
1048
|
+
end
|
1037
1049
|
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1050
|
+
it "should match public attribute writers for objects only when the :writers option is specified." do
|
1051
|
+
object = ClassWithAttribs.new
|
1052
|
+
pc = Pointcut.new :object => object, :attributes => [/^:attr.*ClassWithAttribs/], :attribute_options => [:writers]
|
1053
|
+
pc.join_points_matched.should == Set.new([
|
1054
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1055
|
+
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1056
|
+
end
|
1044
1057
|
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1058
|
+
it "should match attribute writers for types whether or not the attributes specification ends with an equal sign." do
|
1059
|
+
pc = Pointcut.new :types => "ClassWithAttribs",
|
1060
|
+
:attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:writers]
|
1061
|
+
pc.join_points_matched.should == Set.new([
|
1062
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
|
1063
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
|
1064
|
+
pc2 = Pointcut.new :types => "ClassWithAttribs",
|
1065
|
+
:attributes => [/^attr[RW]+_ClassWithAttribs/], :attribute_options => [:writers]
|
1066
|
+
pc2.join_points_matched.should == Set.new([
|
1067
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
|
1068
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
|
1069
|
+
end
|
1052
1070
|
|
1053
|
-
|
1054
|
-
|
1055
|
-
:attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:writers]
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
end
|
1071
|
+
it "should match attribute writers for objects whether or not the attributes specification ends with an equal sign." do
|
1072
|
+
object = ClassWithAttribs.new
|
1073
|
+
pc = Pointcut.new :object => object, :attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:writers]
|
1074
|
+
pc.join_points_matched.should == Set.new([
|
1075
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1076
|
+
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1077
|
+
pc2 = Pointcut.new :object => object, :attributes => [/^attr[RW]+_ClassWithAttribs/], :attribute_options => [:writers]
|
1078
|
+
pc2.join_points_matched.should == Set.new([
|
1079
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1080
|
+
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1081
|
+
end
|
1065
1082
|
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1083
|
+
it "should match attribute readers for types when the :readers option is specified even if the attributes specification ends with an equal sign!" do
|
1084
|
+
pc = Pointcut.new :types => "ClassWithAttribs",
|
1085
|
+
:attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:readers]
|
1086
|
+
pc.join_points_matched.should == Set.new([
|
1087
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
|
1088
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
|
1089
|
+
pc2 = Pointcut.new :types => "ClassWithAttribs",
|
1090
|
+
:attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:readers]
|
1091
|
+
pc2.join_points_matched.should == Set.new([
|
1092
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
|
1093
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
|
1094
|
+
end
|
1077
1095
|
|
1078
|
-
|
1079
|
-
|
1080
|
-
:attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:readers]
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1096
|
+
it "should match attribute readers for objects when the :readers option is specified even if the attributes specification ends with an equal sign!" do
|
1097
|
+
object = ClassWithAttribs.new
|
1098
|
+
pc = Pointcut.new :object => object, :attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:readers]
|
1099
|
+
pc.join_points_matched.should == Set.new([
|
1100
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1101
|
+
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
|
1102
|
+
pc2 = Pointcut.new :object => object, :attributes => [/^attr[RW]+_ClassWithAttribs/], :attribute_options => [:readers]
|
1103
|
+
pc2.join_points_matched.should == Set.new([
|
1104
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1105
|
+
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
|
1106
|
+
end
|
1089
1107
|
end
|
1090
|
-
|
1091
|
-
it "should match attribute readers for objects when the :readers option is specified even if the attributes specification ends with an equal sign!" do
|
1092
|
-
object = ClassWithAttribs.new
|
1093
|
-
pc = Pointcut.new :object => object, :attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:readers]
|
1094
|
-
pc.join_points_matched.should == Set.new([
|
1095
|
-
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1096
|
-
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
|
1097
|
-
pc2 = Pointcut.new :object => object, :attributes => [/^attr[RW]+_ClassWithAttribs/], :attribute_options => [:readers]
|
1098
|
-
pc2.join_points_matched.should == Set.new([
|
1099
|
-
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1100
|
-
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
|
1101
|
-
end
|
1102
|
-
end
|
1103
1108
|
|
1104
|
-
describe Pointcut, ".new (types or objects specified with :accessing regular expressions)" do
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1109
|
+
describe Pointcut, ".new (types or objects specified with :accessing regular expressions)" do
|
1110
|
+
before(:each) do
|
1111
|
+
before_pointcut_class_spec
|
1112
|
+
@jp_rwe = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
1113
|
+
@jp_rw = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
1114
|
+
@jp_we = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
1115
|
+
@jp_r = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
1116
|
+
@expected_for_types = Set.new([@jp_rw, @jp_rwe, @jp_r, @jp_we])
|
1117
|
+
@object_of_ClassWithAttribs = ClassWithAttribs.new
|
1118
|
+
@jp_rwe_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
1119
|
+
@jp_rw_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
1120
|
+
@jp_we_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
1121
|
+
@jp_r_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
1122
|
+
@expected_for_objects = Set.new([@jp_rw_o, @jp_rwe_o, @jp_r_o, @jp_we_o])
|
1123
|
+
end
|
1119
1124
|
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
+
it "should match on public attribute readers and writers for type names by default." do
|
1126
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :accessing => [/^attr/]
|
1127
|
+
pc.join_points_matched.size.should == 4
|
1128
|
+
pc.join_points_matched.should == @expected_for_types
|
1129
|
+
end
|
1125
1130
|
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1131
|
+
it "should match on public attribute readers and writers for types by default." do
|
1132
|
+
pc = Pointcut.new :types => ClassWithAttribs, :accessing => [/^attr/]
|
1133
|
+
pc.join_points_matched.should == @expected_for_types
|
1134
|
+
end
|
1130
1135
|
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1136
|
+
it "should match on public attribute readers and writers for objects by default." do
|
1137
|
+
pc = Pointcut.new :object => @object_of_ClassWithAttribs, :accessing => [/^attr/]
|
1138
|
+
pc.join_points_matched.should == @expected_for_objects
|
1139
|
+
end
|
1135
1140
|
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1141
|
+
it "should match attribute specifications for types that are prefixed with @." do
|
1142
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :accessing => [/^@attr.*ClassWithAttribs/]
|
1143
|
+
pc.join_points_matched.should == @expected_for_types
|
1144
|
+
end
|
1140
1145
|
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1146
|
+
it "should match attribute specifications for objects that are prefixed with @." do
|
1147
|
+
pc = Pointcut.new :object => @object_of_ClassWithAttribs, :accessing => [/^@attr.*ClassWithAttribs/]
|
1148
|
+
pc.join_points_matched.should == @expected_for_objects
|
1149
|
+
end
|
1145
1150
|
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1151
|
+
it "should match attribute specifications that are regular expressions of symbols." do
|
1152
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :accessing => [/^:attr.*ClassWithAttribs/]
|
1153
|
+
pc.join_points_matched.should == @expected_for_types
|
1154
|
+
end
|
1150
1155
|
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1156
|
+
it "should match attribute specifications for objects that are regular expressions of symbols." do
|
1157
|
+
object = ClassWithAttribs.new
|
1158
|
+
pc = Pointcut.new :object => object, :accessing => [/^:attr.*ClassWithAttribs/]
|
1159
|
+
pc.join_points_matched.should == Set.new([
|
1160
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1161
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1162
|
+
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs),
|
1163
|
+
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1164
|
+
end
|
1159
1165
|
end
|
1160
|
-
end
|
1161
1166
|
|
1162
|
-
describe Pointcut, ".new (types or objects specified with reading and/or writing regular expressions)" do
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1167
|
+
describe Pointcut, ".new (types or objects specified with reading and/or writing regular expressions)" do
|
1168
|
+
before(:each) do
|
1169
|
+
before_pointcut_class_spec
|
1170
|
+
@jp_rwe = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
1171
|
+
@jp_rw = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
1172
|
+
@jp_we = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
1173
|
+
@jp_r = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
1174
|
+
@expected_for_types = Set.new([@jp_rw, @jp_rwe, @jp_r, @jp_we])
|
1175
|
+
@object_of_ClassWithAttribs = ClassWithAttribs.new
|
1176
|
+
@jp_rwe_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
|
1177
|
+
@jp_rw_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
|
1178
|
+
@jp_we_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
|
1179
|
+
@jp_r_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
|
1180
|
+
@expected_for_objects = Set.new([@jp_rw_o, @jp_rwe_o, @jp_r_o, @jp_we_o])
|
1181
|
+
end
|
1177
1182
|
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1183
|
+
it "should only allow :reading and :writing options together if they specify the same attributes." do
|
1184
|
+
lambda {Pointcut.new :types => "ClassWithAttribs", :reading => [/^attrRW_ClassWithAttribs/], :writing => [/^attr.*ClassWithAttribs/]}.should raise_error(Aquarium::Utils::InvalidOptions)
|
1185
|
+
end
|
1181
1186
|
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1187
|
+
it "should match public attribute readers and writers for types when both the :reading and :writing options are specified." do
|
1188
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :reading => [/^attr.*ClassWithAttribs/], :writing => [/^attr.*ClassWithAttribs/]
|
1189
|
+
pc.join_points_matched.should == @expected_for_types
|
1190
|
+
end
|
1186
1191
|
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1192
|
+
it "should match public attribute readers and writers for types when both the :reading and :changing options are specified." do
|
1193
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :reading => [/^attr.*ClassWithAttribs/], :changing => [/^attr.*ClassWithAttribs/]
|
1194
|
+
pc.join_points_matched.should == @expected_for_types
|
1195
|
+
end
|
1191
1196
|
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1197
|
+
it "should match public attribute readers and writers for objects when both the :reading and :writing options are specified." do
|
1198
|
+
object = ClassWithAttribs.new
|
1199
|
+
pc = Pointcut.new :object => object, :reading => [/^attr.*ClassWithAttribs/], :writing => [/^attr.*ClassWithAttribs/]
|
1200
|
+
pc.join_points_matched.should == Set.new([
|
1201
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1202
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1203
|
+
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs),
|
1204
|
+
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1205
|
+
end
|
1201
1206
|
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1207
|
+
it "should match public attribute readers for types only when the :reading option is specified." do
|
1208
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :reading => [/^attr.*ClassWithAttribs/]
|
1209
|
+
pc.join_points_matched.should == Set.new([
|
1210
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
|
1211
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
|
1212
|
+
end
|
1208
1213
|
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1214
|
+
it "should match public attribute readers for objects only when the :reading option is specified." do
|
1215
|
+
object = ClassWithAttribs.new
|
1216
|
+
pc = Pointcut.new :object => object, :reading => [/^:attr.*ClassWithAttribs/]
|
1217
|
+
pc.join_points_matched.should == Set.new([
|
1218
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1219
|
+
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
|
1220
|
+
end
|
1216
1221
|
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1222
|
+
it "should match public attribute writers for types only when the :writing option is specified." do
|
1223
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :writing => [/^attr.*ClassWithAttribs/]
|
1224
|
+
pc.join_points_matched.should == Set.new([
|
1225
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
|
1226
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
|
1227
|
+
end
|
1223
1228
|
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1229
|
+
it "should match public attribute writers for objects only when the :writing option is specified." do
|
1230
|
+
object = ClassWithAttribs.new
|
1231
|
+
pc = Pointcut.new :object => object, :writing => [/^:attr.*ClassWithAttribs/]
|
1232
|
+
pc.join_points_matched.should == Set.new([
|
1233
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1234
|
+
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1235
|
+
end
|
1231
1236
|
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1237
|
+
it "should match attribute writers for types whether or not the attributes specification ends with an equal sign." do
|
1238
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :writing => [/^attr[RW]+_ClassWithAttribs=/]
|
1239
|
+
pc.join_points_matched.should == Set.new([
|
1240
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
|
1241
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
|
1242
|
+
pc2 = Pointcut.new :types => "ClassWithAttribs", :writing => [/^attr[RW]+_ClassWithAttribs/]
|
1243
|
+
pc2.join_points_matched.should == Set.new([
|
1244
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
|
1245
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
|
1246
|
+
end
|
1242
1247
|
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1248
|
+
it "should match attribute writers for objects whether or not the attributes specification ends with an equal sign." do
|
1249
|
+
object = ClassWithAttribs.new
|
1250
|
+
pc = Pointcut.new :object => object, :writing => [/^attr[RW]+_ClassWithAttribs=/]
|
1251
|
+
pc.join_points_matched.should == Set.new([
|
1252
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1253
|
+
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1254
|
+
pc2 = Pointcut.new :object => object, :writing => [/^attr[RW]+_ClassWithAttribs/]
|
1255
|
+
pc2.join_points_matched.should == Set.new([
|
1256
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
|
1257
|
+
JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
|
1258
|
+
end
|
1254
1259
|
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1260
|
+
it "should match attribute readers for types when the :reading option is specified even if the attributes specification ends with an equal sign!" do
|
1261
|
+
pc = Pointcut.new :types => "ClassWithAttribs", :reading => [/^attr[RW]+_ClassWithAttribs=/]
|
1262
|
+
pc.join_points_matched.should == Set.new([
|
1263
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
|
1264
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
|
1265
|
+
pc2 = Pointcut.new :types => "ClassWithAttribs", :reading => [/^attr[RW]+_ClassWithAttribs=/]
|
1266
|
+
pc2.join_points_matched.should == Set.new([
|
1267
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
|
1268
|
+
JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
|
1269
|
+
end
|
1265
1270
|
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
end
|
1278
|
-
|
1279
|
-
describe Pointcut, ".new (join points specified)" do
|
1280
|
-
before(:each) do
|
1281
|
-
before_pointcut_class_spec
|
1282
|
-
@anClassWithPublicInstanceMethod = ClassWithPublicInstanceMethod.new
|
1283
|
-
@expected_matched = [@pub_jp, @pro_jp, @pri_jp, @cpub_jp, @cpri_jp,
|
1284
|
-
JoinPoint.new(:object => @anClassWithPublicInstanceMethod, :method => :public_instance_test_method)]
|
1285
|
-
@expected_not_matched = [
|
1286
|
-
JoinPoint.new(:type => ClassWithPublicInstanceMethod, :method => :foo),
|
1287
|
-
JoinPoint.new(:object => @anClassWithPublicInstanceMethod, :method => :foo)]
|
1288
|
-
end
|
1289
|
-
|
1290
|
-
it "should return matches only for existing join points." do
|
1291
|
-
pc = Pointcut.new :join_points => (@expected_matched + @expected_not_matched)
|
1292
|
-
pc.join_points_matched.should == Set.new(@expected_matched)
|
1293
|
-
end
|
1294
|
-
|
1295
|
-
it "should return non-matches for non-existing join points." do
|
1296
|
-
pc = Pointcut.new :join_points => (@expected_matched + @expected_not_matched)
|
1297
|
-
pc.join_points_not_matched.should == Set.new(@expected_not_matched)
|
1298
|
-
end
|
1299
|
-
|
1300
|
-
it "should ignore :methods and :method_options for the join points specified." do
|
1301
|
-
pc = Pointcut.new :join_points => (@expected_matched + @expected_not_matched),
|
1302
|
-
:methods => :kind_of?, :method_options => [:class]
|
1303
|
-
pc.join_points_matched.should == Set.new(@expected_matched)
|
1304
|
-
pc.join_points_not_matched.should == Set.new(@expected_not_matched)
|
1305
|
-
end
|
1306
|
-
|
1307
|
-
it "should ignore :attributes and :attribute_options for the join points specified." do
|
1308
|
-
pc = Pointcut.new :join_points => (@expected_matched + @expected_not_matched),
|
1309
|
-
:attributes => :name, :attribute_options => [:readers]
|
1310
|
-
pc.join_points_matched.should == Set.new(@expected_matched)
|
1311
|
-
pc.join_points_not_matched.should == Set.new(@expected_not_matched)
|
1271
|
+
it "should match attribute readers for objects when the :reading option is specified even if the attributes specification ends with an equal sign!" do
|
1272
|
+
object = ClassWithAttribs.new
|
1273
|
+
pc = Pointcut.new :object => object, :reading => [/^attr[RW]+_ClassWithAttribs=/]
|
1274
|
+
pc.join_points_matched.should == Set.new([
|
1275
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1276
|
+
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
|
1277
|
+
pc2 = Pointcut.new :object => object, :reading => [/^attr[RW]+_ClassWithAttribs/]
|
1278
|
+
pc2.join_points_matched.should == Set.new([
|
1279
|
+
JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
|
1280
|
+
JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
|
1281
|
+
end
|
1312
1282
|
end
|
1313
1283
|
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1284
|
+
describe Pointcut, ".new (join points specified)" do
|
1285
|
+
before(:each) do
|
1286
|
+
before_pointcut_class_spec
|
1287
|
+
@anClassWithPublicInstanceMethod = ClassWithPublicInstanceMethod.new
|
1288
|
+
@expected_matched = [@pub_jp, @pro_jp, @pri_jp, @cpub_jp, @cpri_jp,
|
1289
|
+
JoinPoint.new(:object => @anClassWithPublicInstanceMethod, :method => :public_instance_test_method)]
|
1290
|
+
@expected_not_matched = [
|
1291
|
+
JoinPoint.new(:type => ClassWithPublicInstanceMethod, :method => :foo),
|
1292
|
+
JoinPoint.new(:object => @anClassWithPublicInstanceMethod, :method => :foo)]
|
1293
|
+
end
|
1321
1294
|
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
def x= other; false; end
|
1327
|
-
def == other; false; end
|
1328
|
-
def =~ other; false; end
|
1329
|
-
end
|
1330
|
-
|
1331
|
-
before(:each) do
|
1332
|
-
@funky = ClassWithFunkyMethodNames.new
|
1333
|
-
end
|
1295
|
+
it "should return matches only for existing join points." do
|
1296
|
+
pc = Pointcut.new :join_points => (@expected_matched + @expected_not_matched)
|
1297
|
+
pc.join_points_matched.should == Set.new(@expected_matched)
|
1298
|
+
end
|
1334
1299
|
|
1335
|
-
|
1336
|
-
|
1337
|
-
pc
|
1338
|
-
expected_jp = JoinPoint.new :type => ClassWithFunkyMethodNames, :method_name => method
|
1339
|
-
pc.join_points_matched.should == Set.new([expected_jp])
|
1300
|
+
it "should return non-matches for non-existing join points." do
|
1301
|
+
pc = Pointcut.new :join_points => (@expected_matched + @expected_not_matched)
|
1302
|
+
pc.join_points_not_matched.should == Set.new(@expected_not_matched)
|
1340
1303
|
end
|
1341
1304
|
|
1342
|
-
it "should
|
1343
|
-
pc = Pointcut.new :
|
1344
|
-
|
1345
|
-
pc.join_points_matched.should == Set.new(
|
1305
|
+
it "should ignore :methods and :method_options for the join points specified." do
|
1306
|
+
pc = Pointcut.new :join_points => (@expected_matched + @expected_not_matched),
|
1307
|
+
:methods => :kind_of?, :method_options => [:class]
|
1308
|
+
pc.join_points_matched.should == Set.new(@expected_matched)
|
1309
|
+
pc.join_points_not_matched.should == Set.new(@expected_not_matched)
|
1346
1310
|
end
|
1347
1311
|
|
1348
|
-
it "should
|
1349
|
-
pc = Pointcut.new :
|
1350
|
-
|
1351
|
-
pc.join_points_matched.should == Set.new(
|
1312
|
+
it "should ignore :attributes and :attribute_options for the join points specified." do
|
1313
|
+
pc = Pointcut.new :join_points => (@expected_matched + @expected_not_matched),
|
1314
|
+
:attributes => :name, :attribute_options => [:readers]
|
1315
|
+
pc.join_points_matched.should == Set.new(@expected_matched)
|
1316
|
+
pc.join_points_not_matched.should == Set.new(@expected_not_matched)
|
1352
1317
|
end
|
1353
1318
|
|
1354
|
-
it "should
|
1355
|
-
pc = Pointcut.new :
|
1356
|
-
|
1357
|
-
pc.join_points_matched.should == Set.new(
|
1319
|
+
it "should ignore :accessing, :reading, and :writing for the join points specified." do
|
1320
|
+
pc = Pointcut.new :join_points => (@expected_matched + @expected_not_matched),
|
1321
|
+
:accessing => :name, :reading => :name, :writing => :name
|
1322
|
+
pc.join_points_matched.should == Set.new(@expected_matched)
|
1323
|
+
pc.join_points_not_matched.should == Set.new(@expected_not_matched)
|
1358
1324
|
end
|
1359
1325
|
end
|
1360
1326
|
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1327
|
+
describe Pointcut, ".new (methods that end in non-alphanumeric characters)" do
|
1328
|
+
class ClassWithFunkyMethodNames
|
1329
|
+
def huh?; true; end
|
1330
|
+
def yes!; true; end
|
1331
|
+
def x= other; false; end
|
1332
|
+
def == other; false; end
|
1333
|
+
def =~ other; false; end
|
1366
1334
|
end
|
1367
1335
|
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1336
|
+
before(:each) do
|
1337
|
+
@funky = ClassWithFunkyMethodNames.new
|
1338
|
+
end
|
1339
|
+
|
1340
|
+
{'?' => :huh?, '!' => :yes!, '=' => :x=}.each do |char, method|
|
1341
|
+
it "should match instance methods for types when searching for names that end with a '#{char}' character." do
|
1342
|
+
pc = Pointcut.new :types => ClassWithFunkyMethodNames, :method => method, :method_options => [:exclude_ancestor_methods]
|
1343
|
+
expected_jp = JoinPoint.new :type => ClassWithFunkyMethodNames, :method_name => method
|
1344
|
+
pc.join_points_matched.should == Set.new([expected_jp])
|
1345
|
+
end
|
1346
|
+
|
1347
|
+
it "should match instance methods for objects when searching for names that end with a '#{char}' character." do
|
1348
|
+
pc = Pointcut.new :object => @funky, :method => method, :method_options => [:exclude_ancestor_methods]
|
1349
|
+
expected_jp = JoinPoint.new :object => @funky, :method_name => method
|
1350
|
+
pc.join_points_matched.should == Set.new([expected_jp])
|
1351
|
+
end
|
1352
|
+
|
1353
|
+
it "should match instance methods for types when searching for names that end with a '#{char}' character, using a regular expressions." do
|
1354
|
+
pc = Pointcut.new :types => ClassWithFunkyMethodNames, :methods => /#{Regexp.escape(char)}$/, :method_options => [:exclude_ancestor_methods]
|
1355
|
+
expected_jp = JoinPoint.new :type => ClassWithFunkyMethodNames, :method_name => method
|
1356
|
+
pc.join_points_matched.should == Set.new([expected_jp])
|
1357
|
+
end
|
1373
1358
|
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1359
|
+
it "should match instance methods for object when searching for names that end with a '#{char}' character, using a regular expressions." do
|
1360
|
+
pc = Pointcut.new :object => @funky, :methods => /#{Regexp.escape(char)}$/, :method_options => [:exclude_ancestor_methods]
|
1361
|
+
expected_jp = JoinPoint.new :object => @funky, :method_name => method
|
1362
|
+
pc.join_points_matched.should == Set.new([expected_jp])
|
1363
|
+
end
|
1377
1364
|
end
|
1378
1365
|
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1366
|
+
{'=' => :==, '~' => :=~}.each do |char, method|
|
1367
|
+
it "should match the #{method} instance method for types, if you don't suppress ancestor methods, even if the method is defined in the class!" do
|
1368
|
+
pc = Pointcut.new :types => ClassWithFunkyMethodNames, :method => method, :method_options => [:instance]
|
1369
|
+
expected_jp = JoinPoint.new :type => ClassWithFunkyMethodNames, :method_name => method
|
1370
|
+
pc.join_points_matched.should == Set.new([expected_jp])
|
1371
|
+
end
|
1372
|
+
|
1373
|
+
it "should match the #{method} instance method for objects, if you don't suppress ancestor methods, even if the method is defined in the class!" do
|
1374
|
+
pc = Pointcut.new :object => @funky, :method => method, :method_options => [:instance]
|
1375
|
+
expected_jp = JoinPoint.new :object => @funky, :method_name => method
|
1376
|
+
pc.join_points_matched.should == Set.new([expected_jp])
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
it "should match the #{method} instance method for types when using a regular expressions, if you don't suppress ancestor methods, even if the method is defined in the class!" do
|
1380
|
+
pc = Pointcut.new :types => ClassWithFunkyMethodNames, :methods => /#{Regexp.escape(char)}$/, :method_options => [:instance]
|
1381
|
+
pc.join_points_matched.any? {|jp| jp.method_name == method}.should be_true
|
1382
|
+
end
|
1383
|
+
|
1384
|
+
it "should match the #{method} instance method for objects when using a regular expressions, if you don't suppress ancestor methods, even if the method is defined in the class!" do
|
1385
|
+
pc = Pointcut.new :object => @funky, :methods => /#{Regexp.escape(char)}$/, :method_options => [:instance]
|
1386
|
+
pc.join_points_matched.any? {|jp| jp.method_name == method}.should be_true
|
1387
|
+
end
|
1382
1388
|
end
|
1383
1389
|
end
|
1384
|
-
end
|
1385
1390
|
|
1386
|
-
describe Pointcut, ".new (:attributes => :all option not yet supported)" do
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1391
|
+
describe Pointcut, ".new (:attributes => :all option not yet supported)" do
|
1392
|
+
it "should raise if :all is used for types (not yet supported)." do
|
1393
|
+
lambda { Pointcut.new :types => "ClassWithAttribs", :attributes => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
|
1394
|
+
end
|
1390
1395
|
|
1391
|
-
|
1392
|
-
|
1396
|
+
it "should raise if :all is used for objects (not yet supported)." do
|
1397
|
+
lambda { Pointcut.new :object => ClassWithAttribs.new, :attributes => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
|
1398
|
+
end
|
1393
1399
|
end
|
1394
|
-
end
|
1395
1400
|
|
1396
|
-
describe Pointcut, ".new (:accessing => :all option not yet supported)" do
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1401
|
+
describe Pointcut, ".new (:accessing => :all option not yet supported)" do
|
1402
|
+
it "should raise if :all is used for types (not yet supported)." do
|
1403
|
+
lambda { Pointcut.new :types => "ClassWithAttribs", :accessing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
|
1404
|
+
end
|
1400
1405
|
|
1401
|
-
|
1402
|
-
|
1406
|
+
it "should raise if :all is used for objects (not yet supported)." do
|
1407
|
+
lambda { Pointcut.new :object => ClassWithAttribs.new, :accessing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
|
1408
|
+
end
|
1403
1409
|
end
|
1404
|
-
end
|
1405
1410
|
|
1406
|
-
describe Pointcut, ".new (:changing => :all option not yet supported)" do
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1411
|
+
describe Pointcut, ".new (:changing => :all option not yet supported)" do
|
1412
|
+
it "should raise if :all is used for types (not yet supported)." do
|
1413
|
+
lambda { Pointcut.new :types => "ClassWithAttribs", :changing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
|
1414
|
+
end
|
1410
1415
|
|
1411
|
-
|
1412
|
-
|
1416
|
+
it "should raise if :all is used for objects (not yet supported)." do
|
1417
|
+
lambda { Pointcut.new :object => ClassWithAttribs.new, :changing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
|
1418
|
+
end
|
1413
1419
|
end
|
1414
|
-
end
|
1415
1420
|
|
1416
|
-
describe Pointcut, ".new (:reading => :all option not yet supported)" do
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1421
|
+
describe Pointcut, ".new (:reading => :all option not yet supported)" do
|
1422
|
+
it "should raise if :all is used for types (not yet supported)." do
|
1423
|
+
lambda { Pointcut.new :types => "ClassWithAttribs", :reading => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
|
1424
|
+
end
|
1420
1425
|
|
1421
|
-
|
1422
|
-
|
1426
|
+
it "should raise if :all is used for objects (not yet supported)." do
|
1427
|
+
lambda { Pointcut.new :object => ClassWithAttribs.new, :reading => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
|
1428
|
+
end
|
1423
1429
|
end
|
1424
|
-
end
|
1425
1430
|
|
1426
|
-
describe Pointcut, ".new (:writing => :all option not yet supported)" do
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1431
|
+
describe Pointcut, ".new (:writing => :all option not yet supported)" do
|
1432
|
+
it "should raise if :all is used for types (not yet supported)." do
|
1433
|
+
lambda { Pointcut.new :types => "ClassWithAttribs", :writing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
|
1434
|
+
end
|
1430
1435
|
|
1431
|
-
|
1432
|
-
|
1436
|
+
it "should raise if :all is used for objects (not yet supported)." do
|
1437
|
+
lambda { Pointcut.new :object => ClassWithAttribs.new, :writing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
|
1438
|
+
end
|
1433
1439
|
end
|
1434
|
-
end
|
1435
1440
|
|
1436
|
-
describe Pointcut, ".new (singletons specified)" do
|
1441
|
+
describe Pointcut, ".new (singletons specified)" do
|
1437
1442
|
|
1438
|
-
|
1439
|
-
|
1443
|
+
before(:each) do
|
1444
|
+
class Empty; end
|
1440
1445
|
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1446
|
+
@objectWithSingletonMethod = Empty.new
|
1447
|
+
class << @objectWithSingletonMethod
|
1448
|
+
def a_singleton_method
|
1449
|
+
end
|
1444
1450
|
end
|
1445
|
-
end
|
1446
1451
|
|
1447
|
-
|
1448
|
-
end
|
1449
|
-
class << NotQuiteEmpty
|
1450
|
-
def a_class_singleton_method
|
1452
|
+
class NotQuiteEmpty
|
1451
1453
|
end
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1454
|
+
class << NotQuiteEmpty
|
1455
|
+
def a_class_singleton_method
|
1456
|
+
end
|
1457
|
+
end
|
1458
|
+
@notQuiteEmpty = NotQuiteEmpty.new
|
1459
|
+
end
|
1455
1460
|
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
it "should find type-level singleton methods for types when :singleton is specified." do
|
1463
|
-
pc = Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :exclude_ancestor_methods]
|
1464
|
-
pc.join_points_matched.should == Set.new([JoinPoint.new(:type => NotQuiteEmpty, :method_name => :a_class_singleton_method)])
|
1465
|
-
pc.join_points_not_matched.should == Set.new([JoinPoint.new(:type => Empty, :method_name => :all)])
|
1466
|
-
end
|
1461
|
+
it "should find instance-level singleton method joinpoints for objects when :singleton is specified." do
|
1462
|
+
pc = Pointcut.new :objects => [@notQuiteEmpty, @objectWithSingletonMethod], :methods => :all, :method_options => [:singleton]
|
1463
|
+
pc.join_points_matched.should == Set.new([JoinPoint.new(:object => @objectWithSingletonMethod, :method_name => :a_singleton_method)])
|
1464
|
+
pc.join_points_not_matched.should == Set.new([JoinPoint.new(:object => @notQuiteEmpty, :method_name => :all)])
|
1465
|
+
end
|
1467
1466
|
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
end
|
1474
|
-
end
|
1467
|
+
it "should find type-level singleton methods for types when :singleton is specified." do
|
1468
|
+
pc = Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :exclude_ancestor_methods]
|
1469
|
+
pc.join_points_matched.should == Set.new([JoinPoint.new(:type => NotQuiteEmpty, :method_name => :a_class_singleton_method)])
|
1470
|
+
pc.join_points_not_matched.should == Set.new([JoinPoint.new(:type => Empty, :method_name => :all)])
|
1471
|
+
end
|
1475
1472
|
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1473
|
+
it "should raise when specifying method options :singleton with :class, :public, :protected, or :private." do
|
1474
|
+
lambda { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :class]}.should raise_error(Aquarium::Utils::InvalidOptions)
|
1475
|
+
lambda { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :public]}.should raise_error(Aquarium::Utils::InvalidOptions)
|
1476
|
+
lambda { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :protected]}.should raise_error(Aquarium::Utils::InvalidOptions)
|
1477
|
+
lambda { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :private]}.should raise_error(Aquarium::Utils::InvalidOptions)
|
1478
|
+
end
|
1482
1479
|
end
|
1483
1480
|
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1481
|
+
describe Pointcut, "#empty?" do
|
1482
|
+
it "should be true if there are no matched and no unmatched join points." do
|
1483
|
+
pc = Pointcut.new
|
1484
|
+
pc.join_points_matched.size.should == 0
|
1485
|
+
pc.join_points_not_matched.size.should == 0
|
1486
|
+
pc.should be_empty
|
1487
|
+
end
|
1488
|
+
|
1489
|
+
it "should be false if there are matched join points." do
|
1490
|
+
pc = Pointcut.new :types => [ClassWithAttribs], :methods => [/^attr/]
|
1491
|
+
pc.join_points_matched.size.should > 0
|
1492
|
+
pc.join_points_not_matched.size.should == 0
|
1493
|
+
pc.should_not be_empty
|
1494
|
+
end
|
1490
1495
|
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
+
it "should be false if there are unmatched join points." do
|
1497
|
+
pc = Pointcut.new :types => [String], :methods => [/^attr/]
|
1498
|
+
pc.join_points_matched.size.should == 0
|
1499
|
+
pc.join_points_not_matched.size.should > 0
|
1500
|
+
pc.should_not be_empty
|
1501
|
+
end
|
1496
1502
|
end
|
1497
|
-
end
|
1498
1503
|
|
1499
|
-
describe Pointcut, "#eql?" do
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1504
|
+
describe Pointcut, "#eql?" do
|
1505
|
+
it "should return true for the same Pointcut object." do
|
1506
|
+
pc = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
|
1507
|
+
pc.should be_eql(pc)
|
1508
|
+
pc1 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /_test_method$/
|
1509
|
+
pc1.should be_eql(pc1)
|
1510
|
+
end
|
1506
1511
|
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
+
it "should return true for Pointcuts that specify the same types and methods." do
|
1513
|
+
pc1 = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
|
1514
|
+
pc2 = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
|
1515
|
+
pc1.should be_eql(pc2)
|
1516
|
+
end
|
1512
1517
|
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
+
it "should return false if the matched types are different." do
|
1519
|
+
pc1 = Pointcut.new :types => /ClassWithPublicMethod/
|
1520
|
+
pc2 = Pointcut.new :types => /Class.*Method/
|
1521
|
+
pc1.should_not eql(pc2)
|
1522
|
+
end
|
1518
1523
|
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
+
it "should return false for Pointcuts that specify different types, even if no methods match." do
|
1525
|
+
pc1 = Pointcut.new :types => /ClassWithPublicMethod/, :methods => /foobar/
|
1526
|
+
pc2 = Pointcut.new :types => /Class.*Method/ , :methods => /foobar/
|
1527
|
+
pc1.should_not eql(pc2)
|
1528
|
+
end
|
1524
1529
|
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
+
it "should return false for Pointcuts that specify different methods." do
|
1531
|
+
pc1 = Pointcut.new :types => /ClassWithPublicMethod/, :methods =>/^private/
|
1532
|
+
pc2 = Pointcut.new :types => /ClassWithPublicMethod/, :methods =>/^public/
|
1533
|
+
pc1.should_not eql(pc2)
|
1534
|
+
end
|
1530
1535
|
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
+
it "should return false for Pointcuts that specify equivalent objects that are not the same object." do
|
1537
|
+
pc1 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /_test_method$/
|
1538
|
+
pc2 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /_test_method$/
|
1539
|
+
pc1.should_not eql(pc2)
|
1540
|
+
end
|
1536
1541
|
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
+
it "should return false for Pointcuts that specify equivalent objects that are not the same object, even if no methods match." do
|
1543
|
+
pc1 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /foobar/
|
1544
|
+
pc2 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /foobar/
|
1545
|
+
pc1.should_not eql(pc2)
|
1546
|
+
end
|
1542
1547
|
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
+
it "should return false if the matched objects are different objects." do
|
1549
|
+
pc1 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /_test_method$/
|
1550
|
+
pc2 = Pointcut.new :object => ClassWithPrivateClassMethod.new, :methods => /_test_method$/
|
1551
|
+
pc1.should_not eql(pc2)
|
1552
|
+
end
|
1548
1553
|
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1554
|
+
it "should return true if the matched objects are the same object." do
|
1555
|
+
object = ClassWithPublicClassMethod.new
|
1556
|
+
pc1 = Pointcut.new :object => object, :methods => /_test_method$/
|
1557
|
+
pc2 = Pointcut.new :object => object, :methods => /_test_method$/
|
1558
|
+
pc1.should eql(pc2)
|
1559
|
+
end
|
1555
1560
|
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
+
it "should return false if the not_matched types are different." do
|
1562
|
+
pc1 = Pointcut.new :types => :UnknownFoo
|
1563
|
+
pc2 = Pointcut.new :types => :UnknownBar
|
1564
|
+
pc1.should_not eql(pc2)
|
1565
|
+
end
|
1561
1566
|
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
+
it "should return false if the matched methods for the same types are different." do
|
1568
|
+
pc1 = Pointcut.new :types => /Class.*Method/, :methods => /public.*_test_method$/
|
1569
|
+
pc2 = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
|
1570
|
+
pc1.should_not == pc2
|
1571
|
+
end
|
1567
1572
|
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1573
|
+
it "should return false if the matched methods for the same objects are different." do
|
1574
|
+
pub = ClassWithPublicInstanceMethod.new
|
1575
|
+
pri = ClassWithPrivateInstanceMethod.new
|
1576
|
+
pc1 = Pointcut.new :objects => [pub, pri], :methods => /public.*_test_method$/
|
1577
|
+
pc2 = Pointcut.new :objects => [pub, pri], :methods => /_test_method$/
|
1578
|
+
pc1.should_not == pc2
|
1579
|
+
end
|
1575
1580
|
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
+
it "should return false if the not_matched methods for the same types are different." do
|
1582
|
+
pc1 = Pointcut.new :types => /Class.*Method/, :methods => /foo/
|
1583
|
+
pc2 = Pointcut.new :types => /Class.*Method/, :methods => /bar/
|
1584
|
+
pc1.should_not == pc2
|
1585
|
+
end
|
1581
1586
|
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1587
|
+
it "should return false if the not_matched methods for the same objects are different." do
|
1588
|
+
pub = ClassWithPublicInstanceMethod.new
|
1589
|
+
pri = ClassWithPrivateInstanceMethod.new
|
1590
|
+
pc1 = Pointcut.new :objects => [pub, pri], :methods => /foo/
|
1591
|
+
pc2 = Pointcut.new :objects => [pub, pri], :methods => /bar/
|
1592
|
+
pc1.should_not == pc2
|
1593
|
+
end
|
1589
1594
|
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
+
it "should return false if the matched attributes for the same types are different." do
|
1596
|
+
pc1 = Pointcut.new :types => /Class.*Method/, :attributes => /attrRW/
|
1597
|
+
pc2 = Pointcut.new :types => /Class.*Method/, :attributes => /attrR/
|
1598
|
+
pc1.should_not == pc2
|
1599
|
+
end
|
1595
1600
|
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1601
|
+
it "should return false if the matched attributes for the same objects are different." do
|
1602
|
+
pub = ClassWithPublicInstanceMethod.new
|
1603
|
+
pri = ClassWithPrivateInstanceMethod.new
|
1604
|
+
pc1 = Pointcut.new :objects => [pub, pri], :attributes => /attrRW/
|
1605
|
+
pc2 = Pointcut.new :objects => [pub, pri], :attributes => /attrR/
|
1606
|
+
pc1.should_not == pc2
|
1607
|
+
end
|
1603
1608
|
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
+
it "should return false if the not_matched attributes for the same types are different." do
|
1610
|
+
pc1 = Pointcut.new :types => /Class.*Method/, :attributes => /foo/
|
1611
|
+
pc2 = Pointcut.new :types => /Class.*Method/, :attributes => /bar/
|
1612
|
+
pc1.should_not == pc2
|
1613
|
+
end
|
1609
1614
|
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1615
|
+
it "should return false if the not_matched attributes for the same objects are different." do
|
1616
|
+
pub = ClassWithPublicInstanceMethod.new
|
1617
|
+
pri = ClassWithPrivateInstanceMethod.new
|
1618
|
+
pc1 = Pointcut.new :objects => [pub, pri], :attributes => /foo/
|
1619
|
+
pc2 = Pointcut.new :objects => [pub, pri], :attributes => /bar/
|
1620
|
+
pc1.should_not == pc2
|
1621
|
+
end
|
1616
1622
|
end
|
1617
|
-
end
|
1618
1623
|
|
1619
|
-
describe "Pointcut#eql?" do
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1624
|
+
describe "Pointcut#eql?" do
|
1625
|
+
it "should be an alias for #==" do
|
1626
|
+
pc1 = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
|
1627
|
+
pc2 = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
|
1628
|
+
pc3 = Pointcut.new :objects => [ClassWithPublicInstanceMethod.new, ClassWithPublicInstanceMethod.new]
|
1629
|
+
pc1.should be_eql(pc1)
|
1630
|
+
pc1.should be_eql(pc2)
|
1631
|
+
pc1.should_not eql(pc3)
|
1632
|
+
pc2.should_not eql(pc3)
|
1633
|
+
end
|
1628
1634
|
end
|
1629
|
-
end
|
1630
1635
|
|
1631
|
-
describe Pointcut, "#candidate_types" do
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1636
|
+
describe Pointcut, "#candidate_types" do
|
1637
|
+
before(:each) do
|
1638
|
+
before_pointcut_class_spec
|
1639
|
+
end
|
1635
1640
|
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
+
it "should return only candidate matching types when the input types exist." do
|
1642
|
+
pc = Pointcut.new :types => @example_classes
|
1643
|
+
pc.candidate_types.matched_keys.sort {|x,y| x.to_s <=> y.to_s}.should == @example_classes.sort {|x,y| x.to_s <=> y.to_s}
|
1644
|
+
pc.candidate_types.not_matched_keys.should == []
|
1645
|
+
end
|
1641
1646
|
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
+
it "should return only candidate matching types when the input type names correspond to existing types." do
|
1648
|
+
pc = Pointcut.new :types => @example_classes.map {|t| t.to_s}
|
1649
|
+
pc.candidate_types.matched_keys.sort {|x,y| x.to_s <=> y.to_s}.should == @example_classes.sort {|x,y| x.to_s <=> y.to_s}
|
1650
|
+
pc.candidate_types.not_matched_keys.should == []
|
1651
|
+
end
|
1647
1652
|
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
+
it "should return only candidate non-matching types when the input types do not exist." do
|
1654
|
+
pc = Pointcut.new :types => 'NonExistentClass'
|
1655
|
+
pc.candidate_types.matched_keys.should == []
|
1656
|
+
pc.candidate_types.not_matched_keys.should == ['NonExistentClass']
|
1657
|
+
end
|
1653
1658
|
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1659
|
+
it "should return no candidate matching or non-matching types when only objects are input." do
|
1660
|
+
pc = Pointcut.new :objects => @example_classes.map {|t| t.new}
|
1661
|
+
pc.candidate_types.matched_keys.should == []
|
1662
|
+
pc.candidate_types.not_matched_keys.should == []
|
1663
|
+
end
|
1658
1664
|
end
|
1659
|
-
end
|
1660
1665
|
|
1661
|
-
describe Pointcut, "#candidate_objects" do
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1666
|
+
describe Pointcut, "#candidate_objects" do
|
1667
|
+
before(:each) do
|
1668
|
+
before_pointcut_class_spec
|
1669
|
+
end
|
1665
1670
|
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
+
it "should return only candidate matching objects when the input are objects." do
|
1672
|
+
example_objs = @example_classes.map {|t| t.new}
|
1673
|
+
pc = Pointcut.new :objects => example_objs
|
1674
|
+
example_objs.each do |obj|
|
1675
|
+
pc.candidate_objects.matched[obj].should_not be(nil?)
|
1676
|
+
end
|
1677
|
+
pc.candidate_objects.not_matched_keys.should == []
|
1671
1678
|
end
|
1672
|
-
pc.candidate_objects.not_matched_keys.should == []
|
1673
1679
|
end
|
1674
|
-
end
|
1675
1680
|
|
1676
|
-
describe Pointcut, "#candidate_join_points" do
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1681
|
+
describe Pointcut, "#candidate_join_points" do
|
1682
|
+
before(:each) do
|
1683
|
+
before_pointcut_class_spec
|
1684
|
+
end
|
1680
1685
|
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1686
|
+
it "should return only candidate non-matching join points for the input join points that do not exist." do
|
1687
|
+
anClassWithPublicInstanceMethod = ClassWithPublicInstanceMethod.new
|
1688
|
+
example_jps = [
|
1689
|
+
JoinPoint.new(:type => ClassWithPublicInstanceMethod, :method => :foo),
|
1690
|
+
JoinPoint.new(:object => anClassWithPublicInstanceMethod, :method => :foo)]
|
1691
|
+
pc = Pointcut.new :join_points => example_jps
|
1692
|
+
pc.candidate_join_points.matched.size.should == 0
|
1693
|
+
pc.candidate_join_points.not_matched[example_jps[0]].should_not be_nil
|
1694
|
+
pc.candidate_join_points.not_matched[example_jps[1]].should_not be_nil
|
1695
|
+
end
|
1691
1696
|
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1697
|
+
it "should return only candidate matching join points for the input join points that do exist." do
|
1698
|
+
anClassWithPublicInstanceMethod = ClassWithPublicInstanceMethod.new
|
1699
|
+
example_jps = [
|
1700
|
+
JoinPoint.new(:type => ClassWithPublicInstanceMethod, :method => :public_instance_test_method),
|
1701
|
+
JoinPoint.new(:object => anClassWithPublicInstanceMethod, :method => :public_instance_test_method)]
|
1702
|
+
pc = Pointcut.new :join_points => example_jps
|
1703
|
+
pc.candidate_join_points.matched.size.should == 2
|
1704
|
+
pc.candidate_join_points.matched[example_jps[0]].should_not be_nil
|
1705
|
+
pc.candidate_join_points.matched[example_jps[1]].should_not be_nil
|
1706
|
+
pc.candidate_join_points.not_matched.size.should == 0
|
1707
|
+
end
|
1702
1708
|
end
|
1703
|
-
end
|
1704
1709
|
|
1705
|
-
describe Pointcut, "#specification" do
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
@default_specification = {
|
1710
|
-
:types => @empty_set, :objects => @empty_set, :join_points => @empty_set,
|
1711
|
-
:types_and_ancestors => @empty_set,
|
1712
|
-
:types_and_descendents => @empty_set,
|
1713
|
-
:methods => @empty_set, :method_options => Set.new([:instance]),
|
1714
|
-
:attributes => @empty_set, :attribute_options => @empty_set,
|
1715
|
-
:exclude_types => @empty_set,
|
1716
|
-
:exclude_types_calculated => @empty_set,
|
1717
|
-
:exclude_types_and_ancestors => @empty_set,
|
1718
|
-
:exclude_types_and_descendents => @empty_set,
|
1719
|
-
:exclude_objects => @empty_set,
|
1720
|
-
:exclude_join_points => @empty_set,
|
1721
|
-
:exclude_pointcuts => @empty_set,
|
1722
|
-
:exclude_methods => @empty_set,
|
1723
|
-
:default_objects => @empty_set,
|
1724
|
-
:log => Set.new([""]),
|
1725
|
-
:verbose => Set.new([0]),
|
1726
|
-
:noop => Set.new([false])
|
1727
|
-
}
|
1728
|
-
@default_specification_all_methods = { :methods => Set.new([:all]) } | @default_specification
|
1729
|
-
end
|
1710
|
+
describe Pointcut, "#specification" do
|
1711
|
+
before(:each) do
|
1712
|
+
before_pointcut_class_spec
|
1713
|
+
end
|
1730
1714
|
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1715
|
+
it "should return ':attribute_options => []', by default, if no arguments are given." do
|
1716
|
+
pc = Pointcut.new
|
1717
|
+
pc.specification[:attribute_options].should eql(Set.new)
|
1718
|
+
end
|
1735
1719
|
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1720
|
+
it "should return the input :types and :type arguments combined into an array keyed by :types." do
|
1721
|
+
pc = Pointcut.new :types => @example_classes, :type => String
|
1722
|
+
pc.specification[:types].should eql(Set.new(@example_classes + [String]))
|
1723
|
+
end
|
1740
1724
|
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1725
|
+
it "should return the input :objects and :object arguments combined into an array keyed by :objects." do
|
1726
|
+
example_objs = @example_classes.map {|t| t.new}
|
1727
|
+
s1234 = "1234"
|
1728
|
+
pc = Pointcut.new :objects => example_objs, :object => s1234
|
1729
|
+
pc.specification[:objects].should eql(Set.new(example_objs + [s1234]))
|
1730
|
+
end
|
1747
1731
|
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1732
|
+
it "should return the input :methods and :method arguments combined into an array keyed by :methods." do
|
1733
|
+
pc = Pointcut.new :types => @example_classes, :methods => /^get/, :method => "dup"
|
1734
|
+
pc.specification[:types].should eql(Set.new(@example_classes))
|
1735
|
+
pc.specification[:methods].should eql(Set.new([/^get/, "dup"]))
|
1736
|
+
end
|
1752
1737
|
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
end
|
1738
|
+
it "should return the input :method_options verbatim." do
|
1739
|
+
pc = Pointcut.new :types => @example_classes, :methods => /^get/, :method => "dup", :method_options => [:instance, :public]
|
1740
|
+
pc.specification[:method_options].should eql(Set.new([:instance, :public]))
|
1741
|
+
end
|
1758
1742
|
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
:attributes => Set.new([/^state/, "name"]), :attribute_options => @empty_set } | @default_specification
|
1764
|
-
end
|
1743
|
+
it "should return the input :attributes and :attribute arguments combined into an array keyed by :attributes." do
|
1744
|
+
pc = Pointcut.new :types => @example_classes, :attributes => /^state/, :attribute => "name"
|
1745
|
+
pc.specification[:attributes].should eql(Set.new([/^state/, "name"]))
|
1746
|
+
end
|
1765
1747
|
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
:attribute_options
|
1748
|
+
it "should return the input :attributes, :attribute and :attribute_options arguments, verbatim." do
|
1749
|
+
pc = Pointcut.new :types => @example_classes, :attributes => /^state/, :attribute => "name", :attribute_options => :reader
|
1750
|
+
pc.specification[:attributes].should eql(Set.new([/^state/, "name"]))
|
1751
|
+
pc.specification[:attribute_options].should eql(Set.new([:reader]))
|
1752
|
+
end
|
1770
1753
|
end
|
1771
|
-
end
|
1754
|
+
end
|