aquarium 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. data/CHANGES +18 -0
  2. data/README +68 -39
  3. data/RELEASE-PLAN +25 -1
  4. data/UPGRADE +4 -0
  5. data/examples/aspect_design_example.rb +9 -3
  6. data/examples/aspect_design_example_spec.rb +7 -2
  7. data/examples/method_tracing_example.rb +1 -1
  8. data/examples/method_tracing_example_spec.rb +2 -2
  9. data/lib/aquarium/aspects/aspect.rb +53 -60
  10. data/lib/aquarium/aspects/dsl/aspect_dsl.rb +0 -1
  11. data/lib/aquarium/aspects/pointcut.rb +72 -17
  12. data/lib/aquarium/aspects/pointcut_composition.rb +4 -1
  13. data/lib/aquarium/extensions/hash.rb +65 -28
  14. data/lib/aquarium/extensions/set.rb +2 -0
  15. data/lib/aquarium/finders/finder_result.rb +13 -2
  16. data/lib/aquarium/finders/method_finder.rb +54 -28
  17. data/lib/aquarium/finders/type_finder.rb +36 -19
  18. data/lib/aquarium/utils/method_utils.rb +3 -12
  19. data/lib/aquarium/utils/name_utils.rb +27 -1
  20. data/lib/aquarium/version.rb +1 -1
  21. data/spec/aquarium/aspects/aspect_invocation_spec.rb +182 -51
  22. data/spec/aquarium/aspects/aspect_spec.rb +43 -8
  23. data/spec/aquarium/aspects/pointcut_and_composition_spec.rb +32 -3
  24. data/spec/aquarium/aspects/pointcut_or_composition_spec.rb +36 -5
  25. data/spec/aquarium/aspects/pointcut_spec.rb +373 -99
  26. data/spec/aquarium/extensions/hash_spec.rb +129 -38
  27. data/spec/aquarium/finders/finder_result_spec.rb +73 -15
  28. data/spec/aquarium/finders/method_finder_spec.rb +156 -72
  29. data/spec/aquarium/finders/object_finder_spec.rb +1 -0
  30. data/spec/aquarium/finders/type_finder_spec.rb +43 -0
  31. data/spec/aquarium/utils/name_utils_spec.rb +79 -4
  32. metadata +3 -3
@@ -4,31 +4,28 @@ require 'aquarium/extensions/hash'
4
4
  require 'aquarium/utils/array_utils'
5
5
  require 'aquarium/utils/hash_utils'
6
6
  require 'set'
7
-
8
- describe Hash, "#intersection" do
9
- include Aquarium::Utils::ArrayUtils
10
- include Aquarium::Utils::HashUtils
11
-
12
- before(:each) do
13
- @hash = {:a => 'a', :b => [:b1, :b2], :c => 'c'}
14
- end
15
7
 
16
- it "should return the same hash if intersected with itself." do
17
- @hash.intersection(@hash).should == @hash
18
- end
19
-
20
- it "should return the same hash if intersected with an equivalent hash." do
21
- @hash.intersection({:a => 'a', :b => [:b1, :b2], :c => 'c'}).should == @hash
22
- end
23
-
24
- it "should return an empty hash if one of the input hashes is empty." do
25
- {}.intersection(@hash).should == {}
26
- end
8
+ class CC
9
+ include Comparable
10
+ def initialize i
11
+ @value = i
12
+ end
13
+ attr_reader :value
14
+ def == other
15
+ value == other.value
16
+ end
17
+ def <=>
18
+ value <=> other.value
19
+ end
20
+ end
27
21
 
28
- it "should return the common subset hash for two, non-equivalent hashes." do
29
- hash2 = {:b =>:b1, :c => 'c', :d => 'd'}
30
- @hash.intersection(hash2){|values1, values2| Set.new(make_array(values1)).intersection(Set.new(make_array(values2)))}.should == {:b =>Set.new([:b1]), :c => 'c'}
31
- end
22
+ def before_hash_spec
23
+ @c1 = CC.new(1)
24
+ @c2 = CC.new(2)
25
+ @c3 = CC.new(3)
26
+ @cc1 = [@c1, @c2]
27
+ @cc2 = [@c2, @c3]
28
+ @hash = {:a => ['a1'], :b => [:b1, :b2], :c => @cc1}
32
29
  end
33
30
 
34
31
  describe "intersection of hashes", :shared => true do
@@ -36,25 +33,30 @@ describe "intersection of hashes", :shared => true do
36
33
  include Aquarium::Utils::HashUtils
37
34
 
38
35
  before(:each) do
39
- @hash = {:a => 'a', :b => [:b1, :b2], :c => 'c'}
36
+ before_hash_spec
40
37
  end
41
38
 
42
39
  it "should return the same hash if intersected with itself." do
43
- @hash.intersection(@hash).should == @hash
40
+ @hash.and(@hash).should == @hash
44
41
  end
45
42
 
46
43
  it "should return the same hash if intersected with an equivalent hash." do
47
- @hash.intersection({:a => 'a', :b => [:b1, :b2], :c => 'c'}).should == @hash
44
+ @hash.and({:a => ['a1'], :b => [:b1, :b2], :c => @cc1}).should == @hash
48
45
  end
49
46
 
50
47
  it "should return an empty hash if one of the input hashes is empty." do
51
- {}.intersection(@hash).should == {}
48
+ {}.and(@hash).should == {}
52
49
  end
53
50
 
54
- it "should return the common subset hash for two, non-equivalent hashes." do
55
- hash2 = {:b =>:b1, :c => 'c', :d => 'd'}
56
- @hash.intersection(hash2){|value1, value2| Set.new(make_array(value1)).intersection(Set.new(make_array(value2)))}.should == {:b =>Set.new([:b1]), :c => 'c'}
51
+ it "should return the common subset hash for two, if the values respond to #&." do
52
+ hash2 = {:b => [:b1], :c => @cc2, :d => ['d']}
53
+ @hash.and(hash2).should == {:b => [:b1], :c => [@c2]}
57
54
  end
55
+
56
+ it "should return the common subset of hash values for partially-overlapping keys as specified by a given block." do
57
+ hash2 = {:b =>:b1, :c => @cc2, :d => 'd'}
58
+ @hash.and(hash2){|value1, value2| Set.new(make_array(value1)).intersection(Set.new(make_array(value2)))}.should == {:b => Set.new([:b1]), :c => Set.new([@c2])}
59
+ end
58
60
  end
59
61
 
60
62
  describe Hash, "#intersection" do
@@ -65,12 +67,20 @@ describe Hash, "#and" do
65
67
  it_should_behave_like "intersection of hashes"
66
68
  end
67
69
 
70
+ describe Hash, "#&" do
71
+ it_should_behave_like "intersection of hashes"
72
+
73
+ it "should support operator-style semantics" do
74
+ ({:a => ['a1', 'a2'], :c => @cc1} & {:a => ['a1'], :b => [:b1, :b2], :c => @cc2}).should == {:a => ['a1'], :c => [@c2]}
75
+ end
76
+ end
77
+
68
78
  describe "union of hashes", :shared => true do
69
79
  include Aquarium::Utils::ArrayUtils
70
80
  include Aquarium::Utils::HashUtils
71
81
 
