aquarium 0.4.4 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. data/CHANGES +31 -6
  2. data/README +4 -1
  3. data/RELEASE-PLAN +2 -0
  4. data/Rakefile +20 -30
  5. data/UPGRADE +14 -4
  6. data/lib/aquarium/aspects/advice.rb +25 -10
  7. data/lib/aquarium/aspects/aspect.rb +8 -7
  8. data/lib/aquarium/aspects/join_point.rb +15 -5
  9. data/lib/aquarium/aspects/pointcut.rb +4 -4
  10. data/lib/aquarium/extensions.rb +0 -1
  11. data/lib/aquarium/finders/method_finder.rb +3 -10
  12. data/lib/aquarium/finders/pointcut_finder.rb +15 -5
  13. data/lib/aquarium/finders/type_finder.rb +0 -1
  14. data/lib/aquarium/utils/array_utils.rb +0 -1
  15. data/lib/aquarium/utils/method_utils.rb +13 -2
  16. data/lib/aquarium/utils/options_utils.rb +1 -0
  17. data/lib/aquarium/utils/type_utils.rb +21 -5
  18. data/lib/aquarium/version.rb +2 -2
  19. data/spec/aquarium/aspects/advice_chain_node_spec.rb +0 -1
  20. data/spec/aquarium/aspects/advice_spec.rb +80 -45
  21. data/spec/aquarium/aspects/aspect_invocation_spec.rb +66 -31
  22. data/spec/aquarium/aspects/aspect_spec.rb +88 -91
  23. data/spec/aquarium/aspects/concurrent_aspects_spec.rb +1 -1
  24. data/spec/aquarium/aspects/concurrent_aspects_with_objects_and_types_spec.rb +3 -1
  25. data/spec/aquarium/aspects/join_point_spec.rb +0 -1
  26. data/spec/aquarium/aspects/pointcut_spec.rb +21 -18
  27. data/spec/aquarium/extensions/hash_spec.rb +211 -219
  28. data/spec/aquarium/extensions/set_spec.rb +1 -1
  29. data/spec/aquarium/extras/design_by_contract_spec.rb +1 -1
  30. data/spec/aquarium/finders/finder_result_spec.rb +4 -4
  31. data/spec/aquarium/finders/method_finder_spec.rb +6 -9
  32. data/spec/aquarium/finders/type_finder_spec.rb +2 -2
  33. data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +12 -10
  34. data/spec/aquarium/spec_example_types.rb +2 -2
  35. data/spec/aquarium/spec_helper.rb +1 -1
  36. data/spec/aquarium/utils/array_utils_spec.rb +32 -5
  37. data/spec/aquarium/utils/hash_utils_spec.rb +1 -0
  38. data/spec/aquarium/utils/method_utils_spec.rb +18 -0
  39. data/spec/aquarium/utils/options_utils_spec.rb +16 -20
  40. data/spec/aquarium/utils/type_utils_sample_classes.rb +10 -1
  41. data/spec/aquarium/utils/type_utils_spec.rb +9 -7
  42. metadata +29 -35
  43. data/lib/aquarium/extensions/symbol.rb +0 -22
  44. data/spec/aquarium/extensions/symbol_spec.rb +0 -37
@@ -4,7 +4,6 @@ require 'aquarium/utils/type_utils'
4
4
  require 'aquarium/utils/invalid_options'
5
5
  require 'aquarium/extensions/hash'
6
6
  require 'aquarium/extensions/regexp'
7
- require 'aquarium/extensions/symbol'
8
7
  require 'aquarium/finders/finder_result'
9
8
 
10
9
  # Finds types known to the runtime environment.
@@ -1,4 +1,3 @@
1
- require 'aquarium/extensions/symbol'
2
1
  require 'aquarium/utils/html_escaper'
3
2
 
4
3
  module Aquarium
@@ -5,6 +5,16 @@ module Aquarium
5
5
  module Utils
6
6
  module MethodUtils
7
7
 
8
+ # The metaprogramming methods such as "public_instance_methods" require
9
+ # strings for 1.8, symbols for 1.9.
10
+ def self.to_name string_or_symbol
11
+ if RUBY_VERSION =~ /^1.8/
12
+ string_or_symbol.to_s
13
+ else
14
+ string_or_symbol.intern
15
+ end
16
+ end
17
+
8
18
  def self.method_args_to_hash *args
9
19
  return {} if args.empty? || (args.size == 1 && args[0].nil?)
10
20
  hash = (args[-1] and args[-1].kind_of? Hash) ? args.pop : {}
@@ -37,7 +47,8 @@ module Aquarium
37
47
  %w[public protected private].each do |protection|
38
48
  meta_method = "#{protection}_#{suffix}"
