File tree 6 files changed +54
-0
lines changed
6 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -99,12 +99,24 @@ class A
99
99
def baz ( a , b )
100
100
self . class
101
101
end
102
+ def overridden ; end
102
103
end
103
104
104
105
class B < A
106
+ def overridden ; end
107
+ end
108
+
109
+ module BetweenBAndC
110
+ def overridden ; end
105
111
end
106
112
107
113
class C < B
114
+ include BetweenBAndC
115
+ def overridden ; end
116
+ end
117
+
118
+ module OverrideAgain
119
+ def overridden ; end
108
120
end
109
121
110
122
class D
Original file line number Diff line number Diff line change
1
+ require File . expand_path ( '../../../spec_helper' , __FILE__ )
2
+ require File . expand_path ( '../fixtures/classes' , __FILE__ )
3
+
4
+ describe "Method#super_method" do
5
+ it "returns the method that would be called by super in the method" do
6
+ obj = MethodSpecs ::C . new
7
+ obj . extend MethodSpecs ::OverrideAgain
8
+ meth = obj . method ( :overridden )
9
+
10
+ s_meth = meth . super_method
11
+ s_meth . owner . should == MethodSpecs ::C
12
+ s_meth . receiver . should == obj
13
+ s_meth . name . should == :overridden
14
+
15
+ ss_meth = meth . super_method . super_method
16
+ ss_meth . owner . should == MethodSpecs ::BetweenBAndC
17
+ ss_meth . receiver . should == obj
18
+ ss_meth . name . should == :overridden
19
+
20
+ sss_meth = meth . super_method . super_method . super_method
21
+ sss_meth . owner . should == MethodSpecs ::B
22
+ sss_meth . receiver . should == obj
23
+ sss_meth . name . should == :overridden
24
+ end
25
+ end
Original file line number Diff line number Diff line change @@ -73,11 +73,14 @@ class A
73
73
def baz ( a , b )
74
74
return [ __FILE__ , self . class ]
75
75
end
76
+ def overriden ; end
76
77
end
77
78
78
79
class B < A
80
+ def overridden ; end
79
81
end
80
82
81
83
class C < B
84
+ def overridden ; end
82
85
end
83
86
end
Original file line number Diff line number Diff line change
1
+ require File . expand_path ( '../../../spec_helper' , __FILE__ )
2
+ require File . expand_path ( '../fixtures/classes' , __FILE__ )
3
+
4
+ describe "UnboundMethod#super_method" do
5
+ it "returns the method that would be called by super in the method" do
6
+ meth = UnboundMethodSpecs ::C . instance_method ( :overridden )
7
+ meth = meth . super_method
8
+ meth . should == UnboundMethodSpecs ::B . instance_method ( :overridden )
9
+ meth = meth . super_method
10
+ meth . should == UnboundMethodSpecs ::A . instance_method ( :overridden )
11
+ end
12
+ end
Original file line number Diff line number Diff line change
1
+ fails: returns the method that would be called by super in the method
Original file line number Diff line number Diff line change
1
+ fails: returns the method that would be called by super in the method
You can’t perform that action at this time.
0 commit comments