1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rake/test_win32.rb
nobu 746fe8af5a * test/rake: get rid of name collision.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-03 14:47:46 +00:00

68 lines
1.7 KiB
Ruby

require 'test/unit'
require_relative 'in_environment'
require 'rake'
class Rake::TestWin32 < Test::Unit::TestCase
include InEnvironment
Win32 = Rake::Win32
def test_win32_system_dir_uses_home_if_defined
in_environment('RAKE_SYSTEM' => nil, 'HOME' => 'C:\\HP') do
assert_equal "C:/HP/Rake", Win32.win32_system_dir
end
end
def test_win32_system_dir_uses_homedrive_homepath_when_no_home_defined
in_environment(
'RAKE_SYSTEM' => nil,
'HOME' => nil,
'HOMEDRIVE' => "C:",
'HOMEPATH' => "\\HP"
) do
assert_equal "C:/HP/Rake", Win32.win32_system_dir
end
end
def test_win32_system_dir_uses_appdata_when_no_home_or_home_combo
in_environment(
'RAKE_SYSTEM' => nil,
'HOME' => nil,
'HOMEDRIVE' => nil,
'HOMEPATH' => nil,
'APPDATA' => "C:\\Documents and Settings\\HP\\Application Data"
) do
assert_equal "C:/Documents and Settings/HP/Application Data/Rake", Win32.win32_system_dir
end
end
def test_win32_system_dir_fallback_to_userprofile_otherwise
in_environment(
'RAKE_SYSTEM' => nil,
'HOME' => nil,
'HOMEDRIVE' => nil,
'HOMEPATH' => nil,
'APPDATA' => nil,
'USERPROFILE' => "C:\\Documents and Settings\\HP"
) do
assert_equal "C:/Documents and Settings/HP/Rake", Win32.win32_system_dir
end
end
def test_win32_system_dir_nil_of_no_env_vars
in_environment(
'RAKE_SYSTEM' => nil,
'HOME' => nil,
'HOMEDRIVE' => nil,
"HOMEPATH" => nil,
'APPDATA' => nil,
"USERPROFILE" => nil
) do
assert_raise(Rake::Win32::Win32HomeError) do
Win32.win32_system_dir
end
end
end
end if Rake::Win32.windows?