aquarium 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/CHANGES +59 -2
  2. data/README +33 -16
  3. data/RELEASE-PLAN +28 -5
  4. data/UPGRADE +11 -0
  5. data/examples/aspect_design_example.rb +2 -2
  6. data/examples/aspect_design_example_spec.rb +2 -2
  7. data/examples/design_by_contract_example.rb +4 -4
  8. data/examples/design_by_contract_example_spec.rb +4 -4
  9. data/examples/method_missing_example.rb +4 -1
  10. data/examples/method_missing_example_spec.rb +4 -1
  11. data/examples/method_tracing_example.rb +2 -2
  12. data/examples/method_tracing_example_spec.rb +16 -16
  13. data/lib/aquarium/aspects/advice.rb +47 -25
  14. data/lib/aquarium/aspects/aspect.rb +81 -39
  15. data/lib/aquarium/aspects/dsl/aspect_dsl.rb +1 -1
  16. data/lib/aquarium/aspects/exclusion_handler.rb +2 -2
  17. data/lib/aquarium/aspects/join_point.rb +28 -28
  18. data/lib/aquarium/aspects/pointcut.rb +61 -15
  19. data/lib/aquarium/extras/design_by_contract.rb +7 -7
  20. data/lib/aquarium/finders.rb +0 -1
  21. data/lib/aquarium/finders/method_finder.rb +10 -20
  22. data/lib/aquarium/finders/type_finder.rb +141 -75
  23. data/lib/aquarium/utils.rb +1 -0
  24. data/lib/aquarium/utils/logic_error.rb +9 -0
  25. data/lib/aquarium/utils/method_utils.rb +4 -3
  26. data/lib/aquarium/utils/nil_object.rb +1 -0
  27. data/lib/aquarium/utils/type_utils.rb +19 -0
  28. data/lib/aquarium/version.rb +2 -2
  29. data/spec/aquarium/aspects/advice_chain_node_spec.rb +2 -2
  30. data/spec/aquarium/aspects/advice_spec.rb +28 -5
  31. data/spec/aquarium/aspects/aspect_invocation_spec.rb +522 -289
  32. data/spec/aquarium/aspects/aspect_spec.rb +59 -41
  33. data/spec/aquarium/aspects/aspect_with_nested_types_spec.rb +7 -7
  34. data/spec/aquarium/aspects/aspect_with_subtypes_spec.rb +2 -2
  35. data/spec/aquarium/aspects/concurrent_aspects_spec.rb +1 -2
  36. data/spec/aquarium/aspects/concurrent_aspects_with_objects_and_types_spec.rb +1 -1
  37. data/spec/aquarium/aspects/dsl/aspect_dsl_spec.rb +34 -34
  38. data/spec/aquarium/aspects/join_point_spec.rb +79 -0
  39. data/spec/aquarium/aspects/pointcut_or_composition_spec.rb +13 -3
  40. data/spec/aquarium/aspects/pointcut_spec.rb +310 -63
  41. data/spec/aquarium/extras/design_by_contract_spec.rb +4 -4
  42. data/spec/aquarium/finders/method_finder_spec.rb +208 -54
  43. data/spec/aquarium/finders/type_finder_spec.rb +24 -88
  44. data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +206 -0
  45. data/spec/aquarium/spec_example_classes.rb +75 -12
  46. data/spec/aquarium/utils/logic_error_spec.rb +10 -0
  47. data/spec/aquarium/utils/type_utils_sample_classes.rb +203 -0
  48. data/spec/aquarium/utils/type_utils_spec.rb +47 -1
  49. metadata +48 -39
  50. data/lib/aquarium/finders/object_finder.rb +0 -75
  51. data/spec/aquarium/finders/object_finder_spec.rb +0 -231
@@ -11,7 +11,7 @@ describe "Aspects that specify the private implementation methods inserted by ot
11
11
  class WithAspectLikeMethod
12
12
  def _aspect_foo; end
13
13
  end
