1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-07-27 12:40:09 +02:00
parent a06301b103
commit 5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions

View file

@ -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