diff options
Diffstat (limited to 'spec/ruby/core/kernel/shared/method.rb')
| -rw-r--r-- | spec/ruby/core/kernel/shared/method.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/spec/ruby/core/kernel/shared/method.rb b/spec/ruby/core/kernel/shared/method.rb index 3418966b1b..82abc287d1 100644 --- a/spec/ruby/core/kernel/shared/method.rb +++ b/spec/ruby/core/kernel/shared/method.rb @@ -4,20 +4,26 @@ describe :kernel_method, shared: true do it "returns a method object for a valid method" do class KernelSpecs::Foo; def bar; 'done'; end; end m = KernelSpecs::Foo.new.send(@method, :bar) - m.should be_an_instance_of Method + m.should.instance_of? Method m.call.should == 'done' end it "returns a method object for a valid singleton method" do class KernelSpecs::Foo; def self.bar; 'class done'; end; end m = KernelSpecs::Foo.send(@method, :bar) - m.should be_an_instance_of Method + m.should.instance_of? Method m.call.should == 'class done' end - it "returns a method object if we repond_to_missing? method" do + it "returns a method object if respond_to_missing?(method) is true" do m = KernelSpecs::RespondViaMissing.new.send(@method, :handled_publicly) - m.should be_an_instance_of Method + m.should.instance_of? Method + m.call(42).should == "Done handled_publicly([42])" + end + + it "the returned method object if respond_to_missing?(method) calls #method_missing with a Symbol name" do + m = KernelSpecs::RespondViaMissing.new.send(@method, "handled_publicly") + m.should.instance_of? Method m.call(42).should == "Done handled_publicly([42])" end @@ -25,12 +31,12 @@ describe :kernel_method, shared: true do class KernelSpecs::Foo; def bar; 'done'; end; end -> { KernelSpecs::Foo.new.send(@method, :invalid_and_silly_method_name) - }.should raise_error(NameError) + }.should.raise(NameError) end it "raises a NameError for an invalid singleton method name" do class KernelSpecs::Foo; def self.bar; 'done'; end; end - -> { KernelSpecs::Foo.send(@method, :baz) }.should raise_error(NameError) + -> { KernelSpecs::Foo.send(@method, :baz) }.should.raise(NameError) end it "changes the method called for super on a target aliased method" do |