14
- aspect = Aspect.new(:after, :pointcut => {:type => WithAspectLikeMethod, :methods => :_aspect_foo}) {|jp, *args| fail}
14
+ aspect = Aspect.new(:after, :pointcut => {:type => WithAspectLikeMethod, :methods => :_aspect_foo}) {|jp, obj, *args| fail}
15
15
  WithAspectLikeMethod.new._aspect_foo
16
16
  aspect.unadvise
17
17
  end
@@ -69,7 +69,7 @@ describe "Aspects with :before advice" do
69
69
  it "should pass the context information to the advice, including self and the method parameters." do
70
70
  watchful = Watchful.new
71
71
  context = nil
72
- @aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
72
+ @aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
73
73
  context = jp.context
74
74
  end
75
75
  block_called = 0
@@ -83,7 +83,7 @@ describe "Aspects with :before advice" do
83
83
  end
84
84
 
85
85
  it "should evaluate the advice before the method body and its block (if any)." do
86
- @aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
86
+ @aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
87
87
  @advice_called += 1
88
88
  end
89
89
  do_watchful_public_protected_private
@@ -98,7 +98,7 @@ describe "Aspects with :after advice" do
98
98
  it "should pass the context information to the advice, including self, the method parameters, and the return value when the method returns normally." do
99
99
  watchful = Watchful.new
100
100
  context = nil
101
- @aspect = Aspect.new :after, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
101
+ @aspect = Aspect.new :after, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
102
102
  context = jp.context
103
103
  end
104
104
  block_called = 0
@@ -114,7 +114,7 @@ describe "Aspects with :after advice" do
114
114
  it "should pass the context information to the advice, including self, the method parameters, and the rescued exception when an exception is raised." do
115
115
  watchful = Watchful.new
116
116
  context = nil
117
- @aspect = Aspect.new :after, :pointcut => {:type => Watchful, :methods => /public_watchful_method/} do |jp, *args|
117
+ @aspect = Aspect.new :after, :pointcut => {:type => Watchful, :methods => /public_watchful_method/} do |jp, obj, *args|
118
118
  context = jp.context
119
119
  end
120
120
  block_called = 0
@@ -127,7 +127,7 @@ describe "Aspects with :after advice" do
127
127
  end
128
128
 
129
129
  it "should evaluate the advice after the method body and its block (if any)." do
130
- @aspect = Aspect.new :after, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
130
+ @aspect = Aspect.new :after, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
131
131
  @advice_called += 1
132
132
  end
133
133
  do_watchful_public_protected_private
@@ -141,7 +141,7 @@ describe "Aspects with :after advice" do
141
141
  end
142
142
  ary = %w[a b c]
143
143
  ReturningValue.new.doit(ary).should == %w[a b c d]
144
- @aspect = Aspect.new :after, :type => ReturningValue, :method => :doit do |jp, *args|
144
+ @aspect = Aspect.new :after, :type => ReturningValue, :method => :doit do |jp, obj, *args|
145
145
  %w[aa] + jp.context.returned_value + %w[e]
146
146
  end
147
147
  ReturningValue.new.doit(ary).should == %w[a b c d]
@@ -155,7 +155,7 @@ describe "Aspects with :after advice" do
155
155
  end
156
156
  ary = %w[a b c]
157
157
  ReturningValue.new.doit(ary).should == %w[a b c d]
158
- @aspect = Aspect.new :after, :type => ReturningValue, :method => :doit do |jp, *args|
158
+ @aspect = Aspect.new :after, :type => ReturningValue, :method => :doit do |jp, obj, *args|
159
159
  jp.context.returned_value = %w[aa] + jp.context.returned_value + %w[e]
160
160
  end
161
161
  ReturningValue.new.doit(ary).should == %w[aa a b c d e]
@@ -170,7 +170,7 @@ describe "Aspects with :after_returning advice" do
170
170
  it "should pass the context information to the advice, including self, the method parameters, and the return value." do
171
171
  watchful = Watchful.new
172
172
  context = nil
173
- @aspect = Aspect.new :after_returning, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
173
+ @aspect = Aspect.new :after_returning, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
174
174
  context = jp.context
175
175
  end
176
176
  block_called = 0
@@ -184,7 +184,7 @@ describe "Aspects with :after_returning advice" do
184
184
  end
185
185
 
186
186
  it "should evaluate the advice after the method body and its block (if any)." do
187
- @aspect = Aspect.new :after_returning, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
187
+ @aspect = Aspect.new :after_returning, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
188
188
  @advice_called += 1
189
189
  end
190
190
  do_watchful_public_protected_private
@@ -198,7 +198,7 @@ describe "Aspects with :after_returning advice" do
198
198
  end
199
199
  ary = %w[a b c]
200
200
  ReturningValue.new.doit(ary).should == %w[a b c d]
201
- @aspect = Aspect.new :after_returning, :type => ReturningValue, :method => :doit do |jp, *args|
201
+ @aspect = Aspect.new :after_returning, :type => ReturningValue, :method => :doit do |jp, obj, *args|
202
202
  %w[aa] + jp.context.returned_value + %w[e]
203
203
  end
204
204
  ReturningValue.new.doit(ary).should == %w[a b c d]
@@ -212,7 +212,7 @@ describe "Aspects with :after_returning advice" do
212
212
  end
213
213
  ary = %w[a b c]
214
214
  ReturningValue.new.doit(ary).should == %w[a b c d]
215
- @aspect = Aspect.new :after_returning, :type => ReturningValue, :method => :doit do |jp, *args|
215
+ @aspect = Aspect.new :after_returning, :type => ReturningValue, :method => :doit do |jp, obj, *args|
216
216
  jp.context.returned_value = %w[aa] + jp.context.returned_value + %w[e]
217
217
  end
218
218
  ReturningValue.new.doit(ary).should == %w[aa a b c d e]
@@ -227,7 +227,7 @@ describe "Aspects with :after_raising advice" do
227
227
  it "should pass the context information to the advice, including self, the method parameters, and the rescued exception." do
228
228
  watchful = Watchful.new
229
229
  context = nil
230
- @aspect = Aspect.new :after_raising, :pointcut => {:type => Watchful, :methods => /public_watchful_method/} do |jp, *args|
230
+ @aspect = Aspect.new :after_raising, :pointcut => {:type => Watchful, :methods => /public_watchful_method/} do |jp, obj, *args|
231
231
  context = jp.context
232
232
  end
233
233
  block_called = 0
@@ -241,7 +241,7 @@ describe "Aspects with :after_raising advice" do
241
241
  end
242
242
 
243
243
  it "should evaluate the advice after the method body and its block (if any)." do
244
- @aspect = Aspect.new :after_raising, :pointcut => {:type => Watchful, :methods => /public_watchful_method/} do |jp, *args|
244
+ @aspect = Aspect.new :after_raising, :pointcut => {:type => Watchful, :methods => /public_watchful_method/} do |jp, obj, *args|
245
245
  @advice_called += 1
246
246
  end
247
247
  do_watchful_public_protected_private true
@@ -250,7 +250,7 @@ describe "Aspects with :after_raising advice" do
250
250
  it "should not advise rescue clauses for raised exceptions of types that don't match the specified exception" do
251
251
  class MyError < StandardError; end
252
252
  aspect_advice_invoked = false
253
- @aspect = Aspect.new(:after_raising => MyError, :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, *args| aspect_advice_invoked = true}
253
+ @aspect = Aspect.new(:after_raising => MyError, :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, obj, *args| aspect_advice_invoked = true}
254
254
  block_invoked = false
255
255
  watchful = Watchful.new
256
256
  lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.should raise_error(Watchful::WatchfulError)
@@ -262,7 +262,7 @@ describe "Aspects with :after_raising advice" do
262
262
  class MyError1 < StandardError; end
263
263
  class MyError2 < StandardError; end
264
264
  aspect_advice_invoked = false
265
- @aspect = Aspect.new(:after_raising => [MyError1, MyError2], :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, *args| aspect_advice_invoked = true}
265
+ @aspect = Aspect.new(:after_raising => [MyError1, MyError2], :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, obj, *args| aspect_advice_invoked = true}
266
266
  block_invoked = false
267
267
  watchful = Watchful.new
