aquarium 0.3.0 → 0.3.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/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,15 +1,42 @@
1
+ require 'logger'
2
+ require 'aquarium/utils/default_logger'
3
+
1
4
  module Aquarium
2
5
  module Utils
3
6
 
4
7
  # Support parsing and processing of key-value pairs of options.
5
- # Including types must define the following methods (see Pointcut for an example):
6
- # canonical_options # Return the hash of canonical options
7
- # all_allowed_option_symbols # Returns an array of all allowed options as symbols.
8
- # init_type_specific_specification(original_options, options_hash) for any unique options handling (optional).
8
+ # Types including this module must define the following methods (see Pointcut for an example):
9
+ # <tt>all_allowed_option_symbols</tt>
10
+ # Return an array of all allowed options as symbols.
11
+ # <tt>init_type_specific_specification(original_options, options_hash)</tt>
12
+ # Called to perform any final options handling unique for the type (optional).
13
+ # In addition, including types should have their <tt>initialize</tt> methods calls this module's
14
+ # <tt>init_specification</tt> to do the options processing.
15
+ #
16
+ # This module also defines several universal options that will be available to all types that include this module:
17
+ # <tt>:logger => options_hash[:logger] || default system-wide Logger</tt>
18
+ # A standard library Logger used for any messages. A default system-wide logger is used otherwise.
19
+ # The corresponding <tt>logger</tt> and <tt>logger=</tt> accessors are defined.
20
+ #
21
+ # <tt>:logger_stream => options_hash[:logger_stream]</tt>
22
+ # An an alternative to defining the logger, you can define just the output stream where log output will be written.
23
+ # If this option is specified, a new logger will be created for the instance with this output stream.
24
+ # There is no corresponding accessors; use the corresponding methods on the <tt>logger</tt> object instead.
25
+ #
26
+ # <tt>:severity => options_hash[:severity]</tt>
27
+ # The logging severity level, one of the Logger::Severity values or the corresponding integer value.
28
+ # If this option is specified, a new logger will be created for the instance with this output stream.
29
+ # There is no corresponding accessors; use the corresponding methods on the <tt>logger</tt> object instead.
30
+ #
31
+ # <tt>:noop => options_hash[:noop] || false</tt>
32
+ # If true, don't do "anything", the interpretation of which will vary with the type receiving the option.
33
+ # For example, a type might go through some initialization, such as parsng its argument list, but
34
+ # do nothing after that. Primarily useful for debugging.
35
+ # The value can be accessed through the <tt>noop</tt> and <tt>noop=</tt> accessors.
9
36
  module OptionsUtils
10
37
 
11
38
  def self.universal_options
12
- [:verbose, :log, :noop]
39
+ [:logger_stream, :logger, :severity, :noop]
13
40
  end
14
41
 
15
42
  def init_specification options, canonical_options, &optional_block
@@ -26,17 +53,25 @@ module Aquarium
26
53
  end
27
54
  @specification[key.intern] = Set.new(make_array(all_related_options))
28
55
  end
