summaryrefslogtreecommitdiff
path: root/spec/ruby/core/unboundmethod
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-07-27 12:40:09 +0200
committerBenoit Daloze <eregontp@gmail.com>2019-07-27 12:40:09 +0200
commit5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch)
tree05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/core/unboundmethod
parenta06301b103371b0b7da8eaca26ba744961769f99 (diff)
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/core/unboundmethod')
-rw-r--r--spec/ruby/core/unboundmethod/bind_spec.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/spec/ruby/core/unboundmethod/bind_spec.rb b/spec/ruby/core/unboundmethod/bind_spec.rb
index 328c356906..03aaa22e74 100644
--- a/spec/ruby/core/unboundmethod/bind_spec.rb
+++ b/spec/ruby/core/unboundmethod/bind_spec.rb
@@ -10,7 +10,7 @@ describe "UnboundMethod#bind" do
end
it "raises TypeError if object is not kind_of? the Module the method defined in" do
- lambda { @normal_um.bind(UnboundMethodSpecs::B.new) }.should raise_error(TypeError)
+ -> { @normal_um.bind(UnboundMethodSpecs::B.new) }.should raise_error(TypeError)
end
it "returns Method for any object that is kind_of? the Module method was extracted from" do
@@ -21,11 +21,21 @@ describe "UnboundMethod#bind" do
UnboundMethodSpecs::Mod.instance_method(:from_mod).bind(Object.new).should be_kind_of(Method)
end
- it "returns Method returned for obj is equal to one directly returned by obj.method" do
+ it "the returned Method is equal to the one directly returned by obj.method" do
obj = UnboundMethodSpecs::Methods.new
@normal_um.bind(obj).should == obj.method(:foo)
end
+ it "returns Method for any object kind_of? the Module the method is defined in" do
+ @parent_um.bind(UnboundMethodSpecs::Child1.new).should be_kind_of(Method)
+ @child1_um.bind(UnboundMethodSpecs::Parent.new).should be_kind_of(Method)
+ @child2_um.bind(UnboundMethodSpecs::Child1.new).should be_kind_of(Method)
+ end
+
+ it "allows binding a Kernel method retrieved from Object on BasicObject" do
+ Object.instance_method(:instance_of?).bind(BasicObject.new).call(BasicObject).should == true
+ end
+
it "returns a callable method" do
obj = UnboundMethodSpecs::Methods.new
@normal_um.bind(obj).call.should == obj.foo
@@ -46,6 +56,6 @@ describe "UnboundMethod#bind" do
end
end
um = p.method(:singleton_method).unbind
- lambda{ um.bind(other) }.should raise_error(TypeError)
+ ->{ um.bind(other) }.should raise_error(TypeError)
end
end