39
49
  found_methods = type_or_instance.send(meta_method, include_ancestors)
40
- if found_methods.include?(method_sym.to_s)
50
+ # Try both the symbol (ruby 1.9) and the string (1.8).
51
+ if found_methods.include?(method_sym) or found_methods.include?(method_sym.to_s)
41
52
  return yield(type_or_instance, method_sym, protection.intern)
42
53
  end
43
54
  end
@@ -61,7 +72,7 @@ module Aquarium
61
72
  object.ancestors
62
73
  else
63
74
  eigen = (class << object; self; end)
64
- [eigen] + eigen.ancestors
75
+ eigen.ancestors + [eigen]
65
76
  end
66
77
  end
67
78
 
@@ -125,6 +125,7 @@ module Aquarium
125
125
  def hashify options
126
126
  return options if options.kind_of?(Hash)
127
127
  new_options = {}
128
+ options = [options] unless options.kind_of?(Array)
128
129
  options.each do |x|
129
130
  if x.kind_of?(Hash)
130
131
  new_options.merge!(x)
@@ -1,3 +1,5 @@
1
+ require 'set'
2
+
1
3
  module Aquarium
2
4
  module Utils
3
5
  module TypeUtils
@@ -6,10 +8,13 @@ module Aquarium
6
8
  end
7
9
 
8
10
  def self.descendents clazz
9
- visited = [Class, Object, Module, clazz]
11
+ visited = Set.new([Class, Object, Module, clazz])
12
+ if RUBY_VERSION =~ /^1.9/
13
+ visited << BasicObject
14
+ end
10
15
  result = [clazz]
11
16
  Module.constants.each do |const|
12
- mod = Module.class_eval(const)
17
+ mod = Module.class_eval(const.to_s)
13
18
  if mod.respond_to?(:ancestors)
14
19
  result << mod if mod.ancestors.include?(clazz)
15
20
  do_descendents clazz, mod, visited, result
@@ -21,7 +26,7 @@ module Aquarium
21
26
  def self.nested clazz
22
27
  result = [clazz]
23
28
  clazz.constants.each do |const|
24
- mod = clazz.class_eval(const)
29
+ mod = clazz.class_eval(const.to_s)
25
30
  next unless is_type?(mod)
26
31
  result << mod
27
32
  result << nested(mod)
@@ -34,13 +39,16 @@ module Aquarium
34
39
  # For JRuby classes, we have to "__x__" forms of the reflection methods that don't end in '?'.
35
40
  # That includes "send", so we do some ugly switching, rather than call "mod.send(method_name)"
36
41
  # or "mod.__send__(method_name)"!
42
+ # TODO: is this still true with the latest JRUBY versions?
37
43
  def self.do_descendents clazz, visiting_module, visited, result
38
44
  visited << visiting_module
39
45
  use_underscore_methods = use_underscore_methods? visiting_module
40
46
  nested_constants = use_underscore_methods ? visiting_module.__constants__ : visiting_module.constants
41
47
  nested_constants.each do |const|
42
48
  next unless visiting_module.const_defined?(const)
43
- nested_module = use_underscore_methods ? visiting_module.__const_get__(const) : visiting_module.const_get(const)
49
+ nested_module = ignore_warning do
50
+ use_underscore_methods ? visiting_module.__const_get__(const) : visiting_module.const_get(const)
51
+ end
44
52
  next if visited.include?(nested_module)
45
53
  next unless responds_to_ancestors?(nested_module)
46
54
  use_underscore_methods2 = use_underscore_methods? nested_module
@@ -57,6 +65,14 @@ module Aquarium
57
65
  def self.responds_to_ancestors? mod
58
66
  mod.respond_to?(:ancestors) or mod.respond_to?(:__ancestors__)
59
67
  end
68
+
69
+ def self.ignore_warning
70
+ warning_orig = $-w
71
+ $-w = nil
72
+ res = yield
73
+ $-w = warning_orig
74
+ return res
75
+ end
60
76
  end
61
77
  end
62
- end
78
+ end
@@ -8,8 +8,8 @@ module Aquarium
8
8
 
9
9
  unless defined? MAJOR
10
10
  MAJOR = 0
11
- MINOR = 4
12
- TINY = 4
11
+ MINOR = 5
12
+ TINY = 1
13
13
  RELEASE_CANDIDATE = nil
14
14
 
15
15
  # RANDOM_TOKEN: 0.598704893979657
@@ -1,5 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'aquarium/spec_example_types'
3
2
  require 'aquarium'
4
3
 
5
4
  include Aquarium::Aspects::Advice
@@ -18,6 +18,19 @@ describe Advice, "#sort_by_priority_order" do
18
18
  end
19
19
  end
