[Feature #21205] Fix up birthtime in ruby/spec

This commit is contained in:
Nobuyoshi Nakada 2025-05-10 15:40:24 +09:00
parent 18a036a613
commit 8872d3e10b
No known key found for this signature in database
GPG key ID: 3582D74E1FEE4465
Notes: git 2025-05-30 13:00:32 +00:00
2 changed files with 26 additions and 47 deletions

View file

@ -1,15 +1,15 @@
require_relative '../../spec_helper'
describe "File.birthtime" do
before :each do
@file = __FILE__
end
platform_is :windows, :darwin, :freebsd, :netbsd, :linux do
describe "File.birthtime" do
before :each do
@file = __FILE__
end
after :each do
@file = nil
end
after :each do
@file = nil
end
platform_is :windows, :darwin, :freebsd, :netbsd do
it "returns the birth time for the named file as a Time object" do
File.birthtime(@file)
File.birthtime(@file).should be_kind_of(Time)
@ -24,37 +24,21 @@ describe "File.birthtime" do
end
end
platform_is :openbsd do
it "raises an NotImplementedError" do
-> { File.birthtime(@file) }.should raise_error(NotImplementedError)
describe "File#birthtime" do
before :each do
@file = File.open(__FILE__)
end
end
# TODO: depends on Linux kernel version
end
after :each do
@file.close
@file = nil
end
describe "File#birthtime" do
before :each do
@file = File.open(__FILE__)
end
after :each do
@file.close
@file = nil
end
platform_is :windows, :darwin, :freebsd, :netbsd do
it "returns the birth time for self" do
@file.birthtime
@file.birthtime.should be_kind_of(Time)
end
end
platform_is :openbsd do
it "raises an NotImplementedError" do
-> { @file.birthtime }.should raise_error(NotImplementedError)
end
end
# TODO: depends on Linux kernel version
end

View file

@ -1,27 +1,22 @@
require_relative '../../../spec_helper'
describe "File::Stat#birthtime" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
platform_is(:windows, :darwin, :freebsd, :netbsd,
*ruby_version_is("3.5") { :linux },
) do
describe "File::Stat#birthtime" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do
rm_r @file
end
after :each do
rm_r @file
end
platform_is :windows, :darwin, :freebsd, :netbsd do
it "returns the birthtime of a File::Stat object" do
st = File.stat(@file)
st.birthtime.should be_kind_of(Time)
st.birthtime.should <= Time.now
end
end
platform_is :linux, :openbsd do
it "raises an NotImplementedError" do
st = File.stat(@file)
-> { st.birthtime }.should raise_error(NotImplementedError)
end
end
end