|
1 | 1 | require_relative '../../spec_helper'
|
2 | 2 |
|
3 | 3 | 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 | + |
4 | 9 | describe "File.birthtime" do
|
5 | 10 | before :each do
|
6 | 11 | @file = __FILE__
|
|
14 | 19 | File.birthtime(@file)
|
15 | 20 | File.birthtime(@file).should be_kind_of(Time)
|
16 | 21 | rescue NotImplementedError => e
|
17 |
| - skip e.message if e.message.start_with?("birthtime() function") |
| 22 | + e.message.should.start_with?(*not_implemented_messages) |
18 | 23 | end
|
19 | 24 |
|
20 | 25 | it "accepts an object that has a #to_path method" do
|
21 | 26 | File.birthtime(@file) # Avoid to failure of mock object with old Kernel and glibc
|
22 | 27 | File.birthtime(mock_to_path(@file))
|
23 | 28 | rescue NotImplementedError => e
|
24 |
| - e.message.should.start_with?("birthtime() function") |
| 29 | + e.message.should.start_with?(*not_implemented_messages) |
25 | 30 | end
|
26 | 31 |
|
27 | 32 | it "raises an Errno::ENOENT exception if the file is not found" do
|
28 | 33 | -> { File.birthtime('bogus') }.should raise_error(Errno::ENOENT)
|
29 | 34 | rescue NotImplementedError => e
|
30 |
| - e.message.should.start_with?("birthtime() function") |
| 35 | + e.message.should.start_with?(*not_implemented_messages) |
31 | 36 | end
|
32 | 37 | end
|
33 | 38 |
|
|
45 | 50 | @file.birthtime
|
46 | 51 | @file.birthtime.should be_kind_of(Time)
|
47 | 52 | rescue NotImplementedError => e
|
48 |
| - e.message.should.start_with?("birthtime() function") |
| 53 | + e.message.should.start_with?(*not_implemented_messages) |
49 | 54 | end
|
50 | 55 | end
|
51 | 56 | end
|
0 commit comments