Skip to content
Snippets Groups Projects
Commit cf85f757 authored by Markus Reiter's avatar Markus Reiter Committed by GitHub
Browse files

Merge pull request #2224 from reitermarkus/spec-checksum_verification

Convert `checksum_verification` test to spec.
parents 43d1099c ba34cbdc
No related branches found
No related tags found
No related merge requests found
require "formula"
describe Formula do
def formula(&block)
super do
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
instance_eval(&block)
end
end
describe "#brew" do
it "does not raise an error when the checksum matches" do
expect {
shutup do
f = formula do
sha256 TESTBALL_SHA256
end
f.brew {}
end
}.not_to raise_error
end
it "raises an error when the checksum doesn't match" do
expect {
shutup do
f = formula do
sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8"
end
f.brew {}
end
}.to raise_error(ChecksumMismatchError)
end
end
end
require "testing_env"
require "formula"
class ChecksumVerificationTests < Homebrew::TestCase
def assert_checksum_good
assert_nothing_raised { shutup { @_f.brew {} } }
end
def assert_checksum_bad
assert_raises(ChecksumMismatchError) { shutup { @_f.brew {} } }
end
def formula(&block)
super do
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
instance_eval(&block)
end
end
def test_good_sha256
formula do
sha256 TESTBALL_SHA256
end
assert_checksum_good
end
def test_bad_sha256
formula do
sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8"
end
assert_checksum_bad
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment