diff options
Diffstat (limited to 'spec/ruby/core/exception/standard_error_spec.rb')
-rw-r--r-- | spec/ruby/core/exception/standard_error_spec.rb | 61 |
1 files changed, 14 insertions, 47 deletions
diff --git a/spec/ruby/core/exception/standard_error_spec.rb b/spec/ruby/core/exception/standard_error_spec.rb index 1b469b5090..17e98ce7f0 100644 --- a/spec/ruby/core/exception/standard_error_spec.rb +++ b/spec/ruby/core/exception/standard_error_spec.rb @@ -1,56 +1,23 @@ require_relative '../../spec_helper' describe "StandardError" do - it "is a superclass of ArgumentError" do - StandardError.should be_ancestor_of(ArgumentError) - end - - it "is a superclass of IOError" do - StandardError.should be_ancestor_of(IOError) - end - - it "is a superclass of IndexError" do - StandardError.should be_ancestor_of(IndexError) - end - - it "is a superclass of LocalJumpError" do - StandardError.should be_ancestor_of(LocalJumpError) - end - - it "is a superclass of NameError" do - StandardError.should be_ancestor_of(NameError) - end - - it "is a superclass of RangeError" do - StandardError.should be_ancestor_of(RangeError) - end - - it "is a superclass of RegexpError" do - StandardError.should be_ancestor_of(RegexpError) - end - - it "is a superclass of RuntimeError" do - StandardError.should be_ancestor_of(RuntimeError) - end - - it "is a superclass of SystemCallError" do - StandardError.should be_ancestor_of(SystemCallError.new("").class) - end - it "is a superclass of ThreadError" do - StandardError.should be_ancestor_of(ThreadError) - end - - it "is a superclass of TypeError" do - StandardError.should be_ancestor_of(TypeError) + it "rescues StandardError" do + begin + raise StandardError + rescue => exception + exception.class.should == StandardError + end end - it "is a superclass of ZeroDivisionError" do - StandardError.should be_ancestor_of(ZeroDivisionError) + it "rescues subclass of StandardError" do + begin + raise RuntimeError + rescue => exception + exception.class.should == RuntimeError + end end - ruby_version_is '2.5' do - it "is a superclass of FrozenError" do - StandardError.should be_ancestor_of(FrozenError) - end + it "does not rescue superclass of StandardError" do + -> { begin; raise Exception; rescue; end }.should raise_error(Exception) end end |