aquarium 0.2.0 → 0.3.0

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