diff options
author | Benoit Daloze <eregontp@gmail.com> | 2023-04-25 17:04:25 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2023-04-25 17:09:53 +0200 |
commit | d562663e4098801c1d7fa7c64a335ea71231a598 (patch) | |
tree | 5b2ab2c9fbb86b4223263485fc5a3224562ae78d /spec/ruby/core/dir | |
parent | d3da01cd110ca99dd0249ee9af92e12cf845998c (diff) |
Update to ruby/spec@7f69c86
Diffstat (limited to 'spec/ruby/core/dir')
-rw-r--r-- | spec/ruby/core/dir/fchdir_spec.rb | 12 | ||||
-rw-r--r-- | spec/ruby/core/dir/home_spec.rb | 6 |
2 files changed, 12 insertions, 6 deletions
diff --git a/spec/ruby/core/dir/fchdir_spec.rb b/spec/ruby/core/dir/fchdir_spec.rb index dde459e98e..08b1cdfc7e 100644 --- a/spec/ruby/core/dir/fchdir_spec.rb +++ b/spec/ruby/core/dir/fchdir_spec.rb @@ -6,15 +6,13 @@ ruby_version_is '3.3' do dir = Dir.new('.') Dir.fchdir(dir.fileno) true - rescue NotImplementedError + rescue NotImplementedError, NoMethodError false - rescue Exception - true ensure dir.close end - if has_fchdir + guard -> { has_fchdir } do describe "Dir.fchdir" do before :all do DirSpecs.create_mock_dirs @@ -58,7 +56,7 @@ ruby_version_is '3.3' do end it "raises a SystemCallError if the file descriptor given is not valid" do - -> { Dir.fchdir -1 }.should raise_error(SystemCallError) + -> { Dir.fchdir(-1) }.should raise_error(SystemCallError) -> { Dir.fchdir(-1) { } }.should raise_error(SystemCallError) end @@ -67,7 +65,9 @@ ruby_version_is '3.3' do -> { Dir.fchdir($stdout.fileno) { } }.should raise_error(SystemCallError) end end - else + end + + guard_not -> { has_fchdir } do describe "Dir.fchdir" do it "raises NotImplementedError" do -> { Dir.fchdir 1 }.should raise_error(NotImplementedError) diff --git a/spec/ruby/core/dir/home_spec.rb b/spec/ruby/core/dir/home_spec.rb index bbe347ba9e..90a008faf1 100644 --- a/spec/ruby/core/dir/home_spec.rb +++ b/spec/ruby/core/dir/home_spec.rb @@ -85,4 +85,10 @@ describe "Dir.home" do it "raises an ArgumentError if the named user doesn't exist" do -> { Dir.home('geuw2n288dh2k') }.should raise_error(ArgumentError) end + + describe "when called with a nil user name" do + it "returns the current user's home directory, reading $HOME first" do + Dir.home(nil).should == "/rubyspec_home" + end + end end |