Sha256: 2a005cbcba55358ccbbd72cc8d68e6bac8a7dff67b4977241838efb119d86bc9

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

require "spec_helper"

require 'fileutils'

describe Cbt::Digester do
  TEMP_FILE = 'history.yml'
  subject(:dst) { Cbt::Digester.new(TEMP_FILE) }

  describe '#add_history' do
    it "can add history" do
      dst.add_history('filename', 'digeststringverylong')
      dst.last_change('filename').should_not be_nil
    end

    it "can get last history" do
      dst.last_change('filename')['digest'].should eq('digeststringverylong')
    end

    it "can handle more than one file" do
      dst.add_history('filename2', 'lfgjhowtqerpfdfflou4o8rywo')
      dst.last_change('filename')['digest'].should eq('digeststringverylong')
    end

    it "can test file change" do
      dst.changed?('filename', 'digeststringverylong').should be_false
      dst.changed?('filename', 'digeststringverylongzz').should be_true
    end

    it "can test file version in history" do
      dst.add_history('filename', '34dofy8yeroerhfdofsdf')
      dst.known?('filename', 'digeststringverylong').should be_true
      dst.known?('filename', 'digeststringverylozng').should be_false
    end

    it "compare file change only for the last version" do
      dst.changed?('filename', '34dofy8yeroerhfdofsdf').should be_false
      dst.changed?('filename', 'digeststringverylong').should be_true
    end

    it "compare file change without digest" do
      FileUtils.cp 'examples/config/components.yml', 'history_test'
      dst.add_history('history_test')
      dst.changed?('history_test').should be_false
      #wfh = File.open('history_test', 'w')
      #wfh.puts "history file test"
      #wfh.close
      #dst.changed?('history_test').should be_true
    end

    after(:all) do
      FileUtils.rm TEMP_FILE
      FileUtils.rm 'history_test'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cbt-0.0.1 spec/digester_spec.rb