Sha256: 4c6ea1053d7bc6838a5f84173bcfd5b4fc5db7c0aef7b5eb7ccc9db72f3d24ee

Contents?: true

Size: 929 Bytes

Versions: 1

Compression:

Stored size: 929 Bytes

Contents

require 'spec_helper'

describe Treehash do
  it { should respond_to(:calculate_tree_hash) }
  specify { subject::MEGA_BYTE.should == 1024 * 1024 }

  context "for large strings" do
    it "should calculate the proper tree hash" do
      hash = Treehash::calculate_tree_hash('boo' * 1048576)
      hash.should == 'd53de7216088837ece12b81c0d233c18a2d0ef1f7e96b8f80cbf1b27f49dc4c5'
    end
  end

  context "for small strings" do
    it "should calculate the proper tree hash" do
      hash = Treehash::calculate_tree_hash "foo"
      hash.should == '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
    end

    it "should calculate the proper tree hash when given a file" do
      file = File.open File.join(File.dirname(__FILE__), 'fixtures', 'small_file')
      hash = Treehash::calculate_tree_hash file
      hash.should == '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
treehash-0.0.1 spec/tree_hash_spec.rb