Skip to content

Commit 20adae4

Browse files
committed
Fix up birthtime specs
There are two different possible messages: unsupported OS/version, and unsupported filesystem on a supported system.
1 parent 6184793 commit 20adae4

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

spec/ruby/core/file/birthtime_spec.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
require_relative '../../spec_helper'
22

33
platform_is :windows, :darwin, :freebsd, :netbsd, :linux do
4+
not_implemented_messages = [
5+
"birthtime() function is unimplemented", # unsupported OS/version
6+
"birthtime is unimplemented", # unsupported filesystem
7+
]
8+
49
describe "File.birthtime" do
510
before :each do
611
@file = __FILE__
@@ -14,20 +19,20 @@
1419
File.birthtime(@file)
1520
File.birthtime(@file).should be_kind_of(Time)
1621
rescue NotImplementedError => e
17-
skip e.message if e.message.start_with?("birthtime() function")
22+
e.message.should.start_with?(*not_implemented_messages)
1823
end
1924

2025
it "accepts an object that has a #to_path method" do
2126
File.birthtime(@file) # Avoid to failure of mock object with old Kernel and glibc
2227
File.birthtime(mock_to_path(@file))
2328
rescue NotImplementedError => e
24-
e.message.should.start_with?("birthtime() function")
29+
e.message.should.start_with?(*not_implemented_messages)
2530
end
2631

2732
it "raises an Errno::ENOENT exception if the file is not found" do
2833
-> { File.birthtime('bogus') }.should raise_error(Errno::ENOENT)
2934
rescue NotImplementedError => e
30-
e.message.should.start_with?("birthtime() function")
35+
e.message.should.start_with?(*not_implemented_messages)
3136
end
3237
end
3338

@@ -45,7 +50,7 @@
4550
@file.birthtime
4651
@file.birthtime.should be_kind_of(Time)
4752
rescue NotImplementedError => e
48-
e.message.should.start_with?("birthtime() function")
53+
e.message.should.start_with?(*not_implemented_messages)
4954
end
5055
end
5156
end

spec/ruby/core/file/stat/birthtime_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
platform_is(:windows, :darwin, :freebsd, :netbsd,
44
*ruby_version_is("3.5") { :linux },
55
) do
6+
not_implemented_messages = [
7+
"birthtime() function is unimplemented", # unsupported OS/version
8+
"birthtime is unimplemented", # unsupported filesystem
9+
]
10+
611
describe "File::Stat#birthtime" do
712
before :each do
813
@file = tmp('i_exist')
@@ -18,7 +23,7 @@
1823
st.birthtime.should be_kind_of(Time)
1924
st.birthtime.should <= Time.now
2025
rescue NotImplementedError => e
21-
e.message.should.start_with?("birthtime() function")
26+
e.message.should.start_with?(*not_implemented_messages)
2227
end
2328
end
2429
end

0 commit comments

Comments
 (0)