20
20
 
21
+ def puts_advice_chain aspect, label
22
+ puts label
23
+ aspect.pointcuts.each do |pc|
24
+ pc.join_points_matched.each do |jp|
25
+ chain = Aspect.get_advice_chain(jp)
26
+ chain.each do |a|
27
+ puts "advice_node: #{a.inspect}"
28
+ end
29
+ puts "last: #{chain.last}"
30
+ end
31
+ end
32
+ puts ""
33
+ end
21
34
  describe Advice, "#invoke_original_join_point" do
22
35
  class InvocationCounter
23
36
  def initialize; @counter = 0; end
@@ -62,28 +75,39 @@ def should_raise_expected_exception_with_message message
62
75
  end
63
76
 
64
77
  describe Advice, "that raises an exception" do
65
- it "should add the kind of advice to the exception message." do
66
- aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
67
- raise SpecExceptionForTesting.new("advice called with args: #{args.inspect}")
78
+ context "when debug_backtraces is true" do
79
+ before do
80
+ @debug_backtraces_orig = Aquarium::Aspects::Advice.debug_backtraces
81
+ Aquarium::Aspects::Advice.debug_backtraces = true
68
82
  end
69
- should_raise_expected_exception_with_message("\"before\" advice") {Watchful.new.public_watchful_method(:a1, :a2)}
70
- aspect.unadvise
71
- end
72
83
 
73
- it "should add the \"Class#method\" of the advised object's type and method to the exception message." do
74
- aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
75
- raise "advice called with args: #{args.inspect}"
84
+ after do
85
+ Aquarium::Aspects::Advice.debug_backtraces = @debug_backtraces_orig
76
86
  end
77
- should_raise_expected_exception_with_message("Watchful#public_watchful_method") {Watchful.new.public_watchful_method(:a1, :a2)}
78
- aspect.unadvise
79
- end
80
87
 
81
- it "should add the \"Class.method\" of the advised type's class method to the exception message." do
82
- aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_class_watchful_method, :method_options => [:class]} do |jp, obj, *args|
83
- raise "advice called with args: #{args.inspect}"
88
+ it "should add the kind of advice to the exception message." do
89
+ aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
90
+ raise SpecExceptionForTesting.new("advice called with args: #{args.inspect}")
91
+ end
92
+ should_raise_expected_exception_with_message("\"before\" advice") {Watchful.new.public_watchful_method(:a1, :a2)}
93
+ aspect.unadvise
94
+ end
95
+
96
+ it "should add the \"Class#method\" of the advised object's type and method to the exception message." do
97
+ aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_watchful_method} do |jp, obj, *args|
98
+ raise "advice called with args: #{args.inspect}"
99
+ end
100
+ should_raise_expected_exception_with_message("Watchful#public_watchful_method") {Watchful.new.public_watchful_method(:a1, :a2)}
101
+ aspect.unadvise
102
+ end
103
+
104
+ it "should add the \"Class.method\" of the advised type's class method to the exception message." do
105
+ aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_class_watchful_method, :method_options => [:class]} do |jp, obj, *args|
106
+ raise "advice called with args: #{args.inspect}"
107
+ end
108
+ should_raise_expected_exception_with_message("Watchful.public_class_watchful_method") {Watchful.public_class_watchful_method(:a1, :a2)}
109
+ aspect.unadvise
84
110
  end
85
- should_raise_expected_exception_with_message("Watchful.public_class_watchful_method") {Watchful.public_class_watchful_method(:a1, :a2)}
86
- aspect.unadvise
87
111
  end
88
112
 
89
113
  it "should rethrow an exception of the same type as the original exception." do
@@ -126,45 +150,56 @@ describe Advice, "#invoke_original_join_point that raises an exception" do
126
150
  raise IOJPRException.new(":class_raise_exception called with args: #{args.inspect}")
127
151
  end
128
152
  end
129
-
130
- it "should add the kind of advice to the exception message." do
131
- aspect = Aspect.new :before,
132
- :pointcut => {:type => InvokeOriginalJoinPointRaisingException, :methods => :raise_exception} do |jp, obj, *args|
133
- jp.invoke_original_join_point
153
+
154
+ context "when debug_backtraces is true" do
155
+ before do
156
+ @debug_backtraces_orig = Aquarium::Aspects::Advice.debug_backtraces
157
+ Aquarium::Aspects::Advice.debug_backtraces = true
134
158
  end
135
- begin
136
- InvokeOriginalJoinPointRaisingException.new.raise_exception(:a1, :a2) ; fail
137
- rescue InvokeOriginalJoinPointRaisingException::IOJPRException => e
138
- e.message.should include("\"before\" advice")
159
+
160
+ after do
161
+ Aquarium::Aspects::Advice.debug_backtraces = @debug_backtraces_orig
139
162
  end
