Sha256: 578561bb0a2beb54d54c8e0b4faefca381127ceb6af0735b77d6bd3f6842b4c3

Contents?: true

Size: 1.28 KB

Versions: 83

Compression:

Stored size: 1.28 KB

Contents

require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../../spec_helper'

describe "File::Stat#<=>" do
  before :each do
    @name1 = tmp("i_exist")
    @name2 = tmp("i_exist_too")
    @file1 = File.new @name1, "w"
    @file2 = File.new @name2, "w"
  end

  after :each do
    @file1.close unless @file1.closed?
    @file2.close unless @file2.closed?
    File.delete @name1 if File.exists? @name1
    File.delete @name2 if File.exists? @name2
  end

  it "is able to compare files by the same modification times" do
    (@file1.stat <=> @file2.stat).should == 0
  end

  it "is able to compare files by different modification times" do
    File.utime(Time.now, Time.now + 100, @name2)
    (@file1.stat <=> @file2.stat).should == -1

    File.utime(Time.now, Time.now - 100, @name2)
    (@file1.stat <=> @file2.stat).should == 1
  end

  it "should also include Comparable and thus == shows mtime equality between two File::Stat objects" do
    (@file1.stat == @file2.stat).should == true
    (@file1.stat == @file1.stat).should == true
    (@file2.stat == @file2.stat).should == true

    File.utime(Time.now, Time.now + 100, @name2)

    (@file1.stat == @file2.stat).should == false
    (@file1.stat == @file1.stat).should == true
    (@file2.stat == @file2.stat).should == true
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
rhodes-3.1.1 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.1.1.beta spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.1.0 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.1.0.beta.5 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.1.0.beta.4 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.1.0.beta.3 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.1.0.beta.2 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.1.0.beta.1 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.2 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.2.beta.1 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.1 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.1.beta.8 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.1.beta.7 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.1.beta.6 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.1.beta.5 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.1.beta.4 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.1.beta.3 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.1.beta.2 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.0 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb
rhodes-3.0.0.beta.7 spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb