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

describe "FrozenError.new" do
  it "should take optional receiver argument" do
    o = Object.new
    FrozenError.new("msg", receiver: o).receiver.should equal(o)
  end
end

describe "FrozenError#receiver" do
  it "should return frozen object that modification was attempted on" do
    o = Object.new.freeze
    begin
      def o.x; end
    rescue => e
      e.should be_kind_of(FrozenError)
      e.receiver.should equal(o)
    else
      raise
    end
  end
end