aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/os_requirement_spec.rb18
-rw-r--r--Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb21
-rw-r--r--Library/Homebrew/test/rubocops/lines_cop_spec.rb25
3 files changed, 59 insertions, 5 deletions
diff --git a/Library/Homebrew/test/os_requirement_spec.rb b/Library/Homebrew/test/os_requirement_spec.rb
new file mode 100644
index 000000000..87f86231c
--- /dev/null
+++ b/Library/Homebrew/test/os_requirement_spec.rb
@@ -0,0 +1,18 @@
+require "requirements/linux_requirement"
+require "requirements/macos_requirement"
+
+describe LinuxRequirement do
+ describe "#satisfied?" do
+ it "returns true if OS is Linux" do
+ expect(subject.satisfied?).to eq(OS.linux?)
+ end
+ end
+end
+
+describe MacOSRequirement do
+ describe "#satisfied?" do
+ it "returns true if OS is macOS" do
+ expect(subject.satisfied?).to eq(OS.mac?)
+ end
+ end
+end
diff --git a/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb b/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb
index ac8893e18..4816c3b26 100644
--- a/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb
+++ b/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb
@@ -27,6 +27,27 @@ describe RuboCop::Cop::FormulaAuditStrict::DescLength do
end
end
+ it "reports an offense when desc is an empty string" do
+ source = <<-EOS.undent
+ class Foo < Formula
+ url 'http://example.com/foo-1.0.tgz'
+ desc ''
+ end
+ EOS
+
+ msg = "The desc (description) should not be an empty string."
+ expected_offenses = [{ message: msg,
+ severity: :convention,
+ line: 3,
+ column: 2,
+ source: source }]
+
+ inspect_source(source, "/homebrew-core/Formula/foo.rb")
+ expected_offenses.zip(cop.offenses).each do |expected, actual|
+ expect_offense(expected, actual)
+ end
+ end
+
it "When desc is too long" do
source = <<-EOS.undent
class Foo < Formula
diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb
index 753439c8e..af816a5a9 100644
--- a/Library/Homebrew/test/rubocops/lines_cop_spec.rb
+++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb
@@ -82,7 +82,7 @@ end
describe RuboCop::Cop::FormulaAudit::Comments do
subject(:cop) { described_class.new }
- context "When auditing formula" do
+ context "When auditing formulae" do
it "with commented cmake call" do
source = <<-EOS.undent
class Foo < Formula
@@ -154,7 +154,7 @@ end
describe RuboCop::Cop::FormulaAudit::Miscellaneous do
subject(:cop) { described_class.new }
- context "When auditing formula" do
+ context "When auditing formulae" do
it "with FileUtils" do
source = <<-EOS.undent
class Foo < Formula
@@ -380,7 +380,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
end
end
- it "with build.universal? exempted formula" do
+ it "with a build.universal? exemption reports no offenses" do
source = <<-EOS.undent
class Wine < Formula
desc "foo"
@@ -392,7 +392,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
EOS
inspect_source(source, "/homebrew-core/Formula/wine.rb")
- expect(cop.offenses).to eq([])
+ expect(cop.offenses).to be_empty
end
it "with ENV.universal_binary" do
@@ -419,7 +419,22 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
end
end
- it "with ENV.universal_binary" do
+ it "with an ENV.universal_binary exemption reports no offenses" do
+ source = <<-EOS.undent
+ class Wine < Formula
+ desc "foo"
+ url 'http://example.com/foo-1.0.tgz'
+ if build?
+ ENV.universal_binary
+ end
+ end
+ EOS
+
+ inspect_source(source, "/homebrew-core/Formula/wine.rb")
+ expect(cop.offenses).to be_empty
+ end
+
+ it "with ENV.x11" do
source = <<-EOS.undent
class Foo < Formula
desc "foo"