140
- aspect.unadvise
141
- end
142
163
 
143
- it "should add the \"Class#method\" of the advised object's type and method to the exception message." do
144
- aspect = Aspect.new :before,
164
+ it "should add the kind of advice to the exception message." do
165
+ aspect = Aspect.new :before,
145
166
  :pointcut => {:type => InvokeOriginalJoinPointRaisingException, :methods => :raise_exception} do |jp, obj, *args|
146
167
  jp.invoke_original_join_point
168
+ end
169
+ begin
170
+ InvokeOriginalJoinPointRaisingException.new.raise_exception(:a1, :a2) ; fail
171
+ rescue InvokeOriginalJoinPointRaisingException::IOJPRException => e
172
+ e.message.should include("\"before\" advice")
173
+ end
174
+ aspect.unadvise
147
175
  end
148
- begin
149
- InvokeOriginalJoinPointRaisingException.new.raise_exception(:a1, :a2) ; fail
150
- rescue InvokeOriginalJoinPointRaisingException::IOJPRException => e
151
- e.message.should include("InvokeOriginalJoinPointRaisingException#raise_exception")
176
+
177
+ it "should add the \"Class#method\" of the advised object's type and method to the exception message." do
178
+ aspect = Aspect.new :before,
179
+ :pointcut => {:type => InvokeOriginalJoinPointRaisingException, :methods => :raise_exception} do |jp, obj, *args|
180
+ jp.invoke_original_join_point
181
+ end
182
+ begin
183
+ InvokeOriginalJoinPointRaisingException.new.raise_exception(:a1, :a2) ; fail
184
+ rescue InvokeOriginalJoinPointRaisingException::IOJPRException => e
185
+ e.message.should include("InvokeOriginalJoinPointRaisingException#raise_exception")
186
+ end
187
+ aspect.unadvise
152
188
  end
153
- aspect.unadvise
154
- end
155
189
 
156
- it "should add the \"Class.method\" of the advised type's class method to the exception message." do
157
- aspect = Aspect.new :before,
190
+ it "should add the \"Class.method\" of the advised type's class method to the exception message." do
191
+ aspect = Aspect.new :before,
158
192
  :pointcut => {:type => InvokeOriginalJoinPointRaisingException, :methods => :class_raise_exception,
159
- :method_options => [:class]} do |jp, obj, *args|
193
+ :method_options => [:class]} do |jp, obj, *args|
160
194
  jp.invoke_original_join_point
195
+ end
196
+ begin
197
+ InvokeOriginalJoinPointRaisingException.class_raise_exception(:a1, :a2) ; fail
198
+ rescue InvokeOriginalJoinPointRaisingException::IOJPRException => e
199
+ e.message.should include("InvokeOriginalJoinPointRaisingException.class_raise_exception")
200
+ end
201
+ aspect.unadvise
161
202
  end
162
- begin
163
- InvokeOriginalJoinPointRaisingException.class_raise_exception(:a1, :a2) ; fail
164
- rescue InvokeOriginalJoinPointRaisingException::IOJPRException => e
165
- e.message.should include("InvokeOriginalJoinPointRaisingException.class_raise_exception")
166
- end
167
- aspect.unadvise
168
203
  end
169
204
 
170
205
  it "should rethrow an exception of the same type as the original exception." do
@@ -5,7 +5,7 @@ require 'aquarium/aspects/aspect'
5
5
  require 'aquarium/dsl'
6
6
  require 'aquarium/utils/array_utils'
7
7
  require 'aquarium/finders/pointcut_finder_spec_test_classes'
8
-
8
+ require 'stringio'
9
9
  require 'profiler'
10
10
 
11
11
  include Aquarium::Aspects
@@ -156,6 +156,7 @@ describe Aspect, "methods" do
156
156
  aspect = Aspect.new(:after, :default_objects => object1, :object => object2, :method => :public_test_method) {true}
157
157
  aspect.join_points_matched.size.should == 1
158
158
  aspect.join_points_matched.each {|jp| jp.type_or_object.should_not == object1}
159
+ aspect.unadvise
159
160
  end
160
161
 
161
162
  it "should ignore the :default_objects if at least one other :object is given and the :default_objects are types." do
@@ -164,6 +165,7 @@ describe Aspect, "methods" do
164
165
  :object => object, :method => :public_test_method) {true}
165
166
  aspect.join_points_matched.size.should == 1
166
167
  aspect.join_points_matched.each {|jp| jp.type_or_object.should_not == Aquarium::AspectInvocationTestClass}
168
+ aspect.unadvise
167
169
  end
168
170
 