268
268
  lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.should raise_error(Watchful::WatchfulError)
@@ -278,7 +278,7 @@ describe "Aspects with :after_raising advice" do
278
278
  end
279
279
  end
280
280
  aspect_advice_invoked = false
281
- @aspect = Aspect.new :after_raising, :pointcut => {:type => ClassThatRaises, :methods => :raises} do |jp, *args|
281
+ @aspect = Aspect.new :after_raising, :pointcut => {:type => ClassThatRaises, :methods => :raises} do |jp, obj, *args|
282
282
  aspect_advice_invoked = true
283
283
  end
284
284
  aspect_advice_invoked.should be_false
@@ -295,7 +295,7 @@ describe "Aspects with :before and :after advice" do
295
295
 
296
296
  it "should pass the context information to the advice, including self and the method parameters, plus the return value for the after-advice case." do
297
297
  contexts = []
298
- @aspect = Aspect.new :before, :after, :pointcut => {:type => Watchful, :methods => [:public_watchful_method]} do |jp, *args|
298
+ @aspect = Aspect.new :before, :after, :pointcut => {:type => Watchful, :methods => [:public_watchful_method]} do |jp, obj, *args|
299
299
  contexts << jp.context
300
300
  end
301
301
  watchful = Watchful.new
@@ -322,7 +322,7 @@ describe "Aspects with :before and :after advice" do
322
322
  end
323
323
 
324
324
  it "should evaluate the advice before and after the method body and its block (if any)." do
325
- @aspect = Aspect.new :before, :after, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
325
+ @aspect = Aspect.new :before, :after, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
326
326
  @advice_called += 1
327
327
  end
328
328
  do_watchful_public_protected_private false, 2
@@ -337,7 +337,7 @@ describe "Aspects with :before and :after_returning advice" do
337
337
  it "should pass the context information to the advice, including self and the method parameters, plus the return value for the after-advice case." do
338
338
  watchful = Watchful.new
339
339
  contexts = []
340
- @aspect = Aspect.new :before, :after_returning, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
340
+ @aspect = Aspect.new :before, :after_returning, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
341
341
  contexts << jp.context
342
342
  end
343
343
  block_called = 0
@@ -356,7 +356,7 @@ describe "Aspects with :before and :after_returning advice" do
356
356
  end
357
357
 
358
358
  it "should evaluate the advice before and after the method body and its block (if any)." do
359
- @aspect = Aspect.new :before, :after_returning, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
359
+ @aspect = Aspect.new :before, :after_returning, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
360
360
  @advice_called += 1
361
361
  end
362
362
  do_watchful_public_protected_private false, 2
@@ -371,7 +371,7 @@ describe "Aspects with :before and :after_raising advice" do
371
371
  it "should pass the context information to the advice, including self and the method parameters, plus the raised exception for the after-advice case." do
372
372
  watchful = Watchful.new
373
373
  contexts = []
374
- @aspect = Aspect.new :before, :after_raising, :pointcut => {:type => Watchful, :methods => :public_watchful_method_that_raises} do |jp, *args|
374
+ @aspect = Aspect.new :before, :after_raising, :pointcut => {:type => Watchful, :methods => :public_watchful_method_that_raises} do |jp, obj, *args|
375
375
  contexts << jp.context
376
376
  end
377
377
  block_called = 0
@@ -390,7 +390,7 @@ describe "Aspects with :before and :after_raising advice" do
390
390
  end
391
391
 
392
392
  it "should evaluate the advice before and after the method body and its block (if any)." do
393
- @aspect = Aspect.new :before, :after_raising, :pointcut => {:type => Watchful, :methods => :public_watchful_method_that_raises} do |jp, *args|
393
+ @aspect = Aspect.new :before, :after_raising, :pointcut => {:type => Watchful, :methods => :public_watchful_method_that_raises} do |jp, obj, *args|
394
394
  @advice_called += 1
395
395
  end
396
396
  do_watchful_public_protected_private true, 2
@@ -404,7 +404,7 @@ describe "Aspects with :around advice" do
404
404
 
