Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize RSpec configuration #16699

Merged
merged 8 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 16 additions & 10 deletions Library/Homebrew/extend/os/mac/dev-cmd/bottle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@
# frozen_string_literal: true

module Homebrew
sig { returns(T::Array[String]) }
def self.tar_args
if MacOS.version >= :catalina
["--no-mac-metadata", "--no-acls", "--no-xattrs"].freeze
else
[].freeze
class << self
undef tar_args
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved

sig { returns(T::Array[String]) }
def tar_args
if MacOS.version >= :catalina
["--no-mac-metadata", "--no-acls", "--no-xattrs"].freeze
else
[].freeze
end
end
end

sig { params(gnu_tar_formula: Formula).returns(String) }
def self.gnu_tar(gnu_tar_formula)
"#{gnu_tar_formula.opt_bin}/gtar"
undef gnu_tar
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved

sig { params(gnu_tar_formula: Formula).returns(String) }
def gnu_tar(gnu_tar_formula)
"#{gnu_tar_formula.opt_bin}/gtar"
end
end
end
2 changes: 0 additions & 2 deletions Library/Homebrew/livecheck/skip_conditions.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# typed: true
# frozen_string_literal: true

require "livecheck/livecheck"

module Homebrew
module Livecheck
# The `Livecheck::SkipConditions` module primarily contains methods that
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/ENV_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "extend/ENV"

describe "ENV" do
RSpec.describe "ENV" do
shared_examples EnvActivation do
subject(:env) { env_activation.extend(described_class) }

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/PATH_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "PATH"

describe PATH do
RSpec.describe PATH do
describe "#initialize" do
it "can take multiple arguments" do
expect(described_class.new("/path1", "/path2")).to eq("/path1:/path2")
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/api/cask_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "api"

describe Homebrew::API::Cask do
RSpec.describe Homebrew::API::Cask do
let(:cache_dir) { mktmpdir }

before do
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/api/formula_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "api"

describe Homebrew::API::Formula do
RSpec.describe Homebrew::API::Formula do
let(:cache_dir) { mktmpdir }

before do
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "api"

describe Homebrew::API do
RSpec.describe Homebrew::API do
let(:text) { "foo" }
let(:json) { '{"foo":"bar"}' }
let(:json_hash) { JSON.parse(json) }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/bash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "open3"

describe "Bash" do
RSpec.describe "Bash" do
matcher :have_valid_bash_syntax do
match do |file|
stdout, stderr, status = Open3.capture3("/bin/bash", "-n", file)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/bottle_filename_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "formula"
require "software_spec"

describe Bottle::Filename do
RSpec.describe Bottle::Filename do
subject { described_class.new(name, version, tag, rebuild) }

let(:name) { "user/repo/foo" }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/build_environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "build_environment"

describe BuildEnvironment do
RSpec.describe BuildEnvironment do
let(:env) { described_class.new }

describe "#<<" do
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/build_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "build_options"
require "options"

describe BuildOptions do
RSpec.describe BuildOptions do
alias_matcher :be_built_with, :be_with
alias_matcher :be_built_without, :be_without

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/bump_version_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "bump_version_parser"

describe Homebrew::BumpVersionParser do
RSpec.describe Homebrew::BumpVersionParser do
let(:general_version) { "1.2.3" }
let(:intel_version) { "2.3.4" }
let(:arm_version) { "3.4.5" }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/bundle_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "bundle_version"

describe Homebrew::BundleVersion do
RSpec.describe Homebrew::BundleVersion do
describe "#<=>" do
it "compares both the `short_version` and `version`" do
expect(described_class.new("1.2.3", "3000")).to be < described_class.new("1.2.3", "4000")
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cache_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "cache_store"

describe CacheStoreDatabase do
RSpec.describe CacheStoreDatabase do
subject(:sample_db) { described_class.new(:sample) }

describe "self.use" do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::AbstractArtifact, :cask do
RSpec.describe Cask::Artifact::AbstractArtifact, :cask do
describe ".read_script_arguments" do
let(:stanza) { :installer }

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/artifact/alt_target_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::App, :cask do
RSpec.describe Cask::Artifact::App, :cask do
describe "activate to alternate target" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-alt-target")) }

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/artifact/app_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::App, :cask do
RSpec.describe Cask::Artifact::App, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("local-caffeine")) }
let(:command) { NeverSudoSystemCommand }
let(:adopt) { false }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/artifact/binary_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::Binary, :cask do
RSpec.describe Cask::Artifact::Binary, :cask do
let(:cask) do
Cask::CaskLoader.load(cask_path("with-binary")).tap do |cask|
InstallHelper.install_without_artifacts(cask)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::Artifact, :cask do
RSpec.describe Cask::Artifact::Artifact, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-generic-artifact")) }

let(:install_phase) do
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/artifact/installer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::Installer, :cask do
RSpec.describe Cask::Artifact::Installer, :cask do
subject(:installer) { described_class.new(cask, **args) }

let(:staged_path) { mktmpdir }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/artifact/manpage_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::Manpage, :cask do
RSpec.describe Cask::Artifact::Manpage, :cask do
let(:cask) { Cask::CaskLoader.load(cask_token) }

