aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorGautham Goli2017-06-16 19:44:14 +0530
committerGautham Goli2017-06-16 19:45:16 +0530
commit0e1c88e7aefb93a8e2cc927fa9a4e903ac015c57 (patch)
tree0c91ca4b66538b4d179fd7877fc2e2caf5368a48 /Library/Homebrew/test
parent77da75e7d6ecc2ca749eb939d8e24ad9e3dfc5e1 (diff)
downloadbrew-0e1c88e7aefb93a8e2cc927fa9a4e903ac015c57.tar.bz2
Refactor Checksum cop to add autocorrect method
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/rubocops/checksum_cop_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/Library/Homebrew/test/rubocops/checksum_cop_spec.rb b/Library/Homebrew/test/rubocops/checksum_cop_spec.rb
index 633f3117a..644152c32 100644
--- a/Library/Homebrew/test/rubocops/checksum_cop_spec.rb
+++ b/Library/Homebrew/test/rubocops/checksum_cop_spec.rb
@@ -108,7 +108,13 @@ describe RuboCop::Cop::FormulaAudit::Checksum do
expect_offense(expected, actual)
end
end
+ end
+end
+describe RuboCop::Cop::FormulaAudit::ChecksumCase do
+ subject(:cop) { described_class.new }
+
+ context "When auditing spec checksums" do
it "When the checksum has upper case characters" do
source = <<-EOS.undent
class Foo < Formula
@@ -176,4 +182,41 @@ describe RuboCop::Cop::FormulaAudit::Checksum do
end
end
end
+
+ context "When auditing checksum with autocorrect" do
+ it "When there is uppercase sha256" do
+ source = <<-EOS.undent
+ class Foo < Formula
+ url 'http://example.com/foo-1.0.tgz'
+ stable do
+ url "https://github.com/foo-lang/foo-compiler/archive/0.18.0.tar.gz"
+ sha256 "5cf6e1ae0A645b426c0a7cc7cd3f7d1605ffa1ac5756a39a8b2268ddc7ea0e9a"
+
+ resource "foo-package" do
+ url "https://github.com/foo-lang/foo-package/archive/0.18.0.tar.gz"
+ sha256 "5cf6e1Ae0a645b426b047aa4cc7cd3f7d1605ffa1ac5756a39a8b2268ddc7ea9"
+ end
+ end
+ end
+ EOS
+
+ corrected_source = <<-EOS.undent
+ class Foo < Formula
+ url 'http://example.com/foo-1.0.tgz'
+ stable do
+ url "https://github.com/foo-lang/foo-compiler/archive/0.18.0.tar.gz"
+ sha256 "5cf6e1ae0a645b426c0a7cc7cd3f7d1605ffa1ac5756a39a8b2268ddc7ea0e9a"
+
+ resource "foo-package" do
+ url "https://github.com/foo-lang/foo-package/archive/0.18.0.tar.gz"
+ sha256 "5cf6e1ae0a645b426b047aa4cc7cd3f7d1605ffa1ac5756a39a8b2268ddc7ea9"
+ end
+ end
+ end
+ EOS
+
+ new_source = autocorrect_source(cop, source)
+ expect(new_source).to eq(corrected_source)
+ end
+ end
end