405
405
  it "should pass the context information to the advice, including the object, advice kind, the method invocation parameters, etc." do
406
406
  contexts = []
407
- @aspect = Aspect.new :around, :pointcut => {:type => Watchful, :methods => [:public_watchful_method]} do |jp, *args|
407
+ @aspect = Aspect.new :around, :pointcut => {:type => Watchful, :methods => [:public_watchful_method]} do |jp, obj, *args|
408
408
  contexts << jp.context
409
409
  end
410
410
  watchful = Watchful.new
@@ -445,7 +445,7 @@ describe "Aspects with :around advice" do
445
445
  end
446
446
 
447
447
  context = nil
448
- @aspect = Aspect.new :around, :pointcut => {:type => AdvisingSuperClass::SuperClass, :methods => [:public_method]} do |jp, *args|
448
+ @aspect = Aspect.new :around, :pointcut => {:type => AdvisingSuperClass::SuperClass, :methods => [:public_method]} do |jp, obj, *args|
449
449
  context = jp.context
450
450
  end
451
451
  child = AdvisingSuperClass::SubClass.new
@@ -485,7 +485,7 @@ describe "Aspects with :around advice" do
485
485
  end
486
486
 
487
487
  context = nil
488
- @aspect = Aspect.new :around, :pointcut => {:type => AdvisingSubClass::SuperClass, :methods => [:public_method]} do |jp, *args|
488
+ @aspect = Aspect.new :around, :pointcut => {:type => AdvisingSubClass::SuperClass, :methods => [:public_method]} do |jp, obj, *args|
489
489
  context = jp.context
490
490
  end
491
491
  child = AdvisingSubClass::SubClass.new
@@ -517,7 +517,7 @@ describe "Aspects with :around advice" do
517
517
  @override_called = false
518
518
  end
519
519
  end
520
- @aspect = Aspect.new(:around, :pointcut => {:type => Watchful, :methods => [:public_watchful_method]}) {|jp, *args| fail}
520
+ @aspect = Aspect.new(:around, :pointcut => {:type => Watchful, :methods => [:public_watchful_method]}) {|jp, obj, *args| fail}
521
521
  child = WatchfulChild2.new
522
522
  public_block_called = false
523
523
  child.public_watchful_method(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| public_block_called = true }
@@ -542,7 +542,7 @@ describe "Aspects with :around advice" do
542
542
 
543
543
  it "should pass parameters and a block passed explicitly to JoinPoint#proceed, rather than the original method parameters and block." do
544
544
  override_block_called = false
545
- @aspect = Aspect.new :around, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
545
+ @aspect = Aspect.new :around, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
546
546
  jp.proceed(:a4, :a5, :a6) {|*args| override_block_called = true}
547
547
  end
548
548
  watchful = Watchful.new
@@ -561,7 +561,7 @@ describe "Aspects with :around advice" do
561
561
  end
562
562
  ary = %w[a b c]
563
563
  ReturningValue.new.doit(ary).should == %w[a b c d]
564
- @aspect = Aspect.new :around, :type => ReturningValue, :method => :doit do |jp, *args|
564
+ @aspect = Aspect.new :around, :type => ReturningValue, :method => :doit do |jp, obj, *args|
565
565
  jp.proceed
566
566
  %w[aa bb cc]
567
567
  end
@@ -576,7 +576,7 @@ describe "Aspects with :around advice" do
576
576
  end
577
577
  ary = %w[a b c]
578
578
  ReturningValue.new.doit(ary).should == %w[a b c d]
579
- @aspect = Aspect.new :around, :type => ReturningValue, :method => :doit do |jp, *args|
579
+ @aspect = Aspect.new :around, :type => ReturningValue, :method => :doit do |jp, obj, *args|
580
580
  begin
581
581
  jp.proceed
582
582
  ensure
@@ -587,7 +587,7 @@ describe "Aspects with :around advice" do
587
587
  end
588
588
 
589
589
  def do_around_spec *args_passed_to_proceed
590
- @aspect = Aspect.new :around, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, *args|
590
+ @aspect = Aspect.new :around, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
591
591
  @advice_called += 1