72
82
  before(:each) do
73
- @hash = {:a => 'a', :b => [:b1, :b2], :c => 'c'}
83
+ before_hash_spec
74
84
  end
75
85
 
76
86
  it "should return the same hash if unioned with itself." do
@@ -78,7 +88,7 @@ describe "union of hashes", :shared => true do
78
88
  end
79
89
 
80
90
  it "should return the same hash if unioned with an equivalent hash." do
81
- @hash.union({:a => 'a', :b => [:b1, :b2], :c => 'c'}).should == @hash
91
+ @hash.union({:a => ['a1'], :b => [:b1, :b2], :c => @cc1}).should == @hash
82
92
  end
83
93
 
84
94
  it "should return a hash that is equivalent to the non-empty hash if the other hash is empty." do
@@ -90,14 +100,19 @@ describe "union of hashes", :shared => true do
90
100
  @hash.union(nil).should == @hash
91
101
  end
92
102
 
93
- it "should return a hash equivalent to the output of Hash#merge for two, non-equivalent hashes, with no block given." do
94
- hash2 = {:b =>:b3, :c => 'c2', :d => 'd'}
95
- @hash.union(hash2).should == {:a => 'a', :b => :b3, :c => 'c2', :d => 'd'}
103
+ it "should return the combined hash value, if the values respond to #|." do
104
+ hash2 = {:b => [:b3], :c => @cc2, :d => ['d']}
105
+ @hash.union(hash2).should == {:a => ['a1'], :b => [:b1, :b2, :b3], :c => [@c1, @c2, @c3], :d => ['d']}
106
+ end
107
+
108
+ it "should return a hash equivalent to the output of Hash#merge for two, non-equivalent hashes, with no block given and values don't respond to #|." do
109
+ hash2 = {:b => :b3, :c => @cc2, :d => 'd'}
110
+ @hash.union(hash2).should == {:a => ['a1'], :b => :b3, :c => [@c1, @c2, @c3], :d => 'd'}
96
111
  end
97
112
 
98
- it "should return the combined hashes for two, non-equivalent hashes, with a block given to merge values into an array." do
99
- hash2 = {:b =>:b3, :c => 'c2', :d => 'd'}
100
- @hash.union(hash2){|value1, value2| Set.new(make_array(value1)).union(Set.new(make_array(value2)))}.should == {:a => 'a', :b => Set.new([:b1, :b2, :b3]), :c => Set.new(['c', 'c2']), :d => 'd'}
113
+ it "should return the combined hash values as specified by a given block." do
114
+ hash2 = {:b => :b3, :c => @cc2, :d => 'd'}
115
+ @hash.union(hash2){|value1, value2| Set.new(make_array(value1)).union(Set.new(make_array(value2)))}.should == {:a => Set.new(['a1']), :b => Set.new([:b1, :b2, :b3]), :c => Set.new([@c1, @c2, @c3]), :d => Set.new(['d'])}
101
116
  end
102
117
  end
103
118
 
@@ -107,6 +122,82 @@ end
107
122
 
108
123
  describe Hash, "#or" do
109
124
  it_should_behave_like "union of hashes"
125
+ end
126
+
127
+ describe Hash, "#|" do
128
+ it_should_behave_like "union of hashes"
129
+
130
+ it "should support operator-style semantics" do
131
+ ({:a => ['a1'], :d => ['d']} | {:a => ['a2'], :b => [:b1, :b2], :c => @cc2}).should == {:a => ['a1', 'a2'], :b => [:b1, :b2], :c => @cc2, :d => ['d']}
132
+ end
133
+ end
134
+
135
+
136
+ describe "subtraction of hashes", :shared => true do
137
+ include Aquarium::Utils::ArrayUtils
138
+ include Aquarium::Utils::HashUtils
139
+
140
+ before(:each) do
141
+ before_hash_spec
142
+ # override value:
143
+ @hash = {:a => ['a1', 'a2'], :b => [:b1, :b2], :c => @cc1}
144
+ end
145
+
146
+ it "should return an empty hash if subtracted from itself." do
147
+ (@hash - @hash).should be_empty
148
+ end
149
+
150
+ it "should return an empty hash if an equivalent hash is subtracted from it." do
151
+ (@hash - {:a => ['a1', 'a2'], :b => [:b1, :b2], :c => @cc1}).should be_empty
152
+ end
153
+
154
+ it "should return an equivalent hash if the second hash is empty." do
155
+ (@hash - {}).should == @hash
156
+ end
157
+
158
+ it "should return an equivalent hash if the second hash is nil." do
159
+ (@hash - nil).should == @hash
160
+ end
161
+
162
+ it "should return an empty hash if the first hash is empty, independent of the second hash." do
163
+ ({} - @hash).should be_empty
164
+ end
165
+
166
+ it "should return a hash with all keys in the second hash removed, independent of the corresponding values, if no block is given." do
167
+ hash2 = {:b =>:b3, :c => 'c', :d => 'd'}
168
+ (@hash - hash2).should == {:a => ['a1', 'a2']}
169
+ end
170
+
171
+ it "should return a hash with the values subtraced for partially-overlapping keys as specified by a given block." do
172
+ hash2 = {:b =>:b2, :c => @cc2, :d => 'd'}
173
+ @hash.minus(hash2) do |value1, value2|
174
+ Set.new(make_array(value1)) - Set.new(make_array(value2))
175
+ end.should == {:a => Set.new(['a1', 'a2']), :b => Set.new([:b1]), :c => Set.new([@c1])}
176
+ end
177
+
178
+ it "should be not associative." do
179
+ hash1 = {:a => :a1, :b =>:b1, :c => :c1, :d => :d1}
180
+ hash2 = {:b =>:b3, :c => 'c'}
181
+ hash3 = {:a =>:a4, :c => 'c'}
182
+ ((hash1 - hash2) - hash3).should == {:d => :d1}
183
+ (hash1 - (hash2 - hash3)).should == {:a => :a1, :c => :c1, :d => :d1}
184
+ end
185
+ end
186
+
187
+ describe Hash, "#minus" do
188
+ it_should_behave_like "subtraction of hashes"
189
+ end
190
+
191
+ describe Hash, "#-" do
192
+ it_should_behave_like "subtraction of hashes"
193
+
194
+ it "should support operator-style semantics" do
195
+ hash1 = {:a => :a1, :b =>:b1, :c => :c1, :d => :d1}
196
+ hash2 = {:b =>:b3, :c => 'c'}
197
+ hash3 = {:a =>:a4, :c => 'c'}
198
+ ((hash1 - hash2) - hash3).should == {:d => :d1}
199
+ (hash1 - (hash2 - hash3)).should == {:a => :a1, :c => :c1, :d => :d1}
200
+ end
110
201
  end
111
202
 
112
203
  describe Hash, "#eql_when_keys_compared?" do
@@ -13,7 +13,7 @@ describe Aquarium::Finders::FinderResult, "#initialize" do
13
13
  result = Aquarium::Finders::FinderResult.new
14
14
  result.matched.should == {}
15
15
  result.not_matched.should == {}
16
- result.empty?.should be_true
16
+ result.should be_empty
17
17
  end
18
18
 
19
19
  it "should accept a value for the :not_matched parameter and convert it into a hash with the input value as the key and an empty set as the corresponding value" do
