aquarium 0.5.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGES +240 -215
- data/README +61 -44
- data/RELEASE-PLAN +21 -23
- data/Rakefile +64 -94
- data/UPGRADE +45 -35
- data/aquarium.gemspec +50 -0
- data/examples/README.txt +6 -0
- data/examples/aspect_design_example_spec.rb +2 -2
- data/examples/design_by_contract_example_spec.rb +3 -3
- data/examples/exception_wrapping_example_spec.rb +2 -2
- data/examples/introductions_example_spec.rb +1 -1
- data/examples/method_tracing_example_spec.rb +17 -16
- data/examples/reusable_aspect_hack_example_spec.rb +5 -5
- data/jruby/Rakefile +61 -0
- data/jruby/java/example/Worker.java +9 -0
- data/jruby/java/example/sorter/StringListSorter.java +22 -0
- data/jruby/java/example/sorter/converter/StringListCaseConverterAndSorter.java +42 -0
- data/jruby/java/example/visibility/Visibility.java +13 -0
- data/jruby/spec/java_class_aspects_spec.rb +434 -0
- data/jruby/spec/java_visibility_spec.rb +122 -0
- data/jruby/spec/spec_helper.rb +5 -0
- data/lib/aquarium/aspects/aspect.rb +8 -4
- data/lib/aquarium/utils/type_utils.rb +4 -1
- data/lib/aquarium/version.rb +29 -28
- data/previous_failures.txt +0 -0
- data/rspec.watchr +60 -0
- data/spec/aquarium/aspects/advice_spec.rb +10 -10
- data/spec/aquarium/aspects/aspect_invocation_spec.rb +79 -79
- data/spec/aquarium/aspects/aspect_spec.rb +73 -73
- data/spec/aquarium/aspects/aspect_with_nested_types_spec.rb +5 -5
- data/spec/aquarium/aspects/concurrent_aspects_spec.rb +1 -1
- data/spec/aquarium/aspects/default_objects_handler_spec.rb +5 -5
- data/spec/aquarium/aspects/join_point_spec.rb +40 -40
- data/spec/aquarium/aspects/pointcut_and_composition_spec.rb +8 -8
- data/spec/aquarium/aspects/pointcut_spec.rb +25 -25
- data/spec/aquarium/extensions/regex_spec.rb +6 -6
- data/spec/aquarium/extras/design_by_contract_spec.rb +6 -6
- data/spec/aquarium/finders/finder_result_spec.rb +2 -2
- data/spec/aquarium/finders/method_finder_spec.rb +24 -24
- data/spec/aquarium/finders/pointcut_finder_spec.rb +10 -10
- data/spec/aquarium/finders/pointcut_finder_spec_test_classes.rb +4 -4
- data/spec/aquarium/finders/type_finder_spec.rb +5 -5
- data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +6 -5
- data/spec/aquarium/finders/type_finder_with_nested_types_spec.rb +2 -2
- data/spec/aquarium/utils/logic_error_spec.rb +1 -1
- data/spec/aquarium/utils/method_utils_spec.rb +38 -38
- data/spec/aquarium/utils/nil_object_spec.rb +11 -11
- data/spec/aquarium/utils/options_utils_spec.rb +8 -8
- data/spec/aquarium/utils/type_utils_spec.rb +3 -3
- metadata +238 -57
@@ -45,8 +45,8 @@ describe Pointcut, "#and (when both pointcuts are not empty)" do
|
|
45
45
|
pc1 = Pointcut.new :types => [ClassWithAttribs, ClassWithPublicInstanceMethod, ClassWithPrivateInstanceMethod], :attributes => [/^attr/], :attribute_options => [:readers]
|
46
46
|
pc2 = Pointcut.new :types => [ClassWithAttribs, ClassWithPublicInstanceMethod, ClassWithProtectedInstanceMethod], :attributes => :attrRW_ClassWithAttribs, :attribute_options => [:exclude_ancestor_methods]
|
47
47
|
pc = pc1.and pc2
|
48
|
-
|
49
|
-
pc.join_points_matched.should == Set.new([
|
48
|
+
lambdaed_jp = JoinPoint.new :type => ClassWithAttribs, :method => :attrRW_ClassWithAttribs
|
49
|
+
pc.join_points_matched.should == Set.new([lambdaed_jp])
|
50
50
|
pc.join_points_not_matched.should == @empty_set
|
51
51
|
end
|
52
52
|
|
@@ -58,8 +58,8 @@ describe Pointcut, "#and (when both pointcuts are not empty)" do
|
|
58
58
|
pc1 = Pointcut.new :objects => [cwa, pub, pri], :attributes => [/^attr/], :attribute_options => [:readers, :exclude_ancestor_methods]
|
59
59
|
pc2 = Pointcut.new :objects => [cwa, pub, pro], :attributes => :attrRW_ClassWithAttribs
|
60
60
|
pc = pc1.and pc2
|
61
|
-
|
62
|
-
pc.join_points_matched.should == Set.new([
|
61
|
+
lambdaed_jp = JoinPoint.new :object => cwa, :method => :attrRW_ClassWithAttribs
|
62
|
+
pc.join_points_matched.should == Set.new([lambdaed_jp])
|
63
63
|
pc.join_points_not_matched.should == @empty_set
|
64
64
|
end
|
65
65
|
|
@@ -67,8 +67,8 @@ describe Pointcut, "#and (when both pointcuts are not empty)" do
|
|
67
67
|
pc1 = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^attr/], :attribute_options => [:readers]
|
68
68
|
pc2 = Pointcut.new :types => "ClassWithAttribs", :attributes => :attrRW_ClassWithAttribs
|
69
69
|
pc = pc1.and pc2
|
70
|
-
|
71
|
-
pc.join_points_matched.should == Set.new([
|
70
|
+
lambdaed_jp = JoinPoint.new :type => ClassWithAttribs, :method => :attrRW_ClassWithAttribs
|
71
|
+
pc.join_points_matched.should == Set.new([lambdaed_jp])
|
72
72
|
pc.join_points_not_matched.should == @empty_set
|
73
73
|
end
|
74
74
|
|
@@ -77,8 +77,8 @@ describe Pointcut, "#and (when both pointcuts are not empty)" do
|
|
77
77
|
pc1 = Pointcut.new :object => cwa, :attributes => [/^attr/], :attribute_options => [:readers]
|
78
78
|
pc2 = Pointcut.new :object => cwa, :attributes => :attrRW_ClassWithAttribs
|
79
79
|
pc = pc1.and pc2
|
80
|
-
|
81
|
-
pc.join_points_matched.should == Set.new([
|
80
|
+
lambdaed_jp = JoinPoint.new :object => cwa, :method => :attrRW_ClassWithAttribs
|
81
|
+
pc.join_points_matched.should == Set.new([lambdaed_jp])
|
82
82
|
pc.join_points_not_matched.should == @empty_set
|
83
83
|
end
|
84
84
|
end
|
@@ -117,7 +117,7 @@ describe Pointcut, "methods" do
|
|
117
117
|
|
118
118
|
describe Pointcut, ".new (invalid arguments)" do
|
119
119
|
it "should raise if an unknown argument is specified" do
|
120
|
-
|
120
|
+
expect { Pointcut.new :foo => :bar }.to raise_error(Aquarium::Utils::InvalidOptions)
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
@@ -309,13 +309,13 @@ describe Pointcut, "methods" do
|
|
309
309
|
|
310
310
|
Aspect::CANONICAL_OPTIONS["types_and_ancestors"].reject{|key| key.eql?("types_and_ancestors")}.each do |key|
|
311
311
|
it "should accept :#{key} as a synonym for :types_and_ancestors." do
|
312
|
-
|
312
|
+
expect {Pointcut.new key.intern => /^Module.*Method/, :methods => :all, :noop => true}.not_to raise_error
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
316
316
|
Aspect::CANONICAL_OPTIONS["types_and_descendents"].reject{|key| key.eql?("types_and_descendents")}.each do |key|
|
317
317
|
it "should accept :#{key} as a synonym for :types_and_descendents." do
|
318
|
-
|
318
|
+
expect {Pointcut.new key.intern => /^Module.*Method/, :methods => :all, :noop => true}.not_to raise_error
|
319
319
|
end
|
320
320
|
end
|
321
321
|
end
|
@@ -337,7 +337,7 @@ describe Pointcut, "methods" do
|
|
337
337
|
|
338
338
|
Aspect::CANONICAL_OPTIONS["types_and_nested_types"].reject{|key| key.eql?("types_and_nested_types")}.each do |key|
|
339
339
|
it "should accept :#{key} as a synonym for :types_and_nested_types." do
|
340
|
-
|
340
|
+
expect {Pointcut.new key.intern => /^Module.*Method/, :methods => :all, :noop => true}.not_to raise_error
|
341
341
|
end
|
342
342
|
end
|
343
343
|
end
|
@@ -385,12 +385,12 @@ describe Pointcut, "methods" do
|
|
385
385
|
|
386
386
|
it "does confuse strings specified with :objects as type names." do
|
387
387
|
string = "mystring"
|
388
|
-
|
388
|
+
expect { Pointcut.new :object => string, :methods => :capitalize }.to raise_error(NameError)
|
389
389
|
end
|
390
390
|
|
391
391
|
it "does confuse symbols specified with :objects as type names." do
|
392
392
|
symbol = :mystring
|
393
|
-
|
393
|
+
expect { Pointcut.new :object => symbol, :methods => :capitalize }.to raise_error(NameError)
|
394
394
|
end
|
395
395
|
end
|
396
396
|
|
@@ -667,13 +667,13 @@ describe Pointcut, "methods" do
|
|
667
667
|
|
668
668
|
Aspect::CANONICAL_OPTIONS["exclude_types_and_descendents"].reject{|key| key.eql?("exclude_types_and_descendents")}.each do |key|
|
669
669
|
it "should accept :#{key} as a synonym for :exclude_types_and_descendents." do
|
670
|
-
|
670
|
+
expect {Pointcut.new :types => /ExcludeTest/, key.intern => [ExcludeTestTwo, ExcludeTestThree], :method_options => :exclude_ancestor_methods, :noop => true}.not_to raise_error
|
671
671
|
end
|
672
672
|
end
|
673
673
|
|
674
674
|
Aspect::CANONICAL_OPTIONS["exclude_types_and_ancestors"].reject{|key| key.eql?("exclude_types_and_ancestors")}.each do |key|
|
675
675
|
it "should accept :#{key} as a synonym for :exclude_types_and_ancestors." do
|
676
|
-
|
676
|
+
expect {Pointcut.new :types => /ExcludeTest/, key.intern => [ExcludeTestTwo, ExcludeTestThree], :method_options => :exclude_ancestor_methods, :noop => true}.not_to raise_error
|
677
677
|
end
|
678
678
|
end
|
679
679
|
end
|
@@ -1282,7 +1282,7 @@ describe Pointcut, "methods" do
|
|
1282
1282
|
end
|
1283
1283
|
|
1284
1284
|
it "should only allow :reading and :writing options together if they specify the same attributes." do
|
1285
|
-
|
1285
|
+
expect {Pointcut.new :types => "ClassWithAttribs", :reading => [/^attrRW_ClassWithAttribs/], :writing => [/^attr.*ClassWithAttribs/]}.to raise_error(Aquarium::Utils::InvalidOptions)
|
1286
1286
|
end
|
1287
1287
|
|
1288
1288
|
it "should match public attribute readers and writers for types when both the :reading and :writing options are specified." do
|
@@ -1479,63 +1479,63 @@ describe Pointcut, "methods" do
|
|
1479
1479
|
|
1480
1480
|
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
|
1481
1481
|
pc = Pointcut.new :types => ClassWithFunkyMethodNames, :methods => /#{Regexp.escape(char)}$/, :method_options => [:instance]
|
1482
|
-
pc.join_points_matched.any? {|jp| jp.method_name == method}.should
|
1482
|
+
pc.join_points_matched.any? {|jp| jp.method_name == method}.should be_truthy
|
1483
1483
|
end
|
1484
1484
|
|
1485
1485
|
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
|
1486
1486
|
pc = Pointcut.new :object => @funky, :methods => /#{Regexp.escape(char)}$/, :method_options => [:instance]
|
1487
|
-
pc.join_points_matched.any? {|jp| jp.method_name == method}.should
|
1487
|
+
pc.join_points_matched.any? {|jp| jp.method_name == method}.should be_truthy
|
1488
1488
|
end
|
1489
1489
|
end
|
1490
1490
|
end
|
1491
1491
|
|
1492
1492
|
describe Pointcut, ".new (:attributes => :all option not yet supported)" do
|
1493
1493
|
it "should raise if :all is used for types (not yet supported)." do
|
1494
|
-
|
1494
|
+
expect { Pointcut.new :types => "ClassWithAttribs", :attributes => :all }.to raise_error(Aquarium::Utils::InvalidOptions)
|
1495
1495
|
end
|
1496
1496
|
|
1497
1497
|
it "should raise if :all is used for objects (not yet supported)." do
|
1498
|
-
|
1498
|
+
expect { Pointcut.new :object => ClassWithAttribs.new, :attributes => :all }.to raise_error(Aquarium::Utils::InvalidOptions)
|
1499
1499
|
end
|
1500
1500
|
end
|
1501
1501
|
|
1502
1502
|
describe Pointcut, ".new (:accessing => :all option not yet supported)" do
|
1503
1503
|
it "should raise if :all is used for types (not yet supported)." do
|
1504
|
-
|
1504
|
+
expect { Pointcut.new :types => "ClassWithAttribs", :accessing => :all }.to raise_error(Aquarium::Utils::InvalidOptions)
|
1505
1505
|
end
|
1506
1506
|
|
1507
1507
|
it "should raise if :all is used for objects (not yet supported)." do
|
1508
|
-
|
1508
|
+
expect { Pointcut.new :object => ClassWithAttribs.new, :accessing => :all }.to raise_error(Aquarium::Utils::InvalidOptions)
|
1509
1509
|
end
|
1510
1510
|
end
|
1511
1511
|
|
1512
1512
|
describe Pointcut, ".new (:changing => :all option not yet supported)" do
|
1513
1513
|
it "should raise if :all is used for types (not yet supported)." do
|
1514
|
-
|
1514
|
+
expect { Pointcut.new :types => "ClassWithAttribs", :changing => :all }.to raise_error(Aquarium::Utils::InvalidOptions)
|
1515
1515
|
end
|
1516
1516
|
|
1517
1517
|
it "should raise if :all is used for objects (not yet supported)." do
|
1518
|
-
|
1518
|
+
expect { Pointcut.new :object => ClassWithAttribs.new, :changing => :all }.to raise_error(Aquarium::Utils::InvalidOptions)
|
1519
1519
|
end
|
1520
1520
|
end
|
1521
1521
|
|
1522
1522
|
describe Pointcut, ".new (:reading => :all option not yet supported)" do
|
1523
1523
|
it "should raise if :all is used for types (not yet supported)." do
|
1524
|
-
|
1524
|
+
expect { Pointcut.new :types => "ClassWithAttribs", :reading => :all }.to raise_error(Aquarium::Utils::InvalidOptions)
|
1525
1525
|
end
|
1526
1526
|
|
1527
1527
|
it "should raise if :all is used for objects (not yet supported)." do
|
1528
|
-
|
1528
|
+
expect { Pointcut.new :object => ClassWithAttribs.new, :reading => :all }.to raise_error(Aquarium::Utils::InvalidOptions)
|
1529
1529
|
end
|
1530
1530
|
end
|
1531
1531
|
|
1532
1532
|
describe Pointcut, ".new (:writing => :all option not yet supported)" do
|
1533
1533
|
it "should raise if :all is used for types (not yet supported)." do
|
1534
|
-
|
1534
|
+
expect { Pointcut.new :types => "ClassWithAttribs", :writing => :all }.to raise_error(Aquarium::Utils::InvalidOptions)
|
1535
1535
|
end
|
1536
1536
|
|
1537
1537
|
it "should raise if :all is used for objects (not yet supported)." do
|
1538
|
-
|
1538
|
+
expect { Pointcut.new :object => ClassWithAttribs.new, :writing => :all }.to raise_error(Aquarium::Utils::InvalidOptions)
|
1539
1539
|
end
|
1540
1540
|
end
|
1541
1541
|
|
@@ -1572,10 +1572,10 @@ describe Pointcut, "methods" do
|
|
1572
1572
|
end
|
1573
1573
|
|
1574
1574
|
it "should raise when specifying method options :singleton with :class, :public, :protected, or :private." do
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1575
|
+
expect { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :class]}.to raise_error(Aquarium::Utils::InvalidOptions)
|
1576
|
+
expect { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :public]}.to raise_error(Aquarium::Utils::InvalidOptions)
|
1577
|
+
expect { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :protected]}.to raise_error(Aquarium::Utils::InvalidOptions)
|
1578
|
+
expect { Pointcut.new :types => [NotQuiteEmpty, Empty], :methods => :all, :method_options => [:singleton, :private]}.to raise_error(Aquarium::Utils::InvalidOptions)
|
1579
1579
|
end
|
1580
1580
|
end
|
1581
1581
|
|
@@ -4,18 +4,18 @@ require 'aquarium/extensions/regexp'
|
|
4
4
|
describe Regexp, "#empty?" do
|
5
5
|
|
6
6
|
it "should return true for an empty regular expression" do
|
7
|
-
//.empty?.should
|
8
|
-
Regexp.new("").empty?.should
|
7
|
+
//.empty?.should be_truthy
|
8
|
+
Regexp.new("").empty?.should be_truthy
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should return true for an empty regular expression with whitespace" do
|
12
|
-
/ /.empty?.should
|
13
|
-
Regexp.new(" ").empty?.should
|
12
|
+
/ /.empty?.should be_truthy
|
13
|
+
Regexp.new(" ").empty?.should be_truthy
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return false for a non-empty regular expression" do
|
17
|
-
/x/.empty?.should
|
18
|
-
Regexp.new("x").empty?.should
|
17
|
+
/x/.empty?.should be_falsey
|
18
|
+
Regexp.new("x").empty?.should be_falsey
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -13,7 +13,7 @@ describe Aquarium::Extras::DesignByContract, "precondition" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should add advice that raises if the precondition is not satisfied" do
|
16
|
-
|
16
|
+
expect {PreCond.new.action}.to raise_error(Aquarium::Extras::DesignByContract::ContractError)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should add advice that does not raise if the precondition is satisfied" do
|
@@ -33,8 +33,8 @@ describe Aquarium::Extras::DesignByContract, "postcondition" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should add advice that raises if the postcondition is not satisfied" do
|
36
|
-
|
37
|
-
|
36
|
+
expect {PostCond.new.action}.to raise_error(Aquarium::Extras::DesignByContract::ContractError)
|
37
|
+
expect {PostCond.new.action("")}.to raise_error(Aquarium::Extras::DesignByContract::ContractError)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should add advice that does not raise if the postcondition is satisfied" do
|
@@ -64,7 +64,7 @@ describe Aquarium::Extras::DesignByContract, "invariant" do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should add advice that raises if the invariant is not satisfied" do
|
67
|
-
|
67
|
+
expect {InvarCond.new.bad_action}.to raise_error(Aquarium::Extras::DesignByContract::ContractError)
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should add advice that does not raise if the invariant is satisfied" do
|
@@ -90,7 +90,7 @@ describe Aquarium::Extras::DesignByContract, "global enable/disable option" do
|
|
90
90
|
it "should disable creation of the contract aspects when the contracts are disabled" do
|
91
91
|
begin
|
92
92
|
Aquarium::Extras::DesignByContract.disable_all
|
93
|
-
|
93
|
+
expect { ContractEnablement.new.action }.not_to raise_error
|
94
94
|
ensure
|
95
95
|
Aquarium::Extras::DesignByContract.enable_all
|
96
96
|
end
|
@@ -98,6 +98,6 @@ describe Aquarium::Extras::DesignByContract, "global enable/disable option" do
|
|
98
98
|
|
99
99
|
it "should enable creation of the contract aspects when the contracts are enabled" do
|
100
100
|
Aquarium::Extras::DesignByContract.enable_all
|
101
|
-
|
101
|
+
expect { ContractEnablement.new.action }.to raise_error(Aquarium::Extras::DesignByContract::ContractError)
|
102
102
|
end
|
103
103
|
end
|
@@ -37,7 +37,7 @@ describe Aquarium::Finders::FinderResult, "#empty?" do
|
|
37
37
|
result = Aquarium::Finders::FinderResult.new
|
38
38
|
result.matched.should == {}
|
39
39
|
result.not_matched.should == {}
|
40
|
-
result.empty?.should
|
40
|
+
result.empty?.should be_truthy
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should be true if there are no matches, even if there are not_matched values." do
|
@@ -45,7 +45,7 @@ describe Aquarium::Finders::FinderResult, "#empty?" do
|
|
45
45
|
result.matched.should == {}
|
46
46
|
empty_set = Set.new
|
47
47
|
result.not_matched.should == {:a => empty_set, :b => empty_set}
|
48
|
-
result.empty?.should
|
48
|
+
result.empty?.should be_truthy
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -74,7 +74,7 @@ def before_method_finder_spec
|
|
74
74
|
@cpri = ClassWithPrivateClassMethod.new
|
75
75
|
@test_objects = [@pub, @pro, @pri, @cpub, @cpri]
|
76
76
|
|
77
|
-
@
|
77
|
+
@other_methods_lambdaed = []
|
78
78
|
@empty_set = Set.new
|
79
79
|
end
|
80
80
|
|
@@ -86,34 +86,34 @@ describe Aquarium::Finders::MethodFinder, "#find (synonymous input parameters)"
|
|
86
86
|
|
87
87
|
Aquarium::Finders::MethodFinder::CANONICAL_OPTIONS["types"].each do |key|
|
88
88
|
it "should accept :#{key} as a synonym for :types." do
|
89
|
-
|
89
|
+
lambdaed = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mbase/, /^mmodule/]
|
90
90
|
actual = Aquarium::Finders::MethodFinder.new.find key.intern => Derived, :methods => [/^mbase/, /^mmodule/]
|
91
|
-
actual.should ==
|
91
|
+
actual.should == lambdaed
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
Aquarium::Finders::MethodFinder::CANONICAL_OPTIONS["objects"].each do |key|
|
96
96
|
it "should accept :#{key} as a synonym for :objects." do
|
97
97
|
child = Derived.new
|
98
|
-
|
98
|
+
lambdaed = Aquarium::Finders::MethodFinder.new.find :objects => child, :methods => [/^mbase/, /^mmodule/]
|
99
99
|
actual = Aquarium::Finders::MethodFinder.new.find key.intern => child, :methods => [/^mbase/, /^mmodule/]
|
100
|
-
actual.should ==
|
100
|
+
actual.should == lambdaed
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
104
|
Aquarium::Finders::MethodFinder::CANONICAL_OPTIONS["methods"].each do |key|
|
105
105
|
it "should accept :#{key} as a synonym for :methods." do
|
106
|
-
|
106
|
+
lambdaed = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mbase/, /^mmodule/]
|
107
107
|
actual = Aquarium::Finders::MethodFinder.new.find :types => Derived, key.intern => [/^mbase/, /^mmodule/]
|
108
|
-
actual.should ==
|
108
|
+
actual.should == lambdaed
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
112
|
Aquarium::Finders::MethodFinder::CANONICAL_OPTIONS["method_options"].each do |key|
|
113
113
|
it "should accept :#{key} as a synonym for :method_options." do
|
114
|
-
|
114
|
+
lambdaed = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mder/, /^mmod/], :method_options => [:exclude_ancestor_methods], :logger_stream => @logger_stream
|
115
115
|
actual = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mder/, /^mmod/], key.intern => [:exclude_ancestor_methods], :logger_stream => @logger_stream
|
116
|
-
actual.should ==
|
116
|
+
actual.should == lambdaed
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -322,24 +322,24 @@ end
|
|
322
322
|
describe Aquarium::Finders::MethodFinder, "#find (searching for class methods)" do
|
323
323
|
before(:each) do
|
324
324
|
before_method_finder_spec
|
325
|
-
@
|
326
|
-
@
|
325
|
+
@lambdaed_ClassWithPUblicClassMethod = Set.new(ClassWithPublicClassMethod.public_methods.reject{|m| m =~ /^__/}.sort.map{|m| m.intern})
|
326
|
+
@lambdaed_ClassWithPrivateClassMethod = Set.new(ClassWithPrivateClassMethod.public_methods.reject{|m| m =~ /^__/}.sort.map{|m| m.intern})
|
327
327
|
end
|
328
328
|
|
329
329
|
it "should find all class methods specified by regular expression for types when :class is used." do
|
330
330
|
# NOTE: The list of methods defined by Kernel is different for Ruby 1.8 and 1.9.
|
331
|
-
|
332
|
-
|
331
|
+
lambdaed = {}
|
332
|
+
lambdaed[Kernel] = [:respond_to?]
|
333
333
|
if RUBY_VERSION.index("1.8")
|
334
|
-
|
334
|
+
lambdaed[Kernel] += [:chomp!, :chop!]
|
335
335
|
end
|
336
336
|
[Object, Module, Class].each do |clazz|
|
337
|
-
|
337
|
+
lambdaed[clazz] = [:respond_to?]
|
338
338
|
end
|
339
339
|
class_array = [Kernel, Module, Object, Class]
|
340
340
|
actual = Aquarium::Finders::MethodFinder.new.find :types => class_array, :methods => [/^resp.*to\?$/, /^ch.*\!$/], :method_options => :class
|
341
341
|
class_array.each do |c|
|
342
|
-
actual.matched[c].should == Set.new(
|
342
|
+
actual.matched[c].should == Set.new(lambdaed[c])
|
343
343
|
end
|
344
344
|
end
|
345
345
|
|
@@ -347,8 +347,8 @@ describe Aquarium::Finders::MethodFinder, "#find (searching for class methods)"
|
|
347
347
|
actual = Aquarium::Finders::MethodFinder.new.find :types => [ClassWithPublicClassMethod, ClassWithPrivateClassMethod], :methods => :all, :method_options => :class
|
348
348
|
actual.matched.size.should == 2
|
349
349
|
actual.not_matched.size.should == 0
|
350
|
-
actual.matched[ClassWithPublicClassMethod].should == @
|
351
|
-
actual.matched[ClassWithPrivateClassMethod].should == @
|
350
|
+
actual.matched[ClassWithPublicClassMethod].should == @lambdaed_ClassWithPUblicClassMethod
|
351
|
+
actual.matched[ClassWithPrivateClassMethod].should == @lambdaed_ClassWithPrivateClassMethod
|
352
352
|
end
|
353
353
|
|
354
354
|
it "should find any methods that start with double underscores '__' with the :include_system_methods option." do
|
@@ -356,23 +356,23 @@ describe Aquarium::Finders::MethodFinder, "#find (searching for class methods)"
|
|
356
356
|
def self.__foo__; end
|
357
357
|
end
|
358
358
|
actual = Aquarium::Finders::MethodFinder.new.find :types => [WithUnderScores], :methods => :all, :method_options => [:class, :include_system_methods]
|
359
|
-
actual.matched[WithUnderScores].include?(:__foo__).should
|
359
|
+
actual.matched[WithUnderScores].include?(:__foo__).should be_truthy
|
360
360
|
end
|
361
361
|
|
362
362
|
it "should find all public class methods in types when searching with the :all method specification and the :class option." do
|
363
363
|
actual = Aquarium::Finders::MethodFinder.new.find :types => [ClassWithPublicClassMethod, ClassWithPrivateClassMethod], :methods => :all, :method_options => :class
|
364
364
|
actual.matched.size.should == 2
|
365
365
|
actual.not_matched.size.should == 0
|
366
|
-
actual.matched[ClassWithPublicClassMethod].should == @
|
367
|
-
actual.matched[ClassWithPrivateClassMethod].should == @
|
366
|
+
actual.matched[ClassWithPublicClassMethod].should == @lambdaed_ClassWithPUblicClassMethod
|
367
|
+
actual.matched[ClassWithPrivateClassMethod].should == @lambdaed_ClassWithPrivateClassMethod
|
368
368
|
end
|
369
369
|
|
370
370
|
it "should accept :all_methods as a synonym for :all." do
|
371
371
|
actual = Aquarium::Finders::MethodFinder.new.find :types => [ClassWithPublicClassMethod, ClassWithPrivateClassMethod], :methods => :all_methods, :method_options => :class
|
372
372
|
actual.matched.size.should == 2
|
373
373
|
actual.not_matched.size.should == 0
|
374
|
-
actual.matched[ClassWithPublicClassMethod].should == @
|
375
|
-
actual.matched[ClassWithPrivateClassMethod].should == @
|
374
|
+
actual.matched[ClassWithPublicClassMethod].should == @lambdaed_ClassWithPUblicClassMethod
|
375
|
+
actual.matched[ClassWithPrivateClassMethod].should == @lambdaed_ClassWithPrivateClassMethod
|
376
376
|
end
|
377
377
|
|
378
378
|
it "should find all public class methods in types, but not ancestors, when searching with the :all method specification and the :class and :exclude_ancestor_methods options." do
|
@@ -450,7 +450,7 @@ describe Aquarium::Finders::MethodFinder, "#find (searching for instance methods
|
|
450
450
|
def __foo__; end
|
451
451
|
end
|
452
452
|
actual = Aquarium::Finders::MethodFinder.new.find :types => [WithUnderScores], :methods => :all, :method_options => [:include_system_methods]
|
453
|
-
actual.matched[WithUnderScores].include?(:__foo__).should
|
453
|
+
actual.matched[WithUnderScores].include?(:__foo__).should be_truthy
|
454
454
|
end
|
455
455
|
|
456
456
|
it "should find all public instance methods in classes when searching with the :all method specification." do
|
@@ -5,26 +5,26 @@ require File.dirname(__FILE__) + '/pointcut_finder_spec_test_classes'
|
|
5
5
|
|
6
6
|
describe Aquarium::Finders::PointcutFinder, "#find with invalid invocation parameters" do
|
7
7
|
it "should raise if no options are specified." do
|
8
|
-
|
8
|
+
expect { Aquarium::Finders::PointcutFinder.new.find}.to raise_error(Aquarium::Utils::InvalidOptions)
|
9
9
|
end
|
10
10
|
it "should raise if no type options are specified." do
|
11
|
-
|
11
|
+
expect { Aquarium::Finders::PointcutFinder.new.find :matching => :foo}.to raise_error(Aquarium::Utils::InvalidOptions)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe Aquarium::Finders::PointcutFinder, "#find with valid type invocation parameters" do
|
16
16
|
it "should accept :types with a single type." do
|
17
|
-
|
17
|
+
expect { Aquarium::Finders::PointcutFinder.new.find :types => Aquarium::PointcutFinderTestClasses::PointcutConstantHolder1, :noop => true}.not_to raise_error
|
18
18
|
end
|
19
19
|
it "should accept :types with an array of types." do
|
20
|
-
|
20
|
+
expect { Aquarium::Finders::PointcutFinder.new.find :types => [Aquarium::PointcutFinderTestClasses::PointcutConstantHolder1, Aquarium::PointcutFinderTestClasses::PointcutConstantHolder2], :noop => true}.not_to raise_error
|
21
21
|
end
|
22
22
|
it "should accept :types with a regular expression for types." do
|
23
|
-
|
23
|
+
expect { Aquarium::Finders::PointcutFinder.new.find :types => /Aquarium::PointcutFinderTestClasses::PointcutConstantHolder/, :noop => true}.not_to raise_error
|
24
24
|
end
|
25
25
|
Aquarium::Finders::PointcutFinder::CANONICAL_OPTIONS["types"].each do |synonym|
|
26
26
|
it "should accept :#{synonym} as a synonym for :types." do
|
27
|
-
|
27
|
+
expect { Aquarium::Finders::PointcutFinder.new.find synonym.intern => /Aquarium::PointcutFinderTestClasses::PointcutConstantHolder/, :noop => true}.not_to raise_error
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -51,17 +51,17 @@ variants = {'constant and class variable ' => '', 'constant ' => 'constants_', '
|
|
51
51
|
Aquarium::PointcutFinderTestClasses.found_pointcuts_should_match found, eval("Aquarium::PointcutFinderTestClasses.all_#{prefix}pointcuts")
|
52
52
|
end
|
53
53
|
it "should accept :#{prefix}matching with a single pointcut name." do
|
54
|
-
|
54
|
+
expect { Aquarium::Finders::PointcutFinder.new.find "#{prefix}matching".intern => :POINTCUT1, :types => Aquarium::PointcutFinderTestClasses.all_pointcut_classes, :noop => true}.not_to raise_error
|
55
55
|
end
|
56
56
|
it "should accept :#{prefix}matching with an array of pointcut names." do
|
57
|
-
|
57
|
+
expect { Aquarium::Finders::PointcutFinder.new.find "#{prefix}matching".intern => [:POINTCUT1, :POINTCUT2], :types => Aquarium::PointcutFinderTestClasses.all_pointcut_classes, :noop => true}.not_to raise_error
|
58
58
|
end
|
59
59
|
it "should accept :#{prefix}matching with a regular expression for pointcut names." do
|
60
|
-
|
60
|
+
expect { Aquarium::Finders::PointcutFinder.new.find "#{prefix}matching".intern => /POINTCUT/, :types => Aquarium::PointcutFinderTestClasses.all_pointcut_classes, :noop => true}.not_to raise_error
|
61
61
|
end
|
62
62
|
Aquarium::Finders::PointcutFinder::CANONICAL_OPTIONS["#{prefix}matching"].each do |synonym|
|
63
63
|
it "should accept :#{synonym} as a synonym for :#{prefix}matching." do
|
64
|
-
|
64
|
+
expect { Aquarium::Finders::PointcutFinder.new.find synonym.intern => /POINTCUT/, :types => Aquarium::PointcutFinderTestClasses.all_pointcut_classes, :noop => true}.not_to raise_error
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|