aquarium 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/Aquarium.ipr +253 -0
  2. data/Aquarium.iws +629 -0
  3. data/CHANGES +43 -0
  4. data/UPGRADE +13 -7
  5. data/examples/method_tracing_example_spec.rb +4 -1
  6. data/lib/aquarium/aspects/aspect.rb +28 -11
  7. data/lib/aquarium/aspects/exclusion_handler.rb +1 -1
  8. data/lib/aquarium/aspects/join_point.rb +58 -14
  9. data/lib/aquarium/aspects/pointcut.rb +5 -6
  10. data/lib/aquarium/extras/design_by_contract.rb +1 -1
  11. data/lib/aquarium/finders/method_finder.rb +1 -4
  12. data/lib/aquarium/finders/type_finder.rb +8 -1
  13. data/lib/aquarium/utils.rb +1 -0
  14. data/lib/aquarium/utils/default_logger.rb +20 -0
  15. data/lib/aquarium/utils/options_utils.rb +74 -12
  16. data/lib/aquarium/utils/type_utils.rb +1 -7
  17. data/lib/aquarium/version.rb +1 -1
  18. data/spec/aquarium/aspects/advice_chain_node_spec.rb +1 -1
  19. data/spec/aquarium/aspects/advice_spec.rb +1 -1
  20. data/spec/aquarium/aspects/aspect_invocation_spec.rb +1531 -1465
  21. data/spec/aquarium/aspects/aspect_spec.rb +22 -27
  22. data/spec/aquarium/aspects/aspect_with_nested_types_spec.rb +1 -1
  23. data/spec/aquarium/aspects/aspect_with_subtypes_spec.rb +1 -1
  24. data/spec/aquarium/aspects/concurrent_aspects_spec.rb +1 -1
  25. data/spec/aquarium/aspects/concurrent_aspects_with_objects_and_types_spec.rb +1 -1
  26. data/spec/aquarium/aspects/dsl/aspect_dsl_spec.rb +434 -424
  27. data/spec/aquarium/aspects/join_point_spec.rb +27 -4
  28. data/spec/aquarium/aspects/pointcut_and_composition_spec.rb +98 -102
  29. data/spec/aquarium/aspects/pointcut_or_composition_spec.rb +95 -107
  30. data/spec/aquarium/aspects/pointcut_spec.rb +1365 -1382
  31. data/spec/aquarium/extensions/hash_spec.rb +1 -1
  32. data/spec/aquarium/extensions/set_spec.rb +1 -1
  33. data/spec/aquarium/finders/finder_result_spec.rb +1 -1
  34. data/spec/aquarium/finders/method_finder_spec.rb +1 -1
  35. data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +63 -145
  36. data/spec/aquarium/{spec_example_classes.rb → spec_example_types.rb} +35 -0
  37. data/spec/aquarium/utils/default_logger_spec.rb +28 -0
  38. data/spec/aquarium/utils/hash_utils_spec.rb +1 -1
  39. data/spec/aquarium/utils/logic_error_spec.rb +1 -1
  40. data/spec/aquarium/utils/name_utils_spec.rb +1 -1
  41. data/spec/aquarium/utils/nil_object_spec.rb +1 -1
  42. data/spec/aquarium/utils/options_utils_spec.rb +122 -0
  43. data/spec/aquarium/utils/set_utils_spec.rb +1 -1
  44. metadata +9 -4
@@ -1,5 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
- require File.dirname(__FILE__) + '/../spec_example_classes'
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
- describe Pointcut, ".new (invalid arguments)" do
103
- it "should raise if an unknown argument is specified" do
104
- lambda { Pointcut.new :foo => :bar }.should raise_error(Aquarium::Utils::InvalidOptions)
101
+ describe Pointcut, "methods" do
102
+ include Aquarium::TypeUtilsStub
103
+
104
+ before :all do
105
+ stub_type_utils_descendents
105
106
  end
106
- end
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
- it "should match no join points if nil is the only argument specified." do
115
- pc = Pointcut.new nil
116
- pc.should be_empty
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
- it "should match no join points if types = [] specified." do
120
- pc = Pointcut.new :types => []
121
- pc.should be_empty
122
- end
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
- it "should match no join points if types = nil specified." do
125
- pc = Pointcut.new :types => nil
126
- pc.should be_empty
127
- end
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
- it "should match no join points if objects = [] specified." do
130
- pc = Pointcut.new :objects => []
131
- pc.should be_empty
132
- end
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
- it "should match no join points if objects = nil specified." do
135
- pc = Pointcut.new :objects => nil
136
- pc.should be_empty
137
- end
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
- it "should match no join points if join_points = nil specified." do
140
- pc = Pointcut.new :join_points => nil
141
- pc.should be_empty
142
- end
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
- it "should match no join points if join_points = [] specified." do
145
- pc = Pointcut.new :join_points => []
146
- pc.should be_empty
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
- before(:each) do
152
- before_pointcut_class_spec
153
- end
159
+ describe Pointcut, ".new (classes specified using regular expressions)" do
160
+ before(:each) do
161
+ before_pointcut_class_spec
162
+ end
154
163
 
155
- it "should match multiple classes using regular expressions that cover the full class names." do
156
- pc = Pointcut.new :types => /\AClass(?!IncludingModule).*Method\Z/, :method_options => :exclude_ancestor_methods
157
- pc.join_points_matched.should == (@expected_classes_matched_jps + [@cdcimpub_jp])
158
- pc.join_points_not_matched.should == @expected_classes_not_matched_jps
159
- end
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
- it "should match clases using regular expressions that only cover partial class names." do
162
- pc = Pointcut.new :types => /lass(?!IncludingModule).*Pro.*Inst.*Met/, :method_options => [:public, :protected, :exclude_ancestor_methods]
163
- pc.join_points_matched.should == Set.new([@pro_jp])
164
- pc.join_points_not_matched.size.should == 0
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
- before(:each) do
170
- before_pointcut_class_spec
171
- end
177
+ describe Pointcut, ".new (classes specified using names)" do
178
+ before(:each) do
179
+ before_pointcut_class_spec
180
+ end
172
181
 
173
- it "should match multiple classes using names." do
174
- pc = Pointcut.new :types => @example_classes.map {|t| t.to_s}, :method_options => :exclude_ancestor_methods
175
- pc.join_points_matched.should == @expected_classes_matched_jps
176
- pc.join_points_not_matched.should == @expected_classes_not_matched_jps
177
- end
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
- it "should match multiple classes using classes themselves." do
180
- pc = Pointcut.new :types => @example_classes, :method_options => :exclude_ancestor_methods
181
- pc.join_points_matched.should == @expected_classes_matched_jps
182
- pc.join_points_not_matched.should == @expected_classes_not_matched_jps
183
- end
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
- it "should match :all public instance methods for classes by default." do
186
- pc = Pointcut.new :types => @example_classes, :method_options => :exclude_ancestor_methods
187
- pc.join_points_matched.should == @expected_classes_matched_jps
188
- pc.join_points_not_matched.should == @expected_classes_not_matched_jps
189
- end
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
- it "should support MethodFinder's :exclude_ancestor_methods option when using classes." do
204
- pc = Pointcut.new :types => @example_classes, :method_options => :exclude_ancestor_methods
205
- pc.join_points_matched.should == @expected_classes_matched_jps
206
- pc.join_points_not_matched.should == @expected_classes_not_matched_jps
207
- end
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
- Pointcut::CANONICAL_OPTIONS["types"].each do |key|
210
- it "should accept :#{key} as a synonym for :types." do
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
- describe Pointcut, ".new (modules specified using regular expressions)" do
219
- it "should match multiple types using regular expressions that cover the full module names." do
220
- pc = Pointcut.new :types => /\AModule.*Method\Z/, :method_options => :exclude_ancestor_methods
221
- pc.join_points_matched.size.should == 2
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
- pc.join_points_not_matched.size.should == 4
226
- pc.join_points_not_matched.each do |jp|
227
- [ModuleWithPrivateInstanceMethod, ModuleWithProtectedInstanceMethod,
228
- ModuleWithPublicClassMethod, ModuleWithPrivateClassMethod].should include(jp.target_type)
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 names)" do
234
- def do_module type_spec
235
- pc = Pointcut.new :types => type_spec, :method_options => :exclude_ancestor_methods
236
- pc.join_points_matched.size.should == 1
237
- pc.join_points_matched.each do |jp|
238
- jp.target_type.should == ModuleWithPublicInstanceMethod
239
- jp.method_name.should == :public_instance_module_test_method
240
- end
241
- pc.join_points_not_matched.size.should == 1
242
- pc.join_points_not_matched.each do |jp|
243
- jp.target_type.should == ModuleWithPublicClassMethod
244
- jp.method_name.should == :all
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
- it "should match multiple types using module names." do
249
- do_module ["ModuleWithPublicInstanceMethod", "ModuleWithPublicClassMethod"]
250
- end
257
+ it "should match multiple types using module names." do
258
+ do_module ["ModuleWithPublicInstanceMethod", "ModuleWithPublicClassMethod"]
259
+ end
251
260
 