@@ -158,14 +158,14 @@ describe "union of finder results", :shared => true do
158
158
  result1 = Aquarium::Finders::FinderResult.new
159
159
  result2 = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
160
160
  result = result1.or result2
161
- result.should eql(result2)
161
+ result.should be_eql(result2)
162
162
  end
163
163
 
164
164
  it "should return a FinderResult equal to the first, non-empty FinderResult if the second FinderResult is empty." do
165
165
  result1 = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
166
166
  result2 = Aquarium::Finders::FinderResult.new
167
167
  result = result1.or result2
168
- result.should eql(result1)
168
+ result.should be_eql(result1)
169
169
  end
170
170
 
171
171
  it "should return a FinderResult that is the union of self and the second FinderResult." do
@@ -180,8 +180,8 @@ describe "union of finder results", :shared => true do
180
180
  result1 = Aquarium::Finders::FinderResult.new :not_matched => {:b => 'b', :c => 'c'}, :a => [:a1, :a2]
181
181
  result2 = Aquarium::Finders::FinderResult.new :not_matched => {:b => 'b', :c => 'c'}, :a => [:a1, :a2]
182
182
  result = result1.or result2
183
- result.should eql(result1)
184
- result.should eql(result2)
183
+ result.should be_eql(result1)
184
+ result.should be_eql(result2)
185
185
  end
186
186
 
187
187
  it "should be commutative." do
@@ -189,7 +189,7 @@ describe "union of finder results", :shared => true do
189
189
  result2 = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
190
190
  result12 = result1.or result2
191
191
  result21 = result2.or result1
192
- result12.should eql(result21)
192
+ result12.should be_eql(result21)
193
193
  end
194
194
 
195
195
  it "should be associative." do
@@ -198,7 +198,7 @@ describe "union of finder results", :shared => true do
198
198
  result3 = Aquarium::Finders::FinderResult.new :c => [:c1, :c2]
199
199
  result123a = (result1.or result2).or result3
200
200
  result123b = result1.or(result2.or(result3))
201
- result123a.should eql(result123b)
201
+ result123a.should be_eql(result123b)
202
202
  end
203
203
  end
204
204
 
@@ -208,20 +208,32 @@ end
208
208
  describe Aquarium::Finders::FinderResult, "#or" do
209
209
  it_should_behave_like "union of finder results"
210
210
  end
211
+ describe Aquarium::Finders::FinderResult, "#|" do
212
+ it_should_behave_like "union of finder results"
213
+
214
+ it "should support operator-style semantics" do
215
+ result1 = Aquarium::Finders::FinderResult.new :not_matched => {:b => 'b', :c => 'c'}, :a => [:a1, :a2]
216
+ result2 = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
217
+ result3 = Aquarium::Finders::FinderResult.new :c => [:c1, :c2]
218
+ result123a = (result1 | result2) | result3
219
+ result123b = result1 | (result2 | result3)
220
+ result123a.should be_eql(result123b)
221
+ end
222
+ end
211
223
 
212
224
  describe "intersection of finder results", :shared => true do
213
225
  it "should return an empty FinderResult if self is empty." do
214
226
  result1 = Aquarium::Finders::FinderResult.new
215
227
  result2 = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
216
228
  result = result1.and result2
217
- result.should eql(result1)
229
+ result.should be_eql(result1)
218
230
  end
219
231
 
220
232
  it "should return an empty FinderResult if the second FinderResult is empty." do
221
233
  result1 = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
222
234
  result2 = Aquarium::Finders::FinderResult.new
223
235
  result = result1.and result2
224
- result.should eql(result2)
236
+ result.should be_eql(result2)
225
237
  end
226
238
 
227
239
  it "should return an empty FinderResult if there is no overlap between the two FinderResults." do
@@ -244,8 +256,8 @@ describe "intersection of finder results", :shared => true do
244
256
  result1 = Aquarium::Finders::FinderResult.new :not_matched => {:b => 'b', :c => 'c'}, :a => [:a1, :a2]
245
257
  result2 = Aquarium::Finders::FinderResult.new :not_matched => {:b => 'b', :c => 'c'}, :a => [:a1, :a2]
246
258
  result = result1.and result2
247
- result.should eql(result1)
248
- result.should eql(result2)
259
+ result.should be_eql(result1)
260
+ result.should be_eql(result2)
249
261
  end
250
262
 
251
263
  it "should be commutative." do
@@ -253,7 +265,7 @@ describe "intersection of finder results", :shared => true do
253
265
  result2 = Aquarium::Finders::FinderResult.new :not_matched => {:b => [:b1, :b2]}, :a => [:a1]
254
266
  result12 = result1.and result2
255
267
  result21 = result2.and result1
256
- result12.should eql(result21)
268
+ result12.should be_eql(result21)
257
269
  end
258
270
 
259
271
  it "should be associative." do
@@ -262,7 +274,7 @@ describe "intersection of finder results", :shared => true do
262
274
  result3 = Aquarium::Finders::FinderResult.new :not_matched => {:b => [:b1]}, :a => [:a1]
263
275
  result123a = (result1.and result2).and result3
264
276
  result123b = result1.and(result2.and(result3))
265
- result123a.should eql(result123b)
277
+ result123a.should be_eql(result123b)
266
278
  end
267
279
  end
268
280
 
@@ -272,6 +284,52 @@ end
272
284
  describe Aquarium::Finders::FinderResult, "#and" do
273
285
  it_should_behave_like "intersection of finder results"
274
286
  end
287
+ describe Aquarium::Finders::FinderResult, "#&" do
288
+ it_should_behave_like "union of finder results"
289
+
290
+ it "should support operator-style semantics" do
291
+ result1 = Aquarium::Finders::FinderResult.new :not_matched => {:b => 'b', :c => 'c'}, :a => [:a1, :a2]
292
+ result2 = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
293
+ result3 = Aquarium::Finders::FinderResult.new :c => [:c1, :c2]
294
+ result123a = (result1 & result2) & result3
295
+ result123b = result1 & (result2 & result3)
296
+ result123a.should be_eql(result123b)
297
+ end
298
+ end
299
+
300
+
301
+ describe "subtraction of finder results", :shared => true do
302
+ it "should return an empty FinderResult if self is substracted from itself." do
303
+ result = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
304
+ (result - result).should be_empty
305
+ end
306
+
307
+ it "should not be associative" do
308
+ result1 = Aquarium::Finders::FinderResult.new :a => [:a1, :a2], :b => [:b1, :b2], :not_matched => {:c => [:c1, :c2]}
309
+ result2 = Aquarium::Finders::FinderResult.new :a => [:a1]
310
+ result3 = Aquarium::Finders::FinderResult.new :not_matched => {:c => [:c1]}
311
+ result123a = (result1 - result2) - result3
312
+ result123b = result1 - (result2 - result3)
313
+ result123a.should_not be_eql(result123b)
314
+ end
315
+ end
316
+
317
+ describe Aquarium::Finders::FinderResult, "#minus" do
318
+ it_should_behave_like "subtraction of finder results"
319
+ end
320
+ describe Aquarium::Finders::FinderResult, "#-" do
321
+ it_should_behave_like "subtraction of finder results"
322
+
323
+ it "should support operator-style semantics" do
324
+ result1 = Aquarium::Finders::FinderResult.new :a => [:a1, :a2], :b => [:b1, :b2], :not_matched => {:c => [:c1, :c2]}
325
+ result2 = Aquarium::Finders::FinderResult.new :b => [:b1]
326
+ result3 = Aquarium::Finders::FinderResult.new :not_matched => {:c => [:c1]}
327
+ result123a = (result1 - result2) - result3
328
+ result123b = result1 - (result2 - result3)
329
+ result123a.should_not be_eql(result123b)
330
+ end
331
+ end
332
+
275
333
 