169
171
  it "should ignore the :default_objects if at least one :pointcut is given even if the :default_objects => object are given." do
@@ -172,6 +174,7 @@ describe Aspect, "methods" do
172
174
  :pointcut => {:type => Aquarium::AspectInvocationTestClass2, :method => :public_test_method}, :method => :public_test_method) {true}
173
175
  aspect.join_points_matched.size.should == 1
174
176
  aspect.join_points_matched.each {|jp| jp.type_or_object.should_not == object}
177
+ aspect.unadvise
175
178
  end
176
179
 
177
180
  it "should ignore the :default_objects if at least one :pointcut is given even if the :default_objects => type are given." do
@@ -179,6 +182,7 @@ describe Aspect, "methods" do
179
182
  :pointcut => {:type => Aquarium::AspectInvocationTestClass2, :method => :public_test_method}, :method => :public_test_method) {true}
180
183
  aspect.join_points_matched.size.should == 1
181
184
  aspect.join_points_matched.each {|jp| jp.type_or_object.should_not == Aquarium::AspectInvocationTestClass}
185
+ aspect.unadvise
182
186
  end
183
187
 
184
188
  it "should ignore the :default_objects if at least one :join_point is given and the :default_objects are objects." do
@@ -187,6 +191,7 @@ describe Aspect, "methods" do
187
191
  aspect = Aspect.new(:after, :default_objects => object, :join_point => join_point, :method => :public_test_method) {true}
188
192
  aspect.join_points_matched.size.should == 1
189
193
  aspect.join_points_matched.each {|jp| jp.type_or_object.should_not == object}
194
+ aspect.unadvise
190
195
  end
191
196
 
192
197
  it "should ignore the :default_objects if at least one :join_point is given and the :default_objects are types." do
@@ -194,6 +199,7 @@ describe Aspect, "methods" do
194
199
  aspect = Aspect.new(:after, :default_objects => Aquarium::AspectInvocationTestClass, :join_point => join_point, :method => :public_test_method) {true}
195
200
  aspect.join_points_matched.size.should == 1
196
201
  aspect.join_points_matched.each {|jp| jp.type_or_object.should_not == Aquarium::AspectInvocationTestClass}
202
+ aspect.unadvise
197
203
  end
198
204
 
199
205
  [:type, :type_and_descendents, :type_and_ancestors, :type_and_nested_types].each do |type_key|
@@ -202,18 +208,21 @@ describe Aspect, "methods" do
202
208
  aspect = Aspect.new(:after, :default_objects => object, type_key => Aquarium::AspectInvocationTestClass2, :method => :public_test_method, :method => :public_test_method) {true}
203
209
  aspect.join_points_matched.size.should == 1
204
210
  aspect.join_points_matched.each {|jp| jp.type_or_object.should_not == object}
211
+ aspect.unadvise
205
212
  end
206
213
 
207
214
  it "should ignore the :default_objects if at least one :#{type_key} is given and the :default_objects are types." do
208
215
  aspect = Aspect.new(:after, :default_objects => Aquarium::AspectInvocationTestClass, type_key => Aquarium::AspectInvocationTestClass2, :method => :public_test_method, :method => :public_test_method) {true}
209
216
  aspect.join_points_matched.size.should == 1
210
217
  aspect.join_points_matched.each {|jp| jp.type_or_object.should_not == Aquarium::AspectInvocationTestClass}
218
+ aspect.unadvise
211
219
  end
212
220
  end
213
221
 
214
222
  Aspect::CANONICAL_OPTIONS["default_objects"].each do |key|
215
223
  it "should accept :#{key} as a synonym for :default_objects." do
216
224
  aspect = Aspect.new(:after, key.intern => Aquarium::AspectInvocationTestClass.new, :method => :public_test_method, :noop => true) {true}
225
+ aspect.unadvise
217
226
  end
218
227
  end
219
228
 
@@ -234,17 +243,20 @@ describe Aspect, "methods" do
234
243
  aspect = Aspect.new(:after, :default_objects => object, :named_pointcut => {:types => Aquarium::PointcutFinderTestClasses::PointcutClassVariableHolder1}) {true}
235
244
  aspect.join_points_matched.size.should == 1
236
245
  aspect.join_points_matched.each {|jp| jp.type_or_object.should_not == object}
246
+ aspect.unadvise
237
247
  end
238
248
 
239
249
  it "should ignore the :default_objects if at least one :named_pointcut is given even if the :default_objects => type are given." do
240
250
  aspect = Aspect.new(:after, :default_objects => Aquarium::AspectInvocationTestClass, :named_pointcut => {:types => Aquarium::PointcutFinderTestClasses::PointcutClassVariableHolder1}) {true}
241
251
  aspect.join_points_matched.size.should == 1
