C0 code coverage information
Generated on Sun Oct 26 11:18:15 -0500 2008 with rcov 0.8.1.2
Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
1 require File.dirname(__FILE__) + '/../spec_helper'
2 require 'aquarium/utils/type_utils_sample_classes'
3 require 'aquarium/finders/type_finder'
4
5 include Aquarium::Utils
6
7 def purge_actuals actuals
8 # Remove extra stuff inserted by RSpec, Aquarium, and "pretty printer" (rake?), possibly in other specs!
9 actuals.matched_keys.reject do |t2|
10 t2.name.include?("Spec::") or t2.name =~ /Aquarium::(Utils|Extras|Examples|Aspects|PointcutFinderTestClasses)/ or t2.name =~ /^PP/
11 end
12 end
13
14 describe TypeUtils, "#find types and their descendents, using :types_and_descendents" do
15 it "should find the matching types and their descendent subtypes, even in different nested modules." do
16 TypeUtils.sample_types.each do |t|
17 actual = Aquarium::Finders::TypeFinder.new.find :types_and_descendents => (t.name)
18 actual_keys = purge_actuals actual
19 actual_keys.sort{|x,y| x.name <=> y.name}.should == TypeUtils.sample_types_descendents[t].sort{|x,y| x.name <=> y.name}
20 actual.not_matched_keys.should == []
21 end
22 end
23
24 Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["types_and_descendents"].each do |synonym|
25 it "should accept :#{synonym} as a synonym for :types_and_descendents" do
26 lambda {Aquarium::Finders::TypeFinder.new.find synonym.intern => TypeUtils.sample_types, :noop => true}.should_not raise_error(InvalidOptions)
27 end
28 end
29 end
30
31 describe TypeUtils, "#find types subtracting out excluded types and descendents, using :exclude_types_and_descendents" do
32 it "should find the matching types and their descendent subtypes, minus the excluded type hierarchies." do
33 actual = Aquarium::Finders::TypeFinder.new.find :types_and_descendents => ModuleForDescendents, :exclude_types_and_descendents => D1ForDescendents
34 actual_keys = purge_actuals actual
35 expected = TypeUtils.sample_types_descendents[ModuleForDescendents].reject do |c|
36 TypeUtils.sample_types_descendents[D1ForDescendents].include? c
37 end
38 actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}
39 actual.not_matched_keys.should == []
40 end
41
42 Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["exclude_types_and_descendents"].each do |synonym|
43 it "should accept :#{synonym} as a synonym for :exclude_types_and_descendents" do
44 lambda {Aquarium::Finders::TypeFinder.new.find :types_and_descendents => ModuleForDescendents, synonym.intern => D1ForDescendents, :noop => true}.should_not raise_error(InvalidOptions)
45 end
46 end
47 end
48
49
50 describe TypeUtils, "#find types and their ancestors, using :types_and_ancestors" do
51 it "should find the matching types and their ancestors, even in different nested modules." do
52 TypeUtils.sample_types.each do |t|
53 actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => (t.name)
54 actual_keys = purge_actuals actual
55 actual_keys.sort{|x,y| x.name <=> y.name}.should == TypeUtils.sample_types_ancestors[t].sort{|x,y| x.name <=> y.name}
56 actual.not_matched_keys.should == []
57 end
58 end
59
60 Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["types_and_ancestors"].each do |synonym|
61 it "should accept :#{synonym} as a synonym for :types_and_ancestors" do
62 lambda {Aquarium::Finders::TypeFinder.new.find synonym.intern => TypeUtils.sample_types, :noop => true}.should_not raise_error(InvalidOptions)
63 end
64 end
65 end
66
67
68 describe TypeUtils, "#find types subtracting out excluded types and ancestors, using :exclude_types_and_ancestors" do
69 it "should find the matching types and their ancestors, minus the excluded types and ancestors." do
70 actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => D1ForDescendents, :exclude_types_and_ancestors => ModuleForDescendents
71 actual_keys = purge_actuals actual
72 expected = TypeUtils.sample_types_ancestors[D1ForDescendents].reject do |c|
73 TypeUtils.sample_types_ancestors[ModuleForDescendents].include? c
74 end
75 actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}
76 actual.not_matched_keys.should == []
77 end
78
79 Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["exclude_types_and_ancestors"].each do |synonym|
80 it "should accept :#{synonym} as a synonym for :exclude_types_and_ancestors" do
81 lambda {Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => D1ForDescendents, synonym.intern => ModuleForDescendents, :noop => true}.should_not raise_error(InvalidOptions)
82 end
83 end
84 end
85
86
87 describe TypeUtils, "#find types and their descendents and ancestors" do
88 it "should find the matching types and their descendents and ancestors, even in different nested modules." do
89 TypeUtils.sample_types.each do |t|
90 actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => (t.name), :types_and_descendents => (t.name)
91 actual_keys = purge_actuals actual
92 expected = TypeUtils.sample_types_ancestors[t] + TypeUtils.sample_types_descendents[t]
93 actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}.uniq
94 actual.not_matched_keys.should == []
95 end
96 end
97 end
98
99 describe TypeUtils, "#find types subtracting out excluded types and their descendents and ancestors" do
100 it "should find the matching types and their descendents and ancestors, minus the excluded types and their descendents and ancestors." do
101 actual = Aquarium::Finders::TypeFinder.new.find \
102 :types_and_ancestors => Aquarium::ForDescendents::NestedD1ForDescendents,
103 :types_and_descendents => Aquarium::ForDescendents::NestedD1ForDescendents,
104 :exclude_types_and_ancestors => Aquarium::ForDescendents::NestedD2ForDescendents,
105 :exclude_types_and_descendents => Aquarium::ForDescendents::NestedD2ForDescendents
106 actual_keys = purge_actuals actual
107 expected = [Aquarium::ForDescendents::NestedD1ForDescendents, Aquarium::ForDescendents::NestedD11ForDescendents, Aquarium::ForDescendents::NestedModuleForDescendents]
108 actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}.uniq
109 actual.not_matched_keys.should == []
110 end
111 end
112
113 describe TypeUtils, "#find types and their descendents and ancestors, specified with regular expressions" do
114 it "should find the matching types and their descendents and ancestors, even in different nested modules." do
115 regexs = [/ForDescendents$/, /Aquarium::ForDescendents::.*ForDescendents/]
116 actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => regexs, :types_and_descendents => regexs
117 actual_keys = purge_actuals actual
118 expected = TypeUtils.sample_types_descendents_and_ancestors.keys + [Kernel, Object]
119 actual_keys.size.should == expected.size
120 expected.each do |t|
121 actual_keys.should include(t)
122 end
123 actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}
124 actual.not_matched_keys.should == []
125 end
126 end
127
128 describe TypeUtils, "#find types and their descendents and ancestors, subtracting out excluded types and their descendents and ancestors, specified using regular expressions" do
129 it "should find the matching types and their descendents and ancestors, minus the excluded types and their descendents and ancestors." do
130 actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => /Aquarium::ForDescendents::.*D1ForDescendents/,
131 :types_and_descendents => /Aquarium::ForDescendents::.*D1ForDescendents/,
132 :exclude_types_and_ancestors => /Aquarium::ForDescendents::.*D2ForDescendents/,
133 :exclude_types_and_descendents => /Aquarium::ForDescendents::.*D2ForDescendents/
134 actual_keys = purge_actuals actual
135 expected = [Aquarium::ForDescendents::NestedD1ForDescendents, Aquarium::ForDescendents::NestedD11ForDescendents, Aquarium::ForDescendents::NestedModuleForDescendents]
136 actual_keys.sort{|x,y| x.name <=> y.name}.should == expected.sort{|x,y| x.name <=> y.name}
137 actual.not_matched_keys.should == []
138 end
139 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.