276
334
  describe Aquarium::Finders::FinderResult, "#.append_matched" do
277
335
  it "should not change self, if no arguments are specified." do
@@ -328,7 +386,7 @@ describe "equality", :shared => true do
328
386
  it "should return true for two default objects." do
329
387
  result1 = Aquarium::Finders::FinderResult.new
330
388
  result2 = Aquarium::Finders::FinderResult.new
331
- result1.should eql(result2)
389
+ result1.should be_eql(result2)
332
390
  end
333
391
 
334
392
  it "should return false for two different objects that are equal and map to the same method." do
@@ -340,7 +398,7 @@ describe "equality", :shared => true do
340
398
  it "should return true if a key has a single value that equals the value in a 1-element array for the same key in the other FinderResult." do
341
399
  result1 = Aquarium::Finders::FinderResult.new :a => 'a', :not_matched => {:b => 'b'}
342
400
  result2 = Aquarium::Finders::FinderResult.new :a => ['a'], :not_matched => {:b => ['b']}
343
- result1.should eql(result2)
401
+ result1.should be_eql(result2)
344
402
  end
345
403
 
346
404
  it "should return false for two objects that are different." do
@@ -31,7 +31,7 @@ end
31
31
 
32
32
  # :startdoc:
33
33
 
34
- def common_before
34
+ def before_method_finder_spec
35
35
  @test_classes = [
36
36
  ClassWithPublicInstanceMethod,
37
37
  ClassWithProtectedInstanceMethod,
@@ -51,7 +51,7 @@ end
51
51
 
52
52
  describe Aquarium::Finders::MethodFinder, "#find (synonymous input parameters)" do
53
53
  before(:each) do
54
- common_before
54
+ before_method_finder_spec
55
55
  end
56
56
 
57
57
  it "should accept options :types and :type, which are synonymous." do
@@ -76,7 +76,7 @@ end
76
76
 
77
77
  describe Aquarium::Finders::MethodFinder, "#find (invalid input parameters)" do
78
78
  before(:each) do
79
- common_before
79
+ before_method_finder_spec
80
80
  end
81
81
 
82
82
  it "should raise if unrecognized option specified." do
@@ -93,7 +93,7 @@ end
93
93
 
94
94
  describe Aquarium::Finders::MethodFinder, "#find (input parameters that yield empty results)" do
95
95
  before(:each) do
96
- common_before
96
+ before_method_finder_spec
97
97
  end
98
98
 
99
99
  it "should return empty FinderResult#matched and FinderResult#not_matched hashes by default." do
@@ -123,7 +123,7 @@ end
123
123
 
124
124
  describe Aquarium::Finders::MethodFinder, "#find (input parameters specify no methods)" do
125
125
  before(:each) do
126
- common_before
126
+ before_method_finder_spec
127
127
  end
128
128
 
129
129
  it "should return an empty FinderResult#matched hash and a FinderResult#not_matched hash with the specified objects if no methods are specified." do
@@ -162,7 +162,7 @@ end
162
162
 
163
163
  describe Aquarium::Finders::MethodFinder, "#find (input parameters specify method regular expressions that match nothing)" do
164
164
  before(:each) do
165
- common_before
165
+ before_method_finder_spec
166
166
  end
167
167
 
168
168
  it "should find no methods when searching with one type and with a regexp matching no methods." do
@@ -181,7 +181,7 @@ end
181
181
 
182
182
  describe Aquarium::Finders::MethodFinder, "#find (input parameters specify method names that match nothing)" do
183
183
  before(:each) do
184
- common_before
184
+ before_method_finder_spec
185
185
  end
186
186
 
187
187
  it "should find no methods when searching with a type and with a literal name matching no methods." do
@@ -200,7 +200,7 @@ end
200
200
 
201
201
  describe Aquarium::Finders::MethodFinder, "#find (behavior for derived classes)" do
202
202
  before(:each) do
203
- common_before
203
+ before_method_finder_spec
204
204
  end
205
205
 
206
206
  it "should find Base and Derived methods in the specified class, by default." do
@@ -217,14 +217,14 @@ describe Aquarium::Finders::MethodFinder, "#find (behavior for derived classes)"
217
217
  end
218
218
 
219
219
  it "should find Derived methods only for a type when ancestor methods are suppressed, which also suppresses method overrides." do
220
- actual = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mder/, /^mmod/], :options => [:suppress_ancestor_methods]
220
+ actual = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mder/, /^mmod/], :options => [:exclude_ancestor_methods]
221
221
  actual.matched.size.should == 1
222
222
  actual.matched[Derived].should == Set.new([:mderived1, :mmodule3])
223
223
  end
224
224
 
225
225
  it "should find Derived methods only for an object when ancestor methods are suppressed, which also suppresses method overrides." do
226
226
  child = Derived.new
227
- actual = Aquarium::Finders::MethodFinder.new.find :object => child, :methods => [/^mder/, /^mmodule/], :options => [:suppress_ancestor_methods]
227
+ actual = Aquarium::Finders::MethodFinder.new.find :object => child, :methods => [/^mder/, /^mmodule/], :options => [:exclude_ancestor_methods]
228
228
  actual.matched.size.should == 1
229
229
  actual.matched[child].should == Set.new([:mderived1, :mmodule3])
230
230
  end
@@ -232,7 +232,7 @@ end
232
232
 
233
233
  describe Aquarium::Finders::MethodFinder, "#find (searching for class methods)" do
234
234
  before(:each) do
235
- common_before
235
+ before_method_finder_spec
236
236
  end
237
237
 
238
238
  it "should find all class methods matching a regular expression for types when :class is used." do
@@ -257,8 +257,8 @@ describe Aquarium::Finders::MethodFinder, "#find (searching for class methods)"
257
257
  actual.matched[ClassWithPrivateClassMethod].should == Set.new(ClassWithPrivateClassMethod.public_methods.sort.map{|m| m.intern})
258
258
  end
259
259
 
260
- it "should find all public class methods in types, but not ancestors, when searching with the :all method specification and the :class and :suppress_ancestor_methods options." do
261
- actual = Aquarium::Finders::MethodFinder.new.find :types => [ClassWithPublicClassMethod, ClassWithPrivateClassMethod], :methods => :all, :options => [:class, :suppress_ancestor_methods]
260
+ 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
261
+ actual = Aquarium::Finders::MethodFinder.new.find :types => [ClassWithPublicClassMethod, ClassWithPrivateClassMethod], :methods => :all, :options => [:class, :exclude_ancestor_methods]
262
262
  actual.matched.size.should == 1
263
263
  actual.not_matched.size.should == 1
