mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@83063a3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1e658d45e1
commit
3fa5bd38af
494 changed files with 4133 additions and 3109 deletions
|
@ -3,7 +3,7 @@ require File.expand_path('../fixtures/common', __FILE__)
|
|||
require File.expand_path('../shared/new', __FILE__)
|
||||
|
||||
describe "Exception.exception" do
|
||||
it_behaves_like(:exception_new, :exception)
|
||||
it_behaves_like :exception_new, :exception
|
||||
end
|
||||
|
||||
describe "Exception" do
|
||||
|
|
|
@ -53,6 +53,9 @@ module NoMethodErrorSpecs
|
|||
end
|
||||
|
||||
class NoMethodErrorD; end
|
||||
|
||||
class InstanceException < Exception
|
||||
end
|
||||
end
|
||||
|
||||
class NameErrorSpecs
|
||||
|
|
|
@ -3,5 +3,5 @@ require File.expand_path('../fixtures/common', __FILE__)
|
|||
require File.expand_path('../shared/new', __FILE__)
|
||||
|
||||
describe "Exception.new" do
|
||||
it_behaves_like(:exception_new, :new)
|
||||
it_behaves_like :exception_new, :new
|
||||
end
|
||||
|
|
|
@ -56,4 +56,40 @@ describe "NoMethodError#message" do
|
|||
e.message.match(/private method/).should_not == nil
|
||||
end
|
||||
end
|
||||
|
||||
it "calls receiver.inspect only when calling Exception#message" do
|
||||
ScratchPad.record []
|
||||
test_class = Class.new do
|
||||
def inspect
|
||||
ScratchPad << :inspect_called
|
||||
"<inspect>"
|
||||
end
|
||||
end
|
||||
instance = test_class.new
|
||||
begin
|
||||
instance.bar
|
||||
rescue Exception => e
|
||||
e.name.should == :bar
|
||||
ScratchPad.recorded.should == []
|
||||
e.message.should =~ /undefined method.+\bbar\b/
|
||||
ScratchPad.recorded.should == [:inspect_called]
|
||||
end
|
||||
end
|
||||
|
||||
it "fallbacks to a simpler representation of the receiver when receiver.inspect raises an exception" do
|
||||
test_class = Class.new do
|
||||
def inspect
|
||||
raise NoMethodErrorSpecs::InstanceException
|
||||
end
|
||||
end
|
||||
instance = test_class.new
|
||||
begin
|
||||
instance.bar
|
||||
rescue Exception => e
|
||||
e.name.should == :bar
|
||||
message = e.message
|
||||
message.should =~ /undefined method.+\bbar\b/
|
||||
message.should include test_class.inspect
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue