Skip to content

Commit

Permalink
Merge pull request #10332 from SeekingMeaning/text_spec-descriptions
Browse files Browse the repository at this point in the history
rubocops/text: improve test descriptions
  • Loading branch information
SeekingMeaning committed Jan 18, 2021
2 parents 8869208 + 8fa263b commit 32ba87d
Showing 1 changed file with 27 additions and 45 deletions.
72 changes: 27 additions & 45 deletions Library/Homebrew/test/rubocops/text_spec.rb
Expand Up @@ -6,8 +6,8 @@
describe RuboCop::Cop::FormulaAudit::Text do
subject(:cop) { described_class.new }

context "When auditing formula text" do
it "with `require \"formula\"` is present" do
context "when auditing formula text" do
it 'reports an offense if `require "formula"` is present' do
expect_offense(<<~RUBY)
require "formula"
^^^^^^^^^^^^^^^^^ `require "formula"` is now unnecessary
Expand All @@ -25,7 +25,7 @@ class Foo < Formula
RUBY
end

it "with both openssl and libressl optional dependencies" do
it "reports an offense if both openssl and libressl are dependencies" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -36,9 +36,7 @@ class Foo < Formula
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae should not depend on both OpenSSL and LibreSSL (even optionally).
end
RUBY
end

it "with both openssl and libressl dependencies" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -51,7 +49,7 @@ class Foo < Formula
RUBY
end

it "when veclibfort is used instead of OpenBLAS" do
it "reports an offense if veclibfort is used instead of OpenBLAS (in homebrew/core)" do
expect_offense(<<~RUBY, "/homebrew-core/")
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -62,7 +60,7 @@ class Foo < Formula
RUBY
end

it "when lapack is used instead of OpenBLAS" do
it "reports an offense if lapack is used instead of OpenBLAS (in homebrew/core)" do
expect_offense(<<~RUBY, "/homebrew-core/")
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -73,7 +71,7 @@ class Foo < Formula
RUBY
end

it "When xcodebuild is called without SYMROOT" do
it "reports an offense if xcodebuild is called without SYMROOT" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -85,9 +83,7 @@ def install
end
end
RUBY
end

it "When xcodebuild is called without any args" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -101,7 +97,7 @@ def install
RUBY
end

it "When go get is executed" do
it "reports an offense if `go get` is executed" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -115,7 +111,7 @@ def install
RUBY
end

it "When xcodebuild is executed" do
it "reports an offense if `xcodebuild` is executed" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -129,7 +125,7 @@ def install
RUBY
end

it "When plist_options are not defined when using a formula-defined plist", :ruby23 do
it "reports an offense if `plist_options` are not defined when using a formula-defined `plist`", :ruby23 do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand Down Expand Up @@ -157,7 +153,7 @@ def plist
RUBY
end

it "When language/go is require'd" do
it 'reports an offense if `require "language/go"` is present' do
expect_offense(<<~RUBY)
require "language/go"
^^^^^^^^^^^^^^^^^^^^^ require "language/go" is unnecessary unless using `go_resource`s
Expand All @@ -174,7 +170,7 @@ def install
RUBY
end

it "When formula uses virtualenv and also `setuptools` resource" do
it "reports an offense if formula uses virtualenv and also `setuptools` resource" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -193,7 +189,7 @@ def install
RUBY
end

it "When Formula.factory(name) is used" do
it "reports an offense if `Formula.factory(name)` is present" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -207,7 +203,7 @@ def install
RUBY
end

it "When dep ensure is used without `-vendor-only`" do
it "reports an offense if `dep ensure` is used without `-vendor-only`" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -221,7 +217,7 @@ def install
RUBY
end

it "When cargo build is executed" do
it "reports an offense if `cargo build` is executed" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -235,7 +231,7 @@ def install
RUBY
end

it "When make calls are not separated" do
it "reports an offense if `make` calls are not separated" do
expect_offense(<<~RUBY)
class Foo < Formula
def install
Expand All @@ -246,7 +242,7 @@ def install
RUBY
end

it "When concatenating in string interpolation" do
it "reports an offense if paths are concatenated in string interpolation" do
expect_offense(<<~RUBY)
class Foo < Formula
def install
Expand All @@ -257,7 +253,7 @@ def install
RUBY
end

