diff --git a/Library/Homebrew/test/rubocops/components_order_spec.rb b/Library/Homebrew/test/rubocops/components_order_spec.rb index a3ffb2c781..c050472781 100644 --- a/Library/Homebrew/test/rubocops/components_order_spec.rb +++ b/Library/Homebrew/test/rubocops/components_order_spec.rb @@ -6,7 +6,7 @@ require "rubocops/components_order" describe RuboCop::Cop::FormulaAudit::ComponentsOrder do subject(:cop) { described_class.new } - context "When auditing formula components order" do + context "when auditing formula components order" do it "reports and corrects an offense when `uses_from_macos` precedes `depends_on`" do expect_offense(<<~RUBY) class Foo < Formula @@ -337,8 +337,8 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do RUBY end - context "no on_os_block" do - it "does not fail when there is no on_os block" do + context "when formula has no OS-specific blocks" do + it "reports no offenses" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -352,8 +352,8 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do end end - context "on_os_block" do - it "correctly uses on_macos and on_linux blocks" do + context "when formula has OS-specific block(s)" do + it "reports no offenses when `on_macos` and `on_linux` are used correctly" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -400,10 +400,8 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do end RUBY end - end - context "on_macos_block" do - it "correctly uses as single on_macos block" do + it "reports no offenses when `on_macos` is used correctly" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -418,10 +416,8 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do end RUBY end - end - context "on_linux_block" do - it "correctly uses as single on_linux block" do + it "reports no offenses when `on_linux` is used correctly" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -516,7 +512,7 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do RUBY end - it "reports no offenses for a valid `on_macos` and `on_linux` block with versions" do + it "reports no offenses for a valid `on_macos` and `on_linux` block (with `version`)" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" diff --git a/Library/Homebrew/test/rubocops/files_spec.rb b/Library/Homebrew/test/rubocops/files_spec.rb index 746b4212b7..e59550f692 100644 --- a/Library/Homebrew/test/rubocops/files_spec.rb +++ b/Library/Homebrew/test/rubocops/files_spec.rb @@ -6,8 +6,8 @@ require "rubocops/files" describe RuboCop::Cop::FormulaAudit::Files do subject(:cop) { described_class.new } - context "When auditing files" do - it "when the permissions are invalid" do + context "when auditing files" do + it "reports an offense when the permissions are invalid" do filename = Formulary.core_path("test_formula") File.open(filename, "w") do |file| FileUtils.chmod "-rwx", filename diff --git a/Library/Homebrew/test/rubocops/homepage_spec.rb b/Library/Homebrew/test/rubocops/homepage_spec.rb index 1458673a9c..023ac46318 100644 --- a/Library/Homebrew/test/rubocops/homepage_spec.rb +++ b/Library/Homebrew/test/rubocops/homepage_spec.rb @@ -6,7 +6,7 @@ require "rubocops/homepage" describe RuboCop::Cop::FormulaAudit::Homepage do subject(:cop) { described_class.new } - context "When auditing homepage" do + context "when auditing homepage" do it "reports an offense when there is no homepage" do expect_offense(<<~RUBY) class Foo < Formula diff --git a/Library/Homebrew/test/rubocops/lines_spec.rb b/Library/Homebrew/test/rubocops/lines_spec.rb index 3b11159129..fbd08fb2c4 100644 --- a/Library/Homebrew/test/rubocops/lines_spec.rb +++ b/Library/Homebrew/test/rubocops/lines_spec.rb @@ -62,7 +62,7 @@ end describe RuboCop::Cop::FormulaAudit::ClassInheritance do subject(:cop) { described_class.new } - context "auditing formula class inheritance" do + context "when auditing formula class inheritance" do it "reports an offense when not using spaces for class inheritance" do expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo "https://ftpmirror.gnu.org/lightning/lightning-2.1.0.tar.gz", "msg" => 'Please use "https://ftp.gnu.org/gnu/lightning/lightning-2.1.0.tar.gz" instead of https://ftpmirror.gnu.org/lightning/lightning-2.1.0.tar.gz.', @@ -183,21 +183,21 @@ describe RuboCop::Cop::FormulaAudit::Urls do }] } - context "When auditing urls" do - it "with offenses" do - formulae.each do |formula| + context "when auditing URLs" do + it "reports all offenses in `offense_list`" do + offense_list.each do |offense_info| allow_any_instance_of(RuboCop::Cop::FormulaCop).to receive(:formula_tap) - .and_return(formula["formula_tap"]) + .and_return(offense_info["formula_tap"]) source = <<~RUBY class Foo < Formula desc "foo" - url "#{formula["url"]}" + url "#{offense_info["url"]}" end RUBY - expected_offenses = [{ message: formula["msg"], + expected_offenses = [{ message: offense_info["msg"], severity: :convention, line: 3, - column: formula["col"], + column: offense_info["col"], source: source }] offenses = inspect_source(source) @@ -211,7 +211,7 @@ describe RuboCop::Cop::FormulaAudit::Urls do end end - it "with offenses in stable/head block" do + it "reports an offense for GitHub repositories with git:// prefix" do expect_offense(<<~RUBY) class Foo < Formula desc "foo" @@ -228,7 +228,7 @@ describe RuboCop::Cop::FormulaAudit::Urls do RUBY end - it "with duplicate mirror" do + it "reports an offense if `url` is the same as `mirror`" do expect_offense(<<~RUBY) class Foo < Formula desc "foo" diff --git a/Library/Homebrew/test/rubocops/version_spec.rb b/Library/Homebrew/test/rubocops/version_spec.rb index cf36fea015..c055fed61f 100644 --- a/Library/Homebrew/test/rubocops/version_spec.rb +++ b/Library/Homebrew/test/rubocops/version_spec.rb @@ -6,8 +6,8 @@ require "rubocops/version" describe RuboCop::Cop::FormulaAudit::Version do subject(:cop) { described_class.new } - context "When auditing version" do - it "version should not be an empty string" do + context "when auditing version" do + it "reports an offense if `version` is an empty string" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -17,7 +17,7 @@ describe RuboCop::Cop::FormulaAudit::Version do RUBY end - it "version should not have a leading 'v'" do + it "reports an offense if `version` has a leading 'v'" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -27,7 +27,7 @@ describe RuboCop::Cop::FormulaAudit::Version do RUBY end - it "version should not end with underline and number" do + it "reports an offense if `version` ends with an underline and a number" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz'