aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2024-06-19 12:23:12 -0700
committerJeremy Evans <code@jeremyevans.net>2024-06-20 07:54:02 -0700
commita47a176768c637b7d5158a31a5902b2e680fa47f (patch)
treeb8a29041bc426ddd506bee1c8b825eaaf84292c6 /spec/ruby
parent9bd5995b40deedad351089b898b2dafe9de70b6e (diff)
downloadruby-a47a176768c637b7d5158a31a5902b2e680fa47f.tar.gz
Skip 3 specs when $HOME is not a valid directory
If $HOME isn't a valid directory, these specs fail, but I think it is better to skip in this case, as it does not indicate a bug. This fixes specs when run in the OpenBSD port, which sets $HOME to an invalid directory to ensure that software's build system is not accidentally relying on it.
Diffstat (limited to 'spec/ruby')
-rw-r--r--spec/ruby/core/dir/chdir_spec.rb16
-rw-r--r--spec/ruby/core/dir/shared/exist.rb1
2 files changed, 10 insertions, 7 deletions
diff --git a/spec/ruby/core/dir/chdir_spec.rb b/spec/ruby/core/dir/chdir_spec.rb
index 729ac403e3..7ced2a7057 100644
--- a/spec/ruby/core/dir/chdir_spec.rb
+++ b/spec/ruby/core/dir/chdir_spec.rb
@@ -19,14 +19,14 @@ describe "Dir.chdir" do
end
it "defaults to $HOME with no arguments" do
- if ENV['HOME']
- Dir.chdir
- current_dir = Dir.pwd
+ skip "$HOME not valid directory" unless ENV['HOME'] && File.directory?(ENV['HOME'])
- Dir.chdir(ENV['HOME'])
- home = Dir.pwd
- current_dir.should == home
- end
+ Dir.chdir
+ current_dir = Dir.pwd
+
+ Dir.chdir(ENV['HOME'])
+ home = Dir.pwd
+ current_dir.should == home
end
it "changes to the specified directory" do
@@ -70,6 +70,8 @@ describe "Dir.chdir" do
end
it "defaults to the home directory when given a block but no argument" do
+ skip "$HOME not valid directory" unless ENV['HOME'] && File.directory?(ENV['HOME'])
+
# Windows will return a path with forward slashes for ENV["HOME"] so we have
# to compare the route representations returned by Dir.chdir.
current_dir = ""
diff --git a/spec/ruby/core/dir/shared/exist.rb b/spec/ruby/core/dir/shared/exist.rb
index 2ea4f88a80..3097f57715 100644
--- a/spec/ruby/core/dir/shared/exist.rb
+++ b/spec/ruby/core/dir/shared/exist.rb
@@ -34,6 +34,7 @@ describe :dir_exist, shared: true do
end
it "doesn't expand paths" do
+ skip "$HOME not valid directory" unless ENV['HOME'] && File.directory?(ENV['HOME'])
Dir.send(@method, File.expand_path('~')).should be_true
Dir.send(@method, '~').should be_false
end