Sha256: 77c2c902485a399125d4db08935768296c94818bc7900f0fd2b838b09523d3aa

Contents?: true

Size: 853 Bytes

Versions: 1

Compression:

Stored size: 853 Bytes

Contents

require 'spec_helper'
require 'eff/verifier'

describe Eff::Verifier do
  let(:file)   { "spec/support/static_file_for_digesting.txt" }
  let(:sha1)   { "75cfdde12aeb435fd0c68c99df1027190953997e" }
  let(:md5)    { "1c0b1fcddc0cd9677ecfb79e1d127e03" }
  let(:hashes) { { sha1: sha1, md5: md5 } }

  describe '.check' do
    it 'returns true if the hashes match' do
      hashes.each do |hash_function, value|
        Eff::Verifier.check(file, value, hash_function).should be_true
      end
    end

    it 'returns false if the hashes do not match' do
      hashes.each do |hash_function, value|
        Eff::Verifier.check(file, "this doesn't match", hash_function).should be_false
      end
    end

    it 'returns false if the file does not exist' do
      Eff::Verifier.check('non-existant-file.txt', sha1, :sha1).should be_false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eff-0.0.2 spec/eff/verifier_spec.rb