File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11require_relative '../../spec_helper'
22
33describe "Kernel#singleton_method" do
4- it "find a method defined on the singleton class" do
4+ it "finds a method defined on the singleton class" do
55 obj = Object . new
66 def obj . foo ; end
77 obj . singleton_method ( :foo ) . should be_an_instance_of ( Method )
@@ -38,4 +38,48 @@ def foo
3838 e . class . should == NameError
3939 }
4040 end
41+
42+ ruby_bug "#20620" , "" ..."3.4" do
43+ it "finds a method defined in a module included in the singleton class" do
44+ m = Module . new do
45+ def foo
46+ :foo
47+ end
48+ end
49+
50+ obj = Object . new
51+ obj . singleton_class . include ( m )
52+
53+ obj . singleton_method ( :foo ) . should be_an_instance_of ( Method )
54+ obj . singleton_method ( :foo ) . call . should == :foo
55+ end
56+
57+ it "finds a method defined in a module prepended in the singleton class" do
58+ m = Module . new do
59+ def foo
60+ :foo
61+ end
62+ end
63+
64+ obj = Object . new
65+ obj . singleton_class . prepend ( m )
66+
67+ obj . singleton_method ( :foo ) . should be_an_instance_of ( Method )
68+ obj . singleton_method ( :foo ) . call . should == :foo
69+ end
70+
71+ it "finds a method defined in a module that an object is extended with" do
72+ m = Module . new do
73+ def foo
74+ :foo
75+ end
76+ end
77+
78+ obj = Object . new
79+ obj . extend ( m )
80+
81+ obj . singleton_method ( :foo ) . should be_an_instance_of ( Method )
82+ obj . singleton_method ( :foo ) . call . should == :foo
83+ end
84+ end
4185end
You can’t perform that action at this time.
0 commit comments