242
252
  aspect.join_points_matched.each {|jp| jp.type_or_object.should_not == Aquarium::AspectInvocationTestClass}
253
+ aspect.unadvise
243
254
  end
244
255
 
245
256
  Aspect::CANONICAL_OPTIONS["named_pointcuts"].each do |key|
246
257
  it "should accept :#{key} as a synonym for :named_pointcuts." do
247
- lambda { Aspect.new :before, key.intern => {:types => Aquarium::PointcutFinderTestClasses.all_pointcut_classes}, :noop => true do; end }.should_not raise_error
258
+ aspect = Aspect.new :before, key.intern => {:types => Aquarium::PointcutFinderTestClasses.all_pointcut_classes}, :noop => true do; end
259
+ aspect.unadvise
248
260
  end
249
261
  end
250
262
 
@@ -265,7 +277,8 @@ describe Aspect, "methods" do
265
277
 
266
278
  Aspect::CANONICAL_OPTIONS["types"].each do |key|
267
279
  it "should accept :#{key} as a synonym for :types." do
268
- lambda { Aspect.new :before, key.intern => Aquarium::AspectInvocationTestClass, :method => :public_test_method, :noop => true do; end }.should_not raise_error
280
+ aspect = Aspect.new :before, key.intern => Aquarium::AspectInvocationTestClass, :method => :public_test_method, :noop => true do; end
281
+ aspect.unadvise
269
282
  end
270
283
  end
271
284
  end
@@ -281,7 +294,8 @@ describe Aspect, "methods" do
281
294
 
282
295
  Aspect::CANONICAL_OPTIONS["pointcuts"].each do |key|
283
296
  it "should accept :#{key} as a synonym for :pointcuts." do
284
- lambda { Aspect.new :before, key.intern => {:type => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, :noop => true do; end }.should_not raise_error
297
+ aspect = Aspect.new :before, key.intern => {:type => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, :noop => true do; end
298
+ aspect.unadvise
285
299
  end
286
300
  end
287
301
  end
@@ -299,7 +313,8 @@ describe Aspect, "methods" do
299
313
  Aspect::CANONICAL_OPTIONS["objects"].each do |key|
300
314
  it "should accept :#{key} as a synonym for :objects." do
301
315
  object = Aquarium::AspectInvocationTestClass.new
302
- lambda { Aspect.new :before, key.intern => object, :method => :public_test_method, :noop => true do; end }.should_not raise_error
316
+ aspect = Aspect.new :before, key.intern => object, :method => :public_test_method, :noop => true do; end
317
+ aspect.unadvise
303
318
  end
304
319
  end
305
320
  end
@@ -315,7 +330,8 @@ describe Aspect, "methods" do
315
330
 
316
331
  Aspect::CANONICAL_OPTIONS["methods"].each do |key|
317
332
  it "should accept :#{key} as a synonym for :methods." do
318
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, key.intern => :public_test_method, :noop => true do; end }.should_not raise_error
333
+ aspect = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, key.intern => :public_test_method, :noop => true do; end
334
+ aspect.unadvise
319
335
  end
320
336
  end
321
337
  end
@@ -1475,23 +1491,28 @@ describe Aspect, "methods" do
1475
1491
  end
1476
1492
 
1477
1493
  it "should accept an argument list matching |jp, object, *args|." do
1478
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp, object, *args|; end }.should_not raise_error(Exception)
1494
+ aspect = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp, object, *args|; end
1495
+ aspect.unadvise
1479
1496
  end
1480
1497
 
1481
1498
  it "should accept an argument list matching |jp, object|." do
1482
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp, object|; end }.should_not raise_error(Exception)
1499
+ aspect = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp, object|; end
1500
+ aspect.unadvise
1483
1501
  end
1484
1502
 
1485
1503
  it "should accept an argument list matching |jp|." do
1486
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp|; end }.should_not raise_error(Exception)
1504
+ aspect = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp|; end
1505
+ aspect.unadvise
1487
1506
  end
1488
1507
 
1489
1508
  it "should accept an argument list matching ||." do
1490
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do ||; end }.should_not raise_error(Exception)
1509
+ aspect = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do ||; end
1510
+ aspect.unadvise
1491
1511
  end
1492
1512
 
1493
1513
  it "should accept no argument list." do
1494
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do; end }.should_not raise_error(Exception)
1514
+ aspect = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do; end
1515
+ aspect.unadvise
1495
1516
  end
1496
1517
  end
1497
1518
 
@@ -1561,7 +1582,8 @@ describe Aspect, "methods" do
1561
1582
 
1562
1583
  Aspect::CANONICAL_OPTIONS["exclude_types"].each do |key|