592
592
  returned_value = args_passed_to_proceed.empty? ? jp.proceed : jp.proceed(*args_passed_to_proceed)
593
593
  @advice_called += 1
@@ -597,7 +597,25 @@ describe "Aspects with :around advice" do
597
597
  end
598
598
  end
599
599
 
600
-
600
+ describe Aspect, " with advice that calls JoinPoint#invoke_original_join_point" do
601
+ class AdvicesInvocationCounter
602
+ def initialize; @counter = 0; end
603
+ def increment; @counter += 1; end
604
+ def counter; @counter; end
605
+ end
606
+
607
+ it "should not call the intermediate advices" do
608
+ aspect1 = Aspect.new :around, :type => AdvicesInvocationCounter, :method => :increment do |jp, obj, *args|; fail; end
609
+ aspect2 = Aspect.new :around, :type => AdvicesInvocationCounter, :method => :increment do |jp, obj, *args|
610
+ jp.invoke_original_join_point
611
+ end
612
+ aic = AdvicesInvocationCounter.new
613
+ aic.increment
614
+ aic.counter.should == 1
615
+ aspect1.unadvise
616
+ aspect2.unadvise
617
+ end
618
+ end
601
619
 
602
620
  describe Aspect, "#unadvise for 'empty' aspects" do
603
621
  before(:all) do
@@ -660,7 +678,7 @@ describe Aspect, "#unadvise for removes all traces of the aspect" do
660
678
  parameters[:after] = ''
661
679
  expected_methods = send(which_get_methods)
662
680
  advice_called = false
663
- aspect = Aspect.new(:after, parameters) {|jp, *args| advice_called = true}
681
+ aspect = Aspect.new(:after, parameters) {|jp, obj, *args| advice_called = true}
664
682
  diff_methods send(which_get_methods), expected_methods, true
665
683
  aspect.unadvise
666
684
  diff_methods send(which_get_methods), expected_methods
@@ -691,8 +709,8 @@ describe Aspect, "#unadvise for removes all traces of the aspect" do
691
709
  def bar; end
692
710
  end
693
711
  before = Foo.private_instance_methods.sort
694
- aspect1 = Aspect.new(:before, :pointcut => {:type => Foo, :method_options => :exclude_ancestor_methods}) {|jp, *args| true}
695
- aspect2 = Aspect.new(:after, :pointcut => {:type => Foo, :method_options => :exclude_ancestor_methods}) {|jp, *args| true}
712
+ aspect1 = Aspect.new(:before, :pointcut => {:type => Foo, :method_options => :exclude_ancestor_methods}) {|jp, obj, *args| true}
713
+ aspect2 = Aspect.new(:after, :pointcut => {:type => Foo, :method_options => :exclude_ancestor_methods}) {|jp, obj, *args| true}
696
714
  after = Foo.private_instance_methods
697
715
  (after - before).should_not == []
698
716
  aspect1.unadvise
@@ -708,8 +726,8 @@ describe Aspect, "#unadvise for removes all traces of the aspect" do
708
726
  def bar; end
709
727
  end
710
728
  before = Foo.private_instance_methods.sort
711
- aspect1 = Aspect.new(:before, :type => Foo, :method_options => :exclude_ancestor_methods) {|jp, *args| true}
712
- aspect2 = Aspect.new(:after, :type => Foo, :method_options => :exclude_ancestor_methods) {|jp, *args| true}
729
+ aspect1 = Aspect.new(:before, :type => Foo, :method_options => :exclude_ancestor_methods) {|jp, obj, *args| true}
730
+ aspect2 = Aspect.new(:after, :type => Foo, :method_options => :exclude_ancestor_methods) {|jp, obj, *args| true}
713
731
  after = Foo.private_instance_methods
714
732
  (after - before).should_not == []
715
733
  aspect1.unadvise
@@ -726,8 +744,8 @@ describe Aspect, "#unadvise for removes all traces of the aspect" do
726
744
  end
727
745
  overhead = Overhead.new
728
746
  before = overhead.private_methods.sort
