Skip to content

Commit

Permalink
Restore environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Dec 13, 2019
1 parent da6577a commit 2365908
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/irb/test_init.rb
Expand Up @@ -20,9 +20,9 @@ def test_setup_with_minimum_argv_does_not_change_dollar0
end

def test_rc_file
ENV.delete("IRBRC") # This is for RVM...
backup_irbrc = ENV.delete("IRBRC") # This is for RVM...
backup_home = ENV["HOME"]
Dir.mktmpdir("test_irb_init_#{$$}") do |tmpdir|
backup_home = ENV["HOME"]
ENV["HOME"] = tmpdir

IRB.conf[:RC_NAME_GENERATOR] = nil
Expand All @@ -32,15 +32,16 @@ def test_rc_file
FileUtils.touch(tmpdir+"/.irb#{IRB::IRBRC_EXT}")
assert_equal(tmpdir+"/.irb#{IRB::IRBRC_EXT}", IRB.rc_file)
assert_equal(tmpdir+"/.irb_history", IRB.rc_file("_history"))

ENV["HOME"] = backup_home
end
ensure
ENV["HOME"] = backup_home
ENV["IRBRC"] = backup_irbrc
end

def test_rc_file_in_subdir
ENV.delete("IRBRC") # This is for RVM...
backup_irbrc = ENV.delete("IRBRC") # This is for RVM...
backup_home = ENV["HOME"]
Dir.mktmpdir("test_irb_init_#{$$}") do |tmpdir|
backup_home = ENV["HOME"]
ENV["HOME"] = tmpdir

FileUtils.mkdir_p("#{tmpdir}/mydir")
Expand All @@ -53,9 +54,10 @@ def test_rc_file_in_subdir
assert_equal(tmpdir+"/.irb#{IRB::IRBRC_EXT}", IRB.rc_file)
assert_equal(tmpdir+"/.irb_history", IRB.rc_file("_history"))
end

ENV["HOME"] = backup_home
end
ensure
ENV["HOME"] = backup_home
ENV["IRBRC"] = backup_irbrc
end

private
Expand Down

0 comments on commit 2365908

Please sign in to comment.