1563
1584
  it "should accept :#{key} as a synonym for :exclude_types." do
1564
- lambda { Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end }.should_not raise_error
1585
+ aspect = Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end
1586
+ aspect.unadvise
1565
1587
  end
1566
1588
  end
1567
1589
 
@@ -1571,7 +1593,8 @@ describe Aspect, "methods" do
1571
1593
 
1572
1594
  Aspect::CANONICAL_OPTIONS["exclude_types_and_ancestors"].each do |key|
1573
1595
  it "should accept :#{key} as a synonym for :exclude_types_and_ancestors." do
1574
- lambda { Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end }.should_not raise_error
1596
+ aspect = Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end
1597
+ aspect.unadvise
1575
1598
  end
1576
1599
  end
1577
1600
 
@@ -1581,7 +1604,8 @@ describe Aspect, "methods" do
1581
1604
 
1582
1605
  Aspect::CANONICAL_OPTIONS["exclude_types_and_descendents"].each do |key|
1583
1606
  it "should accept :#{key} as a synonym for :exclude_types_and_descendents." do
1584
- lambda { Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end }.should_not raise_error
1607
+ aspect = Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end
1608
+ aspect.unadvise
1585
1609
  end
1586
1610
  end
1587
1611
 
@@ -1591,7 +1615,8 @@ describe Aspect, "methods" do
1591
1615
 
1592
1616
  Aspect::CANONICAL_OPTIONS["exclude_types_and_nested_types"].each do |key|
1593
1617
  it "should accept :#{key} as a synonym for :exclude_types_and_nested_types." do
1594
- lambda { Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end }.should_not raise_error
1618
+ aspect = Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end
1619
+ aspect.unadvise
1595
1620
  end
1596
1621
  end
1597
1622
 
@@ -1631,7 +1656,8 @@ describe Aspect, "methods" do
1631
1656
 
1632
1657
  Aspect::CANONICAL_OPTIONS["exclude_objects"].each do |key|
1633
1658
  it "should accept :#{key} as a synonym for :exclude_objects." do
1634
- lambda { Aspect.new :before, :objects => @all_objects, key.intern => @excluded_objects, :methods => :doit, :noop => true do; end }.should_not raise_error
1659
+ aspect = Aspect.new :before, :objects => @all_objects, key.intern => @excluded_objects, :methods => :doit, :noop => true do; end
1660
+ aspect.unadvise
1635
1661
  end
1636
1662
  end
1637
1663
  end
@@ -1674,7 +1700,8 @@ describe Aspect, "methods" do
1674
1700
 
1675
1701
  Aspect::CANONICAL_OPTIONS["exclude_join_points"].each do |key|
1676
1702
  it "should accept :#{key} as a synonym for :exclude_join_points." do
1677
- lambda { Aspect.new :before, :objects => @all_objects, key.intern => @excluded_join_points, :methods => :doit, :noop => true do; end }.should_not raise_error
1703
+ aspect = Aspect.new :before, :objects => @all_objects, key.intern => @excluded_join_points, :methods => :doit, :noop => true do; end
1704
+ aspect.unadvise
1678
1705
  end
1679
1706
  end
1680
1707
  end
@@ -1836,7 +1863,8 @@ describe Aspect, "methods" do
1836
1863
 
1837
1864
  Aspect::CANONICAL_OPTIONS["exclude_pointcuts"].each do |key|
1838
1865
  it "should accept :#{key} as a synonym for :exclude_pointcuts." do
1839
- lambda {aspect = Aspect.new :before, :objects => @all_objects, key.intern => @excluded_pointcuts, :methods => :doit, :noop => true do; end}.should_not raise_error
1866
+ aspect = Aspect.new :before, :objects => @all_objects, key.intern => @excluded_pointcuts, :methods => :doit, :noop => true do; end
1867
+ aspect.unadvise
1840
1868
  end
1841
1869
  end
1842
1870
  end
@@ -1931,9 +1959,10 @@ describe Aspect, "methods" do
1931
1959
 
1932
1960
  Aspect::CANONICAL_OPTIONS["exclude_named_pointcuts"].each do |key|
1933
1961
  it "should accept :#{key} as a synonym for :exclude_named_pointcuts." do
1934
- lambda {aspect = Aspect.new :before, :pointcuts => Aquarium::PointcutFinderTestClasses.all_pointcuts,
1962
+ aspect = Aspect.new :before, :pointcuts => Aquarium::PointcutFinderTestClasses.all_pointcuts,
1935
1963
  key.intern => {:matching => /POINTCUT/, :in_types => Aquarium::PointcutFinderTestClasses.all_pointcut_classes},
1936
- :noop => true do; end}.should_not raise_error
1964
+ :noop => true do; end
1965
+ aspect.unadvise
1937
1966
  end