729
- aspect1 = Aspect.new(:before, :object => overhead, :method_options => :exclude_ancestor_methods) {|jp, *args| true}
730
- aspect2 = Aspect.new(:after, :object => overhead, :method_options => :exclude_ancestor_methods) {|jp, *args| true}
747
+ aspect1 = Aspect.new(:before, :object => overhead, :method_options => :exclude_ancestor_methods) {|jp, obj, *args| true}
748
+ aspect2 = Aspect.new(:after, :object => overhead, :method_options => :exclude_ancestor_methods) {|jp, obj, *args| true}
731
749
  after = overhead.private_methods
732
750
  (after - before).should_not == []
733
751
  aspect1.unadvise
@@ -745,7 +763,7 @@ describe "invariant protection level of methods under advising and unadvising",
745
763
  meta = "#{protection}_instance_methods"
746
764
  method = "#{protection}_watchful_method"
747
765
  Watchful.send(meta).should include(method)
748
- aspect = Aspect.new(:after, :type => Watchful, :method => method.intern) {|jp, *args| true }
766
+ aspect = Aspect.new(:after, :type => Watchful, :method => method.intern) {|jp, obj, *args| true }
749
767
  Watchful.send(meta).should include(method)
750
768
  aspect.unadvise
751
769
  Watchful.send(meta).should include(method)
@@ -813,7 +831,7 @@ describe "Aspects advising methods with non-alphanumeric characters" do
813
831
  it "should work with any valid ruby character" do
814
832
  actual = ""
815
833
  Aspect.new :before, :type => Aquarium::Aspects::ClassWithMethodNamesContainingOddChars,
816
- :methods => Aquarium::Aspects::ClassWithMethodNamesContainingOddChars.method_names do |jp, *args|
834
+ :methods => Aquarium::Aspects::ClassWithMethodNamesContainingOddChars.method_names do |jp, obj, *args|
817
835
  actual += ", #{jp.method_name}"
818
836
  end
819
837
  object = Aquarium::Aspects::ClassWithMethodNamesContainingOddChars.new
@@ -23,7 +23,7 @@ module Nested1
23
23
  end
24
24
  end
25
25
 
26
- describe Aspect, "#new when advising methods in a nested class" do
26
+ describe Aspect, ".new when advising methods in a nested class" do
27
27
  after(:each) do
28
28
  @aspect.unadvise if @aspect
29
29
  end
@@ -31,7 +31,7 @@ describe Aspect, "#new when advising methods in a nested class" do
31
31
  it "should correctly advise methods in a nested class." do
32
32
  myclass = Nested1::Nested2::MyClass.new
33
33
  context = nil
34
- @aspect = Aspect.new :before, :pointcut => {:type => Nested1::Nested2::MyClass, :methods => :do1} do |jp, *args|
34
+ @aspect = Aspect.new :before, :pointcut => {:type => Nested1::Nested2::MyClass, :methods => :do1} do |jp, obj, *args|
35
35
  context = jp.context
36
36
  end
37
37
  block_called = 0
@@ -47,7 +47,7 @@ describe Aspect, "#new when advising methods in a nested class" do
47
47
  it "should correctly advise methods in an instance of the nested class." do
48
48
  myclass = Nested1::Nested2::MyClass.new
49
49
  context = nil
50
- @aspect = Aspect.new :before, :pointcut => {:object => myclass, :methods => :do1} do |jp, *args|
50
+ @aspect = Aspect.new :before, :pointcut => {:object => myclass, :methods => :do1} do |jp, obj, *args|
51
51
  context = jp.context
52
52
  end
53
53
  block_called = 0
@@ -61,7 +61,7 @@ describe Aspect, "#new when advising methods in a nested class" do
61
61
  end
62
62
  end
63
63
 
64
- describe Aspect, "#new when advising methods in a nested module included by a class" do
64
+ describe Aspect, ".new when advising methods in a nested module included by a class" do
65
65
  after(:each) do
66
66
  @aspect.unadvise if @aspect
67
67
  end
@@ -73,7 +73,7 @@ describe Aspect, "#new when advising methods in a nested module included by a cl
73
73
 
