From 25c2c4154e82282bafc21423a2d010fc3a63a564 Mon Sep 17 00:00:00 2001 From: Herwin Date: Mon, 4 Sep 2023 11:31:13 +0200 Subject: [PATCH] Refresh specs using File.dirname(__FILE__) This follows upstream change https://github.com/ruby/spec/pull/1067 --- spec/core/dir/shared/chroot.rb | 4 ++-- spec/core/dir/shared/exist.rb | 8 ++++---- spec/core/io/eof_spec.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/core/dir/shared/chroot.rb b/spec/core/dir/shared/chroot.rb index 8c0599fe3..a8f7c10a1 100644 --- a/spec/core/dir/shared/chroot.rb +++ b/spec/core/dir/shared/chroot.rb @@ -2,7 +2,7 @@ before :all do DirSpecs.create_mock_dirs - @real_root = "../" * (File.dirname(__FILE__).count('/') - 1) + @real_root = "../" * (__dir__.count('/') - 1) @ref_dir = File.join("/", File.basename(Dir["/*"].first)) end @@ -18,7 +18,7 @@ compilations_ci = ENV["GITHUB_WORKFLOW"] == "Compilations" it "can be used to change the process' root directory" do - -> { Dir.send(@method, File.dirname(__FILE__)) }.should_not raise_error + -> { Dir.send(@method, __dir__) }.should_not raise_error File.should.exist?("/#{File.basename(__FILE__)}") end unless compilations_ci diff --git a/spec/core/dir/shared/exist.rb b/spec/core/dir/shared/exist.rb index bcd59160c..accb51015 100644 --- a/spec/core/dir/shared/exist.rb +++ b/spec/core/dir/shared/exist.rb @@ -1,6 +1,6 @@ describe :dir_exist, shared: true do it "returns true if the given directory exists" do - Dir.send(@method, File.dirname(__FILE__)).should be_true + Dir.send(@method, __dir__).should be_true end it "returns true for '.'" do @@ -20,7 +20,7 @@ end it "understands relative paths" do - Dir.send(@method, File.dirname(__FILE__) + '/../').should be_true + Dir.send(@method, __dir__ + '/../').should be_true end it "returns false if the given directory doesn't exist" do @@ -28,7 +28,7 @@ end it "doesn't require the name to have a trailing slash" do - dir = File.dirname(__FILE__) + dir = __dir__ dir.sub!(/\/$/,'') Dir.send(@method, dir).should be_true end @@ -52,7 +52,7 @@ it "calls #to_path on non String arguments" do p = mock('path') - p.should_receive(:to_path).and_return(File.dirname(__FILE__)) + p.should_receive(:to_path).and_return(__dir__) Dir.send(@method, p) end end diff --git a/spec/core/io/eof_spec.rb b/spec/core/io/eof_spec.rb index fd9f2b82d..6eced0ad6 100644 --- a/spec/core/io/eof_spec.rb +++ b/spec/core/io/eof_spec.rb @@ -84,7 +84,7 @@ end it "returns true on one-byte stream after single-byte read" do - File.open(File.dirname(__FILE__) + '/fixtures/one_byte.txt') { |one_byte| + File.open(__dir__ + '/fixtures/one_byte.txt') { |one_byte| one_byte.read(1) one_byte.should.eof? }