diff options
Diffstat (limited to 'spec/ruby/core/unboundmethod/bind_spec.rb')
-rw-r--r-- | spec/ruby/core/unboundmethod/bind_spec.rb | 16 |
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 |