264
264
  actual.matched[ClassWithPublicClassMethod].should == Set.new([:public_class_test_method])
@@ -268,7 +268,7 @@ end
268
268
 
269
269
  describe Aquarium::Finders::MethodFinder, "#find (searching for instance methods)" do
270
270
  before(:each) do
271
- common_before
271
+ before_method_finder_spec
272
272
  end
273
273
 
274
274
  it "should find all public instance methods in types when searching with the :all method specification." do
@@ -374,7 +374,7 @@ end
374
374
 
375
375
  describe Aquarium::Finders::MethodFinder, "#find (format of results)" do
376
376
  before(:each) do
377
- common_before
377
+ before_method_finder_spec
378
378
  end
379
379
 
380
380
  it "should return found methods for a type as symbols." do
@@ -393,50 +393,134 @@ end
393
393
 
394
394
  describe Aquarium::Finders::MethodFinder, "#find (using :methods => :all)" do
395
395
  before(:each) do
396
- common_before
396
+ before_method_finder_spec
397
397
  end
398
398
 
399
399
  it "should accept :all for the methods argument and find all methods for a type subject to the method options." do
400
- actual = Aquarium::Finders::MethodFinder.new.find :type => ClassWithPublicInstanceMethod, :method => :all, :options => :suppress_ancestor_methods
400
+ actual = Aquarium::Finders::MethodFinder.new.find :type => ClassWithPublicInstanceMethod, :method => :all, :options => :exclude_ancestor_methods
401
401
  actual.matched.size.should == 1
402
402
  actual.matched[ClassWithPublicInstanceMethod].should == Set.new([:public_instance_test_method])
403
403
  end
404
404
 
405
405
  it "should accept :all for the methods argument and find all methods for an object subject to the method options." do
406
406
  pub = ClassWithPublicInstanceMethod.new
407
- actual = Aquarium::Finders::MethodFinder.new.find :object => pub, :method => :all, :options => :suppress_ancestor_methods
407
+ actual = Aquarium::Finders::MethodFinder.new.find :object => pub, :method => :all, :options => :exclude_ancestor_methods
408
408
  actual.matched.size.should == 1
409
409
  actual.matched[pub].should == Set.new([:public_instance_test_method])
410
410
  end
411
411
 
412
412
  it "should ignore other method arguments if :all is present." do
413
- actual = Aquarium::Finders::MethodFinder.new.find :type => ClassWithPublicInstanceMethod, :method => [:all, :none, /.*foo.*/], :methods =>[/.*bar.*/, /^baz/], :options => :suppress_ancestor_methods
413
+ actual = Aquarium::Finders::MethodFinder.new.find :type => ClassWithPublicInstanceMethod, :method => [:all, :none, /.*foo.*/], :methods =>[/.*bar.*/, /^baz/], :options => :exclude_ancestor_methods
414
414
  actual.matched.size.should == 1
415
415
  actual.matched[ClassWithPublicInstanceMethod].should == Set.new([:public_instance_test_method])
416
416
  pub = ClassWithPublicInstanceMethod.new
417
- actual = Aquarium::Finders::MethodFinder.new.find :object => pub, :method => [:all, :none, /.*foo.*/], :methods =>[/.*bar.*/, /^baz/], :options => :suppress_ancestor_methods
417
+ actual = Aquarium::Finders::MethodFinder.new.find :object => pub, :method => [:all, :none, /.*foo.*/], :methods =>[/.*bar.*/, /^baz/], :options => :exclude_ancestor_methods
418
418
  actual.matched.size.should == 1
419
419
  actual.matched[pub].should == Set.new([:public_instance_test_method])
420
420
  end
421
421
 
422
- it "should report [:all] as the not_matched value when :all is the method argument and no methods match, e.g., for :suppress_ancestor_methods." do
423
- actual = Aquarium::Finders::MethodFinder.new.find :type => ClassWithPrivateInstanceMethod, :method => :all, :options => :suppress_ancestor_methods
422
+ it "should report [:all] as the not_matched value when :all is the method argument and no methods match, e.g., for :exclude_ancestor_methods." do
423
+ actual = Aquarium::Finders::MethodFinder.new.find :type => ClassWithPrivateInstanceMethod, :method => :all, :options => :exclude_ancestor_methods
424
424
  actual.matched.size.should == 0
425
425
  actual.not_matched[ClassWithPrivateInstanceMethod].should == Set.new([:all])
426
426
  pri = ClassWithPrivateInstanceMethod.new
427
- actual = Aquarium::Finders::MethodFinder.new.find :object => pri, :method => :all, :options => :suppress_ancestor_methods
427
+ actual = Aquarium::Finders::MethodFinder.new.find :object => pri, :method => :all, :options => :exclude_ancestor_methods
428
428
  actual.matched.size.should == 0
429
429
  actual.not_matched[pri].should == Set.new([:all])
430
430
  end
431
431
  end
432
432
 