context "without section" do
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/artifact/pkg_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::Pkg, :cask do
RSpec.describe Cask::Artifact::Pkg, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-installable")) }
let(:fake_system_command) { class_double(SystemCommand) }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::PostflightBlock, :cask do
RSpec.describe Cask::Artifact::PostflightBlock, :cask do
describe "install_phase" do
it "calls the specified block after installing, passing a Cask mini-dsl" do
called = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::PreflightBlock, :cask do
RSpec.describe Cask::Artifact::PreflightBlock, :cask do
describe "install_phase" do
it "calls the specified block before installing, passing a Cask mini-dsl" do
called = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "benchmark"

shared_examples "#uninstall_phase or #zap_phase" do
RSpec.shared_examples "#uninstall_phase or #zap_phase" do
subject { artifact }

let(:artifact_dsl_key) { described_class.dsl_key }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/artifact/suite_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::Suite, :cask do
RSpec.describe Cask::Artifact::Suite, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-suite")) }

let(:install_phase) do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::App, :cask do
RSpec.describe Cask::Artifact::App, :cask do
describe "multiple apps" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-two-apps-correct")) }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Artifact::Zap, :cask do
RSpec.describe Cask::Artifact::Zap, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-installable")) }

let(:zap_artifact) do
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/artifact/uninstall_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_relative "shared_examples/uninstall_zap"

describe Cask::Artifact::Uninstall, :cask do
RSpec.describe Cask::Artifact::Uninstall, :cask do
describe "#uninstall_phase" do
include_examples "#uninstall_phase or #zap_phase"
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/artifact/zap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_relative "shared_examples/uninstall_zap"

describe Cask::Artifact::Zap, :cask do
RSpec.describe Cask::Artifact::Zap, :cask do
describe "#zap_phase" do
include_examples "#uninstall_phase or #zap_phase"

Expand Down
4 changes: 1 addition & 3 deletions Library/Homebrew/test/cask/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "cask/audit"

describe Cask::Audit, :cask do
RSpec.describe Cask::Audit, :cask do
def include_msg?(problems, msg)
if msg.is_a?(Regexp)
Array(problems).any? { |problem| msg.match?(problem[:message]) }
Expand Down Expand Up @@ -472,7 +472,6 @@ def tmp_cask(name, text)

before do
allow(audit).to receive_messages(download: download_double, signing?: true)
allow(audit).to receive(:check_https_availability)
end

context "when cask is not using a signed artifact" do
Expand Down Expand Up @@ -1024,7 +1023,6 @@ def tmp_cask(name, text)

before do
allow(audit).to receive(:download).and_return(download_double)
allow(audit).to receive(:check_https_availability)
allow(UnpackStrategy).to receive(:detect).and_return(nil)
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::CaskLoader::FromAPILoader, :cask do
RSpec.describe Cask::CaskLoader::FromAPILoader, :cask do
shared_context "with API setup" do |new_token|
let(:token) { new_token }
let(:cask_from_source) { Cask::CaskLoader.load(token) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::CaskLoader::FromContentLoader do
RSpec.describe Cask::CaskLoader::FromContentLoader do
describe "::try_new" do
it "returns a loader for Casks specified with `cask \"token\" do … end`" do
expect(described_class.try_new(<<~RUBY)).not_to be_nil
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::CaskLoader::FromPathLoader do
RSpec.describe Cask::CaskLoader::FromPathLoader do
describe "#load" do
context "when the file does not contain a cask" do
let(:path) do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::CaskLoader::FromTapLoader do
RSpec.describe Cask::CaskLoader::FromTapLoader do
let(:cask_name) { "testball" }
let(:cask_full_name) { "homebrew/cask/#{cask_name}" }
let(:cask_path) { CoreCaskTap.instance.cask_dir/"#{cask_name}.rb" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::CaskLoader::FromURILoader do
RSpec.describe Cask::CaskLoader::FromURILoader do
describe "::try_new" do
it "returns a loader when given an URI" do
expect(described_class.try_new(URI("https://brew.sh/"))).not_to be_nil
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/cask_loader_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::CaskLoader, :cask do
RSpec.describe Cask::CaskLoader, :cask do
describe "::for" do
let(:tap) { CoreCaskTap.instance }

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/cask_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Cask, :cask do
RSpec.describe Cask::Cask, :cask do
let(:cask) { described_class.new("versioned-cask") }

context "when multiple versions are installed" do
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Cask::Config, :cask do
RSpec.describe Cask::Config, :cask do
subject(:config) { described_class.new }

describe "::from_json" do
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/conflicts_with_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe "conflicts_with", :cask do
RSpec.describe "conflicts_with", :cask do
describe "conflicts_with cask" do
let(:local_caffeine) do
Cask::CaskLoader.load(cask_path("local-caffeine"))
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/denylist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "cask/denylist"

describe Cask::Denylist, :cask do
RSpec.describe Cask::Denylist, :cask do
describe "::reason" do
matcher :disallow do |name|
match do |expected|
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/depends_on_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# TODO: this test should be named after the corresponding class, once
# that class is abstracted from installer.rb
describe "Satisfy Dependencies and Requirements", :cask do
RSpec.describe "Satisfy Dependencies and Requirements", :cask do
subject(:install) do
Cask::Installer.new(cask).install
end
Expand Down
Loading
Loading