summaryrefslogtreecommitdiff
path: root/spec/ruby/core/file/stat/birthtime_spec.rb
blob: 9aa39297b24d3cf9c81838c82514f4950d49d35e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require_relative '../../../spec_helper'

platform_is(:windows, :darwin, :freebsd, :netbsd,
            *ruby_version_is("4.0") { :linux },
           ) do
  not_implemented_messages = [
    "birthtime() function is unimplemented", # unsupported OS/version
    "birthtime is unimplemented",            # unsupported filesystem
  ]

  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

    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
    rescue NotImplementedError => e
      e.message.should.start_with?(*not_implemented_messages)
    end
  end
end