diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-30 00:05:56 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-30 00:05:56 +0000 |
commit | 7f54f1b5543b4a3267a64c47cff9127cbcafcc42 (patch) | |
tree | b4321a0e6aca9aed1a05cfc97b9ca209a5e5a0fd /spec/ruby/core/dir/home_spec.rb | |
parent | 2eee74ef54a2e23eb870680a83dcf74c5d9d9d01 (diff) | |
download | ruby-7f54f1b5543b4a3267a64c47cff9127cbcafcc42.tar.gz |
Update to ruby/spec@2d89e48
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/dir/home_spec.rb')
-rw-r--r-- | spec/ruby/core/dir/home_spec.rb | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/spec/ruby/core/dir/home_spec.rb b/spec/ruby/core/dir/home_spec.rb index 7e2256e1a1..db46b80c54 100644 --- a/spec/ruby/core/dir/home_spec.rb +++ b/spec/ruby/core/dir/home_spec.rb @@ -2,27 +2,40 @@ require_relative '../../spec_helper' require_relative 'fixtures/common' describe "Dir.home" do - it "returns the current user's home directory as a string if called without arguments" do - home_directory = ENV['HOME'] - platform_is :windows do - unless home_directory - home_directory = ENV['HOMEDRIVE'] + ENV['HOMEPATH'] - end - home_directory = home_directory.tr('\\', '/').chomp('/') - end + before :each do + @home = ENV['HOME'] + ENV['HOME'] = "/rubyspec_home" + end - Dir.home.should == home_directory + after :each do + ENV['HOME'] = @home end - platform_is :solaris do - it "returns the named user's home directory, from the user database, as a string if called with an argument" do - Dir.home(ENV['USER']).should == `getent passwd #{ENV['USER']}|cut -d: -f6`.chomp + 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 - platform_is_not :windows, :solaris do - it "returns the named user's home directory, from the user database, as a string if called with an argument" do - Dir.home(ENV['USER']).should == `echo ~#{ENV['USER']}`.chomp + 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 |