mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
7f54f1b554
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
45 lines
1.2 KiB
Ruby
45 lines
1.2 KiB
Ruby
require_relative '../../spec_helper'
|
|
require_relative 'fixtures/common'
|
|
|
|
describe "Dir.home" do
|
|
before :each do
|
|
@home = ENV['HOME']
|
|
ENV['HOME'] = "/rubyspec_home"
|
|
end
|
|
|
|
after :each do
|
|
ENV['HOME'] = @home
|
|
end
|
|
|
|
describe "when called without arguments" do
|
|
it "returns the current user's home directory, reading $HOME first" do
|
|
Dir.home.should == "/rubyspec_home"
|
|
end
|
|
|
|
it "returns a non-frozen string" do
|
|
Dir.home.frozen?.should == false
|
|
end
|
|
end
|
|
|
|
describe "when called with the current user name" do
|
|
platform_is :solaris do
|
|
it "returns the named user's home directory from the user database" do
|
|
Dir.home(ENV['USER']).should == `getent passwd #{ENV['USER']}|cut -d: -f6`.chomp
|
|
end
|
|
end
|
|
|
|
platform_is_not :windows, :solaris do
|
|
it "returns the named user's home directory, from the user database" do
|
|
Dir.home(ENV['USER']).should == `echo ~#{ENV['USER']}`.chomp
|
|
end
|
|
end
|
|
|
|
it "returns a non-frozen string" do
|
|
Dir.home(ENV['USER']).frozen?.should == false
|
|
end
|
|
end
|
|
|
|
it "raises an ArgumentError if the named user doesn't exist" do
|
|
lambda { Dir.home('geuw2n288dh2k') }.should raise_error(ArgumentError)
|
|
end
|
|
end
|