Merge pull request #17015 from Homebrew/describe-class

Enable RSpec/DescribeClass
This commit is contained in:
Mike McQuaid 2024-04-03 19:27:45 +01:00 committed by GitHub
commit fcc190b5c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 34 additions and 52 deletions

View File

@ -15,8 +15,7 @@ AllCops:
TargetRubyVersion: 3.1 TargetRubyVersion: 3.1
NewCops: enable NewCops: enable
Include: Include:
# FIXME: https://github.com/rubocop/rubocop/issues/12695 - "**/*.rbi"
- "Homebrew/**/*.rbi"
Exclude: Exclude:
- "Homebrew/sorbet/rbi/{dsl,gems}/**/*.rbi" - "Homebrew/sorbet/rbi/{dsl,gems}/**/*.rbi"
- "Homebrew/sorbet/rbi/parlour.rbi" - "Homebrew/sorbet/rbi/parlour.rbi"
@ -228,8 +227,6 @@ RSpec:
# Intentionally disabled as it doesn't fit with our code style. # Intentionally disabled as it doesn't fit with our code style.
RSpec/AnyInstance: RSpec/AnyInstance:
Enabled: false Enabled: false
RSpec/DescribeClass:
Enabled: false
RSpec/SpecFilePathFormat: RSpec/SpecFilePathFormat:
Enabled: false Enabled: false
RSpec/StubbedMock: RSpec/StubbedMock:

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.describe "Internal Tap JSON -- Formula" do RSpec.describe "Internal Tap JSON -- Formula", type: :system do
include FileUtils include FileUtils
let(:internal_tap_json) { File.read(TEST_FIXTURE_DIR/"internal_tap_json/homebrew-core.json").chomp } let(:internal_tap_json) { File.read(TEST_FIXTURE_DIR/"internal_tap_json/homebrew-core.json").chomp }

View File

@ -1,25 +0,0 @@
# frozen_string_literal: true
RSpec.describe "conflicts_with", :cask do
describe "conflicts_with cask" do
let(:local_caffeine) do
Cask::CaskLoader.load(cask_path("local-caffeine"))
end
let(:with_conflicts_with) do
Cask::CaskLoader.load(cask_path("with-conflicts-with"))
end
it "installs the dependency of a Cask and the Cask itself" do
Cask::Installer.new(local_caffeine).install
expect(local_caffeine).to be_installed
expect do
Cask::Installer.new(with_conflicts_with).install
end.to raise_error(Cask::CaskConflictError, "Cask 'with-conflicts-with' conflicts with 'local-caffeine'.")
expect(with_conflicts_with).not_to be_installed
end
end
end

View File

@ -2,7 +2,9 @@
# TODO: this test should be named after the corresponding class, once # TODO: this test should be named after the corresponding class, once
# that class is abstracted from installer.rb # that class is abstracted from installer.rb
# rubocop:disable RSpec/DescribeClass
RSpec.describe "Satisfy Dependencies and Requirements", :cask do RSpec.describe "Satisfy Dependencies and Requirements", :cask do
# rubocop:enable RSpec/DescribeClass
subject(:install) do subject(:install) do
Cask::Installer.new(cask).install Cask::Installer.new(cask).install
end end

View File

@ -444,6 +444,28 @@ RSpec.describe Cask::DSL, :cask do
end end
end end
describe "conflicts_with cask" do
let(:local_caffeine) do
Cask::CaskLoader.load(cask_path("local-caffeine"))
end
let(:with_conflicts_with) do
Cask::CaskLoader.load(cask_path("with-conflicts-with"))
end
it "installs the dependency of a Cask and the Cask itself" do
Cask::Installer.new(local_caffeine).install
expect(local_caffeine).to be_installed
expect do
Cask::Installer.new(with_conflicts_with).install
end.to raise_error(Cask::CaskConflictError, "Cask 'with-conflicts-with' conflicts with 'local-caffeine'.")
expect(with_conflicts_with).not_to be_installed
end
end
describe "conflicts_with stanza" do describe "conflicts_with stanza" do
context "when valid" do context "when valid" do
let(:token) { "with-conflicts-with" } let(:token) { "with-conflicts-with" }