252
- it "should match multiple types using module-name regular expressions." do
253
- do_module /^ModuleWithPublic.*Method/
254
- end
261
+ it "should match multiple types using module-name regular expressions." do
262
+ do_module /^ModuleWithPublic.*Method/
263
+ end
255
264
 
256
- it "should match multiple types using modules themselves." do
257
- do_module [ModuleWithPublicInstanceMethod, ModuleWithPublicClassMethod]
258
- end
265
+ it "should match multiple types using modules themselves." do
266
+ do_module [ModuleWithPublicInstanceMethod, ModuleWithPublicClassMethod]
267
+ end
259
268
 
260
- it "should match :all public instance methods for modules by default." do
261
- do_module [ModuleWithPublicInstanceMethod, ModuleWithPublicClassMethod]
262
- end
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
- describe Pointcut, ".new (types and their descendents and ancestors)" do
270
- before(:each) do
271
- before_pointcut_module_spec
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
- it "should match classes specified and their ancestor and descendent modules and classes." do
275
- pc = Pointcut.new :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/, :types_and_descendents => /^Class(Including|DerivedFrom).*Method/, :methods => :all, :method_options => :exclude_ancestor_methods
276
- expected_types = @example_modules_with_public_instance_method + [Kernel, Module, Object]
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
- not_expected_types = @expected_modules_not_matched_jps.map {|jp| jp.target_type}
282
- pc.join_points_not_matched.each do |jp|
283
- next if ignored_join_point(jp)
284
- not_expected_types.should include(jp.target_type)
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
- it "should match modules specified, their ancestor and descendent modules, and including classes." do
289
- pc = Pointcut.new :types_and_ancestors => /^Module.*Method/, :types_and_descendents => /^Module.*Method/, :methods => :all, :method_options => :exclude_ancestor_methods
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
- end
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
- Aspect::CANONICAL_OPTIONS["types_and_descendents"].each do |key|
303
- it "should accept :#{key} as a synonym for :types_and_descendents." do
304
- pc = Pointcut.new :types_and_ancestors => /^Module.*Method/, key.intern => /^Module.*Method/, :methods => :all, :method_options => :exclude_ancestor_methods
305
- pc.join_points_matched.should == (@expected_modules_matched_jps + [@mimpub_jp])
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
- before(:each) do
313
- before_pointcut_class_spec
314
- end
316
+ describe Pointcut, ".new (objects specified)" do
317
+ before(:each) do
318
+ before_pointcut_class_spec
319
+ end
315
320
 
316
- it "should match :all public instance methods for objects by default." do
317
- pub, pro = ClassWithPublicInstanceMethod.new, ClassWithProtectedInstanceMethod.new
318
- pc = Pointcut.new :objects => [pub, pro], :method_options => :exclude_ancestor_methods
319
- pc.join_points_matched.should == Set.new([JoinPoint.new(:object => pub, :method_name => :public_instance_test_method)])
320
- pc.join_points_not_matched.should == Set.new([JoinPoint.new(:object => pro, :method_name => :all)])
321
- end
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
- it "should support MethodFinder's :exclude_ancestor_methods option when using objects." do
324
- pub, pro = ClassWithPublicInstanceMethod.new, ClassWithProtectedInstanceMethod.new
325
- pc = Pointcut.new :objects => [pub, pro], :method_options => :exclude_ancestor_methods
326
- pc.join_points_matched.should == Set.new([JoinPoint.new(:object => pub, :method_name => :public_instance_test_method)])
327
- pc.join_points_not_matched.should == Set.new([JoinPoint.new(:object => pro, :method_name => :all)])
328
- end
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
- it "should match all possible methods on the specified objects." do
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 key.intern => [pub, pro], :methods => :all, :method_options => [:public, :protected, :exclude_ancestor_methods]
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
- it "does confuse strings specified with :objects as type names." do
353
- string = "mystring"
354
- lambda { Pointcut.new :object => string, :methods => :capitalize }.should raise_error(NameError)
355
- end
356
-
357
- it "does confuse symbols specified with :objects as type names." do
358
- symbol = :mystring
359
- lambda { Pointcut.new :object => symbol, :methods => :capitalize }.should raise_error(NameError)
360
- end
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
- it "should remove from a list of explicitly-specified types the set of explicitly-specified excluded types." do
369
- pc = Pointcut.new :types => [ExcludeTestOne, ExcludeTestTwo, ExcludeTestThree], :exclude_type => ExcludeTestTwo, :method_options => :exclude_ancestor_methods
370
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
371
- actual.size.should == 2
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
- it "should remove from a list of explicitly-specified types the set of excluded types specified by regular expression." do
378
- pc = Pointcut.new :types => [ExcludeTestOne, ExcludeTestTwo, ExcludeTestThree], :exclude_types => /Two$/, :method_options => :exclude_ancestor_methods
379
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
380
- actual.size.should == 2
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
- it "should remove from a list of explicitly-specified types the set of excluded types specified by name." do
387
- pc = Pointcut.new :types => [ExcludeTestOne, ExcludeTestTwo, ExcludeTestThree], :exclude_type => "ExcludeTestTwo", :method_options => :exclude_ancestor_methods
388
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
389
- actual.size.should == 2
390
- actual.should include(ExcludeTestOne)
391
- actual.should include(ExcludeTestThree)
392
- pc.join_points_not_matched.size.should == 0
393
- end
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
- it "should remove from the types specified by regular expression the explicitly-specified excluded types." do
396
- pc = Pointcut.new :types => /ExcludeTest/, :exclude_type => ExcludeTestTwo, :method_options => :exclude_ancestor_methods
397
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
398
- actual.size.should == 2
399
- actual.should include(ExcludeTestOne)
400
- actual.should include(ExcludeTestThree)
401
- pc.join_points_not_matched.size.should == 0
402
- end
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
- it "should remove from the types specified by regular expression the excluded types specified by regular expression." do
405
- pc = Pointcut.new :types => /ExcludeTest/, :exclude_type => /Two$/, :method_options => :exclude_ancestor_methods
406
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
407
- actual.size.should == 2
408
- actual.should include(ExcludeTestOne)
409
- actual.should include(ExcludeTestThree)
410
- pc.join_points_not_matched.size.should == 0
411
- end
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
- it "should remove from the types specified by regular expression the excluded types specified by name." do
414
- pc = Pointcut.new :types => /ExcludeTest/, :exclude_type => "ExcludeTestTwo", :method_options => :exclude_ancestor_methods
415
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
416
- actual.size.should == 2
417
- actual.should include(ExcludeTestOne)
418
- actual.should include(ExcludeTestThree)
419
- pc.join_points_not_matched.size.should == 0
420
- end
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
- it "should remove from the join points corresponding to the excluded types, specified by name." do
423
- pc = Pointcut.new :join_points => @all_type_jps, :exclude_type => "ExcludeTestTwo", :method_options => :exclude_ancestor_methods
424
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
425
- actual.size.should == 2
426
- actual.should include(ExcludeTestOne)
427
- actual.should include(ExcludeTestThree)
428
- pc.join_points_not_matched.size.should == 0
429
- end
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
- it "should remove the specified join points corresponding to the excluded types, specified by regular expression." do
432
- pc = Pointcut.new :join_points => @all_type_jps, :exclude_type => /Exclude.*Two/, :method_options => :exclude_ancestor_methods
433
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
434
- actual.size.should == 2
435
- actual.should include(ExcludeTestOne)
436
- actual.should include(ExcludeTestThree)
437
- pc.join_points_not_matched.size.should == 0
438
- end
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
- it "should not add excluded types to the #not_matched results." do
441
- pc = Pointcut.new :types => /ExcludeTest/, :exclude_type => ExcludeTestTwo, :method_options => :exclude_ancestor_methods
442
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
443
- pc.join_points_not_matched.size.should == 0
444
- end
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
- Aspect::CANONICAL_OPTIONS["exclude_types"].each do |key|
447
- it "should accept :#{key} as a synonym for :exclude_types." do
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 == 1
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
- end
455
- end
456
-
457
- describe Pointcut, ".new (exclude types and their descendents and ancestors)" do
458
- before(:each) do
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
- it "should exclude modules specified and their included modules when excluding ancestors." do
483
- pc = Pointcut.new :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
484
- :exclude_types_and_ancestors => ModuleIncludingModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
485
- check_module_ancestors pc
486
- end
487
- it "should exclude join_points whose types match an excluded ancestor modules." do
488
- pc = Pointcut.new :join_point => @mimpub_jp, :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
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
- def check_module_descendents pc
494
- expected_types = [Kernel, Object]
495
- found_types = {}
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
- found_types.size.should == 2
502
- not_expected_types = @expected_modules_not_matched_jps.map {|jp| jp.target_type}
503
- pc.join_points_not_matched.each do |jp|
504
- next if ignored_join_point(jp)
505
- not_expected_types.should include(jp.target_type)
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
- it "should exclude modules specified and their including modules and classes when excluding descendents." do
510
- pc = Pointcut.new :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
511
- :exclude_types_and_descendents => ModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
512
- check_module_descendents pc
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
- found_types.size.should == 2
529
- not_expected_types = @expected_modules_not_matched_jps.map {|jp| jp.target_type}
530
- pc.join_points_not_matched.each do |jp|
531
- next if ignored_join_point(jp)
532
- not_expected_types.should include(jp.target_type)
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
- it "should exclude classes specified and their included modules and ancestor classes when excluding ancestors." do
537
- pc = Pointcut.new :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
538
- :exclude_types_and_ancestors => ClassIncludingModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
539
- check_class_ancestors pc
540
- end
541
- it "should exclude join_points whose types match an excluded ancestor classes." do
542
- pc = Pointcut.new :join_point => @cimpub_jp, :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
545
- end
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
- def check_class_descendents pc
548
- expected_types = [Kernel, ModuleIncludingModuleWithPublicInstanceMethod, ModuleWithPublicInstanceMethod, Object]
549
- found_types = {}
550
- pc.join_points_matched.each do |jp|
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
- found_types.size.should == 4
556
- not_expected_types = @expected_modules_not_matched_jps.map {|jp| jp.target_type}
557
- pc.join_points_not_matched.each do |jp|
558
- next if ignored_join_point(jp)
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
- it "should exclude classes specified and their including modules and descendent classes when excluding descendents." do
564
- pc = Pointcut.new :types_and_ancestors => /^Class(Including|DerivedFrom).*Method/,
565
- :exclude_types_and_descendents => ClassIncludingModuleWithPublicInstanceMethod, :methods => :all, :method_options => :exclude_ancestor_methods
566
- check_class_descendents pc
567
- end
568
- it "should exclude join_points whose types match an excluded descendent types." do
569
- pc = Pointcut.new :join_point => @cimpub_jp, :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
- end
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
- describe Pointcut, ".new (:exclude_objects => objects specified)" do
576
- before(:each) do
577
- @e11 = ExcludeTestOne.new
578
- @e12 = ExcludeTestOne.new
579
- @e21 = ExcludeTestTwo.new
580
- @e22 = ExcludeTestTwo.new
581
- @e31 = ExcludeTestThree.new
582
- @e32 = ExcludeTestThree.new
583
- @objects = [@e11, @e12, @e21, @e22, @e31, @e32]
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
- it "should remove from the matched objects the excluded objects." do
587
- pc = Pointcut.new :objects => @objects, :exclude_objects => [@e22, @e31], :method_options => :exclude_ancestor_methods
588
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
589
- actual.size.should == 4
590
- [@e11, @e12, @e21, @e32].each {|e| actual.should include(e)}
591
- pc.join_points_not_matched.size.should == 0
592
- end
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
- it "should remove the specified join points corresponding to the excluded objects." do
595
- jps11 = JoinPoint.new :object => @e11, :method => :method11
596
- jps21 = JoinPoint.new :object => @e21, :method => :method21
597
- jps22 = JoinPoint.new :object => @e22, :method => :method22
598
- jps31 = JoinPoint.new :object => @e31, :method => :method31
599
- jps = [jps11, jps21, jps22, jps31]
600
- pc = Pointcut.new :join_points => jps, :exclude_objects => [@e22, @e31], :method_options => :exclude_ancestor_methods
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
- it "should not add excluded objects to the #not_matched results." do
608
- pc = Pointcut.new :objects => @objects, :exclude_objects => [@e22, @e31], :method_options => :exclude_ancestor_methods
609
- actual = pc.join_points_matched.collect {|jp| jp.type_or_object}.uniq
610
- pc.join_points_not_matched.size.should == 0
611
- end
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
- Aspect::CANONICAL_OPTIONS["exclude_objects"].each do |key|
614
- it "should accept :#{key} as a synonym for :exclude_objects." do
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
- it "should remove from the list of generated, type-based join points the set of explicitly-specified excluded join points." do
638
- excluded = [@jp11, @jp22, @jp33]
639
- expected = [@jp12, @jp13, @jp21, @jp23, @jp31, @jp32]
640
- pc = Pointcut.new :types => /ExcludeTest/, :exclude_join_points => excluded, :method_options => :exclude_ancestor_methods
641
- pc.join_points_matched.should == Set.new(expected)
642
- pc.join_points_not_matched.size.should == 0
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
- it "should remove from the list of generated, object-based join points the set of explicitly-specified excluded join points." do
646
- excluded = [@ojp12, @ojp23, @ojp31]
647
- expected = [@ojp11, @ojp13, @ojp21, @ojp22, @ojp32, @ojp33]
648
- pc = Pointcut.new :objects => [@et1, @et2, @et3], :exclude_join_points => excluded, :method_options => :exclude_ancestor_methods
649
- pc.join_points_matched.should == Set.new(expected)
650
- pc.join_points_not_matched.size.should == 0
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, key.intern => excluded
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
- it "should remove from a list of explicitly-specified join points the set of explicitly-specified excluded pointcuts." do
676
- excluded_jps = [@jp12, @jp33, @ojp11, @ojp13, @ojp23]
677
- excluded = Pointcut.new :join_points => excluded_jps
678
- expected = [@jp11, @jp13, @jp21, @jp22, @jp23, @jp31, @jp32, @ojp12, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33]
679
- pc = Pointcut.new :join_points => @all_jps, :exclude_pointcuts => excluded
680
- pc.join_points_matched.should == Set.new(expected)
681
- pc.join_points_not_matched.size.should == 0
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
- it "should remove from the list of generated, type-based join points the set of explicitly-specified excluded pointcuts." do
685
- excluded_jps = [@jp11, @jp22, @jp33]
686
- excluded = Pointcut.new :join_points => excluded_jps
687
- expected = [@jp12, @jp13, @jp21, @jp23, @jp31, @jp32]
688
- pc = Pointcut.new :types => /ExcludeTest/, :exclude_pointcuts => excluded, :method_options => :exclude_ancestor_methods
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
- it "should remove from the list of generated, object-based join points the set of explicitly-specified excluded pointcuts." do
694
- excluded_jps = [@ojp12, @ojp23, @ojp31]
695
- excluded = Pointcut.new :join_points => excluded_jps
696
- expected = [@ojp11, @ojp13, @ojp21, @ojp22, @ojp32, @ojp33]
697
- pc = Pointcut.new :objects => [@et1, @et2, @et3], :exclude_pointcuts => excluded, :method_options => :exclude_ancestor_methods
698
- pc.join_points_matched.should == Set.new(expected)
699
- pc.join_points_not_matched.size.should == 0
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
- it "should not add excluded types to the #not_matched results." do
703
- excluded_jps = [@jp12, @jp33, @ojp11, @ojp13, @ojp23]
704
- excluded = Pointcut.new :join_points => excluded_jps
705
- pc = Pointcut.new :join_points => @all_jps, :exclude_pointcuts => excluded
706
- pc.join_points_not_matched.size.should == 0
707
- end
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
- it "should result in an empty pointcut if the join points in the :exclude_pointcuts are a superset of the matched join points." do
710
- excluded = Pointcut.new :join_points => @all_jps
711
- pc = Pointcut.new :join_points => @all_jps, :exclude_pointcut => excluded
712
- pc.join_points_matched.size.should == 0
713
- pc.join_points_not_matched.size.should == 0
714
- end
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
- Aspect::CANONICAL_OPTIONS["exclude_pointcuts"].each do |key|
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
- expected = [@jp11, @jp13, @jp21, @jp22, @jp23, @jp31, @jp32, @ojp12, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33]
721
- pc = Pointcut.new :join_points => @all_jps, key.intern => excluded
722
- pc.join_points_matched.should == Set.new(expected)
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
- before(:each) do
730
- before_pointcut_class_spec
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
- Aspect::CANONICAL_OPTIONS["method_options"].each do |key|
734
- it "should accept :#{key} as a synonym for :method_options." do
735
- pc = Pointcut.new :types => ClassWithPublicInstanceMethod, key.intern => [:public, :instance, :exclude_ancestor_methods]
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
- it "should support MethodFinder's :public and :instance options for the specified objects." do
754
- pub = ClassWithPublicInstanceMethod.new
755
- pc = Pointcut.new :objects => pub, :method_options => [:public, :instance, :exclude_ancestor_methods]
756
- pc.join_points_matched.should be_eql(Set.new([JoinPoint.new(:object => pub, :method_name => :public_instance_test_method)]))
757
- pc.join_points_not_matched.size.should == 0
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
- before(:each) do
763
- before_pointcut_class_spec
764
- end
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
- it "should support MethodFinder's :protected and :instance options for the specified types." do
767
- pc = Pointcut.new :types => ClassWithProtectedInstanceMethod, :method_options => [:protected, :instance, :exclude_ancestor_methods]
768
- pc.join_points_matched.should be_eql(Set.new([@pro_jp]))
769
- pc.join_points_not_matched.size.should == 0
770
- end
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
- it "should support MethodFinder's :protected and :instance options for the specified objects." do
773
- pro = ClassWithProtectedInstanceMethod.new
774
- pc = Pointcut.new :objects => pro, :method_options => [:protected, :instance, :exclude_ancestor_methods]
775
- pc.join_points_matched.should be_eql(Set.new([JoinPoint.new(:object => pro, :method_name => :protected_instance_test_method)]))
776
- pc.join_points_not_matched.size.should == 0
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
- before(:each) do
782
- before_pointcut_class_spec
783
- end
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
- it "should support MethodFinder's :private and :instance options for the specified types." do
786
- pc = Pointcut.new :types => ClassWithPrivateInstanceMethod, :method_options => [:private, :instance, :exclude_ancestor_methods]
787
- pc.join_points_matched.should be_eql(Set.new([@pri_jp]))
788
- pc.join_points_not_matched.size.should == 0
789
- end
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
- it "should support MethodFinder's :private and :instance options for the specified objects." do
792
- pro = ClassWithPrivateInstanceMethod.new
793
- pc = Pointcut.new :objects => pro, :method_options => [:private, :instance, :exclude_ancestor_methods]
794
- pc.join_points_matched.should be_eql(Set.new([JoinPoint.new(:object => pro, :method_name => :private_instance_test_method)]))
795
- pc.join_points_not_matched.size.should == 0
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
- before(:each) do
801
- before_pointcut_class_spec
802
- end
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
- it "should support MethodFinder's :public and :class options for the specified types." do
805
- pc = Pointcut.new :types => ClassWithPublicClassMethod, :method_options => [:public, :class, :exclude_ancestor_methods]
806
- pc.join_points_matched.should be_eql(Set.new([@cpub_jp]))
807
- pc.join_points_not_matched.size.should == 0
808
- end
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
- it "should support MethodFinder's :public and :class options for the specified objects, which will return no methods." do
811
- pub = ClassWithPublicInstanceMethod.new
812
- pc = Pointcut.new :objects => pub, :method_options => [:public, :class, :exclude_ancestor_methods]
813
- pc.join_points_matched.size.should == 0
814
- pc.join_points_not_matched.size.should == 1
815
- pc.join_points_not_matched.should be_eql(Set.new([JoinPoint.new(:object => pub, :method_name => :all, :class_method => true)]))
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
- before(:each) do
821
- before_pointcut_class_spec
822
- end
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
- it "should support MethodFinder's :private and :class options for the specified types." do
825
- pc = Pointcut.new :types => ClassWithPrivateClassMethod, :method_options => [:private, :class, :exclude_ancestor_methods]
826
- pc.join_points_matched.should be_eql(Set.new([@cpri_jp]))
827
- pc.join_points_not_matched.size.should == 0
828
- end
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
- it "should support MethodFinder's :private and :class options for the specified objects, which will return no methods." do
831
- pri = ClassWithPrivateInstanceMethod.new
832
- pc = Pointcut.new :objects => pri, :method_options => [:private, :class, :exclude_ancestor_methods]
833
- pc.join_points_not_matched.should be_eql(Set.new([JoinPoint.new(:object => pri, :method_name => :all, :class_method => true)]))
834
- pc.join_points_not_matched.size.should == 1
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
- before(:each) do
840
- before_pointcut_class_spec
841
- @jp_rwe = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
842
- @jp_rw = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
843
- @jp_we = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
844
- @jp_r = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
845
- @expected_for_types = Set.new([@jp_rw, @jp_rwe, @jp_r, @jp_we])
846
- @object_of_ClassWithAttribs = ClassWithAttribs.new
847
- @jp_rwe_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
848
- @jp_rw_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
849
- @jp_we_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
850
- @jp_r_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
851
- @expected_for_objects = Set.new([@jp_rw_o, @jp_rwe_o, @jp_r_o, @jp_we_o])
852
- end
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
- it "should match on public method readers and writers for type names by default." do
855
- pc = Pointcut.new :types => "ClassWithAttribs", :methods => [/^attr/]
856
- pc.join_points_matched.should == @expected_for_types
857
- end
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
- it "should match on public method readers and writers for types by default." do
860
- pc = Pointcut.new :types => ClassWithAttribs, :methods => [/^attr/]
861
- pc.join_points_matched.should == @expected_for_types
862
- end
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
- it "should match on public method readers and writers for objects by default." do
865
- pc = Pointcut.new :object => @object_of_ClassWithAttribs, :methods => [/^attr/]
866
- pc.join_points_matched.should == @expected_for_objects
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
- before(:each) do
872
- before_pointcut_class_spec
873
- @jp_rwe = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
874
- @jp_rw = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
875
- @jp_we = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
876
- @jp_r = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
877
- @expected_for_types = Set.new([@jp_rw, @jp_rwe, @jp_r, @jp_we])
878
- @object_of_ClassWithAttribs = ClassWithAttribs.new
879
- @jp_rwe_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
880
- @jp_rw_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
881
- @jp_we_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
882
- @jp_r_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
883
- @expected_for_objects = Set.new([@jp_rw_o, @jp_rwe_o, @jp_r_o, @jp_we_o])
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
- Aspect::CANONICAL_OPTIONS["methods"].each do |key|
887
- it "should accept :#{key} as a synonym for :methods." do
888
- pc = Pointcut.new :types => "ClassWithAttribs", key.intern => [/^attr/]
889
- pc.join_points_matched.should == @expected_for_types
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
- it "should remove type-specified JoinPoints matching the excluded methods specified by name." do
900
- pc = Pointcut.new :types => [ExcludeTestOne, ExcludeTestTwo, ExcludeTestThree], :exclude_methods => [:method11, :method23], :method_options => :exclude_ancestor_methods
901
- pc.join_points_matched.size.should == 7
902
- pc.join_points_matched.should == Set.new([@jp12, @jp13, @jp21, @jp22, @jp31, @jp32, @jp33])
903
- pc.join_points_not_matched.size.should == 0
904
- end
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
- it "should remove type-specified JoinPoints matching the excluded methods specified by regular expression." do
907
- pc = Pointcut.new :types => [ExcludeTestOne, ExcludeTestTwo, ExcludeTestThree], :exclude_methods => /method[12][13]/, :method_options => :exclude_ancestor_methods
908
- pc.join_points_matched.size.should == 5
909
- pc.join_points_matched.should == Set.new([@jp12, @jp22, @jp31, @jp32, @jp33])
910
- pc.join_points_not_matched.size.should == 0
911
- end
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
- it "should remove object-specified JoinPoints matching the excluded methods specified by name." do
914
- pc = Pointcut.new :objects => [@et1, @et2, @et3], :exclude_methods => [:method11, :method23], :method_options => :exclude_ancestor_methods
915
- pc.join_points_matched.size.should == 7
916
- pc.join_points_matched.should == Set.new([@ojp12, @ojp13, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33])
917
- pc.join_points_not_matched.size.should == 0
918
- end
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
- it "should remove object-specified JoinPoints matching the excluded methods specified by regular expression." do
921
- pc = Pointcut.new :objects => [@et1, @et2, @et3], :exclude_methods => /method[12][13]/, :method_options => :exclude_ancestor_methods
922
- pc.join_points_matched.size.should == 5
923
- pc.join_points_matched.should == Set.new([@ojp12, @ojp22, @ojp31, @ojp32, @ojp33])
924
- pc.join_points_not_matched.size.should == 0
925
- end
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
- it "should remove join-point-specified JoinPoints matching the excluded methods specified by name." do
928
- pc = Pointcut.new :join_points => @all_jps, :exclude_methods => [:method11, :method23], :method_options => :exclude_ancestor_methods
929
- pc.join_points_matched.size.should == 14
930
- pc.join_points_matched.should == Set.new([@jp12, @jp13, @jp21, @jp22, @jp31, @jp32, @jp33, @ojp12, @ojp13, @ojp21, @ojp22, @ojp31, @ojp32, @ojp33])
931
- pc.join_points_not_matched.size.should == 0
932
- end
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
- it "should remove join-point-specified JoinPoints matching the excluded methods specified by regular expression." do
935
- pc = Pointcut.new :join_points => @all_jps, :exclude_methods => /method[12][13]/, :method_options => :exclude_ancestor_methods
936
- pc.join_points_matched.size.should == 10
937
- pc.join_points_matched.should == Set.new([@jp12, @jp22, @jp31, @jp32, @jp33, @ojp12, @ojp22, @ojp31, @ojp32, @ojp33])
938
- pc.join_points_not_matched.size.should == 0
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
- Aspect::CANONICAL_OPTIONS["exclude_methods"].each do |key|
942
- it "should accept :#{key} as a synonym for :exclude_methods." do
943
- pc = Pointcut.new :join_points => @all_jps, key.intern => /method[12][13]/, :method_options => :exclude_ancestor_methods
944
- pc.join_points_matched.size.should == 10
945
- pc.join_points_matched.should == Set.new([@jp12, @jp22, @jp31, @jp32, @jp33, @ojp12, @ojp22, @ojp31, @ojp32, @ojp33])
946
- pc.join_points_not_matched.size.should == 0
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
- describe Pointcut, ".new (types or objects specified with attribute regular expressions)" do
952
- before(:each) do
953
- before_pointcut_class_spec
954
- @jp_rwe = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
955
- @jp_rw = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
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
- it "should match on public attribute readers and writers for type names by default." do
968
- pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^attr/]
969
- pc.join_points_matched.size.should == 4
970
- pc.join_points_matched.should == @expected_for_types
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
- it "should match on public attribute readers and writers for types by default." do
974
- pc = Pointcut.new :types => ClassWithAttribs, :attributes => [/^attr/]
975
- pc.join_points_matched.should == @expected_for_types
976
- end
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
- it "should match on public attribute readers and writers for objects by default." do
979
- pc = Pointcut.new :object => @object_of_ClassWithAttribs, :attributes => [/^attr/]
980
- pc.join_points_matched.should == @expected_for_objects
981
- end
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
- it "should match attribute specifications for types that are prefixed with @." do
984
- pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^@attr.*ClassWithAttribs/]
985
- pc.join_points_matched.should == @expected_for_types
986
- end
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
- it "should match attribute specifications for objects that are prefixed with @." do
989
- pc = Pointcut.new :object => @object_of_ClassWithAttribs, :attributes => [/^@attr.*ClassWithAttribs/]
990
- pc.join_points_matched.should == @expected_for_objects
991
- end
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
- it "should match attribute specifications that are regular expressions of symbols." do
994
- pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^:attr.*ClassWithAttribs/]
995
- pc.join_points_matched.should == @expected_for_types
996
- end
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
- it "should match attribute specifications for objects that are regular expressions of symbols." do
999
- object = ClassWithAttribs.new
1000
- pc = Pointcut.new :object => object, :attributes => [/^:attr.*ClassWithAttribs/]
1001
- pc.join_points_matched.should == Set.new([
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
- it "should match public attribute readers and writers for types when both the :readers and :writers options are specified." do
1009
- pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^attr.*ClassWithAttribs/], :attribute_options => [:readers, :writers]
1010
- pc.join_points_matched.should == @expected_for_types
1011
- end
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
- it "should match public attribute readers and writers for objects when both the :readers and :writers options are specified." do
1014
- object = ClassWithAttribs.new
1015
- pc = Pointcut.new :object => object, :attributes => [/^:attr.*ClassWithAttribs/], :attribute_options => [:readers, :writers]
1016
- pc.join_points_matched.should == Set.new([
1017
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
1018
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
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
- it "should match public attribute readers for types only when the :readers option is specified." do
1024
- pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^attr.*ClassWithAttribs/], :attribute_options => [:readers]
1025
- pc.join_points_matched.should == Set.new([
1026
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
1027
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
1028
- end
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
- it "should match public attribute readers for objects only when the :readers option is specified." do
1031
- object = ClassWithAttribs.new
1032
- pc = Pointcut.new :object => object, :attributes => [/^:attr.*ClassWithAttribs/], :attribute_options => [:readers]
1033
- pc.join_points_matched.should == Set.new([
1034
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
1035
- JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
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
- it "should match public attribute writers for types only when the :writers option is specified." do
1039
- pc = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^attr.*ClassWithAttribs/], :attribute_options => [:writers]
1040
- pc.join_points_matched.should == Set.new([
1041
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
1042
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
1043
- end
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
- it "should match public attribute writers for objects only when the :writers option is specified." do
1046
- object = ClassWithAttribs.new
1047
- pc = Pointcut.new :object => object, :attributes => [/^:attr.*ClassWithAttribs/], :attribute_options => [:writers]
1048
- pc.join_points_matched.should == Set.new([
1049
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
1050
- JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
1051
- end
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
- it "should match attribute writers for types whether or not the attributes specification ends with an equal sign." do
1054
- pc = Pointcut.new :types => "ClassWithAttribs",
1055
- :attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:writers]
1056
- pc.join_points_matched.should == Set.new([
1057
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
1058
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
1059
- pc2 = Pointcut.new :types => "ClassWithAttribs",
1060
- :attributes => [/^attr[RW]+_ClassWithAttribs/], :attribute_options => [:writers]
1061
- pc2.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
- 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
- it "should match attribute writers for objects whether or not the attributes specification ends with an equal sign." do
1067
- object = ClassWithAttribs.new
1068
- pc = Pointcut.new :object => object, :attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:writers]
1069
- pc.join_points_matched.should == Set.new([
1070
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
1071
- JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
1072
- pc2 = Pointcut.new :object => object, :attributes => [/^attr[RW]+_ClassWithAttribs/], :attribute_options => [:writers]
1073
- pc2.join_points_matched.should == Set.new([
1074
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
1075
- JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
1076
- end
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
- it "should match attribute readers for types when the :readers option is specified even if the attributes specification ends with an equal sign!" do
1079
- pc = Pointcut.new :types => "ClassWithAttribs",
1080
- :attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:readers]
1081
- pc.join_points_matched.should == Set.new([
1082
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
1083
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
1084
- pc2 = Pointcut.new :types => "ClassWithAttribs",
1085
- :attributes => [/^attr[RW]+_ClassWithAttribs=/], :attribute_options => [:readers]
1086
- pc2.join_points_matched.should == Set.new([
1087
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
1088
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
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
- before(:each) do
1106
- before_pointcut_class_spec
1107
- @jp_rwe = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
1108
- @jp_rw = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
1109
- @jp_we = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
1110
- @jp_r = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
1111
- @expected_for_types = Set.new([@jp_rw, @jp_rwe, @jp_r, @jp_we])
1112
- @object_of_ClassWithAttribs = ClassWithAttribs.new
1113
- @jp_rwe_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
1114
- @jp_rw_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
1115
- @jp_we_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
1116
- @jp_r_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
1117
- @expected_for_objects = Set.new([@jp_rw_o, @jp_rwe_o, @jp_r_o, @jp_we_o])
1118
- end
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
- it "should match on public attribute readers and writers for type names by default." do
1121
- pc = Pointcut.new :types => "ClassWithAttribs", :accessing => [/^attr/]
1122
- pc.join_points_matched.size.should == 4
1123
- pc.join_points_matched.should == @expected_for_types
1124
- end
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
- it "should match on public attribute readers and writers for types by default." do
1127
- pc = Pointcut.new :types => ClassWithAttribs, :accessing => [/^attr/]
1128
- pc.join_points_matched.should == @expected_for_types
1129
- end
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
- it "should match on public attribute readers and writers for objects by default." do
1132
- pc = Pointcut.new :object => @object_of_ClassWithAttribs, :accessing => [/^attr/]
1133
- pc.join_points_matched.should == @expected_for_objects
1134
- end
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
- it "should match attribute specifications for types that are prefixed with @." do
1137
- pc = Pointcut.new :types => "ClassWithAttribs", :accessing => [/^@attr.*ClassWithAttribs/]
1138
- pc.join_points_matched.should == @expected_for_types
1139
- end
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
- it "should match attribute specifications for objects that are prefixed with @." do
1142
- pc = Pointcut.new :object => @object_of_ClassWithAttribs, :accessing => [/^@attr.*ClassWithAttribs/]
1143
- pc.join_points_matched.should == @expected_for_objects
1144
- end
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
- it "should match attribute specifications that are regular expressions of symbols." do
1147
- pc = Pointcut.new :types => "ClassWithAttribs", :accessing => [/^:attr.*ClassWithAttribs/]
1148
- pc.join_points_matched.should == @expected_for_types
1149
- end
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
- it "should match attribute specifications for objects that are regular expressions of symbols." do
1152
- object = ClassWithAttribs.new
1153
- pc = Pointcut.new :object => object, :accessing => [/^:attr.*ClassWithAttribs/]
1154
- pc.join_points_matched.should == Set.new([
1155
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
1156
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
1157
- JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs),
1158
- JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
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
- before(:each) do
1164
- before_pointcut_class_spec
1165
- @jp_rwe = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
1166
- @jp_rw = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
1167
- @jp_we = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
1168
- @jp_r = JoinPoint.new :type => ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
1169
- @expected_for_types = Set.new([@jp_rw, @jp_rwe, @jp_r, @jp_we])
1170
- @object_of_ClassWithAttribs = ClassWithAttribs.new
1171
- @jp_rwe_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs=
1172
- @jp_rw_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrRW_ClassWithAttribs
1173
- @jp_we_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrW_ClassWithAttribs=
1174
- @jp_r_o = JoinPoint.new :object => @object_of_ClassWithAttribs, :method_name => :attrR_ClassWithAttribs
1175
- @expected_for_objects = Set.new([@jp_rw_o, @jp_rwe_o, @jp_r_o, @jp_we_o])
1176
- end
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
- it "should only allow :reading and :writing options together if they specify the same attributes." do
1179
- lambda {Pointcut.new :types => "ClassWithAttribs", :reading => [/^attrRW_ClassWithAttribs/], :writing => [/^attr.*ClassWithAttribs/]}.should raise_error(Aquarium::Utils::InvalidOptions)
1180
- end
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
- it "should match public attribute readers and writers for types when both the :reading and :writing options are specified." do
1183
- pc = Pointcut.new :types => "ClassWithAttribs", :reading => [/^attr.*ClassWithAttribs/], :writing => [/^attr.*ClassWithAttribs/]
1184
- pc.join_points_matched.should == @expected_for_types
1185
- end
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
- it "should match public attribute readers and writers for types when both the :reading and :changing options are specified." do
1188
- pc = Pointcut.new :types => "ClassWithAttribs", :reading => [/^attr.*ClassWithAttribs/], :changing => [/^attr.*ClassWithAttribs/]
1189
- pc.join_points_matched.should == @expected_for_types
1190
- end
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
- it "should match public attribute readers and writers for objects when both the :reading and :writing options are specified." do
1193
- object = ClassWithAttribs.new
1194
- pc = Pointcut.new :object => object, :reading => [/^attr.*ClassWithAttribs/], :writing => [/^attr.*ClassWithAttribs/]
1195
- pc.join_points_matched.should == Set.new([
1196
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
1197
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
1198
- JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs),
1199
- JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
1200
- end
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
- it "should match public attribute readers for types only when the :reading option is specified." do
1203
- pc = Pointcut.new :types => "ClassWithAttribs", :reading => [/^attr.*ClassWithAttribs/]
1204
- pc.join_points_matched.should == Set.new([
1205
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
1206
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
1207
- end
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
- it "should match public attribute readers for objects only when the :reading option is specified." do
1210
- object = ClassWithAttribs.new
1211
- pc = Pointcut.new :object => object, :reading => [/^:attr.*ClassWithAttribs/]
1212
- pc.join_points_matched.should == Set.new([
1213
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
1214
- JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
1215
- end
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
- it "should match public attribute writers for types only when the :writing option is specified." do
1218
- pc = Pointcut.new :types => "ClassWithAttribs", :writing => [/^attr.*ClassWithAttribs/]
1219
- pc.join_points_matched.should == Set.new([
1220
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
1221
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
1222
- end
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
- it "should match public attribute writers for objects only when the :writing option is specified." do
1225
- object = ClassWithAttribs.new
1226
- pc = Pointcut.new :object => object, :writing => [/^:attr.*ClassWithAttribs/]
1227
- pc.join_points_matched.should == Set.new([
1228
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
1229
- JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
1230
- end
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
- it "should match attribute writers for types whether or not the attributes specification ends with an equal sign." do
1233
- pc = Pointcut.new :types => "ClassWithAttribs", :writing => [/^attr[RW]+_ClassWithAttribs=/]
1234
- pc.join_points_matched.should == Set.new([
1235
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
1236
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
1237
- pc2 = Pointcut.new :types => "ClassWithAttribs", :writing => [/^attr[RW]+_ClassWithAttribs/]
1238
- pc2.join_points_matched.should == Set.new([
1239
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs=),
1240
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrW_ClassWithAttribs=)])
1241
- end
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
- it "should match attribute writers for objects whether or not the attributes specification ends with an equal sign." do
1244
- object = ClassWithAttribs.new
1245
- pc = Pointcut.new :object => object, :writing => [/^attr[RW]+_ClassWithAttribs=/]
1246
- pc.join_points_matched.should == Set.new([
1247
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
1248
- JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
1249
- pc2 = Pointcut.new :object => object, :writing => [/^attr[RW]+_ClassWithAttribs/]
1250
- pc2.join_points_matched.should == Set.new([
1251
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs=),
1252
- JoinPoint.new(:object => object, :method_name => :attrW_ClassWithAttribs=)])
1253
- end
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
- it "should match attribute readers for types when the :reading option is specified even if the attributes specification ends with an equal sign!" do
1256
- pc = Pointcut.new :types => "ClassWithAttribs", :reading => [/^attr[RW]+_ClassWithAttribs=/]
1257
- pc.join_points_matched.should == Set.new([
1258
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
1259
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
1260
- pc2 = Pointcut.new :types => "ClassWithAttribs", :reading => [/^attr[RW]+_ClassWithAttribs=/]
1261
- pc2.join_points_matched.should == Set.new([
1262
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrRW_ClassWithAttribs),
1263
- JoinPoint.new(:type => "ClassWithAttribs", :method_name => :attrR_ClassWithAttribs)])
1264
- end
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
- it "should match attribute readers for objects when the :reading option is specified even if the attributes specification ends with an equal sign!" do
1267
- object = ClassWithAttribs.new
1268
- pc = Pointcut.new :object => object, :reading => [/^attr[RW]+_ClassWithAttribs=/]
1269
- pc.join_points_matched.should == Set.new([
1270
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
1271
- JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
1272
- pc2 = Pointcut.new :object => object, :reading => [/^attr[RW]+_ClassWithAttribs/]
1273
- pc2.join_points_matched.should == Set.new([
1274
- JoinPoint.new(:object => object, :method_name => :attrRW_ClassWithAttribs),
1275
- JoinPoint.new(:object => object, :method_name => :attrR_ClassWithAttribs)])
1276
- end
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
- it "should ignore :accessing, :reading, and :writing for the join points specified." do
1315
- pc = Pointcut.new :join_points => (@expected_matched + @expected_not_matched),
1316
- :accessing => :name, :reading => :name, :writing => :name
1317
- pc.join_points_matched.should == Set.new(@expected_matched)
1318
- pc.join_points_not_matched.should == Set.new(@expected_not_matched)
1319
- end
1320
- end
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
- describe Pointcut, ".new (methods that end in non-alphanumeric characters)" do
1323
- class ClassWithFunkyMethodNames
1324
- def huh?; true; end
1325
- def yes!; true; end
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
- {'?' => :huh?, '!' => :yes!, '=' => :x=}.each do |char, method|
1336
- it "should match instance methods for types when searching for names that end with a '#{char}' character." do
1337
- pc = Pointcut.new :types => ClassWithFunkyMethodNames, :method => method, :method_options => [:exclude_ancestor_methods]
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 match instance methods for objects when searching for names that end with a '#{char}' character." do
1343
- pc = Pointcut.new :object => @funky, :method => method, :method_options => [:exclude_ancestor_methods]
1344
- expected_jp = JoinPoint.new :object => @funky, :method_name => method
1345
- pc.join_points_matched.should == Set.new([expected_jp])
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 match instance methods for types when searching for names that end with a '#{char}' character, using a regular expressions." do
1349
- pc = Pointcut.new :types => ClassWithFunkyMethodNames, :methods => /#{Regexp.escape(char)}$/, :method_options => [:exclude_ancestor_methods]
1350
- expected_jp = JoinPoint.new :type => ClassWithFunkyMethodNames, :method_name => method
1351
- pc.join_points_matched.should == Set.new([expected_jp])
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 match instance methods for object when searching for names that end with a '#{char}' character, using a regular expressions." do
1355
- pc = Pointcut.new :object => @funky, :methods => /#{Regexp.escape(char)}$/, :method_options => [:exclude_ancestor_methods]
1356
- expected_jp = JoinPoint.new :object => @funky, :method_name => method
1357
- pc.join_points_matched.should == Set.new([expected_jp])
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
- {'=' => :==, '~' => :=~}.each do |char, method|
1362
- 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
1363
- pc = Pointcut.new :types => ClassWithFunkyMethodNames, :method => method, :method_options => [:instance]
1364
- expected_jp = JoinPoint.new :type => ClassWithFunkyMethodNames, :method_name => method
1365
- pc.join_points_matched.should == Set.new([expected_jp])
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
- 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
1369
- pc = Pointcut.new :object => @funky, :method => method, :method_options => [:instance]
1370
- expected_jp = JoinPoint.new :object => @funky, :method_name => method
1371
- pc.join_points_matched.should == Set.new([expected_jp])
1372
- end
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
- 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
1375
- pc = Pointcut.new :types => ClassWithFunkyMethodNames, :methods => /#{Regexp.escape(char)}$/, :method_options => [:instance]
1376
- pc.join_points_matched.any? {|jp| jp.method_name == method}.should be_true
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
- 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
1380
- pc = Pointcut.new :object => @funky, :methods => /#{Regexp.escape(char)}$/, :method_options => [:instance]
1381
- pc.join_points_matched.any? {|jp| jp.method_name == method}.should be_true
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
- it "should raise if :all is used for types (not yet supported)." do
1388
- lambda { Pointcut.new :types => "ClassWithAttribs", :attributes => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
1389
- end
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
- it "should raise if :all is used for objects (not yet supported)." do
1392
- lambda { Pointcut.new :object => ClassWithAttribs.new, :attributes => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
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
- it "should raise if :all is used for types (not yet supported)." do
1398
- lambda { Pointcut.new :types => "ClassWithAttribs", :accessing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
1399
- end
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
- it "should raise if :all is used for objects (not yet supported)." do
1402
- lambda { Pointcut.new :object => ClassWithAttribs.new, :accessing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
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
- it "should raise if :all is used for types (not yet supported)." do
1408
- lambda { Pointcut.new :types => "ClassWithAttribs", :changing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
1409
- end
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
- it "should raise if :all is used for objects (not yet supported)." do
1412
- lambda { Pointcut.new :object => ClassWithAttribs.new, :changing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
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
- it "should raise if :all is used for types (not yet supported)." do
1418
- lambda { Pointcut.new :types => "ClassWithAttribs", :reading => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
1419
- end
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
- it "should raise if :all is used for objects (not yet supported)." do
1422
- lambda { Pointcut.new :object => ClassWithAttribs.new, :reading => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
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
- it "should raise if :all is used for types (not yet supported)." do
1428
- lambda { Pointcut.new :types => "ClassWithAttribs", :writing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
1429
- end
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
- it "should raise if :all is used for objects (not yet supported)." do
1432
- lambda { Pointcut.new :object => ClassWithAttribs.new, :writing => :all }.should raise_error(Aquarium::Utils::InvalidOptions)
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
- before(:each) do
1439
- class Empty; end
1443
+ before(:each) do
1444
+ class Empty; end
1440
1445
 
1441
- @objectWithSingletonMethod = Empty.new
1442
- class << @objectWithSingletonMethod
1443
- def a_singleton_method
1446
+ @objectWithSingletonMethod = Empty.new
1447
+ class << @objectWithSingletonMethod
1448
+ def a_singleton_method
1449
+ end
1444
1450
  end
1445
- end
1446
1451
 
1447
- class NotQuiteEmpty
1448
- end
1449
- class << NotQuiteEmpty
1450
- def a_class_singleton_method
1452
+ class NotQuiteEmpty
1451
1453
  end
1452
- end
1453
- @notQuiteEmpty = NotQuiteEmpty.new
1454
- end
1454
+ class << NotQuiteEmpty
1455
+ def a_class_singleton_method
1456
+ end
1457
+ end
1458
+ @notQuiteEmpty = NotQuiteEmpty.new
1459
+ end
1455
1460
 
1456
- it "should find instance-level singleton method joinpoints for objects when :singleton is specified." do
1457
- pc = Pointcut.new :objects => [@notQuiteEmpty, @objectWithSingletonMethod], :methods => :all, :method_options => [:singleton]
1458
- pc.join_points_matched.should == Set.new([JoinPoint.new(:object => @objectWithSingletonMethod, :method_name => :a_singleton_method)])
1459
- pc.join_points_not_matched.should == Set.new([JoinPoint.new(:object => @notQuiteEmpty, :method_name => :all)])
1460
- end
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
- it "should raise when specifying method options :singleton with :class, :public, :protected, or :private." do
1469
- lambda { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :class]}.should raise_error(Aquarium::Utils::InvalidOptions)
1470
- lambda { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :public]}.should raise_error(Aquarium::Utils::InvalidOptions)
1471
- lambda { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :protected]}.should raise_error(Aquarium::Utils::InvalidOptions)
1472
- lambda { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :private]}.should raise_error(Aquarium::Utils::InvalidOptions)
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
- describe Pointcut, "#empty?" do
1477
- it "should be true if there are no matched and no unmatched join points." do
1478
- pc = Pointcut.new
1479
- pc.join_points_matched.size.should == 0
1480
- pc.join_points_not_matched.size.should == 0
1481
- pc.should be_empty
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
- it "should be false if there are matched join points." do
1485
- pc = Pointcut.new :types => [ClassWithAttribs], :methods => [/^attr/]
1486
- pc.join_points_matched.size.should > 0
1487
- pc.join_points_not_matched.size.should == 0
1488
- pc.should_not be_empty
1489
- end
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
- it "should be false if there are unmatched join points." do
1492
- pc = Pointcut.new :types => [String], :methods => [/^attr/]
1493
- pc.join_points_matched.size.should == 0
1494
- pc.join_points_not_matched.size.should > 0
1495
- pc.should_not be_empty
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
- it "should return true for the same Pointcut object." do
1501
- pc = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
1502
- pc.should be_eql(pc)
1503
- pc1 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /_test_method$/
1504
- pc1.should be_eql(pc1)
1505
- end
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
- it "should return true for Pointcuts that specify the same types and methods." do
1508
- pc1 = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
1509
- pc2 = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
1510
- pc1.should be_eql(pc2)
1511
- end
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
- it "should return false if the matched types are different." do
1514
- pc1 = Pointcut.new :types => /ClassWithPublicMethod/
1515
- pc2 = Pointcut.new :types => /Class.*Method/
1516
- pc1.should_not eql(pc2)
1517
- end
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
- it "should return false for Pointcuts that specify different types, even if no methods match." do
1520
- pc1 = Pointcut.new :types => /ClassWithPublicMethod/, :methods => /foobar/
1521
- pc2 = Pointcut.new :types => /Class.*Method/ , :methods => /foobar/
1522
- pc1.should_not eql(pc2)
1523
- end
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
- it "should return false for Pointcuts that specify different methods." do
1526
- pc1 = Pointcut.new :types => /ClassWithPublicMethod/, :methods =>/^private/
1527
- pc2 = Pointcut.new :types => /ClassWithPublicMethod/, :methods =>/^public/
1528
- pc1.should_not eql(pc2)
1529
- end
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
- it "should return false for Pointcuts that specify equivalent objects that are not the same object." do
1532
- pc1 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /_test_method$/
1533
- pc2 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /_test_method$/
1534
- pc1.should_not eql(pc2)
1535
- end
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
- it "should return false for Pointcuts that specify equivalent objects that are not the same object, even if no methods match." do
1538
- pc1 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /foobar/
1539
- pc2 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /foobar/
1540
- pc1.should_not eql(pc2)
1541
- end
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
- it "should return false if the matched objects are different objects." do
1544
- pc1 = Pointcut.new :object => ClassWithPublicClassMethod.new, :methods => /_test_method$/
1545
- pc2 = Pointcut.new :object => ClassWithPrivateClassMethod.new, :methods => /_test_method$/
1546
- pc1.should_not eql(pc2)
1547
- end
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
- it "should return true if the matched objects are the same object." do
1550
- object = ClassWithPublicClassMethod.new
1551
- pc1 = Pointcut.new :object => object, :methods => /_test_method$/
1552
- pc2 = Pointcut.new :object => object, :methods => /_test_method$/
1553
- pc1.should eql(pc2)
1554
- end
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
- it "should return false if the not_matched types are different." do
1557
- pc1 = Pointcut.new :types => :UnknownFoo
1558
- pc2 = Pointcut.new :types => :UnknownBar
1559
- pc1.should_not eql(pc2)
1560
- end
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
- it "should return false if the matched methods for the same types are different." do
1563
- pc1 = Pointcut.new :types => /Class.*Method/, :methods => /public.*_test_method$/
1564
- pc2 = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
1565
- pc1.should_not == pc2
1566
- end
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
- it "should return false if the matched methods for the same objects are different." do
1569
- pub = ClassWithPublicInstanceMethod.new
1570
- pri = ClassWithPrivateInstanceMethod.new
1571
- pc1 = Pointcut.new :objects => [pub, pri], :methods => /public.*_test_method$/
1572
- pc2 = Pointcut.new :objects => [pub, pri], :methods => /_test_method$/
1573
- pc1.should_not == pc2
1574
- end
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
- it "should return false if the not_matched methods for the same types are different." do
1577
- pc1 = Pointcut.new :types => /Class.*Method/, :methods => /foo/
1578
- pc2 = Pointcut.new :types => /Class.*Method/, :methods => /bar/
1579
- pc1.should_not == pc2
1580
- end
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
- it "should return false if the not_matched methods for the same objects are different." do
1583
- pub = ClassWithPublicInstanceMethod.new
1584
- pri = ClassWithPrivateInstanceMethod.new
1585
- pc1 = Pointcut.new :objects => [pub, pri], :methods => /foo/
1586
- pc2 = Pointcut.new :objects => [pub, pri], :methods => /bar/
1587
- pc1.should_not == pc2
1588
- end
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
- it "should return false if the matched attributes for the same types are different." do
1591
- pc1 = Pointcut.new :types => /Class.*Method/, :attributes => /attrRW/
1592
- pc2 = Pointcut.new :types => /Class.*Method/, :attributes => /attrR/
1593
- pc1.should_not == pc2
1594
- end
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
- it "should return false if the matched attributes for the same objects are different." do
1597
- pub = ClassWithPublicInstanceMethod.new
1598
- pri = ClassWithPrivateInstanceMethod.new
1599
- pc1 = Pointcut.new :objects => [pub, pri], :attributes => /attrRW/
1600
- pc2 = Pointcut.new :objects => [pub, pri], :attributes => /attrR/
1601
- pc1.should_not == pc2
1602
- end
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
- it "should return false if the not_matched attributes for the same types are different." do
1605
- pc1 = Pointcut.new :types => /Class.*Method/, :attributes => /foo/
1606
- pc2 = Pointcut.new :types => /Class.*Method/, :attributes => /bar/
1607
- pc1.should_not == pc2
1608
- end
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
- it "should return false if the not_matched attributes for the same objects are different." do
1611
- pub = ClassWithPublicInstanceMethod.new
1612
- pri = ClassWithPrivateInstanceMethod.new
1613
- pc1 = Pointcut.new :objects => [pub, pri], :attributes => /foo/
1614
- pc2 = Pointcut.new :objects => [pub, pri], :attributes => /bar/
1615
- pc1.should_not == pc2
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
- it "should be an alias for #==" do
1621
- pc1 = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
1622
- pc2 = Pointcut.new :types => /Class.*Method/, :methods => /_test_method$/
1623
- pc3 = Pointcut.new :objects => [ClassWithPublicInstanceMethod.new, ClassWithPublicInstanceMethod.new]
1624
- pc1.should be_eql(pc1)
1625
- pc1.should be_eql(pc2)
1626
- pc1.should_not eql(pc3)
1627
- pc2.should_not eql(pc3)
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
- before(:each) do
1633
- before_pointcut_class_spec
1634
- end
1636
+ describe Pointcut, "#candidate_types" do
1637
+ before(:each) do
1638
+ before_pointcut_class_spec
1639
+ end
1635
1640
 
1636
- it "should return only candidate matching types when the input types exist." do
1637
- pc = Pointcut.new :types => @example_classes
1638
- 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}
1639
- pc.candidate_types.not_matched_keys.should == []
1640
- end
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
- it "should return only candidate matching types when the input type names correspond to existing types." do
1643
- pc = Pointcut.new :types => @example_classes.map {|t| t.to_s}
1644
- 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}
1645
- pc.candidate_types.not_matched_keys.should == []
1646
- end
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
- it "should return only candidate non-matching types when the input types do not exist." do
1649
- pc = Pointcut.new :types => 'NonExistentClass'
1650
- pc.candidate_types.matched_keys.should == []
1651
- pc.candidate_types.not_matched_keys.should == ['NonExistentClass']
1652
- end
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
- it "should return no candidate matching or non-matching types when only objects are input." do
1655
- pc = Pointcut.new :objects => @example_classes.map {|t| t.new}
1656
- pc.candidate_types.matched_keys.should == []
1657
- pc.candidate_types.not_matched_keys.should == []
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
- before(:each) do
1663
- before_pointcut_class_spec
1664
- end
1666
+ describe Pointcut, "#candidate_objects" do
1667
+ before(:each) do
1668
+ before_pointcut_class_spec
1669
+ end
1665
1670
 
1666
- it "should return only candidate matching objects when the input are objects." do
1667
- example_objs = @example_classes.map {|t| t.new}
1668
- pc = Pointcut.new :objects => example_objs
1669
- example_objs.each do |obj|
1670
- pc.candidate_objects.matched[obj].should_not be(nil?)
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
- before(:each) do
1678
- before_pointcut_class_spec
1679
- end
1681
+ describe Pointcut, "#candidate_join_points" do
1682
+ before(:each) do
1683
+ before_pointcut_class_spec
1684
+ end
1680
1685
 
1681
- it "should return only candidate non-matching join points for the input join points that do not exist." do
1682
- anClassWithPublicInstanceMethod = ClassWithPublicInstanceMethod.new
1683
- example_jps = [
1684
- JoinPoint.new(:type => ClassWithPublicInstanceMethod, :method => :foo),
1685
- JoinPoint.new(:object => anClassWithPublicInstanceMethod, :method => :foo)]
1686
- pc = Pointcut.new :join_points => example_jps
1687
- pc.candidate_join_points.matched.size.should == 0
1688
- pc.candidate_join_points.not_matched[example_jps[0]].should_not be_nil
1689
- pc.candidate_join_points.not_matched[example_jps[1]].should_not be_nil
1690
- end
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
- it "should return only candidate matching join points for the input join points that do exist." do
1693
- anClassWithPublicInstanceMethod = ClassWithPublicInstanceMethod.new
1694
- example_jps = [
1695
- JoinPoint.new(:type => ClassWithPublicInstanceMethod, :method => :public_instance_test_method),
1696
- JoinPoint.new(:object => anClassWithPublicInstanceMethod, :method => :public_instance_test_method)]
1697
- pc = Pointcut.new :join_points => example_jps
1698
- pc.candidate_join_points.matched.size.should == 2
1699
- pc.candidate_join_points.matched[example_jps[0]].should_not be_nil
1700
- pc.candidate_join_points.matched[example_jps[1]].should_not be_nil
1701
- pc.candidate_join_points.not_matched.size.should == 0
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
- before(:each) do
1707
- before_pointcut_class_spec
1708
- @empty_set = Set.new
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
- it "should return ':attribute_options => []', by default, if no arguments are given." do
1732
- pc = Pointcut.new
1733
- pc.specification.should == @default_specification_all_methods
1734
- end
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
- it "should return the input :types and :type arguments combined into an array keyed by :types." do
1737
- pc = Pointcut.new :types => @example_classes, :type => String
1738
- pc.specification.should == { :types => Set.new(@example_classes + [String]) } | @default_specification_all_methods
1739
- end
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
- it "should return the input :objects and :object arguments combined into an array keyed by :objects." do
1742
- example_objs = @example_classes.map {|t| t.new}
1743
- s1234 = "1234"
1744
- pc = Pointcut.new :objects => example_objs, :object => s1234
1745
- pc.specification.should == { :objects => Set.new(example_objs + [s1234]) } | @default_specification_all_methods
1746
- end
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
- it "should return the input :methods and :method arguments combined into an array keyed by :methods." do
1749
- pc = Pointcut.new :types => @example_classes, :methods => /^get/, :method => "dup"
1750
- pc.specification.should == { :types => Set.new(@example_classes), :methods => Set.new([/^get/, "dup"]) } | @default_specification
1751
- end
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
- it "should return the input :method_options verbatim." do
1754
- pc = Pointcut.new :types => @example_classes, :methods => /^get/, :method => "dup", :method_options => [:instance, :public]
1755
- pc.specification.should == { :types => Set.new(@example_classes), :methods => Set.new([/^get/, "dup"]),
1756
- :method_options => Set.new([:instance, :public]), :default_objects => @empty_set } | @default_specification
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
- it "should return the input :methods and :method arguments combined into an array keyed by :methods." do
1760
- pc = Pointcut.new :types => @example_classes, :attributes => /^state/, :attribute => "name"
1761
- pc.specification.should == { :types => Set.new(@example_classes), :objects => @empty_set, :join_points => @empty_set,
1762
- :methods => @empty_set, :method_options => Set.new([]), :default_objects => @empty_set,
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
- it "should return the input :attributes, :attribute and :attribute_options arguments, verbatim." do
1767
- pc = Pointcut.new :types => @example_classes, :attributes => /^state/, :attribute => "name", :attribute_options => :reader
1768
- pc.specification.should == { :types => Set.new(@example_classes), :attributes => Set.new([/^state/, "name"]),
1769
- :attribute_options => Set.new([:reader]) } | @default_specification
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