summaryrefslogtreecommitdiff
path: root/spec/ruby/core/kernel/method_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/kernel/method_spec.rb')
-rw-r--r--spec/ruby/core/kernel/method_spec.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/spec/ruby/core/kernel/method_spec.rb b/spec/ruby/core/kernel/method_spec.rb
index 3fc566d6a6..9187b8c7e7 100644
--- a/spec/ruby/core/kernel/method_spec.rb
+++ b/spec/ruby/core/kernel/method_spec.rb
@@ -11,12 +11,12 @@ describe "Kernel#method" do
it "can be called on a private method" do
@obj.send(:private_method).should == :private_method
- @obj.method(:private_method).should be_an_instance_of(Method)
+ @obj.method(:private_method).should.instance_of?(Method)
end
it "can be called on a protected method" do
@obj.send(:protected_method).should == :protected_method
- @obj.method(:protected_method).should be_an_instance_of(Method)
+ @obj.method(:protected_method).should.instance_of?(Method)
end
it "will see an alias of the original method as == when in a derived class" do
@@ -31,7 +31,7 @@ describe "Kernel#method" do
it "can be called even if we only respond_to_missing? method, true" do
m = KernelSpecs::RespondViaMissing.new.method(:handled_privately)
- m.should be_an_instance_of(Method)
+ m.should.instance_of?(Method)
m.call(1, 2, 3).should == "Done handled_privately([1, 2, 3])"
end
@@ -45,7 +45,7 @@ describe "Kernel#method" do
end
end
m = cls.new.method(:foo)
- -> { m.call }.should raise_error(ArgumentError)
+ -> { m.call }.should.raise(ArgumentError)
cls = Class.new do
def respond_to_missing?(name, *)
@@ -67,14 +67,22 @@ describe "Kernel#method" do
end
it "raises a TypeError if the given name can't be converted to a String" do
- -> { Object.method(nil) }.should raise_error(TypeError)
- -> { Object.method([]) }.should raise_error(TypeError)
+ -> { Object.method(nil) }.should.raise(TypeError)
+ -> { Object.method([]) }.should.raise(TypeError)
end
it "raises a NoMethodError if the given argument raises a NoMethodError during type coercion to a String" do
name = mock("method-name")
name.should_receive(:to_str).and_raise(NoMethodError)
- -> { Object.method(name) }.should raise_error(NoMethodError)
+ -> { Object.method(name) }.should.raise(NoMethodError)
+
+ name = mock("method-name")
+ name.should_receive(:to_str).and_raise(NoMethodError)
+ begin
+ raise RuntimeError.new
+ rescue => cause
+ -> { Object.method(name) }.should.raise(NoMethodError, cause:)
+ end
end
end
end