summaryrefslogtreecommitdiff
path: root/spec/ruby/language/safe_spec.rb
blob: ee5c1b3ccc1853079dfe0651a0064ed95dcd1f4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require_relative '../spec_helper'

describe "The $SAFE variable" do
  ruby_version_is ""..."3.0" do
    it "warn when access" do
      -> {
        $SAFE
      }.should complain(/\$SAFE will become a normal global variable in Ruby 3.0/)
    end

    it "warn when set" do
      -> {
        $SAFE = 1
      }.should complain(/\$SAFE will become a normal global variable in Ruby 3.0/)
    end
  end

  ruby_version_is "3.0" do
    it "$SAFE is a regular global variable" do
      $SAFE.should == nil
      $SAFE = 42
      $SAFE.should == 42
    ensure
      $SAFE = nil
    end
  end
end