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/method_utils'
3
4 describe Aquarium::Utils::MethodUtils, ".method_args_to_hash" do
5
6 it "should return an empty hash for no arguments." do
7 Aquarium::Utils::MethodUtils.method_args_to_hash().should == {}
8 end
9
10 it "should return an empty hash for a nil argument." do
11 Aquarium::Utils::MethodUtils.method_args_to_hash(nil).should == {}
12 end
13
14 it "should return a hash with the input arguments as keys and nil for each value, if no block is given and the last argument is not a hash." do
15 Aquarium::Utils::MethodUtils.method_args_to_hash(:a, :b).should == {:a => nil, :b => nil}
16 end
17
18 it "should return a hash with the input arguments as keys and the block result for each value, if a block is given and the last argument is not a hash." do
19 Aquarium::Utils::MethodUtils.method_args_to_hash(:a, :b){|key| key.to_s}.should == {:a => 'a', :b => 'b'}
20 end
21
22 it "should return the input hash if the input arguments consist of a single hash." do
23 Aquarium::Utils::MethodUtils.method_args_to_hash(:a =>'a', :b => 'b'){|key| key.to_s}.should == {:a => 'a', :b => 'b'}
24 end
25
26 it "should return the input hash if the input arguments consist of a single hash, ignoring a given block." do
27 Aquarium::Utils::MethodUtils.method_args_to_hash(:a =>'a', :b => 'b'){|key| key.to_s+key.to_s}.should == {:a => 'a', :b => 'b'}
28 end
29
30 it "should treat a hash that is not at the end of the argument list as a non-hash argument." do
31 hash_arg = {:a =>'a', :b => 'b'}
32 h = Aquarium::Utils::MethodUtils.method_args_to_hash(hash_arg, :c){|key| "foo"}
33 h.size.should == 2
34 h[hash_arg].should == "foo"
35 h[:c].should == "foo"
36 end
37
38 it "should return a hash containing an input hash at the end of the input arguments." do
39 Aquarium::Utils::MethodUtils.method_args_to_hash(:x, :y, :a =>'a', :b => 'b').should == {:a => 'a', :b => 'b', :x => nil, :y => nil}
40 end
41
42 it "should ignore whether or not the trailing input hash is wrapped in {}." do
43 Aquarium::Utils::MethodUtils.method_args_to_hash(:x, :y, {:a =>'a', :b => 'b'}).should == {:a => 'a', :b => 'b', :x => nil, :y => nil}
44 end
45
46 it "should return a hash with the non-hash arguments mapped to key-value pairs with value specified by the input block (or null) and the input unchanged." do
47 Aquarium::Utils::MethodUtils.method_args_to_hash(:x, :y, :a =>'a', :b => 'b'){|a| a.to_s.capitalize}.should == {:a => 'a', :b => 'b', :x => 'X', :y => 'Y'}
48 end
49 end
50
51 class MethodUtilsSpecProtectionExample
52 def public_instance_m; end
53 protected
54 def protected_instance_m; end
55 private
56 def private_instance_m; end
57 def self.public_class_m; end
58 def self.private_class_m; end
59 private_class_method :private_class_m
60 end
61 class MethodUtilsSpecProtectionExample2 < MethodUtilsSpecProtectionExample
62 end
63
64 describe Aquarium::Utils::MethodUtils, ".visibility" do
65 it "should return :public for public class methods on a class" do
66 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :public_class_m).should == :public
67 end
68 it "should return :public for public class methods on a class when only class methods are specified" do
69 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :public_class_m, :class_method_only).should == :public
70 end
71 it "should return nil for public class methods on a class when only instance methods are specified" do
72 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :public_class_m, :instance_method_only).should be_nil
73 end
74
75 it "should return :public for public instance methods on a class" do
76 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :public_instance_m).should == :public
77 end
78 it "should return nil for public instance methods on a class when only class methods are specified" do
79 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :public_instance_m, :class_method_only).should be_nil
80 end
81 it "should return :public for public instance methods on a class when only instance methods are specified" do
82 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :public_instance_m, :instance_method_only).should == :public
83 end
84
85 it "should return nil for public class methods on an instance of a class" do
86 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :public_class_m).should be_nil
87 end
88 it "should return nil for public class methods on an instance of a class when only class methods are specified" do
89 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :public_class_m, :class_method_only).should be_nil
90 end
91 it "should return nil for public class methods on an instance of a class when only instance methods are specified" do
92 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :public_class_m, :instance_method_only).should be_nil
93 end
94
95 it "should return :public for public instance methods on an instance of a class" do
96 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :public_instance_m).should == :public
97 end
98 it "should return nil for public instance methods on an instance of a class when only class methods are specified" do
99 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :public_instance_m, :class_method_only).should be_nil
100 end
101 it "should return :public for public instance methods on an instance of a class when only instance methods are specified" do
102 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :public_instance_m, :instance_method_only).should == :public
103 end
104
105 it "should return :protected for protected instance methods on a class" do
106 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :protected_instance_m).should == :protected
107 end
108 it "should return nil for protected instance methods on a class when only class methods are specified" do
109 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :protected_instance_m, :class_method_only).should be_nil
110 end
111 it "should return :protected for protected instance methods on a class when only instance methods are specified" do
112 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :protected_instance_m, :instance_method_only).should == :protected
113 end
114
115 it "should return :protected for protected instance methods on an instance of a class" do
116 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :protected_instance_m).should == :protected
117 end
118 it "should return nil for protected instance methods on an instance of a class when only class methods are specified" do
119 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :protected_instance_m, :class_method_only).should be_nil
120 end
121 it "should return :protected for protected instance methods on an instance of a class when only instance methods are specified" do
122 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :protected_instance_m, :instance_method_only).should == :protected
123 end
124
125 it "should return :private for private class methods on a class" do
126 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :private_class_m).should == :private #expected_private
127 end
128 it "should return :private for private class methods on a class when only class methods are specified" do
129 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :private_class_m, :class_method_only).should == :private #expected_private
130 end
131 it "should return nil for private class methods on a class when only instance methods are specified" do
132 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :private_class_m, :instance_method_only).should be_nil
133 end
134
135 it "should return :private for private instance methods on a class" do
136 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :private_instance_m).should == :private
137 end
138 it "should return nil for private instance methods on a class when only class methods are specified" do
139 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :private_instance_m, :class_method_only).should be_nil
140 end
141 it "should return :private for private instance methods on a class when only instance methods are specified" do
142 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample, :private_instance_m, :instance_method_only).should == :private
143 end
144
145 it "should return nil for private class methods on an instance of a class" do
146 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :private_class_m).should be_nil
147 end
148 it "should return nil for private class methods on an instance of a class when only class methods are specified" do
149 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :private_class_m, :class_method_only).should be_nil
150 end
151 it "should return nil for private class methods on an instance of a class when only instance methods are specified" do
152 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :private_class_m, :instance_method_only).should be_nil
153 end
154
155 it "should return :private for private instance methods on an instance of a class" do
156 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :private_instance_m).should == :private
157 end
158 it "should return nil for private instance methods on an instance of a class when only class methods are specified" do
159 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :private_instance_m, :class_method_only).should be_nil
160 end
161 it "should return :private for private instance methods on an instance of a class when only instance methods are specified" do
162 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :private_instance_m, :instance_method_only).should == :private
163 end
164
165 it "should ignore whether the exclude_ancestors flag is true or false for class methods when running under MRI" do
166 unless Object.const_defined?('JRUBY_VERSION')
167 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample2, :public_class_m, :class_method_only, false).should == :public
168 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample2, :private_class_m, :class_method_only, false).should == :private
169 end
170 end
171 it "should NOT ignore whether the exclude_ancestors flag is true or false for class methods when running under JRuby" do
172 if Object.const_defined?('JRUBY_VERSION')
173 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample2, :public_class_m, :class_method_only, false).should == nil
174 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample2, :private_class_m, :class_method_only, false).should == nil
175 end
176 end
177
178 it "should return nil for public instance methods on a subclass when the exclude_ancestors flag is false" do
179 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample2, :public_instance_m, :instance_method_only, false).should == nil
180 end
181 it "should return nil for protected instance methods on a subclass when the exclude_ancestors flag is false" do
182 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample2, :protected_instance_m, :instance_method_only, false).should == nil
183 end
184 it "should return nil for private instance methods on a subclass when the exclude_ancestors flag is false" do
185 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample2, :private_instance_m, :instance_method_only, false).should == nil
186 end
187
188 it "should return nil for an unknown method" do
189 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :nonexistent_method).should be_nil
190 end
191 it "should return nil for an unknown method when only class methods are specified" do
192 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :nonexistent_method, :class_method_only).should be_nil
193 end
194 it "should return nil for an unknown method when only instance methods are specified" do
195 Aquarium::Utils::MethodUtils.visibility(MethodUtilsSpecProtectionExample.new, :nonexistent_method, :instance_method_only).should be_nil
196 end
197 end
198
199 describe Aquarium::Utils::MethodUtils, ".has_method" do
200 it "should return true for public class methods on a class" do
201 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :public_class_m).should be_true
202 end
203 it "should return true for public class methods on a class when only class methods are specified" do
204 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :public_class_m, :class_method_only).should be_true
205 end
206 it "should return false for public class methods on a class when only instance methods are specified" do
207 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :public_class_m, :instance_method_only).should be_false
208 end
209
210 it "should return true for public instance methods on a class" do
211 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :public_instance_m).should be_true
212 end
213 it "should return false for public instance methods on a class when only class methods are specified" do
214 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :public_instance_m, :class_method_only).should be_false
215 end
216 it "should return true for public instance methods on a class when only instance methods are specified" do
217 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :public_instance_m, :instance_method_only).should be_true
218 end
219
220 it "should return false for public class methods on an instance of a class" do
221 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :public_class_m).should be_false
222 end
223 it "should return false for public class methods on an instance of a class when only class methods are specified" do
224 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :public_class_m, :class_method_only).should be_false
225 end
226 it "should return false for public class methods on an instance of a class when only instance methods are specified" do
227 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :public_class_m, :instance_method_only).should be_false
228 end
229
230 it "should return true for public instance methods on an instance of a class" do
231 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :public_instance_m).should be_true
232 end
233 it "should return false for public instance methods on an instance of a class when only class methods are specified" do
234 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :public_instance_m, :class_method_only).should be_false
235 end
236 it "should return true for public instance methods on an instance of a class when only instance methods are specified" do
237 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :public_instance_m, :instance_method_only).should be_true
238 end
239
240 it "should return true for protected instance methods on a class" do
241 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :protected_instance_m).should be_true
242 end
243 it "should return false for protected instance methods on a class when only class methods are specified" do
244 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :protected_instance_m, :class_method_only).should be_false
245 end
246 it "should return true for protected instance methods on a class when only instance methods are specified" do
247 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :protected_instance_m, :instance_method_only).should be_true
248 end
249
250 it "should return true for protected instance methods on an instance of a class" do
251 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :protected_instance_m).should be_true
252 end
253 it "should return false for protected instance methods on an instance of a class when only class methods are specified" do
254 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :protected_instance_m, :class_method_only).should be_false
255 end
256 it "should return true for protected instance methods on an instance of a class when only instance methods are specified" do
257 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :protected_instance_m, :instance_method_only).should be_true
258 end
259
260 it "should return true for private class methods on a class" do
261 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :private_class_m).should be_true #expected_private
262 end
263 it "should return true for private class methods on a class when only class methods are specified" do
264 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :private_class_m, :class_method_only).should be_true
265 end
266 it "should return false for private class methods on a class when only instance methods are specified" do
267 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :private_class_m, :instance_method_only).should be_false
268 end
269
270 it "should return true for private instance methods on a class" do
271 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :private_instance_m).should be_true
272 end
273 it "should return false for private instance methods on a class when only class methods are specified" do
274 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :private_instance_m, :class_method_only).should be_false
275 end
276 it "should return true for private instance methods on a class when only instance methods are specified" do
277 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample, :private_instance_m, :instance_method_only).should be_true
278 end
279
280 it "should return false for private class methods on an instance of a class" do
281 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :private_class_m).should be_false
282 end
283 it "should return false for private class methods on an instance of a class when only class methods are specified" do
284 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :private_class_m, :class_method_only).should be_false
285 end
286 it "should return false for private class methods on an instance of a class when only instance methods are specified" do
287 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :private_class_m, :instance_method_only).should be_false
288 end
289
290 it "should return true for private instance methods on an instance of a class" do
291 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :private_instance_m).should be_true
292 end
293 it "should return false for private instance methods on an instance of a class when only class methods are specified" do
294 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :private_instance_m, :class_method_only).should be_false
295 end
296 it "should return true for private instance methods on an instance of a class when only instance methods are specified" do
297 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :private_instance_m, :instance_method_only).should be_true
298 end
299
300 not_string, true_or_false, ruby_name = Object.const_defined?('JRUBY_VERSION') ? ['NOT ', false, 'JRuby'] : ['', true, 'MRI']
301 it "should #{not_string}ignore whether the exclude_ancestors flag is true or false for class methods when running under #{ruby_name}" do
302 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample2, :public_class_m, :class_method_only, false).should == true_or_false
303 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample2, :private_class_m, :class_method_only, false).should == true_or_false
304 end
305
306 it "should return false for public instance methods on a subclass when the exclude_ancestors flag is false" do
307 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample2, :public_instance_m, :instance_method_only, false).should be_false
308 end
309 it "should return false for protected instance methods on a subclass when the exclude_ancestors flag is false" do
310 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample2, :protected_instance_m, :instance_method_only, false).should be_false
311 end
312 it "should return false for private instance methods on a subclass when the exclude_ancestors flag is false" do
313 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample2, :private_instance_m, :instance_method_only, false).should be_false
314 end
315
316 it "should return false for an unknown method" do
317 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :nonexistent_method).should be_false
318 end
319 it "should return false for an unknown method when only class methods are specified" do
320 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :nonexistent_method, :class_method_only).should be_false
321 end
322 it "should return false for an unknown method when only instance methods are specified" do
323 Aquarium::Utils::MethodUtils.has_method(MethodUtilsSpecProtectionExample.new, :nonexistent_method, :instance_method_only).should be_false
324 end
325 end
326
327 module DefinerModule1
328 def m1; end
329 end
330 module DefinerModule2
331 def m2; end
332 end
333 class DefinerClass1
334 include DefinerModule1
335 def c1; end
336 end
337 class DefinerClass2 < DefinerClass1
338 include DefinerModule2
339 def c2; end
340 end
341 class DefinerClass2b < DefinerClass1
342 include DefinerModule2
343 end
344
345 describe Aquarium::Utils::MethodUtils, ".definer" do
346 it "should return the type that defines the method, when given a type" do
347 Aquarium::Utils::MethodUtils.definer(DefinerClass2b, :c1).should == DefinerClass1
348 Aquarium::Utils::MethodUtils.definer(DefinerClass2b, :m1).should == DefinerModule1
349 Aquarium::Utils::MethodUtils.definer(DefinerClass2b, :m2).should == DefinerModule2
350 Aquarium::Utils::MethodUtils.definer(DefinerClass2, :c2).should == DefinerClass2
351 Aquarium::Utils::MethodUtils.definer(DefinerClass2, :c1).should == DefinerClass1
352 Aquarium::Utils::MethodUtils.definer(DefinerClass2, :m1).should == DefinerModule1
353 Aquarium::Utils::MethodUtils.definer(DefinerClass2, :m2).should == DefinerModule2
354 Aquarium::Utils::MethodUtils.definer(DefinerClass1, :c1).should == DefinerClass1
355 Aquarium::Utils::MethodUtils.definer(DefinerClass1, :m1).should == DefinerModule1
356 Aquarium::Utils::MethodUtils.definer(DefinerModule2, :m2).should == DefinerModule2
357 Aquarium::Utils::MethodUtils.definer(DefinerModule1, :m1).should == DefinerModule1
358 end
359
360 it "should return the type that defines the method, when given an object" do
361 Aquarium::Utils::MethodUtils.definer(DefinerClass2b.new, :c1).should == DefinerClass1
362 Aquarium::Utils::MethodUtils.definer(DefinerClass2b.new, :m1).should == DefinerModule1
363 Aquarium::Utils::MethodUtils.definer(DefinerClass2b.new, :m2).should == DefinerModule2
364 Aquarium::Utils::MethodUtils.definer(DefinerClass2.new, :c2).should == DefinerClass2
365 Aquarium::Utils::MethodUtils.definer(DefinerClass2.new, :c1).should == DefinerClass1
366 Aquarium::Utils::MethodUtils.definer(DefinerClass2.new, :m1).should == DefinerModule1
367 Aquarium::Utils::MethodUtils.definer(DefinerClass2.new, :m2).should == DefinerModule2
368 Aquarium::Utils::MethodUtils.definer(DefinerClass1.new, :c1).should == DefinerClass1
369 Aquarium::Utils::MethodUtils.definer(DefinerClass1.new, :m1).should == DefinerModule1
370 end
371
372 it "should return the eigenclass/singleton of an object when the method is defined on the object" do
373 dc = DefinerClass2.new
374 eigen = (class << dc; self; end)
375 def dc.dc1; end
376 Aquarium::Utils::MethodUtils.definer(dc, :dc1).should == eigen
377 end
378
379 it "should return the class of an object when the method is defined on the type or ancestor type, even if the eigenclass has been used to define an instance-only type" do
380 dc = DefinerClass2.new
381 eigen = (class << dc; self; end)
382 def dc.dc2; end
383 Aquarium::Utils::MethodUtils.definer(dc, :c2).should == DefinerClass2
384 Aquarium::Utils::MethodUtils.definer(dc, :m1).should == DefinerModule1
385 Aquarium::Utils::MethodUtils.definer(dc, :m2).should == DefinerModule2
386 end
387
388 it "should return nil if the specified method is defined by a subtype of the specified type" do
389 Aquarium::Utils::MethodUtils.definer(DefinerClass1, :c2).should be_nil
390 Aquarium::Utils::MethodUtils.definer(DefinerModule1, :c2).should be_nil
391 Aquarium::Utils::MethodUtils.definer(DefinerModule2, :c2).should be_nil
392 end
393
394 it "should return nil if the specified method is defined by a subtype of the specified object's type" do
395 Aquarium::Utils::MethodUtils.definer(DefinerClass1.new, :c2).should be_nil
396 Aquarium::Utils::MethodUtils.definer(DefinerClass2b.new, :c2).should be_nil
397 end
398
399 it "should return nil if nil is specified for the type or object" do
400 Aquarium::Utils::MethodUtils.definer(nil, :ignored).should be_nil
401 end
402
403 it "should return nil if nil is specified for the method" do
404 Aquarium::Utils::MethodUtils.definer(DefinerModule1, nil).should be_nil
405 Aquarium::Utils::MethodUtils.definer(DefinerClass1, nil).should be_nil
406 Aquarium::Utils::MethodUtils.definer(DefinerClass1.new, nil).should be_nil
407 end
408 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.