433
- describe Aquarium::Finders::MethodFinder, "#find (using :options => :suppress_ancestor_methods)" do
433
+ class ExcludeMethodTester
434
+ def method1; end
435
+ def method2; end
436
+ def method3; end
437
+ end
438
+
439
+ describe Aquarium::Finders::MethodFinder, "#find for types (using :exclude_methods)" do
440
+ it "should return an empty result if :exclude_methods => :all specified." do
441
+ actual = Aquarium::Finders::MethodFinder.new.find :types => ExcludeMethodTester, :methods => :all, :exclude_methods => :all, :options => :exclude_ancestor_methods
442
+ actual.matched.size.should == 0
443
+ actual.not_matched.size.should == 0
444
+ end
445
+
446
+ it "should remove excluded methods from the result where the excluded methods are specified by name." do
447
+ actual = Aquarium::Finders::MethodFinder.new.find :types => ExcludeMethodTester, :methods => :all, :exclude_methods => [:method1, :method2], :options => :exclude_ancestor_methods
448
+ actual.matched.size.should == 1
449
+ actual.matched[ExcludeMethodTester].size.should == 1
450
+ actual.matched[ExcludeMethodTester].should == Set.new([:method3])
451
+ actual.not_matched.size.should == 0
452
+ end
453
+
454
+ it "should remove excluded methods from the result where the excluded methods are specified by regular expression." do
455
+ actual = Aquarium::Finders::MethodFinder.new.find :types => ExcludeMethodTester, :methods => :all, :exclude_methods => /meth.*1$/, :options => :exclude_ancestor_methods
456
+ actual.matched.size.should == 1
457
+ actual.matched[ExcludeMethodTester].size.should == 2
458
+ actual.matched[ExcludeMethodTester].should == Set.new([:method2, :method3])
459
+ actual.not_matched.size.should == 0
460
+ end
461
+
462
+ it "should support :exclude_method as a synonym." do
463
+ actual = Aquarium::Finders::MethodFinder.new.find :types => ExcludeMethodTester, :methods => :all, :exclude_method => :method1, :options => :exclude_ancestor_methods
464
+ actual.matched.size.should == 1
465
+ actual.matched[ExcludeMethodTester].size.should == 2
466
+ actual.matched[ExcludeMethodTester].should == Set.new([:method2, :method3])
467
+ actual.not_matched.size.should == 0
468
+ end
469
+
470
+ it "should not add the excluded methods to the #not_matched results." do
471
+ actual = Aquarium::Finders::MethodFinder.new.find :types => ExcludeMethodTester, :methods => :all, :exclude_methods => /meth.*1$/, :options => :exclude_ancestor_methods
472
+ actual.not_matched.size.should == 0
473
+ end
474
+ end
475
+
476
+ describe Aquarium::Finders::MethodFinder, "#find for objects (using :exclude_methods)" do
477
+ it "should return an empty result if :exclude_methods => :all specified." do
478
+ actual = Aquarium::Finders::MethodFinder.new.find :object => ExcludeMethodTester.new, :methods => :all, :exclude_methods => :all, :options => :exclude_ancestor_methods
479
+ actual.matched.size.should == 0
480
+ actual.not_matched.size.should == 0
481
+ end
482
+
483
+ it "should remove excluded methods from the result where the excluded methods are specified by name." do
484
+ emt = ExcludeMethodTester.new
485
+ actual = Aquarium::Finders::MethodFinder.new.find :object => emt, :methods => :all, :exclude_methods => [:method1, :method2], :options => :exclude_ancestor_methods
486
+ actual.matched.size.should == 1
487
+ actual.matched[emt].size.should == 1
488
+ actual.matched[emt].should == Set.new([:method3])
489
+ actual.not_matched.size.should == 0
490
+ end
491
+
492
+ it "should remove excluded methods from the result where the excluded methods are specified by regular expression." do
493
+ emt = ExcludeMethodTester.new
494
+ actual = Aquarium::Finders::MethodFinder.new.find :object => emt, :methods => :all, :exclude_methods => /meth.*1$/, :options => :exclude_ancestor_methods
495
+ actual.matched.size.should == 1
496
+ actual.matched[emt].size.should == 2
497
+ actual.matched[emt].should == Set.new([:method2, :method3])
498
+ actual.not_matched.size.should == 0
499
+ end
500
+
501
+ it "should support :exclude_method as a synonym." do
502
+ emt = ExcludeMethodTester.new
503
+ actual = Aquarium::Finders::MethodFinder.new.find :object => emt, :methods => :all, :exclude_method => :method1, :options => :exclude_ancestor_methods
504
+ actual.matched.size.should == 1
505
+ actual.matched[emt].size.should == 2
506
+ actual.matched[emt].should == Set.new([:method2, :method3])
507
+ actual.not_matched.size.should == 0
508
+ end
509
+
510
+ it "should not add the excluded methods to the #not_matched results." do
511
+ actual = Aquarium::Finders::MethodFinder.new.find :object => ExcludeMethodTester.new, :methods => :all, :exclude_methods => /meth.*1$/, :options => :exclude_ancestor_methods
512
+ actual.not_matched.size.should == 0
513
+ end
514
+ end
515
+
516
+
517
+ describe Aquarium::Finders::MethodFinder, "#find (using :options => :exclude_ancestor_methods)" do
434
518
  before(:each) do
435
- common_before
519
+ before_method_finder_spec
436
520
  end
437
521
 
438
- it "should suppress ancestor methods for types when :suppress_ancestor_methods is specified." do
439
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :instance, :suppress_ancestor_methods]
522
+ it "should suppress ancestor methods for types when :exclude_ancestor_methods is specified." do
523
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :instance, :exclude_ancestor_methods]
440
524
  actual.matched.size.should == 1
441
525
  actual.matched[ClassWithPublicInstanceMethod].should == Set.new([:public_instance_test_method])
442
526
  actual.not_matched.size.should == 4
@@ -446,8 +530,8 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => :suppress_an
446
530
  actual.not_matched[ClassWithPrivateClassMethod].should == Set.new([/test_method/])
447
531
  end
448
532
 
449
- it "should suppress ancestor methods for objects when :suppress_ancestor_methods is specified." do
450
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :instance, :suppress_ancestor_methods]
533
+ it "should suppress ancestor methods for objects when :exclude_ancestor_methods is specified." do
534
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :instance, :exclude_ancestor_methods]
451
535
  actual.matched.size.should == 1
452
536
  actual.matched[@pub].should == Set.new([:public_instance_test_method])
453
537
  actual.not_matched.size.should == 4
@@ -460,11 +544,11 @@ end
460
544
 
461
545
  describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :instance])" do
462
546
  before(:each) do
463
- common_before
547
+ before_method_finder_spec
464
548
  end
465
549
 
466
550
  it "should find only public instance methods for types when :public, and :instance are specified." do
467
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :instance, :suppress_ancestor_methods]
551
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :instance, :exclude_ancestor_methods]
468
552
  actual.matched.size.should == 1
469
553
  actual.matched[ClassWithPublicInstanceMethod].should == Set.new([:public_instance_test_method])
470
554
  actual.not_matched.size.should == 4
@@ -475,7 +559,7 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :i
475
559
  end
476
560
 
477
561
  it "should find only public instance methods for objects when :public, and :instance are specified." do
478
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :instance, :suppress_ancestor_methods]
562
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :instance, :exclude_ancestor_methods]
479
563
  actual.matched.size.should == 1
480
564
  actual.matched[@pub].should == Set.new([:public_instance_test_method])
481
565
  actual.not_matched.size.should == 4
@@ -488,11 +572,11 @@ end
488
572
 
489
573
  describe Aquarium::Finders::MethodFinder, "#find (using :options => [:protected, :instance])" do
490
574
  before(:each) do
491
- common_before
575
+ before_method_finder_spec
492
576
  end
493
577
 
494
578
  it "should find only protected instance methods when :protected, and :instance are specified." do
495
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:protected, :instance, :suppress_ancestor_methods]
579
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:protected, :instance, :exclude_ancestor_methods]
496
580
  actual.matched.size.should == 1
497
581
  actual.matched[ClassWithProtectedInstanceMethod].should == Set.new([:protected_instance_test_method])
498
582
  actual.not_matched.size.should == 4
@@ -503,7 +587,7 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => [:protected,
503
587
  end
504
588
 
505
589
  it "should find only protected instance methods for objects when :protected, and :instance are specified." do
506
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:protected, :instance, :suppress_ancestor_methods]
590
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:protected, :instance, :exclude_ancestor_methods]
507
591
  actual.matched.size.should == 1
508
592
  actual.matched[@pro].should == Set.new([:protected_instance_test_method])
509
593
  actual.not_matched.size.should == 4
@@ -516,11 +600,11 @@ end
516
600
 
517
601
  describe Aquarium::Finders::MethodFinder, "#find (using :options => [:private, :instance])" do
518
602
  before(:each) do
519
- common_before
603
+ before_method_finder_spec
520
604
  end
521
605
 
522
606
  it "should find only private instance methods when :private, and :instance are specified." do
523
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:private, :instance, :suppress_ancestor_methods]
607
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:private, :instance, :exclude_ancestor_methods]
524
608
  actual.matched.size.should == 1
525
609
  actual.matched[ClassWithPrivateInstanceMethod].should == Set.new([:private_instance_test_method])
526
610
  actual.not_matched.size.should == 4
@@ -531,7 +615,7 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => [:private, :
531
615
  end
532
616
 
533
617
  it "should find only private instance methods for objects when :private, and :instance are specified." do
534
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:private, :instance, :suppress_ancestor_methods]
618
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:private, :instance, :exclude_ancestor_methods]
535
619
  actual.matched.size.should == 1
536
620
  actual.matched[@pri].should == Set.new([:private_instance_test_method])
537
621
  actual.not_matched.size.should == 4
@@ -544,11 +628,11 @@ end
544
628
 
545
629
  describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :class])" do
546
630
  before(:each) do
547
- common_before
631
+ before_method_finder_spec
548
632
  end
549
633
 
550
634
  it "should find only public class methods for types when :public, and :class are specified." do
551
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :class, :suppress_ancestor_methods]
635
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :class, :exclude_ancestor_methods]
552
636
  actual.matched.size.should == 1
553
637
  actual.matched[ClassWithPublicClassMethod].should == Set.new([:public_class_test_method])
554
638
  actual.not_matched.size.should == 4
@@ -559,7 +643,7 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :c
559
643
  end
560
644
 
561
645
  it "should find no public class methods for objects when :public, and :class are specified." do
562
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :class, :suppress_ancestor_methods]
646
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :class, :exclude_ancestor_methods]
563
647
  actual.matched.size.should == 0
564
648
  actual.not_matched.size.should == 5
565
649
  actual.not_matched[@pub].should == Set.new([/test_method/])
@@ -572,11 +656,11 @@ end
572
656
 
573
657
  describe Aquarium::Finders::MethodFinder, "#find (using :options => [:private, :class])" do
574
658
  before(:each) do
575
- common_before
659
+ before_method_finder_spec
576
660
  end
577
661
 
578
662
  it "should find only private class methods for types when :private, and :class are specified." do
579
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:private, :class, :suppress_ancestor_methods]
663
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:private, :class, :exclude_ancestor_methods]
580
664
  actual.matched.size.should == 1
581
665
  actual.matched[ClassWithPrivateClassMethod].should == Set.new([:private_class_test_method])
582
666
  actual.not_matched.size.should == 4
@@ -587,7 +671,7 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => [:private, :
587
671
  end
588
672
 
589
673
  it "should find no private class methods for objects when :private, and :class are specified." do
590
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:private, :class, :suppress_ancestor_methods]
674
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:private, :class, :exclude_ancestor_methods]
591
675
  actual.matched.size.should == 0
592
676
  actual.not_matched.size.should == 5
593
677
  actual.not_matched[@pub].should == Set.new([/test_method/])
@@ -600,11 +684,11 @@ end
600
684
 
601
685
  describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :protected, :instance])" do
602
686
  before(:each) do
603
- common_before
687
+ before_method_finder_spec
604
688
  end
605
689
 
606
690
  it "should find public and protected instance methods for types when :public, :protected, and :instance are specified." do
607
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :protected, :instance, :suppress_ancestor_methods]
691
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :protected, :instance, :exclude_ancestor_methods]
608
692
  actual.matched.size.should == 2
609
693
  actual.matched[ClassWithPublicInstanceMethod].should == Set.new([:public_instance_test_method])
610
694
  actual.matched[ClassWithProtectedInstanceMethod].should == Set.new([:protected_instance_test_method])
@@ -615,7 +699,7 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :p
615
699
  end
616
700
 
617
701
  it "should find public and protected instance methods for objects when :public, :protected, and :instance are specified." do
618
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :protected, :instance, :suppress_ancestor_methods]
702
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :protected, :instance, :exclude_ancestor_methods]
619
703
  actual.matched.size.should == 2
620
704
  actual.matched[@pub].should == Set.new([:public_instance_test_method])
621
705
  actual.matched[@pro].should == Set.new([:protected_instance_test_method])
@@ -628,11 +712,11 @@ end
628
712
 
629
713
  describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :;private, :instance])" do
630
714
  before(:each) do
631
- common_before
715
+ before_method_finder_spec
632
716
  end
633
717
 
634
718
  it "should find public and private instance methods when :public, :private, and :instance are specified." do
635
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :private, :instance, :suppress_ancestor_methods]
719
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :private, :instance, :exclude_ancestor_methods]
636
720
  actual.matched.size.should == 2
637
721
  actual.matched[ClassWithPublicInstanceMethod].should == Set.new([:public_instance_test_method])
638
722
  actual.matched[ClassWithPrivateInstanceMethod].should == Set.new([:private_instance_test_method])
@@ -643,7 +727,7 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :;
643
727
  end
644
728
 
645
729
  it "should find public and private instance methods for objects when :public, :private, and :instance are specified." do
646
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :private, :instance, :suppress_ancestor_methods]
730
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :private, :instance, :exclude_ancestor_methods]
647
731
  actual.matched.size.should == 2
648
732
  actual.matched[@pub].should == Set.new([:public_instance_test_method])
649
733
  actual.matched[@pri].should == Set.new([:private_instance_test_method])
@@ -656,11 +740,11 @@ end
656
740
 
657
741
  describe Aquarium::Finders::MethodFinder, "#find (using :options => [:protected, :private, :instance])" do
658
742
  before(:each) do
659
- common_before
743
+ before_method_finder_spec
660
744
  end
661
745
 
662
746
  it "should find protected and private instance methods when :protected, :private, and :instance are specified." do
663
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:protected, :private, :instance, :suppress_ancestor_methods]
747
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:protected, :private, :instance, :exclude_ancestor_methods]
664
748
  actual.matched.size.should == 2
665
749
  actual.matched[ClassWithProtectedInstanceMethod].should == Set.new([:protected_instance_test_method])
666
750
  actual.matched[ClassWithPrivateInstanceMethod].should == Set.new([:private_instance_test_method])
@@ -671,7 +755,7 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => [:protected,
671
755
  end
672
756
 
673
757
  it "should find protected and private instance methods for objects when :protected, :private, and :instance are specified." do
674
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:protected, :private, :instance, :suppress_ancestor_methods]
758
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:protected, :private, :instance, :exclude_ancestor_methods]
675
759
  actual.matched.size.should == 2
676
760
  actual.matched[@pro].should == Set.new([:protected_instance_test_method])
677
761
  actual.matched[@pri].should == Set.new([:private_instance_test_method])
@@ -684,11 +768,11 @@ end
684
768
 
685
769
  describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :class, :instance])" do
686
770
  before(:each) do
687
- common_before
771
+ before_method_finder_spec
688
772
  end
689
773
 
690
774
  it "should find public class and instance methods for types when :public, :class, and :instance are specified." do
691
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :class, :instance, :suppress_ancestor_methods]
775
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :class, :instance, :exclude_ancestor_methods]
692
776
  actual.matched.size.should == 2
693
777
  actual.matched[ClassWithPublicInstanceMethod].should == Set.new([:public_instance_test_method])
694
778
  actual.matched[ClassWithPublicClassMethod].should == Set.new([:public_class_test_method])
@@ -699,7 +783,7 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :c
699
783
  end
700
784
 
701
785
  it "should find only public instance methods for objects even when :class is specified along with :public and :instance." do
702
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :class, :instance, :suppress_ancestor_methods]
786
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :class, :instance, :exclude_ancestor_methods]
703
787
  actual.matched.size.should == 1
704
788
  actual.matched[@pub].should == Set.new([:public_instance_test_method])
705
789
  actual.not_matched.size.should == 4
@@ -712,11 +796,11 @@ end
712
796
 
713
797
  describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :protected, :class, :instance])" do
714
798
  before(:each) do
715
- common_before
799
+ before_method_finder_spec
716
800
  end
717
801
 
718
802
  it "should find public and protected instance methods when :public, :protected, :class, and :instance are specified." do
719
- actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :protected, :class, :instance, :suppress_ancestor_methods]
803
+ actual = Aquarium::Finders::MethodFinder.new.find :types => @test_classes, :methods => /test_method/, :options => [:public, :protected, :class, :instance, :exclude_ancestor_methods]
720
804
  actual.matched.size.should == 3
721
805
  actual.matched[ClassWithPublicInstanceMethod].should == Set.new([:public_instance_test_method])
722
806
  actual.matched[ClassWithPublicClassMethod].should == Set.new([:public_class_test_method])
@@ -727,7 +811,7 @@ describe Aquarium::Finders::MethodFinder, "#find (using :options => [:public, :p
727
811
  end
728
812
 
729
813
  it "should find only public and protected instance methods for objects even when :class is specified along with :public, :protected, :class, and :instance." do
730
- actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :protected, :class, :instance, :suppress_ancestor_methods]
814
+ actual = Aquarium::Finders::MethodFinder.new.find :objects => @test_objects, :methods => /test_method/, :options => [:public, :protected, :class, :instance, :exclude_ancestor_methods]
731
815
  actual.matched.size.should == 2
732
816
  actual.matched[@pub].should == Set.new([:public_instance_test_method])
733
817
  actual.matched[@pro].should == Set.new([:protected_instance_test_method])
@@ -767,7 +851,7 @@ describe "Aquarium::Finders::MethodFinder#find (looking for singleton methods)"
767
851
  end
768
852
 
769
853
  it "should find type-level singleton methods for types when :singleton is specified." do
770
- actual = Aquarium::Finders::MethodFinder.new.find :types => [NotQuiteEmpty, Empty], :methods => :all, :options => [:singleton, :suppress_ancestor_methods]
854
+ actual = Aquarium::Finders::MethodFinder.new.find :types => [NotQuiteEmpty, Empty], :methods => :all, :options => [:singleton, :exclude_ancestor_methods]
771
855
  actual.matched.size.should == 1
772
856
  actual.matched[NotQuiteEmpty].should == Set.new([:a_class_singleton_method])
773
857
  actual.not_matched.size.should == 1
@@ -820,12 +904,12 @@ end
820
904
 
821
905
  describe "Aquarium::Finders::MethodFinder#find_all_by" do
822
906
  it "should accept :all for the methods argument." do
823
- actual = Aquarium::Finders::MethodFinder.new.find_all_by ClassWithPublicInstanceMethod, :all, :suppress_ancestor_methods
907
+ actual = Aquarium::Finders::MethodFinder.new.find_all_by ClassWithPublicInstanceMethod, :all, :exclude_ancestor_methods
824
908
  actual.matched.size.should == 1
825
909
  actual.matched[ClassWithPublicInstanceMethod].should == Set.new([:public_instance_test_method])
826
910
  actual.not_matched.size.should == 0
827
911
  pub = ClassWithPublicInstanceMethod.new
828
- actual = Aquarium::Finders::MethodFinder.new.find_all_by pub, :all, :suppress_ancestor_methods
912
+ actual = Aquarium::Finders::MethodFinder.new.find_all_by pub, :all, :exclude_ancestor_methods
829
913
  actual.matched.size.should == 1
830
914
  actual.matched[pub].should == Set.new([:public_instance_test_method])
831
915
  actual.not_matched.size.should == 0
@@ -833,35 +917,35 @@ describe "Aquarium::Finders::MethodFinder#find_all_by" do
833
917
 
834
918
  it "should behave like Aquarium::Finders::MethodFinder#find with an explicit parameter list rather than a hash." do
835
919
  expected = Aquarium::Finders::MethodFinder.new.find :types => ClassWithPrivateInstanceMethod,
836
- :methods => /test_method/, :options => [:private, :instance, :suppress_ancestor_methods]
920
+ :methods => /test_method/, :options => [:private, :instance, :exclude_ancestor_methods]
837
921
  actual = Aquarium::Finders::MethodFinder.new.find_all_by ClassWithPrivateInstanceMethod,
838
- /test_method/, :private, :instance, :suppress_ancestor_methods
922
+ /test_method/, :private, :instance, :exclude_ancestor_methods
839
923
  actual.should == expected
840
924
 
841
925
  expected = Aquarium::Finders::MethodFinder.new.find :objects => @pub,
842
- :methods => /test_method/, :options => [:private, :instance, :suppress_ancestor_methods]
926
+ :methods => /test_method/, :options => [:private, :instance, :exclude_ancestor_methods]
843
927
  actual = Aquarium::Finders::MethodFinder.new.find_all_by @pub,
844
- /test_method/, :private, :instance, :suppress_ancestor_methods
928
+ /test_method/, :private, :instance, :exclude_ancestor_methods
845
929
  actual.should == expected
846
930
 
847
931
  expected = Aquarium::Finders::MethodFinder.new.find :types => [ClassWithPublicInstanceMethod, ClassWithPrivateInstanceMethod],
848
- :methods => ["foo", /test_method/], :options => [:instance, :suppress_ancestor_methods]
932
+ :methods => ["foo", /test_method/], :options => [:instance, :exclude_ancestor_methods]
849
933
  actual = Aquarium::Finders::MethodFinder.new.find_all_by [ClassWithPublicInstanceMethod, ClassWithPrivateInstanceMethod],
850
- ["foo", /test_method/], :instance, :suppress_ancestor_methods
934
+ ["foo", /test_method/], :instance, :exclude_ancestor_methods
851
935
  actual.should == expected
852
936
 
853
937
  expected = Aquarium::Finders::MethodFinder.new.find :objects => [@pub, @pri],
854
- :methods => ["foo", /test_method/], :options => [:instance, :suppress_ancestor_methods]
938
+ :methods => ["foo", /test_method/], :options => [:instance, :exclude_ancestor_methods]
855
939
  actual = Aquarium::Finders::MethodFinder.new.find_all_by [@pub, @pri],
856
- ["foo", /test_method/], :instance, :suppress_ancestor_methods
940
+ ["foo", /test_method/], :instance, :exclude_ancestor_methods
857
941
  actual.should == expected
858
942
  end
859
943
  end
860
944
 
861
945
  describe "Aquarium::Finders::MethodFinder.is_recognized_method_option" do
862
946
 
863
- it "should be true for :public, :private, :protected, :instance, :class, and :suppress_ancestor_methods as strings or symbols." do
864
- %w[public private protected instance class suppress_ancestor_methods].each do |s|
947
+ it "should be true for :public, :private, :protected, :instance, :class, and :exclude_ancestor_methods as strings or symbols." do
948
+ %w[public private protected instance class exclude_ancestor_methods].each do |s|
865
949
  Aquarium::Finders::MethodFinder.is_recognized_method_option(s).should == true
866
950
  Aquarium::Finders::MethodFinder.is_recognized_method_option(s.to_sym).should == true
867
951
  end