it "When using `prefix + \"bin\"` instead of `bin`" do
it 'reports an offense if `prefix + "bin"` is present' do
expect_offense(<<~RUBY)
class Foo < Formula
def install
Expand All @@ -266,9 +262,7 @@ def install
end
end
RUBY
end

it "When using `prefix + \"bin/foo\"` instead of `bin`" do
expect_offense(<<~RUBY)
class Foo < Formula
def install
Expand All @@ -284,8 +278,8 @@ def install
describe RuboCop::Cop::FormulaAuditStrict::Text do
subject(:cop) { described_class.new }

context "When auditing formula text" do
it "when deprecated `env :userpaths` is present" do
context "when auditing formula text in homebrew/core" do
it "reports an offense if `env :userpaths` is present" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -296,7 +290,7 @@ class Foo < Formula
RUBY
end

it "when deprecated `env :std` is present in homebrew-core" do
it "reports an offense if `env :std` is present in homebrew/core" do
expect_offense(<<~RUBY, "/homebrew-core/")
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -307,7 +301,7 @@ class Foo < Formula
RUBY
end

it "when `\#{share}/foo` is used instead of `\#{pkgshare}`" do
it %Q(reports an offense if "\#{share}/<formula name>" is present) do
expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
class Foo < Formula
def install
Expand All @@ -316,9 +310,7 @@ def install
end
end
RUBY
end

it "when `\#{share}/foo/bar` is used instead of `\#{pkgshare}/bar`" do
expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
class Foo < Formula
def install
Expand All @@ -327,11 +319,9 @@ def install
end
end
RUBY
end

it "when `\#{share}/foolibc++` is used instead of `\#{pkgshare}/foolibc++`" do
expect_offense(<<~RUBY, "/homebrew-core/Formula/foolibc++.rb")
class Foo < Formula
class Foolibcxx < Formula
def install
ohai "\#{share}/foolibc++"
^^^^^^^^^^^^^^^^^^^^ Use `\#{pkgshare}` instead of `\#{share}/foolibc++`
Expand All @@ -340,7 +330,7 @@ def install
RUBY
end

it "when `share/\"foo\"` is used instead of `pkgshare`" do
it 'reports an offense if `share/"<formula name>"` is present' do
expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
class Foo < Formula
def install
Expand All @@ -349,9 +339,7 @@ def install
end
end
RUBY
end

it "when `share/\"foo/bar\"` is used instead of `pkgshare`" do
expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
class Foo < Formula
def install
Expand All @@ -360,11 +348,9 @@ def install
end
end
RUBY
end

it "when `share/\"foolibc++\"` is used instead of `pkgshare`" do
expect_offense(<<~RUBY, "/homebrew-core/Formula/foolibc++.rb")
class Foo < Formula
class Foolibcxx < Formula
def install
ohai share/"foolibc++"
^^^^^^^^^^^^^^^^^ Use `pkgshare` instead of `share/"foolibc++"`
Expand All @@ -373,7 +359,7 @@ def install
RUBY
end

it "when `\#{share}/foo-bar` doesn't match formula name" do
it %Q(reports no offenses if "\#{share}/<directory name>" doesn't match formula name) do
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
class Foo < Formula
def install
Expand All @@ -383,27 +369,23 @@ def install
RUBY
end

it "when `share/foo-bar` doesn't match formula name" do
it 'reports no offenses if `share/"<formula name>"` is not present' do
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
class Foo < Formula
def install
ohai share/"foo-bar"
end
end
RUBY
end

it "when `share/bar` doesn't match formula name" do
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
class Foo < Formula
def install
ohai share/"bar"
end
end
RUBY
end

it "when formula name appears afer `share/\"bar\"`" do
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
class Foo < Formula
def install
Expand All @@ -413,7 +395,7 @@ def install
RUBY
end

it "when formula name appears afer `\"\#{share}/bar\"`" do
it %Q(reports no offenses if formula name appears afer "\#{share}/<directory name>") do
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
class Foo < Formula
def install
Expand Down

0 comments on commit 32ba87d

Please sign in to comment.