Merge pull request #10332 from SeekingMeaning/text_spec-descriptions
rubocops/text: improve test descriptions
This commit is contained in:
commit
32ba87d254
@ -6,8 +6,8 @@ require "rubocops/text"
|
|||||||
describe RuboCop::Cop::FormulaAudit::Text do
|
describe RuboCop::Cop::FormulaAudit::Text do
|
||||||
subject(:cop) { described_class.new }
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
context "When auditing formula text" do
|
context "when auditing formula text" do
|
||||||
it "with `require \"formula\"` is present" do
|
it 'reports an offense if `require "formula"` is present' do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
require "formula"
|
require "formula"
|
||||||
^^^^^^^^^^^^^^^^^ `require "formula"` is now unnecessary
|
^^^^^^^^^^^^^^^^^ `require "formula"` is now unnecessary
|
||||||
@ -25,7 +25,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -36,9 +36,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae should not depend on both OpenSSL and LibreSSL (even optionally).
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae should not depend on both OpenSSL and LibreSSL (even optionally).
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
|
||||||
|
|
||||||
it "with both openssl and libressl dependencies" do
|
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -51,7 +49,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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/")
|
expect_offense(<<~RUBY, "/homebrew-core/")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -62,7 +60,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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/")
|
expect_offense(<<~RUBY, "/homebrew-core/")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -73,7 +71,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "When xcodebuild is called without SYMROOT" do
|
it "reports an offense if xcodebuild is called without SYMROOT" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -85,9 +83,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
|
||||||
|
|
||||||
it "When xcodebuild is called without any args" do
|
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -101,7 +97,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "When go get is executed" do
|
it "reports an offense if `go get` is executed" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -115,7 +111,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "When xcodebuild is executed" do
|
it "reports an offense if `xcodebuild` is executed" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -129,7 +125,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -157,7 +153,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "When language/go is require'd" do
|
it 'reports an offense if `require "language/go"` is present' do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
require "language/go"
|
require "language/go"
|
||||||
^^^^^^^^^^^^^^^^^^^^^ require "language/go" is unnecessary unless using `go_resource`s
|
^^^^^^^^^^^^^^^^^^^^^ require "language/go" is unnecessary unless using `go_resource`s
|
||||||
@ -174,7 +170,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -193,7 +189,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "When Formula.factory(name) is used" do
|
it "reports an offense if `Formula.factory(name)` is present" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -207,7 +203,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -221,7 +217,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "When cargo build is executed" do
|
it "reports an offense if `cargo build` is executed" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -235,7 +231,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "When make calls are not separated" do
|
it "reports an offense if `make` calls are not separated" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -246,7 +242,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "When concatenating in string interpolation" do
|
it "reports an offense if paths are concatenated in string interpolation" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -257,7 +253,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "When using `prefix + \"bin\"` instead of `bin`" do
|
it 'reports an offense if `prefix + "bin"` is present' do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -266,9 +262,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
|
||||||
|
|
||||||
it "When using `prefix + \"bin/foo\"` instead of `bin`" do
|
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -284,8 +278,8 @@ end
|
|||||||
describe RuboCop::Cop::FormulaAuditStrict::Text do
|
describe RuboCop::Cop::FormulaAuditStrict::Text do
|
||||||
subject(:cop) { described_class.new }
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
context "When auditing formula text" do
|
context "when auditing formula text in homebrew/core" do
|
||||||
it "when deprecated `env :userpaths` is present" do
|
it "reports an offense if `env :userpaths` is present" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -296,7 +290,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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/")
|
expect_offense(<<~RUBY, "/homebrew-core/")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
@ -307,7 +301,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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")
|
expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -316,9 +310,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
|
||||||
|
|
||||||
it "when `\#{share}/foo/bar` is used instead of `\#{pkgshare}/bar`" do
|
|
||||||
expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -327,11 +319,9 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
|
||||||
|
|
||||||
it "when `\#{share}/foolibc++` is used instead of `\#{pkgshare}/foolibc++`" do
|
|
||||||
expect_offense(<<~RUBY, "/homebrew-core/Formula/foolibc++.rb")
|
expect_offense(<<~RUBY, "/homebrew-core/Formula/foolibc++.rb")
|
||||||
class Foo < Formula
|
class Foolibcxx < Formula
|
||||||
def install
|
def install
|
||||||
ohai "\#{share}/foolibc++"
|
ohai "\#{share}/foolibc++"
|
||||||
^^^^^^^^^^^^^^^^^^^^ Use `\#{pkgshare}` instead of `\#{share}/foolibc++`
|
^^^^^^^^^^^^^^^^^^^^ Use `\#{pkgshare}` instead of `\#{share}/foolibc++`
|
||||||
@ -340,7 +330,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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")
|
expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -349,9 +339,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
|
||||||
|
|
||||||
it "when `share/\"foo/bar\"` is used instead of `pkgshare`" do
|
|
||||||
expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -360,11 +348,9 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
|
||||||
|
|
||||||
it "when `share/\"foolibc++\"` is used instead of `pkgshare`" do
|
|
||||||
expect_offense(<<~RUBY, "/homebrew-core/Formula/foolibc++.rb")
|
expect_offense(<<~RUBY, "/homebrew-core/Formula/foolibc++.rb")
|
||||||
class Foo < Formula
|
class Foolibcxx < Formula
|
||||||
def install
|
def install
|
||||||
ohai share/"foolibc++"
|
ohai share/"foolibc++"
|
||||||
^^^^^^^^^^^^^^^^^ Use `pkgshare` instead of `share/"foolibc++"`
|
^^^^^^^^^^^^^^^^^ Use `pkgshare` instead of `share/"foolibc++"`
|
||||||
@ -373,7 +359,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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")
|
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -383,7 +369,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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")
|
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -391,9 +377,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
|
||||||
|
|
||||||
it "when `share/bar` doesn't match formula name" do
|
|
||||||
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -401,9 +385,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
|
||||||
|
|
||||||
it "when formula name appears afer `share/\"bar\"`" do
|
|
||||||
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
@ -413,7 +395,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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")
|
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
def install
|
def install
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user