2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-27 18:51:11 +01:00
|
|
|
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
|
2023-03-08 23:14:46 +00:00
|
|
|
expect do
|
2017-07-29 19:55:05 +02:00
|
|
|
f = formula do
|
|
|
|
sha256 TESTBALL_SHA256
|
2017-02-27 18:51:11 +01:00
|
|
|
end
|
2017-07-29 19:55:05 +02:00
|
|
|
|
2023-03-08 23:14:46 +00:00
|
|
|
f.brew do
|
2023-01-26 21:18:24 -08:00
|
|
|
# do nothing
|
2023-03-08 23:14:46 +00:00
|
|
|
end
|
|
|
|
end.not_to raise_error
|
2017-02-27 18:51:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an error when the checksum doesn't match" do
|
2023-03-08 23:14:46 +00:00
|
|
|
expect do
|
2017-07-29 19:55:05 +02:00
|
|
|
f = formula do
|
|
|
|
sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8"
|
2017-02-27 18:51:11 +01:00
|
|
|
end
|
2017-07-29 19:55:05 +02:00
|
|
|
|
2023-03-08 23:14:46 +00:00
|
|
|
f.brew do
|
2023-01-26 21:18:24 -08:00
|
|
|
# do nothing
|
2023-03-08 23:14:46 +00:00
|
|
|
end
|
|
|
|
end.to raise_error(ChecksumMismatchError)
|
2017-02-27 18:51:11 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|