Skip to content

Commit

Permalink
Refresh specs using File.dirname(__FILE__)
Browse files Browse the repository at this point in the history
This follows upstream change ruby/spec#1067
  • Loading branch information
herwinw committed Sep 4, 2023
1 parent 5d81c35 commit 25c2c41
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions spec/core/dir/shared/chroot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions spec/core/dir/shared/exist.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,15 +20,15 @@
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
Dir.send(@method, 'y26dg27n2nwjs8a/').should be_false
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
Expand All @@ -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
2 changes: 1 addition & 1 deletion spec/core/io/eof_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}
Expand Down

0 comments on commit 25c2c41

Please sign in to comment.