1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2019-01-20 20:38:57 +00:00
parent 58573c33e4
commit 6204e0804b
147 changed files with 2728 additions and 21522 deletions

View file

@ -34,5 +34,42 @@ ruby_version_is "2.5" do
e.full_message(order: :bottom, highlight: false).should =~ /b.rb:2.*a.rb:1/m
end
end
ruby_version_is "2.6" do
it "contains cause of exception" do
begin
begin
raise 'the cause'
rescue
raise 'main exception'
end
rescue => e
exception = e
end
exception.full_message.should include "main exception"
exception.full_message.should include "the cause"
end
it 'contains all the chain of exceptions' do
begin
begin
begin
raise 'origin exception'
rescue
raise 'intermediate exception'
end
rescue
raise 'last exception'
end
rescue => e
exception = e
end
exception.full_message.should include "last exception"
exception.full_message.should include "intermediate exception"
exception.full_message.should include "origin exception"
end
end
end
end

View file

@ -0,0 +1,15 @@
require_relative '../../spec_helper'
describe "KeyError" do
ruby_version_is "2.6" do
it "accepts :receiver and :key options" do
receiver = mock("receiver")
key = mock("key")
error = KeyError.new(receiver: receiver, key: key)
error.receiver.should == receiver
error.key.should == key
end
end
end

View file

@ -10,4 +10,15 @@ describe "NameError.new" do
it "should take optional name argument" do
NameError.new("msg","name").name.should == "name"
end
ruby_version_is "2.6" do
it "accepts a :receiver keyword argument" do
receiver = mock("receiver")
error = NameError.new("msg", :name, receiver: receiver)
error.receiver.should == receiver
error.name.should == :name
end
end
end

View file

@ -3,12 +3,23 @@ require_relative 'fixtures/common'
describe "NoMethodError.new" do
it "allows passing method args" do
NoMethodError.new("msg","name","args").args.should == "args"
NoMethodError.new("msg", "name", ["args"]).args.should == ["args"]
end
it "does not require a name" do
NoMethodError.new("msg").message.should == "msg"
end
ruby_version_is "2.6" do
it "accepts a :receiver keyword argument" do
receiver = mock("receiver")
error = NoMethodError.new("msg", :name, receiver: receiver)
error.receiver.should == receiver
error.name.should == :name
end
end
end
describe "NoMethodError#args" do