Sha256: db649abe18218009932fdc2e2af119eab7ec759fb23bfb54d5ddf57e637a71d6

Contents?: true

Size: 841 Bytes

Versions: 13

Compression:

Stored size: 841 Bytes

Contents

# encoding: utf-8

describe 'Pathname#checksum' do

  it 'should work on empty files' do
    begin
      # Create file
      FileUtils.mkdir_p('tmp')
      File.open('tmp/myfile', 'w') { |io| io.write('') }
      now = Time.now
      File.utime(now, now, 'tmp/myfile')

      # Create checksum
      pathname = Pathname.new('tmp/myfile')
      pathname.checksum.must_equal '0-' + now.to_s
    ensure
      FileUtils.rm_rf('tmp')
    end
  end

  it 'should work on all files' do
    begin
      # Create file
      FileUtils.mkdir_p('tmp')
      File.open('tmp/myfile', 'w') { |io| io.write('abc') }
      now = Time.now
      File.utime(now, now, 'tmp/myfile')

      # Create checksum
      pathname = Pathname.new('tmp/myfile')
      pathname.checksum.must_equal '3-' + now.to_s
    ensure
      FileUtils.rm_rf('tmp')
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
nanoc-3.6.9 test/base/core_ext/pathname_spec.rb
nanoc-3.6.8 test/base/core_ext/pathname_spec.rb
nanoc-3.6.7 test/base/core_ext/pathname_spec.rb
nanoc-3.6.6 test/base/core_ext/pathname_spec.rb
nanoc-3.6.5 test/base/core_ext/pathname_spec.rb
nanoc-3.6.4 test/base/core_ext/pathname_spec.rb
nanoc-3.6.3 test/base/core_ext/pathname_spec.rb
nanoc-3.6.2 test/base/core_ext/pathname_spec.rb
nanoc-3.6.1 test/base/core_ext/pathname_spec.rb
nanoc-3.6.0 test/base/core_ext/pathname_spec.rb
nanoc-3.5.0 test/base/core_ext/pathname_spec.rb
nanoc-3.5.0b2 test/base/core_ext/pathname_spec.rb
nanoc-3.5.0b1 test/base/core_ext/pathname_spec.rb