summaryrefslogtreecommitdiff
path: root/spec/ruby/core/exception/standard_error_spec.rb
blob: 17e98ce7f02c37af5931565c7e8b1b215a9615b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require_relative '../../spec_helper'

describe "StandardError" do
  it "rescues StandardError" do
    begin
      raise StandardError
    rescue => exception
      exception.class.should == StandardError
    end
  end

  it "rescues subclass of StandardError" do
    begin
      raise RuntimeError
    rescue => exception
      exception.class.should == RuntimeError
    end
  end

  it "does not rescue superclass of StandardError" do
    -> { begin; raise Exception; rescue; end }.should raise_error(Exception)
  end
end