74
74
  myclass = MyClassWithModule1.new
75
75
  context = nil
76
- @aspect = Aspect.new :before, :pointcut => {:type => Nested1::Nested2::MyModule, :methods => :do2} do |jp, *args|
76
+ @aspect = Aspect.new :before, :pointcut => {:type => Nested1::Nested2::MyModule, :methods => :do2} do |jp, obj, *args|
77
77
  context = jp.context
78
78
  end
79
79
  block_called = 0
@@ -93,7 +93,7 @@ describe Aspect, "#new when advising methods in a nested module included by a cl
93
93
 
94
94
  myclass = MyClassWithModule2.new
95
95
  context = nil
96
- @aspect = Aspect.new :before, :pointcut => {:type => MyClassWithModule2, :methods => :do2} do |jp, *args|
96
+ @aspect = Aspect.new :before, :pointcut => {:type => MyClassWithModule2, :methods => :do2} do |jp, obj, *args|
97
97
  context = jp.context
98
98
  end
99
99
  block_called = 0
@@ -113,7 +113,7 @@ describe Aspect, "#new when advising methods in a nested module included by a cl
113
113
 
114
114
  myclass = MyClassWithModule3.new
115
115
  context = nil
116
- @aspect = Aspect.new :before, :pointcut => {:object => myclass, :methods => :do2} do |jp, *args|
116
+ @aspect = Aspect.new :before, :pointcut => {:object => myclass, :methods => :do2} do |jp, obj, *args|
117
117
  context = jp.context
118
118
  end
119
119
  block_called = 0
@@ -6,7 +6,7 @@ require 'aquarium/aspects'
6
6
  include Aquarium::Aspects
7
7
 
8
8
  # Explicitly check that advising subtypes works correctly.
9
-
9
+ # TODO Tests with modules included in classes.
10
10
  module SubTypeAspects
11
11
  class Base
12
12
  attr_reader :base_state
@@ -33,7 +33,7 @@ describe Aspect, " when advising overridden methods that call super" do
33
33
 
34
34
  it "should correctly invoke and advise subclass and superclass methods." do
35
35
  advised_types = []
36
- @aspect = Aspect.new :before, :pointcut => {:types => /SubTypeAspects::.*/, :methods => :doit} do |jp, *args|
36
+ @aspect = Aspect.new :before, :pointcut => {:types => /SubTypeAspects::.*/, :methods => :doit} do |jp, obj, *args|
37
37
  advised_types << jp.target_type
38
38
  end
39
39
  derived = SubTypeAspects::Derived.new
@@ -47,7 +47,6 @@ module ConcurrentAspectsSpecSupport
47
47
  end
48
48
 
49
49
  def check_results_for iteration
50
- number_of_unadvised_aspects = iteration + 1
51
50
  @accessed.invoked_count.should == @aspects.size
52
51
  @accessed.invoked_args.should == [:a1, :a2]
53
52
  iteration.times do |n|
@@ -75,7 +74,7 @@ module ConcurrentAspectsSpecSupport
75
74
  else
76
75
  pointcut = Pointcut.new(:methods => method, :object => @accessed)
77
76
  end
78
- @aspects[n] = Aspect.new @advice_kinds[n], :pointcut => pointcut do |jp, *args|
77
+ @aspects[n] = Aspect.new @advice_kinds[n], :pointcut => pointcut do |jp, obj, *args|
79
78
  @contexts[n] = jp.context
80
79
  @argss[n] = *args
81
80
  @advice_invocation_counts[n] += 1
@@ -9,7 +9,7 @@ require 'aquarium/aspects'
9
9
  include Aquarium::Aspects
10
10
 
11
11
  def make_aspect method, advice_kind, type_or_object_key, type_or_object
12
- Aspect.new advice_kind, :pointcut => {type_or_object_key => type_or_object, :method => method} do |jp, *args|
12
+ Aspect.new advice_kind, :pointcut => {type_or_object_key => type_or_object, :method => method} do |jp, obj, *args|
13
13
  @invoked << type_or_object_key
14
14
  jp.proceed if advice_kind == :around
15
15
  end