diff options
| author | Markus Reiter | 2017-02-27 18:51:11 +0100 | 
|---|---|---|
| committer | Markus Reiter | 2017-02-27 18:53:31 +0100 | 
| commit | ba34cbdc6256b76cd5e3bb31dc9c3fc0ec511333 (patch) | |
| tree | 16a2588b94e0eaa7641efd8765fc226858c837b3 | |
| parent | bb18f5251628059a45f55f1e1fcfcd9819dd4ed1 (diff) | |
| download | brew-ba34cbdc6256b76cd5e3bb31dc9c3fc0ec511333.tar.bz2 | |
Convert `checksum_verification` test to spec.
| -rw-r--r-- | Library/Homebrew/test/checksum_verification_spec.rb | 36 | ||||
| -rw-r--r-- | Library/Homebrew/test/checksum_verification_test.rb | 35 | 
2 files changed, 36 insertions, 35 deletions
diff --git a/Library/Homebrew/test/checksum_verification_spec.rb b/Library/Homebrew/test/checksum_verification_spec.rb new file mode 100644 index 000000000..f749f2792 --- /dev/null +++ b/Library/Homebrew/test/checksum_verification_spec.rb @@ -0,0 +1,36 @@ +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 diff --git a/Library/Homebrew/test/checksum_verification_test.rb b/Library/Homebrew/test/checksum_verification_test.rb deleted file mode 100644 index 4c674edd2..000000000 --- a/Library/Homebrew/test/checksum_verification_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -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  | 