View File

@ -1,8 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "cmd/shared_examples/args_parse" RSpec.describe "brew --version", type: :system do
RSpec.describe "brew --version" do
it "prints the Homebrew's version", :integration_test do it "prints the Homebrew's version", :integration_test do
expect { brew_sh "--version" } expect { brew_sh "--version" }
.to output(/^Homebrew #{Regexp.escape(HOMEBREW_VERSION)}\n/o).to_stdout .to output(/^Homebrew #{Regexp.escape(HOMEBREW_VERSION)}\n/o).to_stdout

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.describe "brew custom-external-command", :integration_test do RSpec.describe "brew custom-external-command", :integration_test, type: :system do
it "is supported" do it "is supported" do
mktmpdir do |path| mktmpdir do |path|
cmd = "custom-external-command-#{rand}" cmd = "custom-external-command-#{rand}"

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.describe "globally-scoped helper methods" do RSpec.describe Kernel do
let(:dir) { mktmpdir } let(:dir) { mktmpdir }
def esc(code) def esc(code)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.describe "brew", :integration_test do RSpec.describe Homebrew, :integration_test do
it "does not invoke `require \"formula\"` at startup" do it "does not invoke `require \"formula\"` at startup" do
expect { brew "verify-formula-undefined" } expect { brew "verify-formula-undefined" }
.to not_to_output.to_stdout .to not_to_output.to_stdout

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.describe "Mach-O" do RSpec.describe MachOShim do
describe "Pathname tests" do describe "Pathname tests" do
specify "fat dylib" do specify "fat dylib" do
pn = dylib_path("fat") pn = dylib_path("fat")

View File

@ -12,7 +12,7 @@
# Additionally, libffi version detection cannot be performed on systems running Mojave or earlier. # Additionally, libffi version detection cannot be performed on systems running Mojave or earlier.
# #
# For indeterminable cases, consult https://opensource.apple.com for the version used. # For indeterminable cases, consult https://opensource.apple.com for the version used.
RSpec.describe "pkg-config", :needs_ci do RSpec.describe "pkg-config", :needs_ci, type: :system do
def pc_version(library) def pc_version(library)
path = HOMEBREW_LIBRARY_PATH/"os/mac/pkgconfig/#{MacOS.version}/#{library}.pc" path = HOMEBREW_LIBRARY_PATH/"os/mac/pkgconfig/#{MacOS.version}/#{library}.pc"
version = File.foreach(path) version = File.foreach(path)

View File

@ -2,7 +2,7 @@
require "formula" require "formula"
RSpec.describe "patching" do RSpec.describe "patching", type: :system do
let(:formula_subclass) do let(:formula_subclass) do
Class.new(Formula) do Class.new(Formula) do
# These are defined within an anonymous class to avoid polluting the global namespace. # These are defined within an anonymous class to avoid polluting the global namespace.
@ -229,15 +229,3 @@ RSpec.describe "patching" do
end.to raise_error(BuildError) end.to raise_error(BuildError)
end end
end end
__END__
diff --git a/libexec/NOOP b/libexec/NOOP
index bfdda4c..e08d8f4 100755
--- a/libexec/NOOP
+++ b/libexec/NOOP
@@ -1,2 +1,2 @@
#!/bin/bash
-echo NOOP
\ No newline at end of file
+echo ABCD
\ No newline at end of file

View File

@ -3,7 +3,7 @@
require "rubygems" require "rubygems"
require "yaml" require "yaml"
RSpec.describe "Tapioca Config" do RSpec.describe "Tapioca Config", type: :system do
let(:config) { YAML.load_file(File.join(__dir__, "../../../sorbet/tapioca/config.yml")) } let(:config) { YAML.load_file(File.join(__dir__, "../../../sorbet/tapioca/config.yml")) }
it "only excludes dependencies" do it "only excludes dependencies" do