1938
1967
  end
1939
1968
  end
@@ -1968,8 +1997,9 @@ describe Aspect, "methods" do
1968
1997
 
1969
1998
  Aspect::CANONICAL_OPTIONS["exclude_types"].each do |key|
1970
1999
  it "should accept :#{key} as a synonym for :exclude_types." do
1971
- lambda {aspect = Aspect.new :before, :pointcuts => [@pointcut1, @pointcut2], key.intern => @excluded_types,
1972
- :noop => true do; end}.should_not raise_error
2000
+ aspect = Aspect.new :before, :pointcuts => [@pointcut1, @pointcut2], key.intern => @excluded_types,
2001
+ :noop => true do; end
2002
+ aspect.unadvise
1973
2003
  end
1974
2004
  end
1975
2005
  end
@@ -1993,8 +2023,9 @@ describe Aspect, "methods" do
1993
2023
 
1994
2024
  Aspect::CANONICAL_OPTIONS["exclude_types_and_ancestors"].each do |key|
1995
2025
  it "should accept :#{key} as a synonym for :exclude_types_and_ancestors." do
1996
- lambda {aspect = Aspect.new :before, :pointcuts => @pointcut1, key.intern => @excluded_types,
1997
- :noop => true do; end}.should_not raise_error
2026
+ aspect = Aspect.new :before, :pointcuts => @pointcut1, key.intern => @excluded_types,
2027
+ :noop => true do; end
2028
+ aspect.unadvise
1998
2029
  end
1999
2030
  end
2000
2031
  end
@@ -2014,8 +2045,9 @@ describe Aspect, "methods" do
2014
2045
 
2015
2046
  Aspect::CANONICAL_OPTIONS["exclude_types_and_descendents"].each do |key|
2016
2047
  it "should accept :#{key} as a synonym for :exclude_types_and_descendents." do
2017
- lambda {aspect = Aspect.new :before, :pointcuts => @pointcut1, key.intern => @excluded_types,
2018
- :ignore_no_matching_join_points => true, :noop => true do; end}.should_not raise_error
2048
+ aspect = Aspect.new :before, :pointcuts => @pointcut1, key.intern => @excluded_types,
2049
+ :ignore_no_matching_join_points => true, :noop => true do; end
2050
+ aspect.unadvise
2019
2051
  end
2020
2052
  end
2021
2053
  end
@@ -2035,8 +2067,9 @@ describe Aspect, "methods" do
2035
2067
 
2036
2068
  Aspect::CANONICAL_OPTIONS["exclude_types_and_nested_types"].each do |key|
2037
2069
  it "should accept :#{key} as a synonym for :exclude_types_and_nested_types." do
2038
- lambda {aspect = Aspect.new :before, :pointcuts => @pointcut1, key.intern => @excluded_types,
2039
- :ignore_no_matching_join_points => true, :noop => true do; end}.should_not raise_error
2070
+ aspect = Aspect.new :before, :pointcuts => @pointcut1, key.intern => @excluded_types,
2071
+ :ignore_no_matching_join_points => true, :noop => true do; end
2072
+ aspect.unadvise
2040
2073
  end
2041
2074
  end
2042
2075
  end
@@ -2075,8 +2108,9 @@ describe Aspect, "methods" do
2075
2108
 
2076
2109
  Aspect::CANONICAL_OPTIONS["exclude_objects"].each do |key|
2077
2110
  it "should accept :#{key} as a synonym for :exclude_objects." do
2078
- lambda {aspect = Aspect.new :before, :pointcuts => [@pointcut1, @pointcut2], key.intern => @excluded_objects,
2079
- :noop => true do; end}.should_not raise_error
2111
+ aspect = Aspect.new :before, :pointcuts => [@pointcut1, @pointcut2], key.intern => @excluded_objects,
2112
+ :noop => true do; end
2113
+ aspect.unadvise
2080
2114
  end
2081
2115
  end
2082
2116
  end
@@ -2135,7 +2169,8 @@ describe Aspect, "methods" do
2135
2169
 
2136
2170
  Aspect::CANONICAL_OPTIONS["exclude_methods"].each do |key|
2137
2171
  it "should accept :#{key} as a synonym for :exclude_methods." do
2138
- lambda { Aspect.new :before, :pointcuts => [@pointcut1, @pointcut2, @pointcut3, @pointcut4], key.intern => :doit3, :noop => true }.should_not raise_error
2172
+ aspect = Aspect.new :before, :pointcuts => [@pointcut1, @pointcut2, @pointcut3, @pointcut4], key.intern => :doit3, :noop => true
2173
+ aspect.unadvise
2139
2174
  end
2140
2175
  end
2141
2176