29
- uopts = {
30
- :log => options_hash[:log] || "",
31
- :verbose => options_hash[:verbose] || 0,
32
- :noop => options_hash[:noop] || false
56
+
57
+ universal_options = {
58
+ :logger_stream => options_hash[:logger_stream],
59
+ :severity => options_hash[:severity],
60
+ :noop => options_hash[:noop] || false
33
61
  }
34
- OptionsUtils::universal_options.each { |uopt| @specification[uopt] = Set.new [uopts[uopt]] }
62
+
63
+ set_logger_if_logger_or_stream_specified universal_options, options_hash
64
+ set_logger_severity_if_specified universal_options, options_hash
65
+ set_logger_if_not_specified universal_options, options_hash
66
+
67
+ OptionsUtils::universal_options.each do |uopt|
68
+ @specification[uopt] = Set.new([universal_options[uopt]]) unless universal_options[uopt].nil?
69
+ end
35
70
  init_type_specific_specification @original_options, options_hash, &optional_block
36
71
  validate_options options_hash
37
72
  end
38
73
 
39
- OptionsUtils::universal_options.each do |name|
74
+ [:logger, :noop].each do |name|
40
75
  module_eval(<<-EOF, __FILE__, __LINE__)
41
76
  def #{name}
42
77
  @specification[:#{name}].to_a.first
@@ -48,7 +83,7 @@ module Aquarium
48
83
  end
49
84
 
50
85
  # Override for type-specific initialization
51
- def init_type_specific_specification options, &optional_block
86
+ def init_type_specific_specification original_options, options_hash, &optional_block
52
87
  end
53
88
 
54
89
  def hashify options
@@ -69,6 +104,33 @@ module Aquarium
69
104
  raise Aquarium::Utils::InvalidOptions.new("Unknown options specified: #{unknowns.inspect}") if unknowns.size > 0
70
105
  end
71
106
 
107
+ protected
108
+
109
+ def set_logger_if_logger_or_stream_specified universal_options, options_hash
110
+ if not options_hash[:logger].nil?
111
+ universal_options[:logger] = options_hash[:logger]
112
+ elsif not options_hash[:logger_stream].nil?
113
+ universal_options[:logger] = Logger.new options_hash[:logger_stream]
114
+ end
115
+ end
116
+
117
+ def set_logger_severity_if_specified universal_options, options_hash
118
+ unless options_hash[:severity].nil?
119
+ unless universal_options[:logger].nil?
120
+ universal_options[:logger].level = options_hash[:severity]
121
+ else
122
+ universal_options[:logger] = Logger.new STDERR
123
+ universal_options[:logger].level = options_hash[:severity]
124
+ end
125
+ end
126
+ end
127
+
128
+ def set_logger_if_not_specified universal_options, options_hash
129
+ if universal_options[:logger].nil?
130
+ universal_options[:logger] = DefaultLogger.logger
131
+ end
132
+ end
133
+
72
134
  end
73
135
  end
74
136
  end
@@ -21,16 +21,10 @@ module Aquarium
21
21
  protected
22
22
 
23
23
  def self.do_descendents clazz, visiting_module, visited, result
24
- # p "#{clazz}, #{visiting_module}<br/>"
25
24
  visited << visiting_module
26
- # TODO Odd ruby behavior; a class is constant on the class, yet if it is nested in a module
27
- # it comes up undefined! However, doing class_eval works around it. Is there a better way??
28
- visiting_module.constants.each do |const|
25
+ visiting_module.constants.each do |const|
29
26
  next unless visiting_module.const_defined?(const)
30
27
  clazz2 = visiting_module.const_get(const)
31
- # clazz2 = visiting_module.const_defined?(const) ?
32
- # visiting_module.const_get(const) :
33
- # visiting_module.class_eval(const)
34
28
  next if visited.include?(clazz2) or not clazz2.respond_to?(:ancestors)
35
29
  visited << clazz2
36
30
  result << clazz2 if clazz2.ancestors.include?(clazz)
@@ -9,7 +9,7 @@ module Aquarium
9
9
  unless defined? MAJOR
10
10
  MAJOR = 0
11
11
  MINOR = 3
12
- TINY = 0
12
+ TINY = 1
13
13
  RELEASE_CANDIDATE = nil
14
14
 
15
15
  # RANDOM_TOKEN: 0.598704893979657
@@ -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'
4
4
 
5
5
  include Aquarium::Aspects::Advice
@@ -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/aspects/advice'
4
4
  require 'aquarium/aspects/aspect'
5
5
  include Aquarium::Aspects
@@ -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/aspects/aspect'
4
4
  require 'aquarium/aspects/dsl'
5
5
  require 'aquarium/utils/array_utils'
@@ -44,1169 +44,1194 @@ module Aquarium
44
44
  end
45
45
  end
46
46
 
47
- describe Aspect, ".new (parameters that specify the kind of advice)" do
48
- it "should require the kind of advice as the first parameter." do
49
- lambda { Aspect.new :pointcut => {:type => Aquarium::AspectInvocationTestClass} }.should raise_error(Aquarium::Utils::InvalidOptions)
47
+ describe Aspect, "methods" do
48
+ include Aquarium::TypeUtilsStub
49
+
50
+ before :all do
51
+ stub_type_utils_descendents
50
52
  end
51
-
52
- it "should contain no other advice types if :around advice specified." do
53
- lambda { Aspect.new :around, :before, :pointcut => {:type => Aquarium::AspectInvocationTestClass} }.should raise_error(Aquarium::Utils::InvalidOptions)
54
- lambda { Aspect.new :around, :after, :pointcut => {:type => Aquarium::AspectInvocationTestClass} }.should raise_error(Aquarium::Utils::InvalidOptions)
55
- lambda { Aspect.new :around, :after_returning, :pointcut => {:type => Aquarium::AspectInvocationTestClass} }.should raise_error(Aquarium::Utils::InvalidOptions)
56
- lambda { Aspect.new :around, :after_raising, :pointcut => {:type => Aquarium::AspectInvocationTestClass} }.should raise_error(Aquarium::Utils::InvalidOptions)
53
+ after :all do
54
+ unstub_type_utils_descendents
57
55
  end
58
-
59
- it "should allow only one of :after, :after_returning, or :after_raising advice to be specified." do
60
- lambda { Aspect.new :after, :after_returning, :pointcut => {:type => Aquarium::AspectInvocationTestClass} }.should raise_error(Aquarium::Utils::InvalidOptions)
61
- lambda { Aspect.new :after, :after_raising, :pointcut => {:type => Aquarium::AspectInvocationTestClass} }.should raise_error(Aquarium::Utils::InvalidOptions)
62
- lambda { Aspect.new :after_returning, :after_raising, :pointcut => {:type => Aquarium::AspectInvocationTestClass} }.should raise_error(Aquarium::Utils::InvalidOptions)
56
+
57
+ describe Aspect, ".new (the :ignore_no_matching_join_points parameter that specifies whether or not to warn about no join point matches)" do
58
+ before :each do
59
+ @log_stream = StringIO.new
60
+ end
61
+
62
+ it "should warn about no join point matches if the :ignore_no_matching_join_points is not specified." do
63
+ lambda {Aspect.new(:after, :logger_stream => @log_stream) {|jp, obj, *args| true}}.should raise_error(Aquarium::Utils::InvalidOptions)
64
+ @log_stream.string.should_not be_empty
65
+ end
66
+ it "should warn about no join point matches if :ignore_no_matching_join_points => false is specified." do
67
+ lambda {Aspect.new(:after, :logger_stream => @log_stream, :ignore_no_matching_join_points => false) {|jp, obj, *args| true}}.should raise_error(Aquarium::Utils::InvalidOptions)
68
+ @log_stream.string.should_not be_empty
69
+ end
70
+ it "should not warn about no join point matches if :ignore_no_matching_join_points => true is specified." do
71
+ lambda {Aspect.new(:after, :logger_stream => @log_stream, :ignore_no_matching_join_points => true) {|jp, obj, *args| true}}.should raise_error(Aquarium::Utils::InvalidOptions)
72
+ @log_stream.string.should be_empty
73
+ end
63
74
  end
64
75
 
65
- it "should allow :before to be specified with :after." do
66
- lambda { Aspect.new :before, :after, :pointcut => {:type => Aquarium::AspectInvocationTestClass}, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
67
- end
76
+ describe Aspect, ".new (parameters that specify the kind of advice)" do
77
+ before :all do
78
+ @pointcut_opts = {:type => Aquarium::AspectInvocationTestClass}
79
+ end
80
+
81
+ it "should require the kind of advice as the first parameter." do
82
+ lambda { Aspect.new :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
83
+ end
68
84
 
69
- it "should allow :before to be specified with :after_returning." do
70
- lambda { Aspect.new :before, :after_returning, :pointcut => {:type => Aquarium::AspectInvocationTestClass}, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
71
- end
85
+ it "should contain no other advice types if :around advice specified." do
86
+ lambda { Aspect.new :around, :before, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
87
+ lambda { Aspect.new :around, :after, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
88
+ lambda { Aspect.new :around, :after_returning, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
89
+ lambda { Aspect.new :around, :after_raising, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
90
+ end
72
91
 
73
- it "should allow :before to be specified with :after_raising." do
74
- lambda { Aspect.new :before, :after_raising, :pointcut => {:type => Aquarium::AspectInvocationTestClass}, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
75
- end
92
+ it "should allow only one of :after, :after_returning, or :after_raising advice to be specified." do
93
+ lambda { Aspect.new :after, :after_returning, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
94
+ lambda { Aspect.new :after, :after_raising, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
95
+ lambda { Aspect.new :after_returning, :after_raising, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
96
+ end
76
97
 
77
- it "should accept a single exception specified with :after_raising." do
78
- lambda { Aspect.new :before, :after_raising => Exception, :pointcut => {:type => Aquarium::AspectInvocationTestClass}, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
79
- end
98
+ it "should allow :before to be specified with :after." do
99
+ lambda { Aspect.new :before, :after, :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
100
+ end
101
+
102
+ it "should allow :before to be specified with :after_returning." do
103
+ lambda { Aspect.new :before, :after_returning, :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
104
+ end
105
+
106
+ it "should allow :before to be specified with :after_raising." do
107
+ lambda { Aspect.new :before, :after_raising, :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
108
+ end
109
+
110
+ it "should accept a single exception specified with :after_raising." do
111
+ lambda { Aspect.new :before, :after_raising => Exception, :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
112
+ end
80
113
 
81
- it "should accept a a list of exceptions specified with :after_raising." do
82
- lambda { Aspect.new :before, :after_raising => [Exception, String], :pointcut => {:type => Aquarium::AspectInvocationTestClass}, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
114
+ it "should accept a a list of exceptions specified with :after_raising." do
115
+ lambda { Aspect.new :before, :after_raising => [Exception, String], :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
116
+ end
83
117
  end
84
- end
85
118
 
86
- describe Aspect, ".new (parameters that specify pointcuts)" do
87
- it "should contain at least one of :method(s), :pointcut(s), :type(s), or :object(s)." do
88
- lambda {Aspect.new(:after) {|jp, obj, *args| true}}.should raise_error(Aquarium::Utils::InvalidOptions)
89
- end
119
+ describe Aspect, ".new (parameters that specify pointcuts)" do
120
+ before :all do
121
+ @pointcut_opts = {:type => Aquarium::AspectInvocationTestClass}
122
+ end
123
+
124
+ it "should contain at least one of :method(s), :pointcut(s), :type(s), or :object(s)." do
125
+ lambda {Aspect.new(:after, :ignore_no_matching_join_points => true) {|jp, obj, *args| true}}.should raise_error(Aquarium::Utils::InvalidOptions)
126
+ end
90
127
 
91
- it "should contain at least one of :pointcut(s), :type(s), or :object(s) unless :default_objects => object is given." do
92
- aspect = Aspect.new(:after, :default_objects => Aquarium::AspectInvocationTestClass.new, :methods => :public_test_method) {|jp, obj, *args| true}
93
- aspect.unadvise
128
+ it "should contain at least one of :pointcut(s), :type(s), or :object(s) unless :default_objects => object is given." do
129
+ aspect = Aspect.new(:after, :default_objects => Aquarium::AspectInvocationTestClass.new, :methods => :public_test_method, :noop => true) {|jp, obj, *args| true}
130
+ end
131
+
132
+ Aspect::CANONICAL_OPTIONS["default_objects"].each do |key|
133
+ it "should accept :#{key} as a synonym for :default_objects." do
134
+ aspect = Aspect.new(:after, key.intern => Aquarium::AspectInvocationTestClass.new, :methods => :public_test_method, :noop => true) {|jp, obj, *args| true}
135
+ end
136
+ end
137
+
138
+ it "should not contain :pointcut(s) and either :type(s) or :object(s)." do
139
+ lambda {Aspect.new(:after, :pointcuts => @pointcut_opts, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method) {|jp, obj, *args| true}}.should raise_error(Aquarium::Utils::InvalidOptions)
140
+ lambda {Aspect.new(:after, :pointcuts => @pointcut_opts, :object => Aquarium::AspectInvocationTestClass.new, :methods => :public_test_method) {|jp, obj, *args| true}}.should raise_error(Aquarium::Utils::InvalidOptions)
141
+ end
94
142
  end
95
143
 
96
- Aspect::CANONICAL_OPTIONS["default_objects"].each do |key|
97
- it "should accept :#{key} as a synonym for :default_objects." do
98
- aspect = Aspect.new(:after, key.intern => Aquarium::AspectInvocationTestClass.new, :methods => :public_test_method) {|jp, obj, *args| true}
144
+
145
+ describe Aspect, ".new with :types parameter" do
146
+ it "should advise the specified types." do
147
+ @advice_called = false
148
+ aspect = Aspect.new :before, :types => Aquarium::AspectInvocationTestClass, :method => :public_test_method do; @advice_called = true; end
149
+ Aquarium::AspectInvocationTestClass.new.public_test_method
99
150
  aspect.unadvise
151
+ @advice_called.should be_true
152
+ end
153
+
154
+ Aspect::CANONICAL_OPTIONS["types"].each do |key|
155
+ it "should accept :#{key} as a synonym for :types." do
156
+ lambda { Aspect.new :before, key.intern => Aquarium::AspectInvocationTestClass, :method => :public_test_method, :noop => true do; end }.should_not raise_error
157
+ end
100
158
  end
101
159
  end
102
-
103
- it "should not contain :pointcut(s) and either :type(s) or :object(s)." do
104
- lambda {Aspect.new(:after, :pointcuts => {:type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method}, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method) {|jp, obj, *args| true}}.should raise_error(Aquarium::Utils::InvalidOptions)
105
- lambda {Aspect.new(:after, :pointcuts => {:type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method}, :object => Aquarium::AspectInvocationTestClass.new, :methods => :public_test_method) {|jp, obj, *args| true}}.should raise_error(Aquarium::Utils::InvalidOptions)
160
+
161
+ describe Aspect, ".new with :pointcuts parameter" do
162
+ it "should advise the specified pointcuts." do
163
+ @advice_called = false
164
+ aspect = Aspect.new :before, :pointcuts => {:types => Aquarium::AspectInvocationTestClass, :method => :public_test_method} do; @advice_called = true; end
165
+ Aquarium::AspectInvocationTestClass.new.public_test_method
166
+ aspect.unadvise
167
+ @advice_called.should be_true
168
+ end
169
+
170
+ Aspect::CANONICAL_OPTIONS["pointcuts"].each do |key|
171
+ it "should accept :#{key} as a synonym for :pointcuts." do
172
+ lambda { Aspect.new :before, key.intern => {:type => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, :noop => true do; end }.should_not raise_error
173
+ end
174
+ end
106
175
  end
107
- end
108
176
 
177
+ describe Aspect, ".new with :objects parameter" do
178
+ it "should advise the specified objects." do
179
+ @advice_called = false
180
+ object = Aquarium::AspectInvocationTestClass.new
181
+ aspect = Aspect.new :before, :objects => object, :method => :public_test_method do; @advice_called = true; end
182
+ object.public_test_method
183
+ aspect.unadvise
184
+ @advice_called.should be_true
185
+ end
109
186
 
110
- describe Aspect, ".new (:types parameter)" do
111
- Aspect::CANONICAL_OPTIONS["types"].each do |key|
112
- it "should accept :#{key} as a synonym for :types." do
113
- @advice = Proc.new {}
114
- @expected_methods = [:public_test_method]
115
- aspect1 = Aspect.new :before, key.intern => Aquarium::AspectInvocationTestClass, :method => @expected_methods, :advice => @advice
116
- aspect2 = Aspect.new :before, :types => Aquarium::AspectInvocationTestClass, :method => @expected_methods, :advice => @advice
117
- aspects_should_be_equal 1, aspect1, aspect2
118
- aspect1.unadvise
119
- aspect2.unadvise
187
+ Aspect::CANONICAL_OPTIONS["objects"].each do |key|
188
+ it "should accept :#{key} as a synonym for :objects." do
189
+ object = Aquarium::AspectInvocationTestClass.new
190
+ lambda { Aspect.new :before, key.intern => object, :method => :public_test_method, :noop => true do; end }.should_not raise_error
191
+ end
120
192
  end
121
193
  end
122
- end
123
194
 
124
- describe Aspect, ".new (:pointcuts parameter)" do
125
- Aspect::CANONICAL_OPTIONS["pointcuts"].each do |key|
126
- it "should accept :#{key} as a synonym for :pointcuts." do
127
- @advice = Proc.new {}
128
- @expected_methods = [:public_test_method]
129
- aspect1 = Aspect.new :before, key.intern => {:type => Aquarium::AspectInvocationTestClass, :method => @expected_methods}, :advice => @advice
130
- aspect2 = Aspect.new :before, :pointcuts => {:type => Aquarium::AspectInvocationTestClass, :method => @expected_methods}, :advice => @advice
131
- aspects_should_be_equal 1, aspect1, aspect2
132
- aspect1.unadvise
133
- aspect2.unadvise
195
+ describe Aspect, ".new with :methods parameter" do
196
+ it "should advise the specified methods." do
197
+ @advice_called = false
198
+ aspect = Aspect.new :before, :types => Aquarium::AspectInvocationTestClass, :methods => :public_test_method do; @advice_called = true; end
199
+ Aquarium::AspectInvocationTestClass.new.public_test_method
200
+ aspect.unadvise
201
+ @advice_called.should be_true
202
+ end
203
+
204
+ Aspect::CANONICAL_OPTIONS["methods"].each do |key|
205
+ it "should accept :#{key} as a synonym for :methods." do
206
+ lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, key.intern => :public_test_method, :noop => true do; end }.should_not raise_error
207
+ end
134
208
  end
135
209
  end
136
- end
137
210
 
138
- describe Aspect, ".new (:objects parameter)" do
139
- Aspect::CANONICAL_OPTIONS["objects"].each do |key|
140
- it "should accept :#{key} as a synonym for :objects." do
211
+ describe Aspect, ".new (:attributes parameter)" do
212
+ Aspect::CANONICAL_OPTIONS["attributes"].each do |key|
213
+ it "should accept :#{key} as a synonym for :attributes." do
214
+ @advice_called = false
215
+ aspect = Aspect.new :before, :types => Aquarium::AspectInvocationTestClass, :attributes => :public_test_method_args do; @advice_called = true; end
216
+ Aquarium::AspectInvocationTestClass.new.public_test_method_args
217
+ aspect.unadvise
218
+ end
219
+ end
220
+
221
+ it "should accept :reading => ... as a synonym for :attributes => ..., :attribute_options => [:readers]." do
141
222
  @advice = Proc.new {}
142
- @expected_methods = [:public_test_method]
143
- object = Aquarium::AspectInvocationTestClass.new
144
- aspect1 = Aspect.new :before, key.intern => object, :method => @expected_methods, :advice => @advice
145
- aspect2 = Aspect.new :before, :objects => object, :method => @expected_methods, :advice => @advice
223
+ @expected_methods = [:public_test_method_args]
224
+ aspect1 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :reading => :public_test_method_args, :advice => @advice
225
+ aspect2 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :attributes => :public_test_method_args, :attribute_options => [:readers], :advice => @advice
146
226
  aspects_should_be_equal 1, aspect1, aspect2
147
227
  aspect1.unadvise
148
228
  aspect2.unadvise
149
229
  end
150
- end
151
- end
152
230
 
153
- describe Aspect, ".new (:methods parameter)" do
154
- Aspect::CANONICAL_OPTIONS["methods"].each do |key|
155
- it "should accept :#{key} as a synonym for :methods." do
231
+ it "should accept :writing => ... as a synonym for :attributes => ..., :attribute_options => [:writer]." do
156
232
  @advice = Proc.new {}
157
- @expected_methods = [:public_test_method]
158
- aspect1 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, key.intern => @expected_methods, :advice => @advice
159
- aspect2 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => @expected_methods, :advice => @advice
233
+ @expected_methods = [:public_test_method_args=]
234
+ aspect1 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :writing => :public_test_method_args, :advice => @advice
235
+ aspect2 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :attributes => :public_test_method_args, :attribute_options => [:writers], :advice => @advice
160
236
  aspects_should_be_equal 1, aspect1, aspect2
161
237
  aspect1.unadvise
162
238
  aspect2.unadvise
163
239
  end
164
- end
165
- end
166
240
 
167
- describe Aspect, ".new (:attributes parameter)" do
168
- Aspect::CANONICAL_OPTIONS["attributes"].each do |key|
169
- it "should accept :#{key} as a synonym for :attributes." do
241
+ it "should accept :changing => ... as a synonym for :attributes => ..., :attribute_options => [:writer]." do
170
242
  @advice = Proc.new {}
171
- @expected_methods = [:public_test_method_args, :public_test_method_args=]
172
- aspect1 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, key.intern => @expected_methods, :advice => @advice
173
- aspect2 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :attributes => @expected_methods, :advice => @advice
174
- aspects_should_be_equal 2, aspect1, aspect2
243
+ @expected_methods = [:public_test_method_args=]
244
+ aspect1 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :changing => :public_test_method_args, :advice => @advice
245
+ aspect2 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :attributes => :public_test_method_args, :attribute_options => [:writers], :advice => @advice
246
+ aspects_should_be_equal 1, aspect1, aspect2
175
247
  aspect1.unadvise
176
248
  aspect2.unadvise
177
249
  end
178
250
  end
179
251
 
180
- it "should accept :reading => ... as a synonym for :attributes => ..., :attribute_options => [:readers]." do
181
- @advice = Proc.new {}
182
- @expected_methods = [:public_test_method_args]
183
- aspect1 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :reading => :public_test_method_args, :advice => @advice
184
- aspect2 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :attributes => :public_test_method_args, :attribute_options => [:readers], :advice => @advice
185
- aspects_should_be_equal 1, aspect1, aspect2
186
- aspect1.unadvise
187
- aspect2.unadvise
188
- end
189
-
190
- it "should accept :writing => ... as a synonym for :attributes => ..., :attribute_options => [:writer]." do
191
- @advice = Proc.new {}
192
- @expected_methods = [:public_test_method_args=]
193
- aspect1 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :writing => :public_test_method_args, :advice => @advice
194
- aspect2 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :attributes => :public_test_method_args, :attribute_options => [:writers], :advice => @advice
195
- aspects_should_be_equal 1, aspect1, aspect2
196
- aspect1.unadvise
197
- aspect2.unadvise
198
- end
199
-
200
- it "should accept :changing => ... as a synonym for :attributes => ..., :attribute_options => [:writer]." do
201
- @advice = Proc.new {}
202
- @expected_methods = [:public_test_method_args=]
203
- aspect1 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :changing => :public_test_method_args, :advice => @advice
204
- aspect2 = Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :attributes => :public_test_method_args, :attribute_options => [:writers], :advice => @advice
205
- aspects_should_be_equal 1, aspect1, aspect2
206
- aspect1.unadvise
207
- aspect2.unadvise
208
- end
209
- end
210
-
211
- describe Aspect, ".new (with a :type(s) parameter and a :method(s) parameter)" do
212
- before :each do
213
- @protection = 'public'
214
- @are_class_methods = false
215
- @types_option = :types
216
- @method_options = []
217
- end
252
+ describe Aspect, ".new (with a :type(s) parameter and a :method(s) parameter)" do
253
+ before :each do
254
+ @protection = 'public'
255
+ @are_class_methods = false
256
+ @types_option = :types
257
+ @method_options = []
258
+ end
218
259
 
219
- def do_type_spec
220
- aspect = nil
221
- advice_called = false
222
- aspect = Aspect.new :before, @types_option => @type_spec, :methods => @method_spec, :method_options => @method_options do |jp, obj, *args|
223
- advice_called = true
224
- jp.should_not be_nil
225
- args.size.should == 4
226
- args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
227
- end
228
- if @are_class_methods
229
- Aquarium::AspectInvocationTestClass.method("#{@protection}_class_test_method").call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
230
- else
231
- Aquarium::AspectInvocationTestClass.new.method("#{@protection}_test_method").call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
232
- end
233
- advice_called.should be_true
234
- aspect.unadvise
235
- end
236
-
237
- it "should accept :type(s) => [T1, ...], :methods => [m, ...]" do
238
- @type_spec = [Aquarium::AspectInvocationTestClass]
239
- @method_spec = [:public_test_method]
240
- do_type_spec
241
- end
260
+ def do_type_spec
261
+ aspect = nil
262
+ advice_called = false
263
+ aspect = Aspect.new :before, @types_option => @type_spec, :methods => @method_spec, :method_options => @method_options do |jp, obj, *args|
264
+ advice_called = true
265
+ jp.should_not be_nil
266
+ args.size.should == 4
267
+ args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
268
+ end
269
+ if @are_class_methods
270
+ Aquarium::AspectInvocationTestClass.method("#{@protection}_class_test_method").call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
271
+ else
272
+ Aquarium::AspectInvocationTestClass.new.method("#{@protection}_test_method").call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
273
+ end
274
+ advice_called.should be_true
275
+ aspect.unadvise
276
+ end
242
277
 
243
- it "should accept :type(s)_and_ancestors => [T1, ...], :methods => [m, ...]" do
244
- @types_option = :types_and_ancestors
245
- @type_spec = [Aquarium::AspectInvocationTestClass]
246
- @method_spec = [:public_test_method]
247
- do_type_spec
248
- end
278
+ it "should accept :type(s) => T1, :methods => m" do
279
+ @type_spec = Aquarium::AspectInvocationTestClass
280
+ @method_spec = :public_test_method
281
+ do_type_spec
282
+ end
249
283
 
250
- it "should accept :type(s)_and_descendents => [T1, ...], :methods => [m, ...]" do
251
- @types_option = :types_and_descendents
252
- @type_spec = [Aquarium::AspectInvocationTestClass]
253
- @method_spec = [:public_test_method]
254
- do_type_spec
255
- end
284
+ it "should accept :type(s) => T1, :methods => [m, ...]" do
285
+ @type_spec = Aquarium::AspectInvocationTestClass
286
+ @method_spec = [:public_test_method]
287
+ do_type_spec
288
+ end
256
289
 
257
- it "should accept :type(s) => [T1, ...], :methods => m" do
258
- @type_spec = [Aquarium::AspectInvocationTestClass]
259
- @method_spec = :public_test_method
260
- do_type_spec
261
- end
290
+ it "should accept :type(s) => T1, :methods => /m/" do
291
+ @type_spec = Aquarium::AspectInvocationTestClass
292
+ @method_spec = /test_method/
293
+ do_type_spec
294
+ end
262
295
 
263
- it "should accept :type(s) => [T1, ...], :methods => /m/" do
264
- @type_spec = [Aquarium::AspectInvocationTestClass]
265
- @method_spec = /test_method/
266
- do_type_spec
267
- end
296
+ it "should accept :type(s) => [T1, ...], :methods => m" do
297
+ @type_spec = [Aquarium::AspectInvocationTestClass]
298
+ @method_spec = :public_test_method
299
+ do_type_spec
300
+ end
268
301
 
269
- it "should accept :type(s) => T1, :methods => [m, ...]" do
270
- @type_spec = Aquarium::AspectInvocationTestClass
271
- @method_spec = [:public_test_method]
272
- do_type_spec
273
- end
302
+ it "should accept :type(s) => [T1, ...], :methods => [m, ...]" do
303
+ @type_spec = [Aquarium::AspectInvocationTestClass]
304
+ @method_spec = [:public_test_method]
305
+ do_type_spec
306
+ end
274
307
 
275
- it "should accept :type(s)_and_ancestors => T1, :methods => [m, ...]" do
276
- @types_option = :types_and_ancestors
277
- @type_spec = Aquarium::AspectInvocationTestClass
278
- @method_spec = [:public_test_method]
279
- do_type_spec
280
- end
308
+ it "should accept :type(s) => [T1, ...], :methods => /m/" do
309
+ @type_spec = [Aquarium::AspectInvocationTestClass]
310
+ @method_spec = /test_method/
311
+ do_type_spec
312
+ end
281
313
 
282
- it "should accept :type(s)_and_descendents => T1, :methods => [m, ...]" do
283
- @types_option = :types_and_descendents
284
- @type_spec = Aquarium::AspectInvocationTestClass
285
- @method_spec = [:public_test_method]
286
- do_type_spec
287
- end
314
+ it "should accept :type(s) => /T1/, :methods => m" do
315
+ @type_spec = /Aquarium::AspectInvocationTestClass/
316
+ @method_spec = :public_test_method
317
+ do_type_spec
318
+ end
288
319
 
289
- it "should accept :type(s) => T1, :methods => m" do
290
- @type_spec = Aquarium::AspectInvocationTestClass
291
- @method_spec = :public_test_method
292
- do_type_spec
293
- end
320
+ it "should accept :type(s) => /T1/, :methods => [m, ...]" do
321
+ @type_spec = /Aquarium::AspectInvocationTestClass/
322
+ @method_spec = [:public_test_method]
323
+ do_type_spec
324
+ end
294
325
 
295
- it "should accept :type(s) => T1, :methods => /m/" do
296
- @type_spec = Aquarium::AspectInvocationTestClass
297
- @method_spec = /test_method/
298
- do_type_spec
299
- end
326
+ it "should accept :type(s) => /T1/, :methods => /m/" do
327
+ @type_spec = /Aquarium::AspectInvocationTestClass/
328
+ @method_spec = /test_method/
329
+ do_type_spec
330
+ end
300
331
 
301
- it "should accept :type(s) => /T1/, :methods => [m, ...]" do
302
- @type_spec = /Aquarium::AspectInvocationTestClass/
303
- @method_spec = [:public_test_method]
304
- do_type_spec
305
- end
332
+ it "should accept :type(s)_and_ancestors => T1, :methods => [m, ...]" do
333
+ @types_option = :types_and_ancestors
334
+ @type_spec = Aquarium::AspectInvocationTestClass
335
+ @method_spec = [:public_test_method]
336
+ do_type_spec
337
+ end
306
338
 
307
- it "should accept :type(s)_and_ancestors => /T1/, :methods => [m, ...]" do
308
- @types_option = :types_and_ancestors
309
- @type_spec = /Aquarium::AspectInvocationTestClass/
310
- @method_spec = [:public_test_method]
311
- do_type_spec
312
- end
339
+ it "should accept :type(s)_and_ancestors => [T1, ...], :methods => [m, ...]" do
340
+ @types_option = :types_and_ancestors
341
+ @type_spec = [Aquarium::AspectInvocationTestClass]
342
+ @method_spec = [:public_test_method]
343
+ do_type_spec
344
+ end
313
345
 
314
- it "should accept :type(s)_and_descendents => /T1/, :methods => [m, ...]" do
315
- @types_option = :types_and_descendents
316
- @type_spec = /Aquarium::AspectInvocationTestClass/
317
- @method_spec = [:public_test_method]
318
- do_type_spec
319
- end
346
+ it "should accept :type(s)_and_ancestors => /T1/, :methods => [m, ...]" do
347
+ @types_option = :types_and_ancestors
348
+ @type_spec = /Aquarium::AspectInvocationTestClass/
349
+ @method_spec = [:public_test_method]
350
+ do_type_spec
351
+ end
320
352
 
321
- it "should accept :type(s) => /T1/, :methods => m" do
322
- @type_spec = /Aquarium::AspectInvocationTestClass/
323
- @method_spec = :public_test_method
324
- do_type_spec
325
- end
353
+ it "should accept :type(s)_and_descendents => T1, :methods => [m, ...]" do
354
+ @types_option = :types_and_descendents
355
+ @type_spec = Aquarium::AspectInvocationTestClass
356
+ @method_spec = [:public_test_method]
357
+ do_type_spec
358
+ end
326
359
 
327
- it "should accept :type(s) => /T1/, :methods => /m/" do
328
- @type_spec = /Aquarium::AspectInvocationTestClass/
329
- @method_spec = /test_method/
330
- do_type_spec
331
- end
360
+ it "should accept :type(s)_and_descendents => [T1, ...], :methods => [m, ...]" do
361
+ @types_option = :types_and_descendents
362
+ @type_spec = [Aquarium::AspectInvocationTestClass]
363
+ @method_spec = [:public_test_method]
364
+ do_type_spec
365
+ end
332
366
 
333
- it "should accept :type(s) => ..., :methods => ..., :method_options => [:exclude_ancestor_methods] to exclude methods defined in ancestors" do
334
- @type_spec = /Aquarium::AspectInvocationTestClass/
335
- @method_spec = /test_method/
336
- @method_options = [:exclude_ancestor_methods]
337
- do_type_spec
338
- end
367
+ it "should accept :type(s)_and_descendents => /T1/, :methods => [m, ...]" do
368
+ @types_option = :types_and_descendents
369
+ @type_spec = /Aquarium::AspectInvocationTestClass/
370
+ @method_spec = [:public_test_method]
371
+ do_type_spec
372
+ end
339
373
 
340
- it "should accept :type(s) => ..., :methods => ..., :method_options => [:instance, :public] to match only instance and public (both are the defaults) methods" do
341
- @type_spec = /Aquarium::AspectInvocationTestClass/
342
- @method_spec = /test_method/
343
- @method_options = [:instance, :public]
344
- do_type_spec
345
- end
374
+ it "should accept :type(s) => ..., :methods => ..., :method_options => [:exclude_ancestor_methods] to exclude methods defined in ancestors" do
375
+ @type_spec = /Aquarium::AspectInvocationTestClass/
376
+ @method_spec = /test_method/
377
+ @method_options = [:exclude_ancestor_methods]
378
+ do_type_spec
379
+ end
346
380
 
347
- %w[public protected private].each do |protection|
348
- it "should accept :type(s) => ..., :methods => ..., :method_options => [#{protection.intern}] to match only instance (default) #{protection} methods" do
381
+ it "should accept :type(s) => ..., :methods => ..., :method_options => [:instance, :public] to match only instance and public (both are the defaults) methods" do
349
382
  @type_spec = /Aquarium::AspectInvocationTestClass/
350
383
  @method_spec = /test_method/
351
- @method_options = [protection.intern]
352
- @protection = protection
384
+ @method_options = [:instance, :public]
353
385
  do_type_spec
354
386
  end
355
- end
356
387
 
357
- it "should accept :type(s) => ..., :methods => ..., :method_options => [:class] to match only public (default) class methods" do
358
- @type_spec = /Aquarium::AspectInvocationTestClass/
359
- @method_spec = /test_method/
360
- @method_options = [:class]
361
- @are_class_methods = true
362
- do_type_spec
363
- end
388
+ %w[public protected private].each do |protection|
389
+ it "should accept :type(s) => ..., :methods => ..., :method_options => [#{protection.intern}] to match only instance (default) #{protection} methods" do
390
+ @type_spec = /Aquarium::AspectInvocationTestClass/
391
+ @method_spec = /test_method/
392
+ @method_options = [protection.intern]
393
+ @protection = protection
394
+ do_type_spec
395
+ end
396
+ end
364
397
 
365
- %w[public private].each do |protection|
366
- it "should accept :type(s) => ..., :methods => ..., :method_options => [:class, :#{protection.intern}] to match only class #{protection} methods" do
398
+ it "should accept :type(s) => ..., :methods => ..., :method_options => [:class] to match only public (default) class methods" do
367
399
  @type_spec = /Aquarium::AspectInvocationTestClass/
368
400
  @method_spec = /test_method/
369
- @method_options = [:class, protection.intern]
370
- @protection = protection
401
+ @method_options = [:class]
371
402
  @are_class_methods = true
372
403
  do_type_spec
373
404
  end
405
+
406
+ %w[public private].each do |protection|
407
+ it "should accept :type(s) => ..., :methods => ..., :method_options => [:class, :#{protection.intern}] to match only class #{protection} methods" do
408
+ @type_spec = /Aquarium::AspectInvocationTestClass/
409
+ @method_spec = /test_method/
410
+ @method_options = [:class, protection.intern]
411
+ @protection = protection
412
+ @are_class_methods = true
413
+ do_type_spec
414
+ end
415
+ end
374
416
  end
375
- end
376
417
 
377
418
 
378
- describe Aspect, ".new (with a :type(s) parameter and a :attribute(s) parameter)" do
379
- before :each do
380
- @protection = 'public'
381
- @attribute_options = []
382
- @are_class_methods = false
383
- end
419
+ describe Aspect, ".new (with a :type(s) parameter and a :attribute(s) parameter)" do
420
+ before :each do
421
+ @protection = 'public'
422
+ @attribute_options = []
423
+ @are_class_methods = false
424
+ end
384
425
 
385
- def do_type_attribute_spec
386
- aspect = nil
387
- advice_called = false
388
- aspect = Aspect.new :before, :types => @type_spec, :attributes => @attribute_spec, :attribute_options => @attribute_options do |jp, obj, *args|
389
- advice_called = true
390
- jp.should_not be_nil
391
- expected_args = make_array(@expected_args)
392
- args.should == expected_args
393
- args.size.should == expected_args.size
394
- end
395
- object = Aquarium::AspectInvocationTestClass.new
396
- @expected_args = nil
397
- object.method("#{@protection}_test_method_args".intern).call
398
- @expected_args = :a1
399
- object.method("#{@protection}_test_method_args=".intern).call @expected_args
400
- advice_called.should be_true
401
- aspect.unadvise
402
- end
426
+ def do_type_attribute_spec
427
+ aspect = nil
428
+ advice_called = false
429
+ aspect = Aspect.new :before, :types => @type_spec, :attributes => @attribute_spec, :attribute_options => @attribute_options do |jp, obj, *args|
430
+ advice_called = true
431
+ jp.should_not be_nil
432
+ expected_args = make_array(@expected_args)
433
+ args.should == expected_args
434
+ args.size.should == expected_args.size
435
+ end
436
+ object = Aquarium::AspectInvocationTestClass.new
437
+ @expected_args = nil
438
+ object.method("#{@protection}_test_method_args".intern).call
439
+ @expected_args = :a1
440
+ object.method("#{@protection}_test_method_args=".intern).call @expected_args
441
+ advice_called.should be_true
442
+ aspect.unadvise
443
+ end
403
444
 
404
- it "should accept :type(s) => [T1, ...], :attribute(s) => [a, ...]" do
405
- @type_spec = [Aquarium::AspectInvocationTestClass]
406
- @attribute_spec = [:public_test_method_args]
407
- do_type_attribute_spec
408
- end
445
+ it "should accept :type(s) => [T1, ...], :attribute(s) => [a, ...]" do
446
+ @type_spec = [Aquarium::AspectInvocationTestClass]
447
+ @attribute_spec = [:public_test_method_args]
448
+ do_type_attribute_spec
449
+ end
409
450
 
410
- it "should accept :type(s) => [T1, ...], :attribute(s) => a" do
411
- @type_spec = [Aquarium::AspectInvocationTestClass]
412
- @attribute_spec = :public_test_method_args
413
- do_type_attribute_spec
414
- end
451
+ it "should accept :type(s) => [T1, ...], :attribute(s) => a" do
452
+ @type_spec = [Aquarium::AspectInvocationTestClass]
453
+ @attribute_spec = :public_test_method_args
454
+ do_type_attribute_spec
455
+ end
415
456
 
416
- it "should accept :type(s) => [T1, ...], :attribute(s) => /a/" do
417
- @type_spec = [Aquarium::AspectInvocationTestClass]
418
- @attribute_spec = /test_method_args/
419
- do_type_attribute_spec
420
- end
457
+ it "should accept :type(s) => [T1, ...], :attribute(s) => /a/" do
458
+ @type_spec = [Aquarium::AspectInvocationTestClass]
459
+ @attribute_spec = /test_method_args/
460
+ do_type_attribute_spec
461
+ end
421
462
 
422
- it "should accept :type(s) => T1, :attribute(s) => [a]" do
423
- @type_spec = Aquarium::AspectInvocationTestClass
424
- @attribute_spec = [:public_test_method_args]
425
- do_type_attribute_spec
426
- end
463
+ it "should accept :type(s) => T1, :attribute(s) => [a]" do
464
+ @type_spec = Aquarium::AspectInvocationTestClass
465
+ @attribute_spec = [:public_test_method_args]
466
+ do_type_attribute_spec
467
+ end
427
468
 
428
- it "should accept :type(s) => T1, :attribute(s) => a" do
429
- @type_spec = Aquarium::AspectInvocationTestClass
430
- @attribute_spec = :public_test_method_args
431
- do_type_attribute_spec
432
- end
469
+ it "should accept :type(s) => T1, :attribute(s) => a" do
470
+ @type_spec = Aquarium::AspectInvocationTestClass
471
+ @attribute_spec = :public_test_method_args
472
+ do_type_attribute_spec
473
+ end
433
474
 
434
- it "should accept :type(s) => T1, :attribute(s) => /a/" do
435
- @type_spec = Aquarium::AspectInvocationTestClass
436
- @attribute_spec = /test_method_args/
437
- do_type_attribute_spec
438
- end
475
+ it "should accept :type(s) => T1, :attribute(s) => /a/" do
476
+ @type_spec = Aquarium::AspectInvocationTestClass
477
+ @attribute_spec = /test_method_args/
478
+ do_type_attribute_spec
479
+ end
439
480
 
440
- it "should accept :type(s) => /T1/, :attribute(s) => [a, ...]" do
441
- @type_spec = /Aquarium::AspectInvocationTestClass/
442
- @attribute_spec = [:public_test_method_args]
443
- do_type_attribute_spec
444
- end
481
+ it "should accept :type(s) => /T1/, :attribute(s) => [a, ...]" do
482
+ @type_spec = /Aquarium::AspectInvocationTestClass/
483
+ @attribute_spec = [:public_test_method_args]
484
+ do_type_attribute_spec
485
+ end
445
486
 
446
- it "should accept :type(s) => /T1/, :attribute(s) => a" do
447
- @type_spec = /Aquarium::AspectInvocationTestClass/
448
- @attribute_spec = :public_test_method_args
449
- do_type_attribute_spec
450
- end
487
+ it "should accept :type(s) => /T1/, :attribute(s) => a" do
488
+ @type_spec = /Aquarium::AspectInvocationTestClass/
489
+ @attribute_spec = :public_test_method_args
490
+ do_type_attribute_spec
491
+ end
451
492
 
452
- it "should accept :type(s) => /T1/, :attribute(s) => a" do
453
- @type_spec = /Aquarium::AspectInvocationTestClass/
454
- @attribute_spec = /test_method_args/
455
- do_type_attribute_spec
456
- end
493
+ it "should accept :type(s) => /T1/, :attribute(s) => a" do
494
+ @type_spec = /Aquarium::AspectInvocationTestClass/
495
+ @attribute_spec = /test_method_args/
496
+ do_type_attribute_spec
497
+ end
457
498
 
458
- it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:readers, :writers] to include both attribute reader and writer methods (default)" do
459
- @type_spec = /Aquarium::AspectInvocationTestClass/
460
- @attribute_spec = /test_method_args/
461
- @attribute_options = [:readers, :writers]
462
- do_type_attribute_spec
463
- end
499
+ it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:readers, :writers] to include both attribute reader and writer methods (default)" do
500
+ @type_spec = /Aquarium::AspectInvocationTestClass/
501
+ @attribute_spec = /test_method_args/
502
+ @attribute_options = [:readers, :writers]
503
+ do_type_attribute_spec
504
+ end
464
505
 
465
- it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:readers] to include only attribute reader methods" do
466
- @type_spec = /Aquarium::AspectInvocationTestClass/
467
- @attribute_spec = /test_method_args/
468
- @attribute_options = [:readers]
469
- do_type_attribute_spec
470
- end
506
+ it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:readers] to include only attribute reader methods" do
507
+ @type_spec = /Aquarium::AspectInvocationTestClass/
508
+ @attribute_spec = /test_method_args/
509
+ @attribute_options = [:readers]
510
+ do_type_attribute_spec
511
+ end
471
512
 
472
- it "should accept attribute option :reader as a synonym for :readers" do
473
- @type_spec = /Aquarium::AspectInvocationTestClass/
474
- @attribute_spec = /test_method_args/
475
- @attribute_options = [:reader]
476
- do_type_attribute_spec
477
- end
513
+ it "should accept attribute option :reader as a synonym for :readers" do
514
+ @type_spec = /Aquarium::AspectInvocationTestClass/
515
+ @attribute_spec = /test_method_args/
516
+ @attribute_options = [:reader]
517
+ do_type_attribute_spec
518
+ end
478
519
 
479
- it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:writers] to include only attribute writer methods" do
480
- @type_spec = /Aquarium::AspectInvocationTestClass/
481
- @attribute_spec = /test_method_args/
482
- @attribute_options = [:writers]
483
- do_type_attribute_spec
484
- end
520
+ it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:writers] to include only attribute writer methods" do
521
+ @type_spec = /Aquarium::AspectInvocationTestClass/
522
+ @attribute_spec = /test_method_args/
523
+ @attribute_options = [:writers]
524
+ do_type_attribute_spec
525
+ end
485
526
 
486
- it "should accept attribute option :writer as a synonym for :writers" do
487
- @type_spec = /Aquarium::AspectInvocationTestClass/
488
- @attribute_spec = /test_method_args/
489
- @attribute_options = [:writer]
490
- do_type_attribute_spec
491
- end
527
+ it "should accept attribute option :writer as a synonym for :writers" do
528
+ @type_spec = /Aquarium::AspectInvocationTestClass/
529
+ @attribute_spec = /test_method_args/
530
+ @attribute_options = [:writer]
531
+ do_type_attribute_spec
532
+ end
492
533
 
493
- it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:class, :readers, :writers] to include both attribute reader and writer methods (default) for class methods" do
494
- @type_spec = /Aquarium::AspectInvocationTestClass/
495
- @attribute_spec = /test_method_args/
496
- @attribute_options = [:class, :readers, :writers]
497
- do_type_attribute_spec
498
- end
534
+ it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:class, :readers, :writers] to include both attribute reader and writer methods (default) for class methods" do
535
+ @type_spec = /Aquarium::AspectInvocationTestClass/
536
+ @attribute_spec = /test_method_args/
537
+ @attribute_options = [:class, :readers, :writers]
538
+ do_type_attribute_spec
539
+ end
499
540
 
500
- it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:class, :readers] to include only attribute reader class methods" do
501
- @type_spec = /Aquarium::AspectInvocationTestClass/
502
- @attribute_spec = /test_method_args/
503
- @attribute_options = [:class, :readers]
504
- do_type_attribute_spec
505
- end
541
+ it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:class, :readers] to include only attribute reader class methods" do
542
+ @type_spec = /Aquarium::AspectInvocationTestClass/
543
+ @attribute_spec = /test_method_args/
544
+ @attribute_options = [:class, :readers]
545
+ do_type_attribute_spec
546
+ end
506
547
 
507
- it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:class, :writers] to include only attribute writer class methods" do
508
- @type_spec = /Aquarium::AspectInvocationTestClass/
509
- @attribute_spec = /test_method_args/
510
- @attribute_options = [:class, :writers]
511
- do_type_attribute_spec
548
+ it "should accept :type(s) => ..., :attributes => ..., :attribute_options => [:class, :writers] to include only attribute writer class methods" do
549
+ @type_spec = /Aquarium::AspectInvocationTestClass/
550
+ @attribute_spec = /test_method_args/
551
+ @attribute_options = [:class, :writers]
552
+ do_type_attribute_spec
553
+ end
512
554
  end
513
- end
514
555
 
515
- describe Aspect, ".new (with a :object(s) parameter and a :method(s) parameter)" do
516
- before :each do
517
- @object1 = Aquarium::AspectInvocationTestClass.new
518
- @object2 = Aquarium::AspectInvocationTestClass.new
519
- @protection = 'public'
520
- @method_options = []
521
- end
556
+ describe Aspect, ".new (with a :object(s) parameter and a :method(s) parameter)" do
557
+ before :each do
558
+ @object1 = Aquarium::AspectInvocationTestClass.new
559
+ @object2 = Aquarium::AspectInvocationTestClass.new
560
+ @protection = 'public'
561
+ @method_options = []
562
+ end
522
563
 
523
- def do_object_spec
524
- aspect = nil
525
- advice_called = false
526
- aspect = Aspect.new :before, :objects => @object_spec, :methods => @method_spec, :method_options => @method_options do |jp, obj, *args|
527
- advice_called = true
528
- jp.should_not be_nil
529
- args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
530
- end
531
- make_array(@object_spec).each do |object|
532
- object.method("#{@protection}_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
533
- end
534
- advice_called.should be_true
535
- aspect.unadvise
536
- end
537
-
538
- it "should accept :object(s) => [o1, ...], :methods => [m, ...]" do
539
- @object_spec = [@object1, @object2]
540
- @method_spec = [:public_test_method]
541
- do_object_spec
542
- end
543
-
544
- it "should accept :object(s) => [o1, ...], :methods => m" do
545
- @object_spec = [@object1, @object2]
546
- @method_spec = :public_test_method
547
- do_object_spec
548
- end
564
+ def do_object_spec
565
+ aspect = nil
566
+ advice_called = false
567
+ aspect = Aspect.new :before, :objects => @object_spec, :methods => @method_spec, :method_options => @method_options do |jp, obj, *args|
568
+ advice_called = true
569
+ jp.should_not be_nil
570
+ args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
571
+ end
572
+ make_array(@object_spec).each do |object|
573
+ object.method("#{@protection}_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
574
+ end
575
+ advice_called.should be_true
576
+ aspect.unadvise
577
+ end
549
578
 
550
- it "should accept :object(s) => [o1, ...], :methods => /m/" do
551
- @object_spec = [@object1, @object2]
552
- @method_spec = /test_method/
553
- do_object_spec
554
- end
579
+ it "should accept :object(s) => [o1, ...], :methods => [m, ...]" do
580
+ @object_spec = [@object1, @object2]
581
+ @method_spec = [:public_test_method]
582
+ do_object_spec
583
+ end
555
584
 
556
- it "should accept :object(s) => o1, :methods => [m, ...]" do
557
- @object_spec = @object1
558
- @method_spec = [:public_test_method]
559
- do_object_spec
560
- end
585
+ it "should accept :object(s) => [o1, ...], :methods => m" do
586
+ @object_spec = [@object1, @object2]
587
+ @method_spec = :public_test_method
588
+ do_object_spec
589
+ end
561
590
 
562
- it "should accept :object(s) => o1, :methods => m" do
563
- @object_spec = @object1
564
- @method_spec = :public_test_method
565
- do_object_spec
566
- end
591
+ it "should accept :object(s) => [o1, ...], :methods => /m/" do
592
+ @object_spec = [@object1, @object2]
593
+ @method_spec = /test_method/
594
+ do_object_spec
595
+ end
567
596
 
568
- it "should accept :object(s) => o1, :methods => /m/" do
569
- @object_spec = @object1
570
- @method_spec = /test_method/
571
- do_object_spec
572
- end
597
+ it "should accept :object(s) => o1, :methods => [m, ...]" do
598
+ @object_spec = @object1
599
+ @method_spec = [:public_test_method]
600
+ do_object_spec
601
+ end
573
602
 
574
- it "should accept :object(s) => ..., :methods => ..., :method_options => [:exclude_ancestor_methods] to exclude methods defined in ancestors" do
575
- @object_spec = @object1
576
- @method_spec = /test_method/
577
- @method_options = [:exclude_ancestor_methods]
578
- do_object_spec
579
- end
603
+ it "should accept :object(s) => o1, :methods => m" do
604
+ @object_spec = @object1
605
+ @method_spec = :public_test_method
606
+ do_object_spec
607
+ end
580
608
 
581
- it "should accept :object(s) => ..., :methods => ..., :method_options => [:instance, :public] to match only instance and public (both are the defaults) methods" do
582
- @object_spec = @object1
583
- @method_spec = /test_method/
584
- @method_options = [:instance, :public]
585
- do_object_spec
586
- end
609
+ it "should accept :object(s) => o1, :methods => /m/" do
610
+ @object_spec = @object1
611
+ @method_spec = /test_method/
612
+ do_object_spec
613
+ end
587
614
 
588
- %w[public protected private].each do |protection|
589
- it "should accept :object(s) => ..., :methods => ..., :method_options => [#{protection.intern}] to match only instance (default) #{protection} methods" do
615
+ it "should accept :object(s) => ..., :methods => ..., :method_options => [:exclude_ancestor_methods] to exclude methods defined in ancestors" do
590
616
  @object_spec = @object1
591
617
  @method_spec = /test_method/
592
- @method_options = [protection.intern]
593
- @protection = protection
618
+ @method_options = [:exclude_ancestor_methods]
594
619
  do_object_spec
595
620
  end
596
621
 
597
- it "should accept :object(s) => ..., :methods => ..., :method_options => [:instance, #{protection.intern}] to match only instance #{protection} methods" do
622
+ it "should accept :object(s) => ..., :methods => ..., :method_options => [:instance, :public] to match only instance and public (both are the defaults) methods" do
598
623
  @object_spec = @object1
599
624
  @method_spec = /test_method/
600
- @method_options = [:instance, protection.intern]
601
- @protection = protection
625
+ @method_options = [:instance, :public]
602
626
  do_object_spec
603
627
  end
604
- end
605
- end
606
628
 
607
- describe Aspect, ".new (with a :object(s) parameter and a :attribute(s) parameter)" do
608
- before :each do
609
- @object1 = Aquarium::AspectInvocationTestClass.new
610
- @object2 = Aquarium::AspectInvocationTestClass.new
611
- @protection = 'public'
612
- @attribute_options = []
629
+ %w[public protected private].each do |protection|
630
+ it "should accept :object(s) => ..., :methods => ..., :method_options => [#{protection.intern}] to match only instance (default) #{protection} methods" do
631
+ @object_spec = @object1
632
+ @method_spec = /test_method/
633
+ @method_options = [protection.intern]
634
+ @protection = protection
635
+ do_object_spec
636
+ end
637
+
638
+ it "should accept :object(s) => ..., :methods => ..., :method_options => [:instance, #{protection.intern}] to match only instance #{protection} methods" do
639
+ @object_spec = @object1
640
+ @method_spec = /test_method/
641
+ @method_options = [:instance, protection.intern]
642
+ @protection = protection
643
+ do_object_spec
644
+ end
645
+ end
613
646
  end
647
+
648
+ describe Aspect, ".new (with a :object(s) parameter and a :attribute(s) parameter)" do
649
+ before :each do
650
+ @object1 = Aquarium::AspectInvocationTestClass.new
651
+ @object2 = Aquarium::AspectInvocationTestClass.new
652
+ @protection = 'public'
653
+ @attribute_options = []
654
+ end
614
655
 
615
- def do_object_attribute_spec
616
- aspect = nil
617
- advice_called = false
618
- aspect = Aspect.new :before, :objects => @object_spec, :attributes => @attribute_spec, :attribute_options => @attribute_options do |jp, obj, *args|
619
- advice_called = true
620
- jp.should_not be_nil
621
- expected_args = make_array(@expected_args)
622
- args.should == expected_args
623
- args.size.should == expected_args.size
624
- end
625
- make_array(@object_spec).each do |object|
626
- @expected_args = nil
627
- object.method("#{@protection}_test_method_args".intern).call
628
- @expected_args = :a1
629
- object.method("#{@protection}_test_method_args=".intern).call @expected_args
630
- advice_called.should be_true
656
+ def do_object_attribute_spec
657
+ aspect = nil
658
+ advice_called = false
659
+ aspect = Aspect.new :before, :objects => @object_spec, :attributes => @attribute_spec, :attribute_options => @attribute_options do |jp, obj, *args|
660
+ advice_called = true
661
+ jp.should_not be_nil
662
+ expected_args = make_array(@expected_args)
663
+ args.should == expected_args
664
+ args.size.should == expected_args.size
665
+ end
666
+ make_array(@object_spec).each do |object|
667
+ @expected_args = nil
668
+ object.method("#{@protection}_test_method_args".intern).call
669
+ @expected_args = :a1
670
+ object.method("#{@protection}_test_method_args=".intern).call @expected_args
671
+ advice_called.should be_true
672
+ end
673
+ aspect.unadvise
631
674
  end
632
- aspect.unadvise
633
- end
634
675
 
635
- it "should accept :object(s) => [T1, ...], :attribute(s) => [a, ...]" do
636
- @object_spec = [@object1, @object2]
637
- @attribute_spec = [:public_test_method_args]
638
- do_object_attribute_spec
639
- end
676
+ it "should accept :object(s) => [T1, ...], :attribute(s) => [a, ...]" do
677
+ @object_spec = [@object1, @object2]
678
+ @attribute_spec = [:public_test_method_args]
679
+ do_object_attribute_spec
680
+ end
640
681
 
641
- it "should accept :object(s) => [T1, ...], :attribute(s) => a" do
642
- @object_spec = [@object1, @object2]
643
- @attribute_spec = :public_test_method_args
644
- do_object_attribute_spec
645
- end
682
+ it "should accept :object(s) => [T1, ...], :attribute(s) => a" do
683
+ @object_spec = [@object1, @object2]
684
+ @attribute_spec = :public_test_method_args
685
+ do_object_attribute_spec
686
+ end
646
687
 
647
- it "should accept :object(s) => [T1, ...], :attribute(s) => /a/" do
648
- @object_spec = [@object1, @object2]
649
- @attribute_spec = /test_method_args/
650
- do_object_attribute_spec
651
- end
688
+ it "should accept :object(s) => [T1, ...], :attribute(s) => /a/" do
689
+ @object_spec = [@object1, @object2]
690
+ @attribute_spec = /test_method_args/
691
+ do_object_attribute_spec
692
+ end
652
693
 
653
- it "should accept :object(s) => T1, :attribute(s) => [a]" do
654
- @object_spec = @object1
655
- @attribute_spec = [:public_test_method_args]
656
- do_object_attribute_spec
657
- end
694
+ it "should accept :object(s) => T1, :attribute(s) => [a]" do
695
+ @object_spec = @object1
696
+ @attribute_spec = [:public_test_method_args]
697
+ do_object_attribute_spec
698
+ end
658
699
 
659
- it "should accept :object(s) => T1, :attribute(s) => a" do
660
- @object_spec = @object1
661
- @attribute_spec = :public_test_method_args
662
- do_object_attribute_spec
663
- end
700
+ it "should accept :object(s) => T1, :attribute(s) => a" do
701
+ @object_spec = @object1
702
+ @attribute_spec = :public_test_method_args
703
+ do_object_attribute_spec
704
+ end
664
705
 
665
- it "should accept :object(s) => T1, :attribute(s) => /a/" do
666
- @object_spec = @object1
667
- @attribute_spec = /test_method_args/
668
- do_object_attribute_spec
669
- end
706
+ it "should accept :object(s) => T1, :attribute(s) => /a/" do
707
+ @object_spec = @object1
708
+ @attribute_spec = /test_method_args/
709
+ do_object_attribute_spec
710
+ end
670
711
 
671
- it "should accept :object(s) => ..., :attributes => ..., :attribute_options => [:readers, :writers] to include both attribute reader and writer methods (default)" do
672
- @object_spec = @object1
673
- @attribute_spec = /test_method_args/
674
- @attribute_options = [:readers, :writers]
675
- do_object_attribute_spec
676
- end
712
+ it "should accept :object(s) => ..., :attributes => ..., :attribute_options => [:readers, :writers] to include both attribute reader and writer methods (default)" do
713
+ @object_spec = @object1
714
+ @attribute_spec = /test_method_args/
715
+ @attribute_options = [:readers, :writers]
716
+ do_object_attribute_spec
717
+ end
677
718
 
678
- it "should accept :object(s) => ..., :attributes => ..., :attribute_options => [:readers] to include only attribute reader methods" do
679
- @object_spec = @object1
680
- @attribute_spec = /test_method_args/
681
- @attribute_options = [:readers]
682
- do_object_attribute_spec
683
- end
719
+ it "should accept :object(s) => ..., :attributes => ..., :attribute_options => [:readers] to include only attribute reader methods" do
720
+ @object_spec = @object1
721
+ @attribute_spec = /test_method_args/
722
+ @attribute_options = [:readers]
723
+ do_object_attribute_spec
724
+ end
684
725
 
685
- it "should accept attribute option :reader as a synonym for :readers" do
686
- @object_spec = @object1
687
- @attribute_spec = /test_method_args/
688
- @attribute_options = [:reader]
689
- do_object_attribute_spec
690
- end
726
+ it "should accept attribute option :reader as a synonym for :readers" do
727
+ @object_spec = @object1
728
+ @attribute_spec = /test_method_args/
729
+ @attribute_options = [:reader]
730
+ do_object_attribute_spec
731
+ end
691
732
 
692
- it "should accept :object(s) => ..., :attributes => ..., :attribute_options => [:writers] to include only attribute writer methods" do
693
- @object_spec = @object1
694
- @attribute_spec = /test_method_args/
695
- @attribute_options = [:writers]
696
- do_object_attribute_spec
697
- end
733
+ it "should accept :object(s) => ..., :attributes => ..., :attribute_options => [:writers] to include only attribute writer methods" do
734
+ @object_spec = @object1
735
+ @attribute_spec = /test_method_args/
736
+ @attribute_options = [:writers]
737
+ do_object_attribute_spec
738
+ end
698
739
 
699
- it "should accept attribute option :writer as a synonym for :writers" do
700
- @object_spec = @object1
701
- @attribute_spec = /test_method_args/
702
- @attribute_options = [:writer]
703
- do_object_attribute_spec
740
+ it "should accept attribute option :writer as a synonym for :writers" do
741
+ @object_spec = @object1
742
+ @attribute_spec = /test_method_args/
743
+ @attribute_options = [:writer]
744
+ do_object_attribute_spec
745
+ end
704
746
  end
705
- end
706
747
 
707
- describe Aspect, ".new (with a :pointcut parameter taking a hash with type specifications)" do
708
- before :each do
709
- @protection = 'public'
710
- @are_class_methods = false
711
- end
748
+ describe Aspect, ".new (with a :pointcut parameter taking a hash with type specifications)" do
749
+ before :each do
750
+ @protection = 'public'
751
+ @are_class_methods = false
752
+ end
712
753
 
713
- def do_type_pointcut_spec
714
- aspect = nil
715
- advice_called = false
716
- aspect = Aspect.new :before, :pointcut => @pointcut_hash do |jp, obj, *args|
717
- advice_called = true
718
- jp.should_not be_nil
719
- args.size.should == 4
720
- args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
721
- end
722
- if @are_class_methods
723
- Aquarium::AspectInvocationTestClass.method("#{@protection}_class_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
724
- else
725
- Aquarium::AspectInvocationTestClass.new.method("#{@protection}_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
726
- end
727
- advice_called.should be_true
728
- aspect.unadvise
729
- end
754
+ def do_type_pointcut_spec
755
+ aspect = nil
756
+ advice_called = false
757
+ aspect = Aspect.new :before, :pointcut => @pointcut_hash do |jp, obj, *args|
758
+ advice_called = true
759
+ jp.should_not be_nil
760
+ args.size.should == 4
761
+ args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
762
+ end
763
+ if @are_class_methods
764
+ Aquarium::AspectInvocationTestClass.method("#{@protection}_class_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
765
+ else
766
+ Aquarium::AspectInvocationTestClass.new.method("#{@protection}_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
767
+ end
768
+ advice_called.should be_true
769
+ aspect.unadvise
770
+ end
730
771
 
731
- it "should accept {:type(s) => [T1, ...], :methods => [m, ...]} " do
732
- @pointcut_hash = {:type => [Aquarium::AspectInvocationTestClass], :methods => [:public_test_method]}
733
- do_type_pointcut_spec
734
- end
772
+ it "should accept {:type(s) => [T1, ...], :methods => [m, ...]} " do
773
+ @pointcut_hash = {:type => [Aquarium::AspectInvocationTestClass], :methods => [:public_test_method]}
774
+ do_type_pointcut_spec
775
+ end
735
776
 
736
- it "should accept {:type(s) => [T1, ...], :methods => m} " do
737
- @pointcut_hash = {:type => [Aquarium::AspectInvocationTestClass], :methods => :public_test_method}
738
- do_type_pointcut_spec
739
- end
777
+ it "should accept {:type(s) => [T1, ...], :methods => m} " do
778
+ @pointcut_hash = {:type => [Aquarium::AspectInvocationTestClass], :methods => :public_test_method}
779
+ do_type_pointcut_spec
780
+ end
740
781
 
741
- it "should accept {:type(s) => [T1, ...], :methods => /m/} " do
742
- @pointcut_hash = {:type => [Aquarium::AspectInvocationTestClass], :methods => /test_method/}
743
- do_type_pointcut_spec
744
- end
782
+ it "should accept {:type(s) => [T1, ...], :methods => /m/} " do
783
+ @pointcut_hash = {:type => [Aquarium::AspectInvocationTestClass], :methods => /test_method/}
784
+ do_type_pointcut_spec
785
+ end
745
786
 
746
- it "should accept {:type(s)_and_ancestors => [T1, ...], :methods => /m/} " do
747
- @pointcut_hash = {:type_and_ancestors => [Aquarium::AspectInvocationTestClass], :methods => /test_method/}
748
- do_type_pointcut_spec
749
- end
787
+ it "should accept {:type(s)_and_ancestors => [T1, ...], :methods => /m/} " do
788
+ @pointcut_hash = {:type_and_ancestors => [Aquarium::AspectInvocationTestClass], :methods => /test_method/}
789
+ do_type_pointcut_spec
790
+ end
750
791
 
751
- it "should accept {:type(s)_and_descendents => [T1, ...], :methods => /m/} " do
752
- @pointcut_hash = {:type_and_descendents => [Aquarium::AspectInvocationTestClass], :methods => /test_method/}
753
- do_type_pointcut_spec
754
- end
792
+ it "should accept {:type(s)_and_descendents => [T1, ...], :methods => /m/} " do
793
+ @pointcut_hash = {:type_and_descendents => [Aquarium::AspectInvocationTestClass], :methods => /test_method/}
794
+ do_type_pointcut_spec
795
+ end
755
796
 
756
- it "should accept {:type(s) => T1, :methods => [m, ...]} " do
757
- @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => [:public_test_method]}
758
- do_type_pointcut_spec
759
- end
797
+ it "should accept {:type(s) => T1, :methods => [m, ...]} " do
798
+ @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => [:public_test_method]}
799
+ do_type_pointcut_spec
800
+ end
760
801
 
761
- it "should accept {:type(s) => T1, :methods => m} " do
762
- @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method}
763
- do_type_pointcut_spec
764
- end
802
+ it "should accept {:type(s) => T1, :methods => m} " do
803
+ @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method}
804
+ do_type_pointcut_spec
805
+ end
765
806
 
766
- it "should accept {:type(s) => T1, :methods => /m/} " do
767
- @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => /test_method/}
768
- do_type_pointcut_spec
769
- end
807
+ it "should accept {:type(s) => T1, :methods => /m/} " do
808
+ @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => /test_method/}
809
+ do_type_pointcut_spec
810
+ end
770
811
 
771
- it "should accept {:type(s)_and_ancestors => T1, :methods => /m/} " do
772
- @pointcut_hash = {:type_and_ancestors => Aquarium::AspectInvocationTestClass, :methods => /test_method/}
773
- do_type_pointcut_spec
774
- end
812
+ it "should accept {:type(s)_and_ancestors => T1, :methods => /m/} " do
813
+ @pointcut_hash = {:type_and_ancestors => Aquarium::AspectInvocationTestClass, :methods => /test_method/}
814
+ do_type_pointcut_spec
815
+ end
775
816
 
776
- it "should accept {:type(s)_and_descendents => T1, :methods => /m/} " do
777
- @pointcut_hash = {:type_and_descendents => Aquarium::AspectInvocationTestClass, :methods => /test_method/}
778
- do_type_pointcut_spec
779
- end
817
+ it "should accept {:type(s)_and_descendents => T1, :methods => /m/} " do
818
+ @pointcut_hash = {:type_and_descendents => Aquarium::AspectInvocationTestClass, :methods => /test_method/}
819
+ do_type_pointcut_spec
820
+ end
780
821
 
781
- it "should accept {:type(s) => /T1/, :methods => [m, ...]} " do
782
- @pointcut_hash = {:type => /Aquarium::AspectInvocationTestClass/, :methods => [:public_test_method]}
783
- do_type_pointcut_spec
784
- end
822
+ it "should accept {:type(s) => /T1/, :methods => [m, ...]} " do
823
+ @pointcut_hash = {:type => /Aquarium::AspectInvocationTestClass/, :methods => [:public_test_method]}
824
+ do_type_pointcut_spec
825
+ end
785
826
 
786
- it "should accept {:type(s) => /T1/, :methods => m} " do
787
- @pointcut_hash = {:type => /Aquarium::AspectInvocationTestClass/, :methods => :public_test_method}
788
- do_type_pointcut_spec
789
- end
827
+ it "should accept {:type(s) => /T1/, :methods => m} " do
828
+ @pointcut_hash = {:type => /Aquarium::AspectInvocationTestClass/, :methods => :public_test_method}
829
+ do_type_pointcut_spec
830
+ end
790
831
 
791
- it "should accept {:type(s) => /T1/, :methods => /m/} " do
792
- @pointcut_hash = {:type => /Aquarium::AspectInvocationTestClass/, :methods => /test_method/}
793
- do_type_pointcut_spec
794
- end
832
+ it "should accept {:type(s) => /T1/, :methods => /m/} " do
833
+ @pointcut_hash = {:type => /Aquarium::AspectInvocationTestClass/, :methods => /test_method/}
834
+ do_type_pointcut_spec
835
+ end
795
836
 
796
- it "should accept {:type(s)_and_ancestors => /T1/, :methods => /m/} " do
797
- @pointcut_hash = {:type_and_ancestors => /Aquarium::AspectInvocationTestClass/, :methods => /test_method/}
798
- do_type_pointcut_spec
799
- end
837
+ it "should accept {:type(s)_and_ancestors => /T1/, :methods => /m/} " do
838
+ @pointcut_hash = {:type_and_ancestors => /Aquarium::AspectInvocationTestClass/, :methods => /test_method/}
839
+ do_type_pointcut_spec
840
+ end
800
841
 
801
- it "should accept {:type(s)_and_descendents => /T1/, :methods => /m/} " do
802
- @pointcut_hash = {:type_and_descendents => /Aquarium::AspectInvocationTestClass/, :methods => /test_method/}
803
- do_type_pointcut_spec
804
- end
842
+ it "should accept {:type(s)_and_descendents => /T1/, :methods => /m/} " do
843
+ @pointcut_hash = {:type_and_descendents => /Aquarium::AspectInvocationTestClass/, :methods => /test_method/}
844
+ do_type_pointcut_spec
845
+ end
846
+
847
+ %w[public protected private].each do |protection|
848
+ it "should accept {:type(s) => T1, :methods => /m/, :method_options =>[:instance, #{protection}]} " do
849
+ @protection = protection
850
+ @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => /test_method/, :method_options =>[:instance, protection.intern]}
851
+ do_type_pointcut_spec
852
+ end
853
+ end
805
854
 
806
- %w[public protected private].each do |protection|
807
- it "should accept {:type(s) => T1, :methods => /m/, :method_options =>[:instance, #{protection}]} " do
808
- @protection = protection
809
- @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => /test_method/, :method_options =>[:instance, protection.intern]}
855
+ %w[public private].each do |protection|
856
+ it "should accept {:type(s) => T1, :methods => /m/, :method_options =>[:class, #{protection}]} " do
857
+ @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => /class_test_method/, :method_options =>[:class, protection.intern]}
858
+ @protection = protection
859
+ @are_class_methods = true
860
+ do_type_pointcut_spec
861
+ end
862
+ end
863
+
864
+ it "should accept {:type(s) => T1, :methods => /m/, :method_options =>[:instance]} defaults to public methods" do
865
+ @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => /test_method/, :method_options =>[:instance]}
810
866
  do_type_pointcut_spec
811
867
  end
812
- end
813
868
 
814
- %w[public private].each do |protection|
815
- it "should accept {:type(s) => T1, :methods => /m/, :method_options =>[:class, #{protection}]} " do
816
- @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => /class_test_method/, :method_options =>[:class, protection.intern]}
817
- @protection = protection
869
+ it "should accept {:type(s) => T1, :methods => /m/, :method_options =>[:class]} defaults to public class methods" do
870
+ @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => /test_method/, :method_options =>[:class]}
818
871
  @are_class_methods = true
819
872
  do_type_pointcut_spec
820
873
  end
821
874
  end
822
875
 
823
- it "should accept {:type(s) => T1, :methods => /m/, :method_options =>[:instance]} defaults to public methods" do
824
- @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => /test_method/, :method_options =>[:instance]}
825
- do_type_pointcut_spec
826
- end
827
-
828
- it "should accept {:type(s) => T1, :methods => /m/, :method_options =>[:class]} defaults to public class methods" do
829
- @pointcut_hash = {:type => Aquarium::AspectInvocationTestClass, :methods => /test_method/, :method_options =>[:class]}
830
- @are_class_methods = true
831
- do_type_pointcut_spec
832
- end
833
- end
834
-
835
- describe Aspect, ".new (with a :pointcut parameter taking a hash with object specifications)" do
836
- before :each do
837
- @protection = 'public'
838
- @expected_advice_count = 2
839
- @object1 = Aquarium::AspectInvocationTestClass.new
840
- @object2 = Aquarium::AspectInvocationTestClass.new
841
- end
876
+ describe Aspect, ".new (with a :pointcut parameter taking a hash with object specifications)" do
877
+ before :each do
878
+ @protection = 'public'
879
+ @expected_advice_count = 2
880
+ @object1 = Aquarium::AspectInvocationTestClass.new
881
+ @object2 = Aquarium::AspectInvocationTestClass.new
882
+ end
842
883
 
843
- def do_object_pointcut_spec
844
- aspect = nil
845
- advice_count = 0
846
- aspect = Aspect.new :before, :pointcut => @pointcut_hash do |jp, obj, *args|
847
- advice_count += 1
848
- jp.should_not be_nil
849
- args.size.should == 4
850
- args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
851
- end
852
- @object1.method("#{@protection}_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
853
- @object2.method("#{@protection}_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
854
- advice_count.should == @expected_advice_count
855
- aspect.unadvise
856
- end
884
+ def do_object_pointcut_spec
885
+ aspect = nil
886
+ advice_count = 0
887
+ aspect = Aspect.new :before, :pointcut => @pointcut_hash do |jp, obj, *args|
888
+ advice_count += 1
889
+ jp.should_not be_nil
890
+ args.size.should == 4
891
+ args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
892
+ end
893
+ @object1.method("#{@protection}_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
894
+ @object2.method("#{@protection}_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
895
+ advice_count.should == @expected_advice_count
896
+ aspect.unadvise
897
+ end
857
898
 
858
- it "should accept {:objects => [o1, ...], :methods => [m, ...]} " do
859
- @pointcut_hash = {:objects => [@object1, @object2], :methods => [:public_test_method]}
860
- do_object_pointcut_spec
861
- end
899
+ it "should accept {:objects => [o1, ...], :methods => [m, ...]} " do
900
+ @pointcut_hash = {:objects => [@object1, @object2], :methods => [:public_test_method]}
901
+ do_object_pointcut_spec
902
+ end
862
903
 
863
- it "should accept {:objects => [o1, ...], :methods => m} " do
864
- @pointcut_hash = {:objects => [@object1, @object2], :methods => :public_test_method}
865
- do_object_pointcut_spec
866
- end
904
+ it "should accept {:objects => [o1, ...], :methods => m} " do
905
+ @pointcut_hash = {:objects => [@object1, @object2], :methods => :public_test_method}
906
+ do_object_pointcut_spec
907
+ end
867
908
 
868
- it "should accept {:objects => [o1, ...], :methods => /m/} " do
869
- @pointcut_hash = {:objects => [@object1, @object2], :methods => /test_method/}
870
- do_object_pointcut_spec
871
- end
909
+ it "should accept {:objects => [o1, ...], :methods => /m/} " do
910
+ @pointcut_hash = {:objects => [@object1, @object2], :methods => /test_method/}
911
+ do_object_pointcut_spec
912
+ end
872
913
 
873
- it "should accept {:object => o1, :methods => [m, ...]} " do
874
- @expected_advice_count = 1
875
- @pointcut_hash = {:object => @object1, :methods => [:public_test_method]}
876
- do_object_pointcut_spec
877
- end
914
+ it "should accept {:object => o1, :methods => [m, ...]} " do
915
+ @expected_advice_count = 1
916
+ @pointcut_hash = {:object => @object1, :methods => [:public_test_method]}
917
+ do_object_pointcut_spec
918
+ end
878
919
 
879
- it "should accept {:objects => o1, :methods => m} " do
880
- @expected_advice_count = 1
881
- @pointcut_hash = {:objects => @object1, :methods => :public_test_method}
882
- do_object_pointcut_spec
883
- end
920
+ it "should accept {:objects => o1, :methods => m} " do
921
+ @expected_advice_count = 1
922
+ @pointcut_hash = {:objects => @object1, :methods => :public_test_method}
923
+ do_object_pointcut_spec
924
+ end
884
925
 
885
- it "should accept {:objects => o1, :methods => /m/} " do
886
- @expected_advice_count = 1
887
- @pointcut_hash = {:objects => @object1, :methods => /test_method/}
888
- do_object_pointcut_spec
926
+ it "should accept {:objects => o1, :methods => /m/} " do
927
+ @expected_advice_count = 1
928
+ @pointcut_hash = {:objects => @object1, :methods => /test_method/}
929
+ do_object_pointcut_spec
930
+ end
889
931
  end
890
- end
891
932
 
892
- describe Aspect, ".new (with a :pointcut parameter and a Pointcut object or an array of Pointcuts)" do
893
- def do_pointcut_pointcut_spec
894
- aspect = nil
895
- advice_called = false
896
- aspect = Aspect.new :before, :pointcut => @pointcuts do |jp, obj, *args|
897
- advice_called = true
898
- jp.should_not be_nil
899
- args.size.should == 4
900
- args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
901
- end
902
- Aquarium::AspectInvocationTestClass.new.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
903
- advice_called.should be_true
904
- aspect.unadvise
905
- end
933
+ describe Aspect, ".new (with a :pointcut parameter and a Pointcut object or an array of Pointcuts)" do
934
+ def do_pointcut_pointcut_spec
935
+ aspect = nil
936
+ advice_called = false
937
+ aspect = Aspect.new :before, :pointcut => @pointcuts do |jp, obj, *args|
938
+ advice_called = true
939
+ jp.should_not be_nil
940
+ args.size.should == 4
941
+ args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
942
+ end
943
+ Aquarium::AspectInvocationTestClass.new.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
944
+ advice_called.should be_true
945
+ aspect.unadvise
946
+ end
906
947
 
907
- it "should accept a single Pointcut object." do
908
- @pointcuts = Pointcut.new :type => [Aquarium::AspectInvocationTestClass], :methods => :public_test_method
909
- do_pointcut_pointcut_spec
910
- end
948
+ it "should accept a single Pointcut object." do
949
+ @pointcuts = Pointcut.new :type => [Aquarium::AspectInvocationTestClass], :methods => :public_test_method
950
+ do_pointcut_pointcut_spec
951
+ end
911
952
 
912
- it "should accept an array of Pointcut objects." do
913
- pointcut1 = Pointcut.new :type => [Aquarium::AspectInvocationTestClass], :methods => :public_test_method
914
- pointcut2 = Pointcut.new :type => [Aquarium::AspectInvocationTestClass], :methods => :public_class_test_method, :method_options => [:class]
915
- @pointcuts = [pointcut1, pointcut2]
916
- do_pointcut_pointcut_spec
953
+ it "should accept an array of Pointcut objects." do
954
+ pointcut1 = Pointcut.new :type => [Aquarium::AspectInvocationTestClass], :methods => :public_test_method
955
+ pointcut2 = Pointcut.new :type => [Aquarium::AspectInvocationTestClass], :methods => :public_class_test_method, :method_options => [:class]
956
+ @pointcuts = [pointcut1, pointcut2]
957
+ do_pointcut_pointcut_spec
958
+ end
917
959
  end
918
- end
919
960
 
920
- describe Aspect, ".new (with a :pointcut parameter and an array of Pointcuts)" do
921
- it "should treat the array as if it is one Pointcut \"or'ed\" together." do
922
- advice_called = 0
923
- advice = Proc.new {|jp, obj, *args|
924
- advice_called += 1
925
- jp.should_not be_nil
926
- args.size.should == 4
927
- args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
928
- }
929
- pointcut1 = Pointcut.new :type => [Aquarium::AspectInvocationTestClass], :methods => :public_test_method
930
- pointcut2 = Pointcut.new :type => [Aquarium::AspectInvocationTestClass], :methods => :public_class_test_method, :method_options => [:class]
931
- pointcut12 = pointcut1.or pointcut2
932
- aspect1 = Aspect.new :before, :pointcut => [pointcut1, pointcut2], :advice => advice
933
- Aquarium::AspectInvocationTestClass.new.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
934
- Aquarium::AspectInvocationTestClass.public_class_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
935
- advice_called.should == 2
936
- aspect1.unadvise
937
- advice_called = 0
938
- aspect2 = Aspect.new :before, :pointcut => pointcut12, :advice => advice
939
- Aquarium::AspectInvocationTestClass.new.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
940
- Aquarium::AspectInvocationTestClass.public_class_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
941
- advice_called.should == 2
942
- aspect2.unadvise
943
- aspect1.join_points_matched.should eql(aspect2.join_points_matched)
961
+ describe Aspect, ".new (with a :pointcut parameter and an array of Pointcuts)" do
962
+ it "should treat the array as if it is one Pointcut \"or'ed\" together." do
963
+ advice_called = 0
964
+ advice = Proc.new {|jp, obj, *args|
965
+ advice_called += 1
966
+ jp.should_not be_nil
967
+ args.size.should == 4
968
+ args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
969
+ }
970
+ pointcut1 = Pointcut.new :type => [Aquarium::AspectInvocationTestClass], :methods => :public_test_method
971
+ pointcut2 = Pointcut.new :type => [Aquarium::AspectInvocationTestClass], :methods => :public_class_test_method, :method_options => [:class]
972
+ pointcut12 = pointcut1.or pointcut2
973
+ aspect1 = Aspect.new :before, :pointcut => [pointcut1, pointcut2], :advice => advice
974
+ Aquarium::AspectInvocationTestClass.new.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
975
+ Aquarium::AspectInvocationTestClass.public_class_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
976
+ advice_called.should == 2
977
+ aspect1.unadvise
978
+ advice_called = 0
979
+ aspect2 = Aspect.new :before, :pointcut => pointcut12, :advice => advice
980
+ Aquarium::AspectInvocationTestClass.new.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
981
+ Aquarium::AspectInvocationTestClass.public_class_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
982
+ advice_called.should == 2
983
+ aspect2.unadvise
984
+ aspect1.join_points_matched.should eql(aspect2.join_points_matched)
985
+ end
944
986
  end
945
- end
946
987
 
947
- describe Aspect, ".new (with a :type(s) parameter and a :method(s) parameter or one of several equivalent :pointcut parameters)" do
948
- before :each do
949
- @advice = proc {|jp, obj, *args| "advice"}
950
- @expected_methods = [:public_test_method]
951
- end
952
- after :each do
953
- @aspect1.unadvise
954
- @aspect2.unadvise
955
- end
988
+ describe Aspect, ".new (with a :type(s) parameter and a :method(s) parameter or one of several equivalent :pointcut parameters)" do
989
+ before :each do
990
+ @advice = proc {|jp, obj, *args| "advice"}
991
+ @expected_methods = [:public_test_method]
992
+ end
993
+ after :each do
994
+ @aspect1.unadvise
995
+ @aspect2.unadvise
996
+ end
956
997
 
957
- it "should advise equivalent join points when :type => T and :method => m is used or :pointcut =>{:type => T, :method => m} is used." do
958
- @aspect1 = Aspect.new :after, :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
959
- @aspect2 = Aspect.new :after, :pointcut => {:type => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
960
- aspects_should_be_equal 1, @aspect1, @aspect2
961
- end
998
+ it "should advise equivalent join points when :type => T and :method => m is used or :pointcut =>{:type => T, :method => m} is used." do
999
+ @aspect1 = Aspect.new :after, :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
1000
+ @aspect2 = Aspect.new :after, :pointcut => {:type => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
1001
+ aspects_should_be_equal 1, @aspect1, @aspect2
1002
+ end
962
1003
 
963
- it "should advise equivalent join points when :type => T and :method => m is used or :pointcut => pointcut is used, where pointcut matches :type => T and :method => m." do
964
- @aspect1 = Aspect.new :after, :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
965
- pointcut = Aquarium::Aspects::Pointcut.new :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method
966
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
967
- aspects_should_be_equal 1, @aspect1, @aspect2
968
- end
1004
+ it "should advise equivalent join points when :type => T and :method => m is used or :pointcut => pointcut is used, where pointcut matches :type => T and :method => m." do
1005
+ @aspect1 = Aspect.new :after, :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
1006
+ pointcut = Aquarium::Aspects::Pointcut.new :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method
1007
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1008
+ aspects_should_be_equal 1, @aspect1, @aspect2
1009
+ end
969
1010
 
970
- it "should advise equivalent join points when :pointcut =>{:type => T, :method => m} is used or :pointcut => pointcut is used, where pointcut matches :type => T and :method => m." do
971
- @aspect1 = Aspect.new :after, :pointcut => {:type => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
972
- pointcut = Aquarium::Aspects::Pointcut.new :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method
973
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
974
- aspects_should_be_equal 1, @aspect1, @aspect2
975
- end
1011
+ it "should advise equivalent join points when :pointcut =>{:type => T, :method => m} is used or :pointcut => pointcut is used, where pointcut matches :type => T and :method => m." do
1012
+ @aspect1 = Aspect.new :after, :pointcut => {:type => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
1013
+ pointcut = Aquarium::Aspects::Pointcut.new :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method
1014
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1015
+ aspects_should_be_equal 1, @aspect1, @aspect2
1016
+ end
976
1017
 
977
- it "should advise an equivalent join point when :type => T and :method => m is used or :pointcut => join_point is used, where join_point matches :type => T and :method => m." do
978
- @aspect1 = Aspect.new :after, :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
979
- join_point = Aquarium::Aspects::JoinPoint.new :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method
980
- @aspect2 = Aspect.new :after, :pointcut => join_point, &@advice
981
- join_points_should_be_equal 1, @aspect1, @aspect2
982
- end
1018
+ it "should advise an equivalent join point when :type => T and :method => m is used or :pointcut => join_point is used, where join_point matches :type => T and :method => m." do
1019
+ @aspect1 = Aspect.new :after, :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
1020
+ join_point = Aquarium::Aspects::JoinPoint.new :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method
1021
+ @aspect2 = Aspect.new :after, :pointcut => join_point, &@advice
1022
+ join_points_should_be_equal 1, @aspect1, @aspect2
1023
+ end
983
1024
 
984
- it "should advise equivalent join points when :type_and_ancestors => T and :method => m is used or :pointcut =>{:type_and_ancestors => T, :method => m} is used." do
985
- @aspect1 = Aspect.new :after, :type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
986
- @aspect2 = Aspect.new :after, :pointcut => {:type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
987
- aspects_should_be_equal 1, @aspect1, @aspect2
988
- end
1025
+ it "should advise equivalent join points when :type_and_ancestors => T and :method => m is used or :pointcut =>{:type_and_ancestors => T, :method => m} is used." do
1026
+ @aspect1 = Aspect.new :after, :type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
1027
+ @aspect2 = Aspect.new :after, :pointcut => {:type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
1028
+ aspects_should_be_equal 1, @aspect1, @aspect2
1029
+ end
989
1030
 
990
- it "should advise equivalent join points when :type_and_ancestors => T and :method => m is used or :pointcut => pointcut is used, where pointcut matches :type_and_ancestors => T and :method => m." do
991
- @aspect1 = Aspect.new :after, :type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
992
- pointcut = Aquarium::Aspects::Pointcut.new :type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method
993
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
994
- aspects_should_be_equal 1, @aspect1, @aspect2
995
- end
1031
+ it "should advise equivalent join points when :type_and_ancestors => T and :method => m is used or :pointcut => pointcut is used, where pointcut matches :type_and_ancestors => T and :method => m." do
1032
+ @aspect1 = Aspect.new :after, :type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
1033
+ pointcut = Aquarium::Aspects::Pointcut.new :type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method
1034
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1035
+ aspects_should_be_equal 1, @aspect1, @aspect2
1036
+ end
996
1037
 
997
- it "should advise equivalent join points when :pointcut =>{:type_and_ancestors => T, :method => m} is used or :pointcut => pointcut is used, where pointcut matches :type_and_ancestors => T and :method => m." do
998
- @aspect1 = Aspect.new :after, :pointcut => {:type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
999
- pointcut = Aquarium::Aspects::Pointcut.new :type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method
1000
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1001
- aspects_should_be_equal 1, @aspect1, @aspect2
1002
- end
1038
+ it "should advise equivalent join points when :pointcut =>{:type_and_ancestors => T, :method => m} is used or :pointcut => pointcut is used, where pointcut matches :type_and_ancestors => T and :method => m." do
1039
+ @aspect1 = Aspect.new :after, :pointcut => {:type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
1040
+ pointcut = Aquarium::Aspects::Pointcut.new :type_and_ancestors => Aquarium::AspectInvocationTestClass, :method => :public_test_method
1041
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1042
+ aspects_should_be_equal 1, @aspect1, @aspect2
1043
+ end
1003
1044
 
1004
- it "should advise equivalent join points when :type_and_descendents => T and :method => m is used or :pointcut =>{:type_and_descendents => T, :method => m} is used." do
1005
- @aspect1 = Aspect.new :after, :type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
1006
- @aspect2 = Aspect.new :after, :pointcut => {:type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
1007
- aspects_should_be_equal 1, @aspect1, @aspect2
1008
- end
1045
+ it "should advise equivalent join points when :type_and_descendents => T and :method => m is used or :pointcut =>{:type_and_descendents => T, :method => m} is used." do
1046
+ @aspect1 = Aspect.new :after, :type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
1047
+ @aspect2 = Aspect.new :after, :pointcut => {:type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
1048
+ aspects_should_be_equal 1, @aspect1, @aspect2
1049
+ end
1009
1050
 
1010
- it "should advise equivalent join points when :type_and_descendents => T and :method => m is used or :pointcut => pointcut is used, where pointcut matches :type_and_descendents => T and :method => m." do
1011
- @aspect1 = Aspect.new :after, :type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
1012
- pointcut = Aquarium::Aspects::Pointcut.new :type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method
1013
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1014
- aspects_should_be_equal 1, @aspect1, @aspect2
1015
- end
1051
+ it "should advise equivalent join points when :type_and_descendents => T and :method => m is used or :pointcut => pointcut is used, where pointcut matches :type_and_descendents => T and :method => m." do
1052
+ @aspect1 = Aspect.new :after, :type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method, &@advice
1053
+ pointcut = Aquarium::Aspects::Pointcut.new :type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method
1054
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1055
+ aspects_should_be_equal 1, @aspect1, @aspect2
1056
+ end
1016
1057
 
1017
- it "should advise equivalent join points when :pointcut =>{:type_and_descendents => T, :method => m} is used or :pointcut => pointcut is used, where pointcut matches :type_and_descendents => T and :method => m." do
1018
- @aspect1 = Aspect.new :after, :pointcut => {:type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
1019
- pointcut = Aquarium::Aspects::Pointcut.new :type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method
1020
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1021
- aspects_should_be_equal 1, @aspect1, @aspect2
1022
- end
1023
-
1024
- end
1058
+ it "should advise equivalent join points when :pointcut =>{:type_and_descendents => T, :method => m} is used or :pointcut => pointcut is used, where pointcut matches :type_and_descendents => T and :method => m." do
1059
+ @aspect1 = Aspect.new :after, :pointcut => {:type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method}, &@advice
1060
+ pointcut = Aquarium::Aspects::Pointcut.new :type_and_descendents => Aquarium::AspectInvocationTestClass, :method => :public_test_method
1061
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1062
+ aspects_should_be_equal 1, @aspect1, @aspect2
1063
+ end
1025
1064
 
1026
- describe Aspect, ".new (with a :type(s) parameter and an :attributes(s) parameter or one of several equivalent :pointcut parameters)" do
1027
- class ClassWithAttrib1
1028
- def dummy; end
1029
- attr_accessor :state
1030
1065
  end
1066
+
1067
+ describe Aspect, ".new (with a :type(s) parameter and an :attributes(s) parameter or one of several equivalent :pointcut parameters)" do
1068
+ class ClassWithAttrib1
1069
+ def dummy; end
1070
+ attr_accessor :state
1071
+ end
1031
1072
 
1032
- before :each do
1033
- @advice = proc {|jp, obj, *args| "advice"}
1034
- @expected_methods = [:state, :state=]
1035
- end
1036
- after :each do
1037
- @aspect1.unadvise
1038
- @aspect2.unadvise
1039
- end
1073
+ before :each do
1074
+ @advice = proc {|jp, obj, *args| "advice"}
1075
+ @expected_methods = [:state, :state=]
1076
+ end
1077
+ after :each do
1078
+ @aspect1.unadvise
1079
+ @aspect2.unadvise
1080
+ end
1040
1081
 
1041
- it "should not advise any method join points except those corresponding to attribute methods." do
1042
- @aspect1 = Aspect.new :after, :type => ClassWithAttrib1, :attribute => :state, &@advice
1043
- @aspect2 = Aspect.new :after, :pointcut => {:type => ClassWithAttrib1, :attribute => :state}, &@advice
1044
- aspects_should_be_equal 2, @aspect1, @aspect2
1045
- end
1082
+ it "should not advise any method join points except those corresponding to attribute methods." do
1083
+ @aspect1 = Aspect.new :after, :type => ClassWithAttrib1, :attribute => :state, &@advice
1084
+ @aspect2 = Aspect.new :after, :pointcut => {:type => ClassWithAttrib1, :attribute => :state}, &@advice
1085
+ aspects_should_be_equal 2, @aspect1, @aspect2
1086
+ end
1046
1087
 
1047
- it "should advise equivalent join points when :type => T and :attribute => a is used or :pointcut =>{:type => T, :attribute => a} is used." do
1048
- @aspect1 = Aspect.new :after, :type => ClassWithAttrib1, :attribute => :state, &@advice
1049
- @aspect2 = Aspect.new :after, :pointcut => {:type => ClassWithAttrib1, :attribute => :state}, &@advice
1050
- aspects_should_be_equal 2, @aspect1, @aspect2
1051
- end
1088
+ it "should advise equivalent join points when :type => T and :attribute => a is used or :pointcut =>{:type => T, :attribute => a} is used." do
1089
+ @aspect1 = Aspect.new :after, :type => ClassWithAttrib1, :attribute => :state, &@advice
1090
+ @aspect2 = Aspect.new :after, :pointcut => {:type => ClassWithAttrib1, :attribute => :state}, &@advice
1091
+ aspects_should_be_equal 2, @aspect1, @aspect2
1092
+ end
1052
1093
 
1053
- it "should advise equivalent join points when :type => T and :attribute => a is used or :pointcut => pointcut is used, where pointcut matches :type => T and :attribute => a." do
1054
- @aspect1 = Aspect.new :after, :type => ClassWithAttrib1, :attribute => :state, &@advice
1055
- pointcut = Aquarium::Aspects::Pointcut.new :type => ClassWithAttrib1, :attribute => :state
1056
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1057
- aspects_should_be_equal 2, @aspect1, @aspect2
1058
- end
1094
+ it "should advise equivalent join points when :type => T and :attribute => a is used or :pointcut => pointcut is used, where pointcut matches :type => T and :attribute => a." do
1095
+ @aspect1 = Aspect.new :after, :type => ClassWithAttrib1, :attribute => :state, &@advice
1096
+ pointcut = Aquarium::Aspects::Pointcut.new :type => ClassWithAttrib1, :attribute => :state
1097
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1098
+ aspects_should_be_equal 2, @aspect1, @aspect2
1099
+ end
1059
1100
 
1060
- it "should advise equivalent join points when :pointcut =>{:type => T, :attribute => a} is used or :pointcut => pointcut is used, where pointcut matches :type => T and :attribute => a." do
1061
- @aspect1 = Aspect.new :after, :pointcut => {:type => ClassWithAttrib1, :attribute => :state}, &@advice
1062
- pointcut = Aquarium::Aspects::Pointcut.new :type => ClassWithAttrib1, :attribute => :state
1063
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1064
- aspects_should_be_equal 2, @aspect1, @aspect2
1065
- end
1101
+ it "should advise equivalent join points when :pointcut =>{:type => T, :attribute => a} is used or :pointcut => pointcut is used, where pointcut matches :type => T and :attribute => a." do
1102
+ @aspect1 = Aspect.new :after, :pointcut => {:type => ClassWithAttrib1, :attribute => :state}, &@advice
1103
+ pointcut = Aquarium::Aspects::Pointcut.new :type => ClassWithAttrib1, :attribute => :state
1104
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1105
+ aspects_should_be_equal 2, @aspect1, @aspect2
1106
+ end
1066
1107
 
1067
- it "should advise equivalent join points when :type => T and :attribute => a (the attribute's reader and writer) is used or :pointcut => [join_points] is used, where the join_points match :type => T and :method => :a and :method => :a=." do
1068
- @aspect1 = Aspect.new :after, :type => ClassWithAttrib1, :attribute => :state, &@advice
1069
- join_point1 = Aquarium::Aspects::JoinPoint.new :type => ClassWithAttrib1, :method => :state
1070
- join_point2 = Aquarium::Aspects::JoinPoint.new :type => ClassWithAttrib1, :method => :state=
1071
- @aspect2 = Aspect.new :after, :pointcut => Pointcut.new(:join_points => [join_point1, join_point2]), &@advice
1072
- join_points_should_be_equal 2, @aspect1, @aspect2
1073
- end
1108
+ it "should advise equivalent join points when :type => T and :attribute => a (the attribute's reader and writer) is used or :pointcut => [join_points] is used, where the join_points match :type => T and :method => :a and :method => :a=." do
1109
+ @aspect1 = Aspect.new :after, :type => ClassWithAttrib1, :attribute => :state, &@advice
1110
+ join_point1 = Aquarium::Aspects::JoinPoint.new :type => ClassWithAttrib1, :method => :state
1111
+ join_point2 = Aquarium::Aspects::JoinPoint.new :type => ClassWithAttrib1, :method => :state=
1112
+ @aspect2 = Aspect.new :after, :pointcut => Pointcut.new(:join_points => [join_point1, join_point2]), &@advice
1113
+ join_points_should_be_equal 2, @aspect1, @aspect2
1114
+ end
1074
1115
 
1075
- it "should advise an equivalent join point when :type => T and :method => :a= (the attribute's writer) is used or :pointcut => join_point is used, where join_point matches :type => T and :method => a=." do
1076
- @aspect1 = Aspect.new :after, :type => ClassWithAttrib1, :attribute => :state, :attribute_options => [:writer], &@advice
1077
- join_point = Aquarium::Aspects::JoinPoint.new :type => ClassWithAttrib1, :method => :state=
1078
- @aspect2 = Aspect.new :after, :pointcut => join_point, &@advice
1079
- join_points_should_be_equal 1, @aspect1, @aspect2
1116
+ it "should advise an equivalent join point when :type => T and :method => :a= (the attribute's writer) is used or :pointcut => join_point is used, where join_point matches :type => T and :method => a=." do
1117
+ @aspect1 = Aspect.new :after, :type => ClassWithAttrib1, :attribute => :state, :attribute_options => [:writer], &@advice
1118
+ join_point = Aquarium::Aspects::JoinPoint.new :type => ClassWithAttrib1, :method => :state=
1119
+ @aspect2 = Aspect.new :after, :pointcut => join_point, &@advice
1120
+ join_points_should_be_equal 1, @aspect1, @aspect2
1121
+ end
1080
1122
  end
1081
- end
1082
1123
 
1083
- describe Aspect, ".new (with a :object(s) parameter and a :method(s) parameter or one of several equivalent :pointcut parameters)" do
1084
- before :each do
1085
- @advice = proc {|jp, obj, *args| "advice"}
1086
- @expected_methods = [:public_test_method]
1087
- end
1088
- after :each do
1089
- @aspect1.unadvise
1090
- @aspect2.unadvise
1091
- end
1124
+ describe Aspect, ".new (with a :object(s) parameter and a :method(s) parameter or one of several equivalent :pointcut parameters)" do
1125
+ before :each do
1126
+ @advice = proc {|jp, obj, *args| "advice"}
1127
+ @expected_methods = [:public_test_method]
1128
+ end
1129
+ after :each do
1130
+ @aspect1.unadvise
1131
+ @aspect2.unadvise
1132
+ end
1092
1133
 
1093
- it "should advise equivalent join points when :object => o and :method => m is used or :pointcut =>{:object => o, :method => m} is used." do
1094
- object = Aquarium::AspectInvocationTestClass.new
1095
- @aspect1 = Aspect.new :after, :object => object, :method => :public_test_method, &@advice
1096
- @aspect2 = Aspect.new :after, :pointcut => {:object => object, :method => :public_test_method}, &@advice
1097
- aspects_should_be_equal 1, @aspect1, @aspect2
1098
- end
1134
+ it "should advise equivalent join points when :object => o and :method => m is used or :pointcut =>{:object => o, :method => m} is used." do
1135
+ object = Aquarium::AspectInvocationTestClass.new
1136
+ @aspect1 = Aspect.new :after, :object => object, :method => :public_test_method, &@advice
1137
+ @aspect2 = Aspect.new :after, :pointcut => {:object => object, :method => :public_test_method}, &@advice
1138
+ aspects_should_be_equal 1, @aspect1, @aspect2
1139
+ end
1099
1140
 
1100
- it "should advise equivalent join points when :object => o and :method => m is used or :pointcut => pointcut is used, where pointcut matches :object => o and :method => m." do
1101
- object = Aquarium::AspectInvocationTestClass.new
1102
- @aspect1 = Aspect.new :after, :object => object, :method => :public_test_method, &@advice
1103
- pointcut = Aquarium::Aspects::Pointcut.new :object => object, :method => :public_test_method
1104
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1105
- aspects_should_be_equal 1, @aspect1, @aspect2
1106
- end
1141
+ it "should advise equivalent join points when :object => o and :method => m is used or :pointcut => pointcut is used, where pointcut matches :object => o and :method => m." do
1142
+ object = Aquarium::AspectInvocationTestClass.new
1143
+ @aspect1 = Aspect.new :after, :object => object, :method => :public_test_method, &@advice
1144
+ pointcut = Aquarium::Aspects::Pointcut.new :object => object, :method => :public_test_method
1145
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1146
+ aspects_should_be_equal 1, @aspect1, @aspect2
1147
+ end
1107
1148
 
1108
- it "should advise equivalent join points when :pointcut =>{:object => o, :method => m} is used or :pointcut => pointcut is used, where pointcut matches :object => o and :method => m." do
1109
- object = Aquarium::AspectInvocationTestClass.new
1110
- @aspect1 = Aspect.new :after, :pointcut => {:object => object, :method => :public_test_method}, &@advice
1111
- pointcut = Aquarium::Aspects::Pointcut.new :object => object, :method => :public_test_method
1112
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1113
- aspects_should_be_equal 1, @aspect1, @aspect2
1149
+ it "should advise equivalent join points when :pointcut =>{:object => o, :method => m} is used or :pointcut => pointcut is used, where pointcut matches :object => o and :method => m." do
1150
+ object = Aquarium::AspectInvocationTestClass.new
1151
+ @aspect1 = Aspect.new :after, :pointcut => {:object => object, :method => :public_test_method}, &@advice
1152
+ pointcut = Aquarium::Aspects::Pointcut.new :object => object, :method => :public_test_method
1153
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1154
+ aspects_should_be_equal 1, @aspect1, @aspect2
1155
+ end
1114
1156
  end
1115
- end
1116
1157
 
1117
- describe Aspect, ".new (with a :object(s) parameter and an :attributes(s) parameter or one of several equivalent :pointcut parameters)" do
1118
- class ClassWithAttrib2
1119
- def initialize *args
1120
- @state = args
1158
+ describe Aspect, ".new (with a :object(s) parameter and an :attributes(s) parameter or one of several equivalent :pointcut parameters)" do
1159
+ class ClassWithAttrib2
1160
+ def initialize *args
1161
+ @state = args
1162
+ end
1163
+ def dummy; end
1164
+ attr_accessor :state
1121
1165
  end
1122
- def dummy; end
1123
- attr_accessor :state
1124
- end
1125
1166
 
1126
- before :each do
1127
- @advice = proc {|jp, obj, *args| "advice"}
1128
- @object = ClassWithAttrib2.new
1129
- @expected_methods = [:state, :state=]
1130
- end
1131
- after :each do
1132
- @aspect1.unadvise
1133
- @aspect2.unadvise
1134
- end
1167
+ before :each do
1168
+ @advice = proc {|jp, obj, *args| "advice"}
1169
+ @object = ClassWithAttrib2.new
1170
+ @expected_methods = [:state, :state=]
1171
+ end
1172
+ after :each do
1173
+ @aspect1.unadvise
1174
+ @aspect2.unadvise
1175
+ end
1135
1176
 
1136
- it "should not advise any method join points except those corresponding to attribute methods." do
1137
- @aspect1 = Aspect.new :after, :object => @object, :attribute => :state, &@advice
1138
- @aspect2 = Aspect.new :after, :pointcut => {:object => @object, :attribute => :state}, &@advice
1139
- aspects_should_be_equal 2, @aspect1, @aspect2
1140
- end
1177
+ it "should not advise any method join points except those corresponding to attribute methods." do
1178
+ @aspect1 = Aspect.new :after, :object => @object, :attribute => :state, &@advice
1179
+ @aspect2 = Aspect.new :after, :pointcut => {:object => @object, :attribute => :state}, &@advice
1180
+ aspects_should_be_equal 2, @aspect1, @aspect2
1181
+ end
1141
1182
 
1142
- it "should advise equivalent join points when :type => T and :attribute => a is used or :pointcut =>{:type => T, :attribute => a} is used." do
1143
- @aspect1 = Aspect.new :after, :object => @object, :attribute => :state, &@advice
1144
- @aspect2 = Aspect.new :after, :pointcut => {:object => @object, :attribute => :state}, &@advice
1145
- aspects_should_be_equal 2, @aspect1, @aspect2
1146
- end
1183
+ it "should advise equivalent join points when :type => T and :attribute => a is used or :pointcut =>{:type => T, :attribute => a} is used." do
1184
+ @aspect1 = Aspect.new :after, :object => @object, :attribute => :state, &@advice
1185
+ @aspect2 = Aspect.new :after, :pointcut => {:object => @object, :attribute => :state}, &@advice
1186
+ aspects_should_be_equal 2, @aspect1, @aspect2
1187
+ end
1147
1188
 
1148
- it "should advise equivalent join points when :type => T and :attribute => a is used or :pointcut => pointcut is used, where pointcut matches :type => T and :attribute => a." do
1149
- @aspect1 = Aspect.new :after, :object => @object, :attribute => :state, &@advice
1150
- pointcut = Aquarium::Aspects::Pointcut.new :object => @object, :attribute => :state
1151
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1152
- aspects_should_be_equal 2, @aspect1, @aspect2
1153
- end
1189
+ it "should advise equivalent join points when :type => T and :attribute => a is used or :pointcut => pointcut is used, where pointcut matches :type => T and :attribute => a." do
1190
+ @aspect1 = Aspect.new :after, :object => @object, :attribute => :state, &@advice
1191
+ pointcut = Aquarium::Aspects::Pointcut.new :object => @object, :attribute => :state
1192
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1193
+ aspects_should_be_equal 2, @aspect1, @aspect2
1194
+ end
1154
1195
 
1155
- it "should advise equivalent join points when :pointcut =>{:type => T, :attribute => a} is used or :pointcut => pointcut is used, where pointcut matches :type => T and :attribute => a." do
1156
- @aspect1 = Aspect.new :after, :pointcut => {:object => @object, :attribute => :state}, &@advice
1157
- pointcut = Aquarium::Aspects::Pointcut.new :object => @object, :attribute => :state
1158
- @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1159
- aspects_should_be_equal 2, @aspect1, @aspect2
1160
- end
1196
+ it "should advise equivalent join points when :pointcut =>{:type => T, :attribute => a} is used or :pointcut => pointcut is used, where pointcut matches :type => T and :attribute => a." do
1197
+ @aspect1 = Aspect.new :after, :pointcut => {:object => @object, :attribute => :state}, &@advice
1198
+ pointcut = Aquarium::Aspects::Pointcut.new :object => @object, :attribute => :state
1199
+ @aspect2 = Aspect.new :after, :pointcut => pointcut, &@advice
1200
+ aspects_should_be_equal 2, @aspect1, @aspect2
1201
+ end
1161
1202
 
1162
- it "should advise equivalent join points when :type => T and :attribute => a (the attribute's reader and writer) is used or :pointcut => [join_points] is used, where the join_points match :type => T and :method => :a and :method => :a=." do
1163
- @aspect1 = Aspect.new :after, :object => @object, :attribute => :state, &@advice
1164
- join_point1 = Aquarium::Aspects::JoinPoint.new :object => @object, :method => :state
1165
- join_point2 = Aquarium::Aspects::JoinPoint.new :object => @object, :method => :state=
1166
- @aspect2 = Aspect.new :after, :pointcut => Pointcut.new(:join_points => [join_point1, join_point2]), &@advice
1167
- join_points_should_be_equal 2, @aspect1, @aspect2
1168
- end
1203
+ it "should advise equivalent join points when :type => T and :attribute => a (the attribute's reader and writer) is used or :pointcut => [join_points] is used, where the join_points match :type => T and :method => :a and :method => :a=." do
1204
+ @aspect1 = Aspect.new :after, :object => @object, :attribute => :state, &@advice
1205
+ join_point1 = Aquarium::Aspects::JoinPoint.new :object => @object, :method => :state
1206
+ join_point2 = Aquarium::Aspects::JoinPoint.new :object => @object, :method => :state=
1207
+ @aspect2 = Aspect.new :after, :pointcut => Pointcut.new(:join_points => [join_point1, join_point2]), &@advice
1208
+ join_points_should_be_equal 2, @aspect1, @aspect2
1209
+ end
1169
1210
 
1170
- it "should advise an equivalent join point when :type => T and :method => :a= (the attribute's writer) is used or :pointcut => join_point is used, where join_point matches :type => T and :method => a=." do
1171
- @aspect1 = Aspect.new :after, :object => @object, :attribute => :state, :attribute_options => [:writer], &@advice
1172
- join_point = Aquarium::Aspects::JoinPoint.new :object => @object, :method => :state=
1173
- @aspect2 = Aspect.new :after, :pointcut => join_point, &@advice
1174
- join_points_should_be_equal 1, @aspect1, @aspect2
1211
+ it "should advise an equivalent join point when :type => T and :method => :a= (the attribute's writer) is used or :pointcut => join_point is used, where join_point matches :type => T and :method => a=." do
1212
+ @aspect1 = Aspect.new :after, :object => @object, :attribute => :state, :attribute_options => [:writer], &@advice
1213
+ join_point = Aquarium::Aspects::JoinPoint.new :object => @object, :method => :state=
1214
+ @aspect2 = Aspect.new :after, :pointcut => join_point, &@advice
1215
+ join_points_should_be_equal 1, @aspect1, @aspect2
1216
+ end
1175
1217
  end
1176
- end
1177
1218
 
1178
- describe Aspect, ".new (block for advice)" do
1179
- it "should accept a block as the advice to use." do
1180
- object = Aquarium::AspectInvocationTestClass.new
1181
- advice_called = false
1182
- aspect = Aspect.new :before, :object => object, :methods => :public_test_method do |jp, obj, *args|
1183
- advice_called = true
1184
- jp.should_not be_nil
1185
- args.size.should == 4
1186
- args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
1187
- end
1188
- object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1189
- advice_called.should be_true
1190
- aspect.unadvise
1191
- end
1219
+ describe Aspect, ".new (block for advice)" do
1220
+ it "should accept a block as the advice to use." do
1221
+ object = Aquarium::AspectInvocationTestClass.new
1222
+ advice_called = false
1223
+ aspect = Aspect.new :before, :object => object, :methods => :public_test_method do |jp, obj, *args|
1224
+ advice_called = true
1225
+ jp.should_not be_nil
1226
+ args.size.should == 4
1227
+ args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
1228
+ end
1229
+ object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1230
+ advice_called.should be_true
1231
+ aspect.unadvise
1232
+ end
1192
1233
 
1193
- it "should accept an :advice => Proc parameter indicating the advice to use." do
1194
- object = Aquarium::AspectInvocationTestClass.new
1195
- advice_called = false
1196
- advice = Proc.new {|jp, obj, *args|
1197
- advice_called = true
1198
- jp.should_not be_nil
1199
- args.size.should == 4
1200
- args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
1201
- }
1202
- aspect = Aspect.new :before, :object => object, :methods => :public_test_method, :advice => advice
1203
- object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1204
- advice_called.should be_true
1205
- aspect.unadvise
1206
- end
1207
-
1208
- Aspect::CANONICAL_OPTIONS["advice"].each do |key|
1209
- it "should accept :#{key} => proc as a synonym for :advice." do
1234
+ it "should accept an :advice => Proc parameter indicating the advice to use." do
1210
1235
  object = Aquarium::AspectInvocationTestClass.new
1211
1236
  advice_called = false
1212
1237
  advice = Proc.new {|jp, obj, *args|
@@ -1215,612 +1240,653 @@ describe Aspect, ".new (block for advice)" do
1215
1240
  args.size.should == 4
1216
1241
  args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
1217
1242
  }
1218
- aspect = Aspect.new :before, :object => object, :methods => :public_test_method, key.intern => advice
1243
+ aspect = Aspect.new :before, :object => object, :methods => :public_test_method, :advice => advice
1219
1244
  object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1220
1245
  advice_called.should be_true
1221
1246
  aspect.unadvise
1222
1247
  end
1223
- end
1224
1248
 
1225
- it "should allow only one :advice object to be specified (including synonyms)." do
1226
- object = Aquarium::AspectInvocationTestClass.new
1227
- advice_called = false
1228
- advice1 = Proc.new {|jp, obj, *args| fail "advice1"}
1229
- advice2 = Proc.new {|jp, obj, *args| fail "advice2"}
1230
- lambda {Aspect.new :before, :object => object, :methods => :public_test_method, :advice => advice1, :invoke => advice2}.should raise_error(Aquarium::Utils::InvalidOptions)
1231
- end
1232
-
1233
- it "should allow ignore an :advice option if a block is given." do
1234
- object = Aquarium::AspectInvocationTestClass.new
1235
- advice_called = false
1236
- advice1 = Proc.new {|jp, obj, *args| fail "advice1"}
1237
- advice2 = Proc.new {|jp, obj, *args| fail "advice2"}
1238
- aspect = Aspect.new :before, :object => object, :methods => :public_test_method, :advice => advice1 do |jp, obj, *args|
1239
- advice_called = true
1240
- end
1241
- object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1242
- advice_called.should be_true
1243
- aspect.unadvise
1244
- end
1249
+ Aspect::CANONICAL_OPTIONS["advice"].each do |key|
1250
+ it "should accept :#{key} => proc as a synonym for :advice." do
1251
+ object = Aquarium::AspectInvocationTestClass.new
1252
+ advice_called = false
1253
+ advice = Proc.new {|jp, obj, *args|
1254
+ advice_called = true
1255
+ jp.should_not be_nil
1256
+ args.size.should == 4
1257
+ args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
1258
+ }
1259
+ aspect = Aspect.new :before, :object => object, :methods => :public_test_method, key.intern => advice
1260
+ object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1261
+ advice_called.should be_true
1262
+ aspect.unadvise
1263
+ end
1264
+ end
1265
+
1266
+ it "should allow only one :advice object to be specified (including synonyms)." do
1267
+ object = Aquarium::AspectInvocationTestClass.new
1268
+ advice_called = false
1269
+ advice1 = Proc.new {|jp, obj, *args| fail "advice1"}
1270
+ advice2 = Proc.new {|jp, obj, *args| fail "advice2"}
1271
+ lambda {Aspect.new :before, :object => object, :methods => :public_test_method, :advice => advice1, :invoke => advice2}.should raise_error(Aquarium::Utils::InvalidOptions)
1272
+ end
1245
1273
 
1246
- end
1274
+ it "should allow ignore an :advice option if a block is given." do
1275
+ object = Aquarium::AspectInvocationTestClass.new
1276
+ advice_called = false
1277
+ advice1 = Proc.new {|jp, obj, *args| fail "advice1"}
1278
+ advice2 = Proc.new {|jp, obj, *args| fail "advice2"}
1279
+ aspect = Aspect.new :before, :object => object, :methods => :public_test_method, :advice => advice1 do |jp, obj, *args|
1280
+ advice_called = true
1281
+ end
1282
+ object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1283
+ advice_called.should be_true
1284
+ aspect.unadvise
1285
+ end
1247
1286
 
1248
- describe Aspect, ".new (advice block or proc parameter list)" do
1249
- it "should raise unless an advice block or :advice => advice parameter is specified." do
1250
- lambda {Aspect.new(:after, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method)}.should raise_error(Aquarium::Utils::InvalidOptions)
1251
1287
  end
1252
1288
 
1253
- it "should raise if obsolete |jp, *args| list is used." do
1254
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method do |jp, *args|; end }.should raise_error(Aquarium::Utils::InvalidOptions)
1255
- end
1289
+ describe Aspect, ".new (advice block or proc parameter list)" do
1290
+ it "should raise unless an advice block or :advice => advice parameter is specified." do
1291
+ lambda {Aspect.new(:after, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method)}.should raise_error(Aquarium::Utils::InvalidOptions)
1292
+ end
1256
1293
 
1257
- it "should accept an argument list matching |jp, object, *args|." do
1258
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp, object, *args|; end }.should_not raise_error(Exception)
1259
- end
1294
+ it "should raise if obsolete |jp, *args| list is used." do
1295
+ lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method do |jp, *args|; end }.should raise_error(Aquarium::Utils::InvalidOptions)
1296
+ end
1260
1297
 
1261
- it "should accept an argument list matching |jp, object|." do
1262
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp, object|; end }.should_not raise_error(Exception)
1263
- end
1298
+ it "should accept an argument list matching |jp, object, *args|." do
1299
+ lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp, object, *args|; end }.should_not raise_error(Exception)
1300
+ end
1264
1301
 
1265
- it "should accept an argument list matching |jp|." do
1266
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp|; end }.should_not raise_error(Exception)
1267
- end
1302
+ it "should accept an argument list matching |jp, object|." do
1303
+ lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp, object|; end }.should_not raise_error(Exception)
1304
+ end
1268
1305
 
1269
- it "should accept an argument list matching ||." do
1270
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do ||; end }.should_not raise_error(Exception)
1271
- end
1306
+ it "should accept an argument list matching |jp|." do
1307
+ lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do |jp|; end }.should_not raise_error(Exception)
1308
+ end
1309
+
1310
+ it "should accept an argument list matching ||." do
1311
+ lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do ||; end }.should_not raise_error(Exception)
1312
+ end
1272
1313
 
1273
- it "should accept no argument list." do
1274
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do; end }.should_not raise_error(Exception)
1314
+ it "should accept no argument list." do
1315
+ lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method, :noop => true do; end }.should_not raise_error(Exception)
1316
+ end
1275
1317
  end
1276
- end
1277
1318
 
1278
1319
 
1279
- class ExcludeBase
1280
- def doit; end
1281
- def initialize arg; @value = arg; end
1282
- attr_accessor :value
1283
- def inspect; "(#{self.class}: #{@value})"; end
1284
- def eql? other
1285
- return false unless other.kind_of?(self.class)
1286
- @value == other.value
1287
- end
1288
- alias_method :==, :eql?
1289
- end
1290
- class DontExclude1 < ExcludeBase; end
1291
- class DontExclude2 < ExcludeBase; end
1292
- class Exclude1 < ExcludeBase; end
1293
- class Exclude2 < ExcludeBase; end
1294
-
1295
- class Exclude1b < Exclude1
1296
- def initialize arg; super(arg); end
1297
- def doit2; end
1298
- end
1299
- class Exclude1c < Exclude1
1300
- def initialize arg; super(arg); end
1301
- def doit3; end
1302
- end
1303
-
1304
- describe Aspect, ".new (with a :type(s) parameter and an :exclude_type(s), and :exclude_type(s)_and_ancestors, or an :exclude_type(s)_and_descendents parameter)" do
1305
- def do_exclude_types exclude_type_sym
1306
- included_types = [DontExclude1, DontExclude2]
1307
- excluded_types = [Exclude1, Exclude2]
1308
- aspect = nil
1309
- advice_called = false
1310
- aspect = Aspect.new :before, :types => (included_types + excluded_types), exclude_type_sym => excluded_types, :methods => :doit do |jp, obj, *args|
1311
- advice_called = true
1312
- excluded_types.should_not include(jp.target_type)
1313
- end
1314
- included_types.each do |type|
1315
- advice_called = false
1316
- type.new(1).doit
1317
- advice_called.should be_true
1320
+ class ExcludeBase
1321
+ def doit; end
1322
+ def initialize arg; @value = arg; end
1323
+ attr_accessor :value
1324
+ def inspect; "(#{self.class}: #{@value})"; end
1325
+ def eql? other
1326
+ return false unless other.kind_of?(self.class)
1327
+ @value == other.value
1328
+ end
1329
+ alias_method :==, :eql?
1330
+ end
1331
+ class DontExclude1 < ExcludeBase; end
1332
+ class DontExclude2 < ExcludeBase; end
1333
+ class Exclude1 < ExcludeBase; end
1334
+ class Exclude2 < ExcludeBase; end
1335
+
1336
+ class Exclude1b < Exclude1
1337
+ def initialize arg; super(arg); end
1338
+ def doit2; end
1339
+ end
1340
+ class Exclude1c < Exclude1
1341
+ def initialize arg; super(arg); end
1342
+ def doit3; end
1343
+ end
1344
+
1345
+ describe Aspect, ".new (with a :type(s) parameter and an :exclude_type(s), and :exclude_type(s)_and_ancestors, or an :exclude_type(s)_and_descendents parameter)" do
1346
+ before :all do
1347
+ @included_types = [DontExclude1, DontExclude2]
1348
+ @excluded_types = [Exclude1, Exclude2]
1349
+ @all_types = @included_types + @excluded_types
1318
1350
  end
1319
- excluded_types.each do |type|
1351
+
1352
+ def do_exclude_types exclude_type_sym
1353
+ aspect = nil
1320
1354
  advice_called = false
1321
- type.new(1).doit
1322
- advice_called.should_not be_true
1355
+ aspect = Aspect.new :before, :types => @all_types, exclude_type_sym => @excluded_types, :methods => :doit do |jp, obj, *args|
1356
+ advice_called = true
1357
+ @excluded_types.should_not include(jp.target_type)
1358
+ end
1359
+ @included_types.each do |type|
1360
+ advice_called = false
1361
+ type.new(1).doit
1362
+ advice_called.should be_true
1363
+ end
1364
+ @excluded_types.each do |type|
1365
+ advice_called = false
1366
+ type.new(1).doit
1367
+ advice_called.should_not be_true
1368
+ end
1369
+ aspect.unadvise
1323
1370
  end
1324
- aspect.unadvise
1325
- end
1326
1371
 
1327
- it "should accept :type(s) => [T1, ...], :exclude_types => [T2, ...] and exclude join points in the excluded types" do
1328
- do_exclude_types :exclude_types
1329
- end
1372
+ it "should accept :type(s) => [T1, ...], :exclude_types => [T2, ...] and exclude join points in the excluded types" do
1373
+ do_exclude_types :exclude_types
1374
+ end
1330
1375
 
1331
- Aspect::CANONICAL_OPTIONS["exclude_types"].each do |key|
1332
- it "should accept :#{key} as a synonym for :exclude_types." do
1333
- do_exclude_types key.intern
1376
+ Aspect::CANONICAL_OPTIONS["exclude_types"].each do |key|
1377
+ it "should accept :#{key} as a synonym for :exclude_types." do
1378
+ lambda { Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end }.should_not raise_error
1379
+ end
1334
1380
  end
1335
- end
1336
1381
 
1337
- it "should accept :type(s) => [T1, ...], :exclude_types_and_ancestors => [T2, ...] and exclude join points in the excluded types" do
1338
- do_exclude_types :exclude_types_and_ancestors
1339
- end
1382
+ it "should accept :type(s) => [T1, ...], :exclude_types_and_ancestors => [T2, ...] and exclude join points in the excluded types" do
1383
+ do_exclude_types :exclude_types_and_ancestors
1384
+ end
1340
1385
 
1341
- Aspect::CANONICAL_OPTIONS["exclude_types_and_ancestors"].each do |key|
1342
- it "should accept :#{key} as a synonym for :exclude_types_and_ancestors." do
1343
- do_exclude_types key.intern
1386
+ Aspect::CANONICAL_OPTIONS["exclude_types_and_ancestors"].each do |key|
1387
+ it "should accept :#{key} as a synonym for :exclude_types_and_ancestors." do
1388
+ lambda { Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end }.should_not raise_error
1389
+ end
1344
1390
  end
1345
- end
1346
1391
 
1347
- it "should accept :type(s) => [T1, ...], :exclude_types_and_descendents => [T2, ...] and exclude join points in the excluded types" do
1348
- do_exclude_types :exclude_types_and_descendents
1349
- end
1392
+ it "should accept :type(s) => [T1, ...], :exclude_types_and_descendents => [T2, ...] and exclude join points in the excluded types" do
1393
+ do_exclude_types :exclude_types_and_descendents
1394
+ end
1350
1395
 
1351
- Aspect::CANONICAL_OPTIONS["exclude_types_and_descendents"].each do |key|
1352
- it "should accept :#{key} as a synonym for :exclude_types_and_descendents." do
1353
- do_exclude_types key.intern
1396
+ Aspect::CANONICAL_OPTIONS["exclude_types_and_descendents"].each do |key|
1397
+ it "should accept :#{key} as a synonym for :exclude_types_and_descendents." do
1398
+ lambda { Aspect.new :before, :types => @all_types, key.intern => @excluded_types, :methods => :doit, :noop => true do; end }.should_not raise_error
1399
+ end
1354
1400
  end
1355
- end
1356
1401
 
1357
- end
1402
+ end
1358
1403
 
1359
1404
 
1360
- describe Aspect, ".new (with a :object(s) parameter and an :exclude_object(s) parameter)" do
1361
- def do_exclude_objects exclude_object_sym
1362
- dontExclude1 = DontExclude1.new(1)
1363
- dontExclude2 = DontExclude1.new(2)
1364
- exclude1 = DontExclude1.new(3)
1365
- exclude2 = DontExclude1.new(4)
1366
- included_objects = [dontExclude1, dontExclude2]
1367
- excluded_objects = [exclude1, exclude2]
1368
- aspect = nil
1369
- advice_called = false
1370
- aspect = Aspect.new :before, :objects => (included_objects + excluded_objects), exclude_object_sym => excluded_objects, :methods => :doit do |jp, obj, *args|
1371
- advice_called = true
1372
- excluded_objects.should_not include(obj)
1373
- end
1374
- included_objects.each do |object|
1375
- advice_called = false
1376
- object.doit
1377
- advice_called.should be_true
1405
+ describe Aspect, ".new (with a :object(s) parameter and an :exclude_object(s) parameter)" do
1406
+ before :all do
1407
+ dontExclude1 = DontExclude1.new(1)
1408
+ dontExclude2 = DontExclude1.new(2)
1409
+ exclude1 = DontExclude1.new(3)
1410
+ exclude2 = DontExclude1.new(4)
1411
+ @included_objects = [dontExclude1, dontExclude2]
1412
+ @excluded_objects = [exclude1, exclude2]
1413
+ @all_objects = @included_objects + @excluded_objects
1378
1414
  end
1379
- excluded_objects.each do |object|
1415
+
1416
+ it "should accept :object(s) => [o1, ...], :exclude_object(s) => [o2, ...] and exclude join points in the excluded objects" do
1417
+ aspect = nil
1380
1418
  advice_called = false
1381
- object.doit
1382
- advice_called.should_not be_true
1419
+ aspect = Aspect.new :before, :objects => @all_objects, :exclude_objects => @excluded_objects, :methods => :doit do |jp, obj, *args|
1420
+ advice_called = true
1421
+ @excluded_objects.should_not include(obj)
1422
+ end
1423
+ @included_objects.each do |object|
1424
+ advice_called = false
1425
+ object.doit
1426
+ advice_called.should be_true
1427
+ end
1428
+ @excluded_objects.each do |object|
1429
+ advice_called = false
1430
+ object.doit
1431
+ advice_called.should_not be_true
1432
+ end
1433
+ aspect.unadvise
1383
1434
  end
1384
- aspect.unadvise
1385
- end
1386
-
1387
- it "should accept :object(s) => [o1, ...], :exclude_object(s) => [o2, ...] and exclude join points in the excluded objects" do
1388
- do_exclude_objects :exclude_objects
1389
- end
1390
1435
 
1391
- Aspect::CANONICAL_OPTIONS["exclude_objects"].each do |key|
1392
- it "should accept :#{key} as a synonym for :exclude_objects." do
1393
- do_exclude_objects key.intern
1436
+ Aspect::CANONICAL_OPTIONS["exclude_objects"].each do |key|
1437
+ it "should accept :#{key} as a synonym for :exclude_objects." do
1438
+ lambda { Aspect.new :before, :objects => @all_objects, key.intern => @excluded_objects, :methods => :doit, :noop => true do; end }.should_not raise_error
1439
+ end
1394
1440
  end
1395
1441
  end
1396
- end
1397
1442
 
1398
1443
 
1399
- describe Aspect, ".new (with a :pointcut(s), :type(s), :type(s)_with_ancestors, :type(s)_with_descendents, :object(s), and :method(s) parameter and an :exclude_join_point(s) parameter)" do
1400
- def do_exclude_join_points exclude_join_points_sym
1401
- dontExclude1 = DontExclude1.new(1)
1402
- dontExclude2 = DontExclude1.new(2)
1403
- exclude1 = DontExclude1.new(3)
1404
- exclude2 = DontExclude1.new(4)
1405
- included_objects = [dontExclude1, dontExclude2]
1406
- excluded_objects = [exclude1, exclude2]
1407
- excluded_join_point1 = JoinPoint.new :object => exclude1, :method => :doit
1408
- excluded_join_point2 = JoinPoint.new :object => exclude2, :method => :doit
1409
- excluded_join_points = [excluded_join_point1, excluded_join_point2]
1410
- aspect = nil
1411
- advice_called = false
1412
- aspect = Aspect.new :before, :objects => (included_objects + excluded_objects), exclude_join_points_sym => excluded_join_points, :methods => :doit do |jp, obj, *args|
1413
- advice_called = true
1414
- excluded_objects.should_not include(obj)
1415
- end
1416
-
1417
- included_objects.each do |object|
1418
- advice_called = false
1419
- object.doit
1420
- advice_called.should be_true
1444
+ describe Aspect, ".new (with an :object(s) and an :exclude_join_point(s) parameter)" do
1445
+ before :all do
1446
+ dontExclude1 = DontExclude1.new(1)
1447
+ dontExclude2 = DontExclude1.new(2)
1448
+ exclude1 = DontExclude1.new(3)
1449
+ exclude2 = DontExclude1.new(4)
1450
+ @included_objects = [dontExclude1, dontExclude2]
1451
+ @excluded_objects = [exclude1, exclude2]
1452
+ @all_objects = @included_objects + @excluded_objects
1453
+ excluded_join_point1 = JoinPoint.new :object => exclude1, :method => :doit
1454
+ excluded_join_point2 = JoinPoint.new :object => exclude2, :method => :doit
1455
+ @excluded_join_points = [excluded_join_point1, excluded_join_point2]
1421
1456
  end
1422
- excluded_objects.each do |object|
1457
+
1458
+ it "should accept :type(s) => [T1, ...], :exclude_join_point(s) => [jps], where [jps] are the list of join points for the types and methods to exclude" do
1459
+ aspect = nil
1423
1460
  advice_called = false
1424
- object.doit
1425
- advice_called.should_not be_true
1461
+ aspect = Aspect.new :before, :objects => @all_objects, :exclude_join_points => @excluded_join_points, :methods => :doit do |jp, obj, *args|
1462
+ advice_called = true
1463
+ @excluded_objects.should_not include(obj)
1464
+ end
1465
+
1466
+ @included_objects.each do |object|
1467
+ advice_called = false
1468
+ object.doit
1469
+ advice_called.should be_true
1470
+ end
1471
+ @excluded_objects.each do |object|
1472
+ advice_called = false
1473
+ object.doit
1474
+ advice_called.should_not be_true
1475
+ end
1476
+ aspect.unadvise
1426
1477
  end
1427
- aspect.unadvise
1428
- end
1429
1478
 
1430
- Aspect::CANONICAL_OPTIONS["exclude_join_points"].each do |key|
1431
- it "should accept :#{key} as a synonym for :exclude_join_points." do
1432
- do_exclude_join_points key.intern
1479
+ Aspect::CANONICAL_OPTIONS["exclude_join_points"].each do |key|
1480
+ it "should accept :#{key} as a synonym for :exclude_join_points." do
1481
+ lambda { Aspect.new :before, :objects => @all_objects, key.intern => @excluded_join_points, :methods => :doit, :noop => true do; end }.should_not raise_error
1482
+ end
1483
+ end
1484
+ end
1485
+
1486
+ describe Aspect, ".new (with a :type(s) parameter and an :exclude_join_point(s) parameter)" do
1487
+ it "should accept :type(s) => [T1, ...], :exclude_join_point(s) => [jps], where [jps] are the list of join points for the types and methods to exclude" do
1488
+ included_types = [DontExclude1, DontExclude2]
1489
+ excluded_types = [Exclude1, Exclude2]
1490
+ excluded_join_point1 = JoinPoint.new :type => Exclude1, :method => :doit
1491
+ excluded_join_point2 = JoinPoint.new :type => Exclude2, :method => :doit
1492
+ excluded_join_points = [excluded_join_point1, excluded_join_point2]
1493
+ aspect = nil
1494
+ advice_called = false
1495
+ aspect = Aspect.new :before, :types => (included_types + excluded_types), :exclude_join_points => excluded_join_points, :methods => :doit do |jp, obj, *args|
1496
+ advice_called = true
1497
+ excluded_types.should_not include(jp.target_type)
1498
+ end
1499
+
1500
+ included_types.each do |type|
1501
+ advice_called = false
1502
+ type.new(1).doit
1503
+ advice_called.should be_true
1504
+ end
1505
+ excluded_types.each do |type|
1506
+ advice_called = false
1507
+ type.new(1).doit
1508
+ advice_called.should_not be_true
1509
+ end
1510
+ aspect.unadvise
1433
1511
  end
1434
1512
  end
1435
1513
 
1436
- it "should accept :object(s) => [o1, ...], :exclude_join_point(s) => [jps], where [jps] are the list of join points for the objects and methods to exclude" do
1437
- do_exclude_join_points :exclude_join_points
1438
- end
1439
-
1440
- it "should accept :type(s) => [T1, ...], :exclude_join_point(s) => [jps], where [jps] are the list of join points for the types and methods to exclude" do
1441
- included_types = [DontExclude1, DontExclude2]
1442
- excluded_types = [Exclude1, Exclude2]
1443
- excluded_join_point1 = JoinPoint.new :type => Exclude1, :method => :doit
1444
- excluded_join_point2 = JoinPoint.new :type => Exclude2, :method => :doit
1445
- excluded_join_points = [excluded_join_point1, excluded_join_point2]
1446
- aspect = nil
1447
- advice_called = false
1448
- aspect = Aspect.new :before, :types => (included_types + excluded_types), :exclude_join_points => excluded_join_points, :methods => :doit do |jp, obj, *args|
1449
- advice_called = true
1450
- excluded_types.should_not include(jp.target_type)
1451
- end
1452
-
1453
- included_types.each do |type|
1514
+ describe Aspect, ".new (with a :type(s)_and_ancestors parameter and an :exclude_join_point(s) parameter)" do
1515
+ it "should accept :type(s)_and_ancestors => [T1, ...], :exclude_join_point(s) => [jps], where [jps] are the list of join points for the types and methods to exclude" do
1516
+ included_types = [ClassWithPublicInstanceMethod, ModuleWithPublicInstanceMethod]
1517
+ excluded_join_point1 = JoinPoint.new :type => ClassWithPublicInstanceMethod, :method => :public_instance_test_method
1518
+ excluded_join_point2 = JoinPoint.new :type => ModuleWithPublicInstanceMethod, :method => :public_instance_module_test_method
1519
+ excluded_join_points = [excluded_join_point1, excluded_join_point2]
1520
+ aspect = nil
1454
1521
  advice_called = false
1455
- type.new(1).doit
1456
- advice_called.should be_true
1457
- end
1458
- excluded_types.each do |type|
1522
+ aspect = Aspect.new :before, :types_and_ancestors => included_types, :methods => :doit,
1523
+ :exclude_join_points => excluded_join_points, :ignore_no_matching_join_points => true do |jp, obj, *args|; advice_called = true; end
1524
+
1459
1525
  advice_called = false
1460
- type.new(1).doit
1461
- advice_called.should_not be_true
1526
+ ClassWithPublicInstanceMethod.new.public_instance_test_method
1527
+ advice_called.should be_false
1528
+ advice_called = false
1529
+ ClassIncludingModuleWithPublicInstanceMethod.new.public_instance_module_test_method
1530
+ advice_called.should be_false
1531
+ aspect.unadvise
1462
1532
  end
1463
- aspect.unadvise
1464
- end
1465
-
1466
- it "should accept :type(s)_with_ancestors => [T1, ...], :exclude_join_point(s) => [jps], where [jps] are the list of join points for the types and methods to exclude" do
1467
- included_types = [ClassWithPublicInstanceMethod, ModuleWithPublicInstanceMethod]
1468
- excluded_join_point1 = JoinPoint.new :type => ClassWithPublicInstanceMethod, :method => :public_instance_test_method
1469
- excluded_join_point2 = JoinPoint.new :type => ModuleWithPublicInstanceMethod, :method => :public_instance_module_test_method
1470
- excluded_join_points = [excluded_join_point1, excluded_join_point2]
1471
- aspect = nil
1472
- advice_called = false
1473
- aspect = Aspect.new :before, :types_and_ancestors => included_types, :exclude_join_points => excluded_join_points, :methods => :doit do |jp, obj, *args|; advice_called = true; end
1474
-
1475
- advice_called = false
1476
- ClassWithPublicInstanceMethod.new.public_instance_test_method
1477
- advice_called.should be_false
1478
- advice_called = false
1479
- ClassIncludingModuleWithPublicInstanceMethod.new.public_instance_module_test_method
1480
- advice_called.should be_false
1481
- aspect.unadvise
1482
- end
1483
-
1484
- it "should accept :type(s)_with_descendents => [T1, ...], :exclude_join_point(s) => [jps], where [jps] are the list of join points for the types and methods to exclude" do
1485
- included_types = [ClassWithPublicInstanceMethod, ModuleWithPublicInstanceMethod]
1486
- excluded_join_point1 = JoinPoint.new :type => ClassWithPublicInstanceMethod, :method => :public_instance_test_method
1487
- excluded_join_point2 = JoinPoint.new :type => ModuleWithPublicInstanceMethod, :method => :public_instance_module_test_method
1488
- excluded_join_points = [excluded_join_point1, excluded_join_point2]
1489
- aspect = nil
1490
- advice_called = false
1491
- aspect = Aspect.new :before, :types_and_descendents => included_types, :exclude_join_points => excluded_join_points, :methods => :doit do |jp, obj, *args|; advice_called = true; end
1492
-
1493
- advice_called = false
1494
- ClassWithPublicInstanceMethod.new.public_instance_test_method
1495
- advice_called.should be_false
1496
- advice_called = false
1497
- ClassIncludingModuleWithPublicInstanceMethod.new.public_instance_module_test_method
1498
- advice_called.should be_false
1499
- aspect.unadvise
1500
1533
  end
1534
+
1535
+ describe Aspect, ".new (with a :type(s)_and_descendents parameter and an :exclude_join_point(s) parameter)" do
1536
+ it "should accept :type(s)_and_descendents => [T1, ...], :exclude_join_point(s) => [jps], where [jps] are the list of join points for the types and methods to exclude" do
1537
+ included_types = [ClassWithPublicInstanceMethod, ModuleWithPublicInstanceMethod]
1538
+ excluded_join_point1 = JoinPoint.new :type => ClassWithPublicInstanceMethod, :method => :public_instance_test_method
1539
+ excluded_join_point2 = JoinPoint.new :type => ModuleWithPublicInstanceMethod, :method => :public_instance_module_test_method
1540
+ excluded_join_points = [excluded_join_point1, excluded_join_point2]
1541
+ aspect = nil
1542
+ advice_called = false
1543
+ aspect = Aspect.new :before, :types_and_descendents => included_types, :methods => :doit,
1544
+ :exclude_join_points => excluded_join_points, :ignore_no_matching_join_points => true do |jp, obj, *args|; advice_called = true; end
1501
1545
 
1502
- it "should accept :pointcut(s) => [P1, ...], :exclude_join_point(s) => [jps], where [jps] are the list of join points for the types and methods to exclude" do
1503
- included_types = [DontExclude1, DontExclude2]
1504
- excluded_types = [Exclude1, Exclude2]
1505
- excluded_join_point1 = JoinPoint.new :type => Exclude1, :method => :doit
1506
- excluded_join_point2 = JoinPoint.new :type => Exclude2, :method => :doit
1507
- excluded_join_points = [excluded_join_point1, excluded_join_point2]
1508
- pointcut1 = Pointcut.new :types => included_types, :method => :doit
1509
- pointcut2 = Pointcut.new :types => excluded_types, :method => :doit
1510
- aspect = nil
1511
- advice_called = false
1512
- aspect = Aspect.new :before, :pointcuts => [pointcut1, pointcut2], :exclude_join_points => excluded_join_points do |jp, obj, *args|
1513
- advice_called = true
1514
- excluded_types.should_not include(jp.target_type)
1515
- end
1516
- included_types.each do |type|
1517
1546
  advice_called = false
1518
- type.new(1).doit
1519
- advice_called.should be_true
1547
+ ClassWithPublicInstanceMethod.new.public_instance_test_method
1548
+ advice_called.should be_false
1549
+ advice_called = false
1550
+ ClassIncludingModuleWithPublicInstanceMethod.new.public_instance_module_test_method
1551
+ advice_called.should be_false
1552
+ aspect.unadvise
1520
1553
  end
1521
- excluded_types.each do |type|
1554
+ end
1555
+
1556
+ describe Aspect, ".new (with a :pointcut(s) parameter and an :exclude_join_point(s) parameter)" do
1557
+ it "should accept :pointcut(s) => [P1, ...], :exclude_join_point(s) => [jps], where [jps] are the list of join points for the types and methods to exclude" do
1558
+ included_types = [DontExclude1, DontExclude2]
1559
+ excluded_types = [Exclude1, Exclude2]
1560
+ excluded_join_point1 = JoinPoint.new :type => Exclude1, :method => :doit
1561
+ excluded_join_point2 = JoinPoint.new :type => Exclude2, :method => :doit
1562
+ excluded_join_points = [excluded_join_point1, excluded_join_point2]
1563
+ pointcut1 = Pointcut.new :types => included_types, :method => :doit
1564
+ pointcut2 = Pointcut.new :types => excluded_types, :method => :doit
1565
+ aspect = nil
1522
1566
  advice_called = false
1523
- type.new(1).doit
1524
- advice_called.should_not be_true
1567
+ aspect = Aspect.new :before, :pointcuts => [pointcut1, pointcut2], :exclude_join_points => excluded_join_points do |jp, obj, *args|
1568
+ advice_called = true
1569
+ excluded_types.should_not include(jp.target_type)
1570
+ end
1571
+ included_types.each do |type|
1572
+ advice_called = false
1573
+ type.new(1).doit
1574
+ advice_called.should be_true
1575
+ end
1576
+ excluded_types.each do |type|
1577
+ advice_called = false
1578
+ type.new(1).doit
1579
+ advice_called.should_not be_true
1580
+ end
1581
+ aspect.unadvise
1525
1582
  end
1526
- aspect.unadvise
1527
1583
  end
1528
- end
1529
1584
 
1530
- describe Aspect, ".new (with a :pointcut(s), :type(s), :object(s), and :method(s) parameter and an :exclude_pointcut(s) parameter)" do
1531
- def do_exclude_pointcuts exclude_pointcuts_sym
1532
- dontExclude1 = DontExclude1.new(1)
1533
- dontExclude2 = DontExclude1.new(2)
1534
- exclude1 = DontExclude1.new(3)
1535
- exclude2 = DontExclude1.new(4)
1536
- included_objects = [dontExclude1, dontExclude2]
1537
- excluded_objects = [exclude1, exclude2]
1538
- excluded_pointcut1 = Pointcut.new :object => exclude1, :method => :doit
1539
- excluded_pointcut2 = Pointcut.new :object => exclude2, :method => :doit
1540
- excluded_pointcuts = [excluded_pointcut1, excluded_pointcut2]
1541
- aspect = nil
1542
- advice_called = false
1543
- aspect = Aspect.new :before, :objects => (included_objects + excluded_objects), exclude_pointcuts_sym => excluded_pointcuts, :methods => :doit do |jp, obj, *args|
1544
- advice_called = true
1545
- excluded_objects.should_not include(obj)
1546
- end
1547
-
1548
- included_objects.each do |object|
1549
- advice_called = false
1550
- object.doit
1551
- advice_called.should be_true
1585
+ describe Aspect, ".new (with an :object(s) and an :exclude_pointcut(s) parameter)" do
1586
+ before :all do
1587
+ dontExclude1 = DontExclude1.new(1)
1588
+ dontExclude2 = DontExclude1.new(2)
1589
+ exclude1 = DontExclude1.new(3)
1590
+ exclude2 = DontExclude1.new(4)
1591
+ @included_objects = [dontExclude1, dontExclude2]
1592
+ @excluded_objects = [exclude1, exclude2]
1593
+ @all_objects = @included_objects + @excluded_objects
1594
+ excluded_pointcut1 = Pointcut.new :object => exclude1, :method => :doit
1595
+ excluded_pointcut2 = Pointcut.new :object => exclude2, :method => :doit
1596
+ @excluded_pointcuts = [excluded_pointcut1, excluded_pointcut2]
1552
1597
  end
1553
- excluded_objects.each do |object|
1598
+
1599
+ it "should accept :object(s) => [o1, ...], :exclude_pointcut(s) => [pcs], where [pcs] are the list of pointcuts for the objects and methods to exclude" do
1600
+ aspect = nil
1554
1601
  advice_called = false
1555
- object.doit
1556
- advice_called.should_not be_true
1602
+ aspect = Aspect.new :before, :objects => @all_objects, :methods => :doit, :exclude_pointcuts => @excluded_pointcuts, :ignore_no_matching_join_points => true do |jp, obj, *args|
1603
+ advice_called = true
1604
+ @excluded_objects.should_not include(obj)
1605
+ end
1606
+
1607
+ @included_objects.each do |object|
1608
+ advice_called = false
1609
+ object.doit
1610
+ advice_called.should be_true
1611
+ end
1612
+ @excluded_objects.each do |object|
1613
+ advice_called = false
1614
+ object.doit
1615
+ advice_called.should_not be_true
1616
+ end
1617
+ aspect.unadvise
1557
1618
  end
1558
- aspect.unadvise
1559
- end
1560
1619
 
1561
- Aspect::CANONICAL_OPTIONS["exclude_pointcuts"].each do |key|
1562
- it "should accept :#{key} as a synonym for :exclude_pointcuts." do
1563
- do_exclude_pointcuts key.intern
1620
+ Aspect::CANONICAL_OPTIONS["exclude_pointcuts"].each do |key|
1621
+ it "should accept :#{key} as a synonym for :exclude_pointcuts." do
1622
+ lambda {aspect = Aspect.new :before, :objects => @all_objects, :exclude_pointcuts => @excluded_pointcuts, :methods => :doit, :noop => true do; end}.should_not raise_error
1623
+ end
1564
1624
  end
1565
1625
  end
1566
-
1567
- it "should accept :object(s) => [o1, ...], :exclude_pointcut(s) => [pcs], where [pcs] are the list of pointcuts for the objects and methods to exclude" do
1568
- do_exclude_pointcuts :exclude_pointcuts
1569
- end
1570
-
1571
- it "should accept :type(s) => [T1, ...], :exclude_pointcut(s) => [pcs], where [pcs] are the list of pointcuts for the types and methods to exclude" do
1572
- included_types = [DontExclude1, DontExclude2]
1573
- excluded_types = [Exclude1, Exclude2]
1574
- excluded_pointcut1 = Pointcut.new :type => Exclude1, :method => :doit
1575
- excluded_pointcut2 = Pointcut.new :type => Exclude2, :method => :doit
1576
- excluded_pointcuts = [excluded_pointcut1, excluded_pointcut2]
1577
- aspect = nil
1578
- advice_called = false
1579
- aspect = Aspect.new :before, :types => (included_types + excluded_types), :exclude_pointcuts => excluded_pointcuts, :methods => :doit do |jp, obj, *args|
1580
- advice_called = true
1581
- excluded_types.should_not include(jp.target_type)
1582
- end
1583
-
1584
- included_types.each do |type|
1585
- advice_called = false
1586
- type.new(1).doit
1587
- advice_called.should be_true
1626
+
1627
+ describe Aspect, ".new (with a :type(s) and an :exclude_pointcut(s) parameter)" do
1628
+ before :all do
1629
+ @included_types = [DontExclude1, DontExclude2]
1630
+ @excluded_types = [Exclude1, Exclude2]
1631
+ @all_types = @included_types + @excluded_types
1632
+ excluded_pointcut1 = Pointcut.new :type => Exclude1, :method => :doit
1633
+ excluded_pointcut2 = Pointcut.new :type => Exclude2, :method => :doit
1634
+ @excluded_pointcuts = [excluded_pointcut1, excluded_pointcut2]
1588
1635
  end
1589
- excluded_types.each do |type|
1636
+
1637
+ it "should accept :type(s) => [T1, ...], :exclude_pointcut(s) => [pcs], where [pcs] are the list of pointcuts for the types and methods to exclude" do
1638
+ aspect = nil
1590
1639
  advice_called = false
1591
- type.new(1).doit
1592
- advice_called.should_not be_true
1640
+ aspect = Aspect.new :before, :types => @all_types, :exclude_pointcuts => @excluded_pointcuts, :methods => :doit do |jp, obj, *args|
1641
+ advice_called = true
1642
+ @excluded_types.should_not include(jp.target_type)
1643
+ end
1644
+
1645
+ @included_types.each do |type|
1646
+ advice_called = false
1647
+ type.new(1).doit
1648
+ advice_called.should be_true
1649
+ end
1650
+ @excluded_types.each do |type|
1651
+ advice_called = false
1652
+ type.new(1).doit
1653
+ advice_called.should_not be_true
1654
+ end
1655
+ aspect.unadvise
1593
1656
  end
1594
- aspect.unadvise
1595
1657
  end
1596
-
1597
- it "should accept :pointcut(s) => [P1, ...], :exclude_pointcut(s) => [pcs], where [pcs] are the list of pointcuts for the types and methods to exclude" do
1598
- included_types = [DontExclude1, DontExclude2]
1599
- excluded_types = [Exclude1, Exclude2]
1600
- excluded_pointcut1 = Pointcut.new :type => Exclude1, :method => :doit
1601
- excluded_pointcut2 = Pointcut.new :type => Exclude2, :method => :doit
1602
- excluded_pointcuts = [excluded_pointcut1, excluded_pointcut2]
1603
- pointcut1 = Pointcut.new :types => included_types, :method => :doit
1604
- pointcut2 = Pointcut.new :types => excluded_types, :method => :doit
1605
- aspect = nil
1606
- advice_called = false
1607
- aspect = Aspect.new :before, :pointcuts => [pointcut1, pointcut2], :exclude_pointcuts => excluded_pointcuts do |jp, obj, *args|
1608
- advice_called = true
1609
- excluded_types.should_not include(jp.target_type)
1610
- end
1611
- included_types.each do |type|
1612
- advice_called = false
1613
- type.new(1).doit
1614
- advice_called.should be_true
1658
+
1659
+ describe Aspect, ".new (with a :pointcut(s) and an :exclude_pointcut(s) parameter)" do
1660
+ before :all do
1661
+ @included_types = [DontExclude1, DontExclude2]
1662
+ @excluded_types = [Exclude1, Exclude2]
1663
+ @all_types = @included_types + @excluded_types
1664
+ excluded_pointcut1 = Pointcut.new :type => Exclude1, :method => :doit
1665
+ excluded_pointcut2 = Pointcut.new :type => Exclude2, :method => :doit
1666
+ @excluded_pointcuts = [excluded_pointcut1, excluded_pointcut2]
1667
+ pointcut1 = Pointcut.new :types => @included_types, :method => :doit
1668
+ pointcut2 = Pointcut.new :types => @excluded_types, :method => :doit
1669
+ @all_pointcuts = [pointcut1, pointcut2]
1615
1670
  end
1616
- excluded_types.each do |type|
1671
+
1672
+ it "should accept :pointcut(s) => [P1, ...], :exclude_pointcut(s) => [pcs], where [pcs] are the list of pointcuts for the types and methods to exclude" do
1673
+ aspect = nil
1617
1674
  advice_called = false
1618
- type.new(1).doit
1619
- advice_called.should_not be_true
1675
+ aspect = Aspect.new :before, :pointcuts => @all_pointcuts, :exclude_pointcuts => @excluded_pointcuts do |jp, obj, *args|
1676
+ advice_called = true
1677
+ @excluded_types.should_not include(jp.target_type)
1678
+ end
1679
+ @included_types.each do |type|
1680
+ advice_called = false
1681
+ type.new(1).doit
1682
+ advice_called.should be_true
1683
+ end
1684
+ @excluded_types.each do |type|
1685
+ advice_called = false
1686
+ type.new(1).doit
1687
+ advice_called.should_not be_true
1688
+ end
1689
+ aspect.unadvise
1620
1690
  end
1621
- aspect.unadvise
1622
1691
  end
1623
- end
1624
1692
 
1625
- describe Aspect, ".new (with type-based :pointcut(s) and :exclude_type(s) parameter)" do
1626
- it "should accept :pointcut(s) => [P1, ...], :exclude_type(s) => [types], where join points with [types] are excluded" do
1627
- included_types = [DontExclude1, DontExclude2]
1628
- excluded_types = [Exclude1, Exclude2]
1629
- pointcut1 = Pointcut.new :types => included_types, :method => :doit
1630
- pointcut2 = Pointcut.new :types => excluded_types, :method => :doit
1631
- aspect = nil
1632
- advice_called = false
1633
- aspect = Aspect.new :before, :pointcuts => [pointcut1, pointcut2], :exclude_types => excluded_types do |jp, obj, *args|
1634
- advice_called = true
1635
- excluded_types.should_not include(jp.target_type)
1636
- end
1637
-
1638
- included_types.each do |type|
1693
+ describe Aspect, ".new (with type-based :pointcut(s) and :exclude_type(s) parameter)" do
1694
+ it "should accept :pointcut(s) => [P1, ...], :exclude_type(s) => [types], where join points with [types] are excluded" do
1695
+ included_types = [DontExclude1, DontExclude2]
1696
+ excluded_types = [Exclude1, Exclude2]
1697
+ pointcut1 = Pointcut.new :types => included_types, :method => :doit
1698
+ pointcut2 = Pointcut.new :types => excluded_types, :method => :doit
1699
+ aspect = nil
1639
1700
  advice_called = false
1640
- type.new(1).doit
1641
- advice_called.should be_true
1642
- end
1643
- excluded_types.each do |type|
1644
- advice_called = false
1645
- type.new(1).doit
1646
- advice_called.should_not be_true
1647
- end
1648
- aspect.unadvise
1649
- end
1650
- end
1701
+ aspect = Aspect.new :before, :pointcuts => [pointcut1, pointcut2], :exclude_types => excluded_types do |jp, obj, *args|
1702
+ advice_called = true
1703
+ excluded_types.should_not include(jp.target_type)
1704
+ end
1651
1705
 
1652
- describe Aspect, ".new (with type-based :pointcut(s) and :exclude_type(s)_and_ancestors parameter)" do
1653
- it "should accept :pointcut(s) => [P1, ...], :exclude_type(s)_and_ancestors => [types], where join points with [types] are excluded" do
1654
- excluded_types = [ClassWithPublicInstanceMethod, ModuleWithPublicInstanceMethod]
1655
- types = excluded_types + [ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod]
1656
- pointcut1 = Pointcut.new :types => types, :method => :all, :method_options => [:exclude_ancestor_methods]
1657
- advice_called = false
1658
- aspect = Aspect.new :before, :pointcuts => pointcut1, :exclude_types_and_ancestors => excluded_types do |jp, obj, *args|; end
1659
- aspect.pointcuts.each do |pc|
1660
- pc.join_points_matched.each do |jp|
1661
- jp.target_type.should == ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod
1706
+ included_types.each do |type|
1707
+ advice_called = false
1708
+ type.new(1).doit
1709
+ advice_called.should be_true
1710
+ end
1711
+ excluded_types.each do |type|
1712
+ advice_called = false
1713
+ type.new(1).doit
1714
+ advice_called.should_not be_true
1662
1715
  end
1716
+ aspect.unadvise
1663
1717
  end
1664
- aspect.unadvise
1665
1718
  end
1666
- end
1667
1719
 
1668
- describe Aspect, ".new (with type-based :pointcut(s) and :exclude_type(s)_and_descendents parameter)" do
1669
- it "should accept :pointcut(s) => [P1, ...], :exclude_type(s)_and_descendents => [types], where join points with [types] are excluded" do
1670
- excluded_types = [ClassWithPublicInstanceMethod, ModuleWithPublicInstanceMethod]
1671
- types = excluded_types + [ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod]
1672
- pointcut1 = Pointcut.new :types => types, :method => :all, :method_options => [:exclude_ancestor_methods]
1673
- advice_called = false
1674
- aspect = Aspect.new :before, :pointcuts => pointcut1, :exclude_types_and_descendents => excluded_types do |jp, obj, *args|; end
1675
- aspect.pointcuts.size.should == 0
1676
- aspect.unadvise
1720
+ describe Aspect, ".new (with type-based :pointcut(s) and :exclude_type(s)_and_ancestors parameter)" do
1721
+ it "should accept :pointcut(s) => [P1, ...], :exclude_type(s)_and_ancestors => [types], where join points with [types] are excluded" do
1722
+ excluded_types = [ClassWithPublicInstanceMethod, ModuleWithPublicInstanceMethod]
1723
+ types = excluded_types + [ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod]
1724
+ pointcut1 = Pointcut.new :types => types, :method => :all, :method_options => [:exclude_ancestor_methods]
1725
+ advice_called = false
1726
+ aspect = Aspect.new :before, :pointcuts => pointcut1, :exclude_types_and_ancestors => excluded_types do |jp, obj, *args|; end
1727
+ aspect.pointcuts.each do |pc|
1728
+ pc.join_points_matched.each do |jp|
1729
+ jp.target_type.should == ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod
1730
+ end
1731
+ end
1732
+ aspect.unadvise
1733
+ end
1677
1734
  end
1678
- end
1679
-
1680
1735
 
1681
- describe Aspect, ".new (with object-based :pointcut(s) and :exclude_object(s) or :exclude_method(s) parameter)" do
1682
-
1683
- it "should accept :pointcut(s) => [P1, ...], :exclude_object(s) => [objects], where join points with [objects] are excluded" do
1684
- dontExclude1 = DontExclude1.new(1)
1685
- dontExclude2 = DontExclude1.new(2)
1686
- exclude1 = DontExclude1.new(3)
1687
- exclude2 = DontExclude1.new(4)
1688
- included_objects = [dontExclude1, dontExclude2]
1689
- excluded_objects = [exclude1, exclude2]
1690
- pointcut1 = Pointcut.new :objects => included_objects, :method => :doit
1691
- pointcut2 = Pointcut.new :objects => excluded_objects, :method => :doit
1692
- aspect = nil
1693
- advice_called = false
1694
- aspect = Aspect.new :before, :pointcuts => [pointcut1, pointcut2], :exclude_objects => excluded_objects do |jp, obj, *args|
1695
- advice_called = true
1696
- excluded_objects.should_not include(obj)
1697
- end
1698
- included_objects.each do |object|
1736
+ describe Aspect, ".new (with type-based :pointcut(s) and :exclude_type(s)_and_descendents parameter)" do
1737
+ it "should accept :pointcut(s) => [P1, ...], :exclude_type(s)_and_descendents => [types], where join points with [types] are excluded" do
1738
+ excluded_types = [ClassWithPublicInstanceMethod, ModuleWithPublicInstanceMethod]
1739
+ types = excluded_types + [ClassDerivedFromClassIncludingModuleWithPublicInstanceMethod]
1740
+ pointcut1 = Pointcut.new :types => types, :method => :all, :method_options => [:exclude_ancestor_methods]
1699
1741
  advice_called = false
1700
- object.doit
1701
- advice_called.should be_true
1742
+ aspect = Aspect.new :before, :pointcuts => pointcut1, :exclude_types_and_descendents => excluded_types, :ignore_no_matching_join_points => true do |jp, obj, *args|; end
1743
+ aspect.pointcuts.size.should == 0
1744
+ aspect.unadvise
1702
1745
  end
1703
- excluded_objects.each do |object|
1746
+ end
1747
+
1748
+ describe Aspect, ".new (with object-based :pointcut(s) and :exclude_object(s) or :exclude_method(s) parameter)" do
1749
+ it "should accept :pointcut(s) => [P1, ...], :exclude_object(s) => [objects], where join points with [objects] are excluded" do
1750
+ dontExclude1 = DontExclude1.new(1)
1751
+ dontExclude2 = DontExclude1.new(2)
1752
+ exclude1 = DontExclude1.new(3)
1753
+ exclude2 = DontExclude1.new(4)
1754
+ included_objects = [dontExclude1, dontExclude2]
1755
+ excluded_objects = [exclude1, exclude2]
1756
+ pointcut1 = Pointcut.new :objects => included_objects, :method => :doit
1757
+ pointcut2 = Pointcut.new :objects => excluded_objects, :method => :doit
1758
+ aspect = nil
1704
1759
  advice_called = false
1705
- object.doit
1706
- advice_called.should_not be_true
1760
+ aspect = Aspect.new :before, :pointcuts => [pointcut1, pointcut2], :exclude_objects => excluded_objects do |jp, obj, *args|
1761
+ advice_called = true
1762
+ excluded_objects.should_not include(obj)
1763
+ end
1764
+ included_objects.each do |object|
1765
+ advice_called = false
1766
+ object.doit
1767
+ advice_called.should be_true
1768
+ end
1769
+ excluded_objects.each do |object|
1770
+ advice_called = false
1771
+ object.doit
1772
+ advice_called.should_not be_true
1773
+ end
1774
+ aspect.unadvise
1707
1775
  end
1708
- aspect.unadvise
1709
1776
  end
1710
- end
1711
1777
 
1712
- describe Aspect, ".new (with :method(s) and :exclude_method(s) parameter)" do
1713
- before :each do
1714
- @dontExclude1 = DontExclude1.new(1)
1715
- @dontExclude2 = DontExclude1.new(2)
1716
- @exclude1 = DontExclude1.new(3)
1717
- @exclude2 = DontExclude1.new(4)
1718
- @exclude1c = Exclude1c.new(5)
1719
- @included_objects = [@dontExclude1, @dontExclude2, @exclude1, @exclude2]
1720
- @excluded_objects = [@exclude1c]
1721
- @included_types = [DontExclude1, DontExclude2, Exclude1, Exclude2]
1722
- @excluded_types = [Exclude1c]
1723
- @excluded_methods = [:doit3]
1724
- @pointcut1 = Pointcut.new :objects => @included_objects, :method => /doit/
1725
- @pointcut2 = Pointcut.new :objects => @excluded_objects, :method => /doit/
1726
- @pointcut3 = Pointcut.new :types => @included_types, :method => /doit/
1727
- @pointcut4 = Pointcut.new :types => @excluded_types, :method => /doit/
1728
- end
1778
+ describe Aspect, ".new (with :method(s) and :exclude_method(s) parameter)" do
1779
+ before :each do
1780
+ @dontExclude1 = DontExclude1.new(1)
1781
+ @dontExclude2 = DontExclude1.new(2)
1782
+ @exclude1 = DontExclude1.new(3)
1783
+ @exclude2 = DontExclude1.new(4)
1784
+ @exclude1c = Exclude1c.new(5)
1785
+ @included_objects = [@dontExclude1, @dontExclude2, @exclude1, @exclude2]
1786
+ @excluded_objects = [@exclude1c]
1787
+ @included_types = [DontExclude1, DontExclude2, Exclude1, Exclude2]
1788
+ @excluded_types = [Exclude1c]
1789
+ @excluded_methods = [:doit3]
1790
+ @pointcut1 = Pointcut.new :objects => @included_objects, :method => /doit/
1791
+ @pointcut2 = Pointcut.new :objects => @excluded_objects, :method => /doit/
1792
+ @pointcut3 = Pointcut.new :types => @included_types, :method => /doit/
1793
+ @pointcut4 = Pointcut.new :types => @excluded_types, :method => /doit/
1794
+ end
1729
1795
 
1730
- def do_method_exclusion parameter_hash, types_were_specified, option_key = :exclude_methods
1731
- parameter_hash[:before] = ''
1732
- parameter_hash[option_key] = :doit3
1733
- aspect = nil
1734
- advice_called = false
1735
- aspect = Aspect.new parameter_hash do |jp, obj, *args|
1736
- advice_called = true
1737
- @excluded_methods.should_not include(jp.method_name)
1738
- end
1739
- if types_were_specified
1740
- (@included_types + @excluded_types).each do |type|
1796
+ def do_method_exclusion parameter_hash, types_were_specified
1797
+ parameter_hash[:before] = ''
1798
+ parameter_hash[:exclude_methods] = :doit3
1799
+ aspect = nil
1800
+ advice_called = false
1801
+ aspect = Aspect.new parameter_hash do |jp, obj, *args|
1802
+ advice_called = true
1803
+ @excluded_methods.should_not include(jp.method_name)
1804
+ end
1805
+ if types_were_specified
1806
+ (@included_types + @excluded_types).each do |type|
1807
+ advice_called = false
1808
+ type.new(1).doit
1809
+ advice_called.should be_true
1810
+ end
1811
+ @excluded_types.each do |type|
1812
+ advice_called = false
1813
+ type.new(1).doit3
1814
+ advice_called.should_not be_true
1815
+ end
1816
+ end
1817
+ (@included_objects + @excluded_objects).each do |object|
1741
1818
  advice_called = false
1742
- type.new(1).doit
1819
+ object.doit
1743
1820
  advice_called.should be_true
1744
1821
  end
1745
- @excluded_types.each do |type|
1822
+ @excluded_objects.each do |object|
1746
1823
  advice_called = false
1747
- type.new(1).doit3
1824
+ object.doit3
1748
1825
  advice_called.should_not be_true
1749
1826
  end
1827
+ aspect.unadvise
1750
1828
  end
1751
- (@included_objects + @excluded_objects).each do |object|
1752
- advice_called = false
1753
- object.doit
1754
- advice_called.should be_true
1829
+
1830
+ Aspect::CANONICAL_OPTIONS["exclude_methods"].each do |key|
1831
+ it "should accept :#{key} as a synonym for :exclude_methods." do
1832
+ lambda { Aspect.new :before, :pointcuts => [@pointcut1, @pointcut2, @pointcut3, @pointcut4], key.intern => :doit3, :noop => true }.should_not raise_error
1833
+ end
1755
1834
  end
1756
- @excluded_objects.each do |object|
1757
- advice_called = false
1758
- object.doit3
1759
- advice_called.should_not be_true
1835
+
1836
+ it "should accept :pointcut(s) => [P1, ...], :exclude_method(s) => [methods], where join points with [methods] are excluded" do
1837
+ parameter_hash = { :pointcuts => [@pointcut1, @pointcut2, @pointcut3, @pointcut4] }
1838
+ do_method_exclusion parameter_hash, true
1760
1839
  end
1761
- aspect.unadvise
1762
- end
1763
1840
 
1764
- Aspect::CANONICAL_OPTIONS["exclude_methods"].each do |key|
1765
- it "should accept :#{key} as a synonym for :exclude_methods." do
1766
- parameter_hash = { :pointcuts => [@pointcut1, @pointcut2, @pointcut3, @pointcut4] }
1767
- do_method_exclusion parameter_hash, true, key.intern
1841
+ it "should accept :type(s) => ..., :method(s) => ..., :exclude_method(s) => [methods], where join points with [methods] are excluded" do
1842
+ parameter_hash = { :types => (@included_types + @excluded_types), :methods => /doit/ }
1843
+ do_method_exclusion parameter_hash, true
1768
1844
  end
1769
- end
1770
-
1771
- it "should accept :pointcut(s) => [P1, ...], :exclude_method(s) => [methods], where join points with [methods] are excluded" do
1772
- parameter_hash = { :pointcuts => [@pointcut1, @pointcut2, @pointcut3, @pointcut4] }
1773
- do_method_exclusion parameter_hash, true
1774
- end
1775
1845
 
1776
- it "should accept :type(s) => ..., :method(s) => ..., :exclude_method(s) => [methods], where join points with [methods] are excluded" do
1777
- parameter_hash = { :types => (@included_types + @excluded_types), :methods => /doit/ }
1778
- do_method_exclusion parameter_hash, true
1846
+ # it "should accept :object(s) => ..., :method(s) => ..., :exclude_method(s) => [methods], where join points with [methods] are excluded" do
1847
+ # pending "bug fix"
1848
+ # Aspect.echo = true
1849
+ # parameter_hash = { :objects => (@included_objects + @excluded_objects), :methods => /doit/ }
1850
+ # do_method_exclusion parameter_hash, false
1851
+ # Aspect.echo = false
1852
+ # end
1853
+ #
1854
+ # def do_method_exclusion2 parameter_hash, types_were_specified
1855
+ # parameter_hash[:before] = ''
1856
+ # parameter_hash[:exclude_method] = :doit3
1857
+ # parameter_hash[:method] = /doit/
1858
+ # aspect = nil
1859
+ # advice_called = false
1860
+ # aspect = Aspect.new parameter_hash do |jp, obj, *args|
1861
+ # advice_called = true
1862
+ # @excluded_methods.should_not include(jp.method_name)
1863
+ # end
1864
+ # (@excluded_objects).each do |object|
1865
+ # advice_called = false
1866
+ # object.doit
1867
+ # advice_called.should be_true
1868
+ # end
1869
+ # aspect.unadvise
1870
+ # end
1871
+ #
1872
+ # def buggy parameter_hash
1873
+ # parameter_hash[:before] = ''
1874
+ # parameter_hash[:exclude_method] = :doit3
1875
+ # aspect = Aspect.new parameter_hash do |jp, obj, *args|
1876
+ # end
1877
+ # @excluded_objects.each do |object|
1878
+ # object.doit
1879
+ # end
1880
+ # aspect.unadvise
1881
+ # end
1882
+ #
1883
+ # it "#15202 bug..." do
1884
+ # pending "bug fix"
1885
+ # @pointcut5 = Pointcut.new :types => [Exclude1, Exclude1c], :method => /doit/
1886
+ # parameter_hash = { :pointcuts => [@pointcut5] } #[@pointcut1, @pointcut2, @pointcut3, @pointcut4] }
1887
+ # buggy parameter_hash
1888
+ # parameter_hash = { :objects => (@excluded_objects), :method => /doit/ }
1889
+ # buggy parameter_hash
1890
+ # end
1779
1891
  end
1780
-
1781
- # it "should accept :object(s) => ..., :method(s) => ..., :exclude_method(s) => [methods], where join points with [methods] are excluded" do
1782
- # pending "bug fix"
1783
- # Aspect.echo = true
1784
- # parameter_hash = { :objects => (@included_objects + @excluded_objects), :methods => /doit/ }
1785
- # do_method_exclusion parameter_hash, false
1786
- # Aspect.echo = false
1787
- # end
1788
- #
1789
- # def do_method_exclusion2 parameter_hash, types_were_specified
1790
- # parameter_hash[:before] = ''
1791
- # parameter_hash[:exclude_method] = :doit3
1792
- # parameter_hash[:method] = /doit/
1793
- # aspect = nil
1794
- # advice_called = false
1795
- # aspect = Aspect.new parameter_hash do |jp, obj, *args|
1796
- # advice_called = true
1797
- # @excluded_methods.should_not include(jp.method_name)
1798
- # end
1799
- # (@excluded_objects).each do |object|
1800
- # advice_called = false
1801
- # object.doit
1802
- # advice_called.should be_true
1803
- # end
1804
- # aspect.unadvise
1805
- # end
1806
- #
1807
- # def buggy parameter_hash
1808
- # parameter_hash[:before] = ''
1809
- # parameter_hash[:exclude_method] = :doit3
1810
- # aspect = Aspect.new parameter_hash do |jp, obj, *args|
1811
- # end
1812
- # @excluded_objects.each do |object|
1813
- # object.doit
1814
- # end
1815
- # aspect.unadvise
1816
- # end
1817
- #
1818
- # it "#15202 bug..." do
1819
- # pending "bug fix"
1820
- # @pointcut5 = Pointcut.new :types => [Exclude1, Exclude1c], :method => /doit/
1821
- # parameter_hash = { :pointcuts => [@pointcut5] } #[@pointcut1, @pointcut2, @pointcut3, @pointcut4] }
1822
- # buggy parameter_hash
1823
- # parameter_hash = { :objects => (@excluded_objects), :method => /doit/ }
1824
- # buggy parameter_hash
1825
- # end
1826
1892
  end