Merge pull request #15263 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rspec-2.20.0

build(deps): bump rubocop-rspec from 2.19.0 to 2.20.0 in /Library/Homebrew
This commit is contained in:
Issy Long 2023-04-22 18:58:03 +01:00 committed by GitHub
commit 935649abaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
161 changed files with 474 additions and 180 deletions

View File

@ -151,7 +151,7 @@ GEM
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0) rubocop (>= 1.33.0, < 2.0)
rubocop-rspec (2.19.0) rubocop-rspec (2.20.0)
rubocop (~> 1.33) rubocop (~> 1.33)
rubocop-capybara (~> 2.17) rubocop-capybara (~> 2.17)
rubocop-sorbet (0.7.0) rubocop-sorbet (0.7.0)

View File

@ -85,6 +85,16 @@ end
RuboCop::Cop::RSpec::Be::MSG = T.let(T.unsafe(nil), String) RuboCop::Cop::RSpec::Be::MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::RSpec::Be::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array) RuboCop::Cop::RSpec::Be::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
class RuboCop::Cop::RSpec::BeEmpty < ::RuboCop::Cop::RSpec::Base
extend ::RuboCop::Cop::AutoCorrector
def expect_array_matcher?(param0 = T.unsafe(nil)); end
def on_send(node); end
end
RuboCop::Cop::RSpec::BeEmpty::MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::RSpec::BeEmpty::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
class RuboCop::Cop::RSpec::BeEq < ::RuboCop::Cop::RSpec::Base class RuboCop::Cop::RSpec::BeEq < ::RuboCop::Cop::RSpec::Base
extend ::RuboCop::Cop::AutoCorrector extend ::RuboCop::Cop::AutoCorrector
@ -219,7 +229,8 @@ class RuboCop::Cop::RSpec::ContainExactly < ::RuboCop::Cop::RSpec::Base
private private
def autocorrect(node, corrector); end def autocorrect_for_populated_array(node, corrector); end
def check_populated_collection(node); end
end end
RuboCop::Cop::RSpec::ContainExactly::MSG = T.let(T.unsafe(nil), String) RuboCop::Cop::RSpec::ContainExactly::MSG = T.let(T.unsafe(nil), String)
@ -325,7 +336,7 @@ RuboCop::Cop::RSpec::DescribedClass::DESCRIBED_CLASS = T.let(T.unsafe(nil), Stri
RuboCop::Cop::RSpec::DescribedClass::MSG = T.let(T.unsafe(nil), String) RuboCop::Cop::RSpec::DescribedClass::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::RSpec::DescribedClassModuleWrapping < ::RuboCop::Cop::RSpec::Base class RuboCop::Cop::RSpec::DescribedClassModuleWrapping < ::RuboCop::Cop::RSpec::Base
def find_rspec_blocks(param0); end def include_rspec_blocks?(param0); end
def on_module(node); end def on_module(node); end
end end
@ -662,6 +673,7 @@ class RuboCop::Cop::RSpec::FactoryBot::ConsistentParenthesesStyle < ::RuboCop::C
end end
end end
RuboCop::Cop::RSpec::FactoryBot::ConsistentParenthesesStyle::AMBIGUOUS_TYPES = T.let(T.unsafe(nil), Array)
RuboCop::Cop::RSpec::FactoryBot::ConsistentParenthesesStyle::FACTORY_CALLS = T.let(T.unsafe(nil), Set) RuboCop::Cop::RSpec::FactoryBot::ConsistentParenthesesStyle::FACTORY_CALLS = T.let(T.unsafe(nil), Set)
RuboCop::Cop::RSpec::FactoryBot::ConsistentParenthesesStyle::MSG_OMIT_PARENS = T.let(T.unsafe(nil), String) RuboCop::Cop::RSpec::FactoryBot::ConsistentParenthesesStyle::MSG_OMIT_PARENS = T.let(T.unsafe(nil), String)
RuboCop::Cop::RSpec::FactoryBot::ConsistentParenthesesStyle::MSG_REQUIRE_PARENS = T.let(T.unsafe(nil), String) RuboCop::Cop::RSpec::FactoryBot::ConsistentParenthesesStyle::MSG_REQUIRE_PARENS = T.let(T.unsafe(nil), String)
@ -938,6 +950,19 @@ RuboCop::Cop::RSpec::ImplicitSubject::MSG_REQUIRE_EXPLICIT = T.let(T.unsafe(nil)
RuboCop::Cop::RSpec::ImplicitSubject::MSG_REQUIRE_IMPLICIT = T.let(T.unsafe(nil), String) RuboCop::Cop::RSpec::ImplicitSubject::MSG_REQUIRE_IMPLICIT = T.let(T.unsafe(nil), String)
RuboCop::Cop::RSpec::ImplicitSubject::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array) RuboCop::Cop::RSpec::ImplicitSubject::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
class RuboCop::Cop::RSpec::IndexedLet < ::RuboCop::Cop::RSpec::Base
def let_name(param0 = T.unsafe(nil)); end
def on_block(node); end
private
def filter_indexed_lets(candidates); end
def indexed_let?(node); end
end
RuboCop::Cop::RSpec::IndexedLet::INDEX_REGEX = T.let(T.unsafe(nil), Regexp)
RuboCop::Cop::RSpec::IndexedLet::MSG = T.let(T.unsafe(nil), String)
module RuboCop::Cop::RSpec::InflectedHelper module RuboCop::Cop::RSpec::InflectedHelper
include ::RuboCop::RSpec::Language include ::RuboCop::RSpec::Language
extend ::RuboCop::AST::NodePattern::Macros extend ::RuboCop::AST::NodePattern::Macros
@ -1107,7 +1132,12 @@ end
class RuboCop::Cop::RSpec::MatchArray < ::RuboCop::Cop::RSpec::Base class RuboCop::Cop::RSpec::MatchArray < ::RuboCop::Cop::RSpec::Base
extend ::RuboCop::Cop::AutoCorrector extend ::RuboCop::Cop::AutoCorrector
def match_array_with_empty_array?(param0 = T.unsafe(nil)); end
def on_send(node); end def on_send(node); end
private
def check_populated_array(node); end
end end
RuboCop::Cop::RSpec::MatchArray::MSG = T.let(T.unsafe(nil), String) RuboCop::Cop::RSpec::MatchArray::MSG = T.let(T.unsafe(nil), String)
@ -1346,6 +1376,7 @@ class RuboCop::Cop::RSpec::PendingWithoutReason < ::RuboCop::Cop::RSpec::Base
def pending_step_without_reason?(param0 = T.unsafe(nil)); end def pending_step_without_reason?(param0 = T.unsafe(nil)); end
def skipped_by_example_group_method?(param0 = T.unsafe(nil)); end def skipped_by_example_group_method?(param0 = T.unsafe(nil)); end
def skipped_by_example_method?(param0 = T.unsafe(nil)); end def skipped_by_example_method?(param0 = T.unsafe(nil)); end
def skipped_by_example_method_with_block?(param0 = T.unsafe(nil)); end
def skipped_in_example?(param0 = T.unsafe(nil)); end def skipped_in_example?(param0 = T.unsafe(nil)); end
private private
@ -1354,7 +1385,7 @@ class RuboCop::Cop::RSpec::PendingWithoutReason < ::RuboCop::Cop::RSpec::Base
def on_pending_by_metadata(node); end def on_pending_by_metadata(node); end
def on_skipped_by_example_group_method(node); end def on_skipped_by_example_group_method(node); end
def on_skipped_by_example_method(node); end def on_skipped_by_example_method(node); end
def on_skipped_by_in_example_method(node, _direct_parent); end def on_skipped_by_in_example_method(node); end
def parent_node(node); end def parent_node(node); end
end end
@ -1405,42 +1436,55 @@ class RuboCop::Cop::RSpec::Rails::HttpStatus < ::RuboCop::Cop::RSpec::Base
def checker_class; end def checker_class; end
end end
class RuboCop::Cop::RSpec::Rails::HttpStatus::NumericStyleChecker class RuboCop::Cop::RSpec::Rails::HttpStatus::BeStatusStyleChecker < ::RuboCop::Cop::RSpec::Rails::HttpStatus::StyleCheckerBase
def initialize(node); end def current; end
def offense_range; end
def message; end
def node; end
def offensive?; end def offensive?; end
def preferred_style; end def prefer; end
private
def number; end
def symbol; end
end
class RuboCop::Cop::RSpec::Rails::HttpStatus::NumericStyleChecker < ::RuboCop::Cop::RSpec::Rails::HttpStatus::StyleCheckerBase
def current; end
def offensive?; end
def prefer; end
private private
def allowed_symbol?; end
def number; end def number; end
def symbol; end def symbol; end
end end
RuboCop::Cop::RSpec::Rails::HttpStatus::NumericStyleChecker::ALLOWED_STATUSES = T.let(T.unsafe(nil), Array)
RuboCop::Cop::RSpec::Rails::HttpStatus::NumericStyleChecker::MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::RSpec::Rails::HttpStatus::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array) RuboCop::Cop::RSpec::Rails::HttpStatus::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
class RuboCop::Cop::RSpec::Rails::HttpStatus::SymbolicStyleChecker class RuboCop::Cop::RSpec::Rails::HttpStatus::StyleCheckerBase
def initialize(node); end def initialize(node); end
def allowed_symbol?; end
def custom_http_status_code?; end
def message; end def message; end
def node; end def node; end
def offense_range; end
end
RuboCop::Cop::RSpec::Rails::HttpStatus::StyleCheckerBase::ALLOWED_STATUSES = T.let(T.unsafe(nil), Array)
RuboCop::Cop::RSpec::Rails::HttpStatus::StyleCheckerBase::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::RSpec::Rails::HttpStatus::SymbolicStyleChecker < ::RuboCop::Cop::RSpec::Rails::HttpStatus::StyleCheckerBase
def current; end
def offensive?; end def offensive?; end
def preferred_style; end def prefer; end
private private
def custom_http_status_code?; end
def number; end def number; end
def symbol; end def symbol; end
end end
RuboCop::Cop::RSpec::Rails::HttpStatus::SymbolicStyleChecker::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::RSpec::Rails::InferredSpecType < ::RuboCop::Cop::RSpec::Base class RuboCop::Cop::RSpec::Rails::InferredSpecType < ::RuboCop::Cop::RSpec::Base
extend ::RuboCop::Cop::AutoCorrector extend ::RuboCop::Cop::AutoCorrector
@ -1683,11 +1727,16 @@ end
RuboCop::Cop::RSpec::ScatteredLet::MSG = T.let(T.unsafe(nil), String) RuboCop::Cop::RSpec::ScatteredLet::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::RSpec::ScatteredSetup < ::RuboCop::Cop::RSpec::Base class RuboCop::Cop::RSpec::ScatteredSetup < ::RuboCop::Cop::RSpec::Base
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
def on_block(node); end def on_block(node); end
private private
def autocorrect(corrector, first_occurrence, occurrence); end
def lines_msg(numbers); end def lines_msg(numbers); end
def message(occurrences, occurrence); end
def repeated_hooks(node); end def repeated_hooks(node); end
end end

View File

@ -6520,6 +6520,7 @@ module RuboCop::AST::NodePattern::Sets
SET_MAC_LINUX = ::T.let(nil, ::T.untyped) SET_MAC_LINUX = ::T.let(nil, ::T.untyped)
SET_ON_INTEL_ON_ARM = ::T.let(nil, ::T.untyped) SET_ON_INTEL_ON_ARM = ::T.let(nil, ::T.untyped)
SET_OR_NEWER_OR_OLDER = ::T.let(nil, ::T.untyped) SET_OR_NEWER_OR_OLDER = ::T.let(nil, ::T.untyped)
SET_STATUS_CODE = ::T.let(nil, ::T.untyped)
SET_SYSTEM_SHELL_OUTPUT_PIPE_OUTPUT = ::T.let(nil, ::T.untyped) SET_SYSTEM_SHELL_OUTPUT_PIPE_OUTPUT = ::T.let(nil, ::T.untyped)
SET_T_TRANSLATE_L_LOCALIZE = ::T.let(nil, ::T.untyped) SET_T_TRANSLATE_L_LOCALIZE = ::T.let(nil, ::T.untyped)
SET_WITH_WITHOUT = ::T.let(nil, ::T.untyped) SET_WITH_WITHOUT = ::T.let(nil, ::T.untyped)

View File

@ -3,8 +3,8 @@
require "cask/upgrade" require "cask/upgrade"
describe Cask::Upgrade, :cask do describe Cask::Upgrade, :cask do
let(:version_latest_path_2) { version_latest.config.appdir.join("Caffeine Pro.app") } let(:version_latest_path_second) { version_latest.config.appdir.join("Caffeine Pro.app") }
let(:version_latest_path_1) { version_latest.config.appdir.join("Caffeine Mini.app") } let(:version_latest_path_first) { version_latest.config.appdir.join("Caffeine Mini.app") }
let(:version_latest) { Cask::CaskLoader.load("version-latest") } let(:version_latest) { Cask::CaskLoader.load("version-latest") }
let(:auto_updates_path) { auto_updates.config.appdir.join("MyFancyApp.app") } let(:auto_updates_path) { auto_updates.config.appdir.join("MyFancyApp.app") }
let(:auto_updates) { Cask::CaskLoader.load("auto-updates") } let(:auto_updates) { Cask::CaskLoader.load("auto-updates") }
@ -107,7 +107,7 @@ describe Cask::Upgrade, :cask do
expect(local_transmission.versions).to include("2.60") expect(local_transmission.versions).to include("2.60")
expect(version_latest).to be_installed expect(version_latest).to be_installed
expect(version_latest_path_1).to be_a_directory expect(version_latest_path_first).to be_a_directory
expect(version_latest.versions).to include("latest") expect(version_latest.versions).to include("latest")
# Change download sha so that :latest cask decides to update itself # Change download sha so that :latest cask decides to update itself
version_latest.download_sha_path.write("fake download sha") version_latest.download_sha_path.write("fake download sha")
@ -128,7 +128,7 @@ describe Cask::Upgrade, :cask do
expect(local_transmission.versions).to include("2.61") expect(local_transmission.versions).to include("2.61")
expect(version_latest).to be_installed expect(version_latest).to be_installed
expect(version_latest_path_2).to be_a_directory expect(version_latest_path_second).to be_a_directory
expect(version_latest.versions).to include("latest") expect(version_latest.versions).to include("latest")
expect(version_latest.outdated_download_sha?).to be(false) expect(version_latest.outdated_download_sha?).to be(false)
end end
@ -153,8 +153,8 @@ describe Cask::Upgrade, :cask do
it 'does not include the Casks with "version latest" when the version did not change' do it 'does not include the Casks with "version latest" when the version did not change' do
expect(version_latest).to be_installed expect(version_latest).to be_installed
expect(version_latest_path_1).to be_a_directory expect(version_latest_path_first).to be_a_directory
expect(version_latest_path_2).to be_a_directory expect(version_latest_path_second).to be_a_directory
expect(version_latest.versions).to include("latest") expect(version_latest.versions).to include("latest")
# Change download sha so that :latest cask decides to update itself # Change download sha so that :latest cask decides to update itself
version_latest.download_sha_path.write("fake download sha") version_latest.download_sha_path.write("fake download sha")
@ -163,16 +163,16 @@ describe Cask::Upgrade, :cask do
described_class.upgrade_casks(version_latest, greedy: true, args: args) described_class.upgrade_casks(version_latest, greedy: true, args: args)
expect(version_latest).to be_installed expect(version_latest).to be_installed
expect(version_latest_path_1).to be_a_directory expect(version_latest_path_first).to be_a_directory
expect(version_latest_path_2).to be_a_directory expect(version_latest_path_second).to be_a_directory
expect(version_latest.versions).to include("latest") expect(version_latest.versions).to include("latest")
expect(version_latest.outdated_download_sha?).to be(false) expect(version_latest.outdated_download_sha?).to be(false)
described_class.upgrade_casks(version_latest, greedy: true, args: args) described_class.upgrade_casks(version_latest, greedy: true, args: args)
expect(version_latest).to be_installed expect(version_latest).to be_installed
expect(version_latest_path_1).to be_a_directory expect(version_latest_path_first).to be_a_directory
expect(version_latest_path_2).to be_a_directory expect(version_latest_path_second).to be_a_directory
expect(version_latest.versions).to include("latest") expect(version_latest.versions).to include("latest")
expect(version_latest.outdated_download_sha?).to be(false) expect(version_latest.outdated_download_sha?).to be(false)
end end
@ -330,8 +330,8 @@ describe Cask::Upgrade, :cask do
expect(described_class).not_to receive(:upgrade_cask) expect(described_class).not_to receive(:upgrade_cask)
expect(version_latest).to be_installed expect(version_latest).to be_installed
expect(version_latest_path_1).to be_a_directory expect(version_latest_path_first).to be_a_directory
expect(version_latest_path_2).to be_a_directory expect(version_latest_path_second).to be_a_directory
expect(version_latest.versions).to include("latest") expect(version_latest.versions).to include("latest")
# Change download sha so that :latest cask decides to update itself # Change download sha so that :latest cask decides to update itself
version_latest.download_sha_path.write("fake download sha") version_latest.download_sha_path.write("fake download sha")
@ -340,8 +340,8 @@ describe Cask::Upgrade, :cask do
described_class.upgrade_casks(version_latest, dry_run: true, greedy: true, args: args) described_class.upgrade_casks(version_latest, dry_run: true, greedy: true, args: args)
expect(version_latest).to be_installed expect(version_latest).to be_installed
expect(version_latest_path_1).to be_a_directory expect(version_latest_path_first).to be_a_directory
expect(version_latest_path_2).to be_a_directory expect(version_latest_path_second).to be_a_directory
expect(version_latest.versions).to include("latest") expect(version_latest.versions).to include("latest")
expect(version_latest.outdated_download_sha?).to be(true) expect(version_latest.outdated_download_sha?).to be(true)
end end

View File

@ -66,11 +66,11 @@ describe Homebrew::Cleanup do
end end
context "when it can't remove a keg" do context "when it can't remove a keg" do
let(:f1) { Class.new(Testball) { version "0.1" }.new } let(:formula_zero_dot_one) { Class.new(Testball) { version "0.1" }.new }
let(:f2) { Class.new(Testball) { version "0.2" }.new } let(:formula_zero_dot_two) { Class.new(Testball) { version "0.2" }.new }
before do before do
[f1, f2].each do |f| [formula_zero_dot_one, formula_zero_dot_two].each do |f|
f.brew do f.brew do
f.install f.install
end end
@ -84,13 +84,13 @@ describe Homebrew::Cleanup do
end end
it "doesn't remove any kegs" do it "doesn't remove any kegs" do
cleanup.cleanup_formula f2 cleanup.cleanup_formula formula_zero_dot_one
expect(f1.installed_kegs.size).to eq(2) expect(formula_zero_dot_one.installed_kegs.size).to eq(2)
end end
it "lists the unremovable kegs" do it "lists the unremovable kegs" do
cleanup.cleanup_formula f2 cleanup.cleanup_formula formula_zero_dot_two
expect(cleanup.unremovable_kegs).to contain_exactly(f1.installed_kegs[0]) expect(cleanup.unremovable_kegs).to contain_exactly(formula_zero_dot_one.installed_kegs[0])
end end
end end
end end

View File

@ -202,10 +202,10 @@ describe "Exception" do
end end
describe ChecksumMismatchError do describe ChecksumMismatchError do
subject { described_class.new("/file.tar.gz", hash1, hash2) } subject { described_class.new("/file.tar.gz", expected_checksum, actual_checksum) }
let(:hash1) { instance_double(Checksum, to_s: "deadbeef") } let(:expected_checksum) { instance_double(Checksum, to_s: "deadbeef") }
let(:hash2) { instance_double(Checksum, to_s: "deadcafe") } let(:actual_checksum) { instance_double(Checksum, to_s: "deadcafe") }
its(:to_s) { is_expected.to match(/SHA256 mismatch/) } its(:to_s) { is_expected.to match(/SHA256 mismatch/) }
end end

View File

@ -145,16 +145,16 @@ describe "globally-scoped helper methods" do
end end
describe "#which_all" do describe "#which_all" do
let(:cmd1) { dir/"foo" } let(:cmd_foo) { dir/"foo" }
let(:cmd2) { dir/"bar/foo" } let(:cmd_foo_bar) { dir/"bar/foo" }
let(:cmd3) { dir/"bar/baz/foo" } let(:cmd_bar_baz_foo) { dir/"bar/baz/foo" }
before do before do
(dir/"bar/baz").mkpath (dir/"bar/baz").mkpath
FileUtils.touch cmd2 FileUtils.touch cmd_foo_bar
[cmd1, cmd3].each do |cmd| [cmd_foo, cmd_bar_baz_foo].each do |cmd|
FileUtils.touch cmd FileUtils.touch cmd
cmd.chmod 0744 cmd.chmod 0744
end end
@ -166,7 +166,7 @@ describe "globally-scoped helper methods" do
"#{dir}/baz:#{dir}", "#{dir}/baz:#{dir}",
"~baduserpath", "~baduserpath",
].join(File::PATH_SEPARATOR) ].join(File::PATH_SEPARATOR)
expect(which_all("foo", path)).to eq([cmd3, cmd1]) expect(which_all("foo", path)).to eq([cmd_bar_baz_foo, cmd_foo])
end end
end end

View File

@ -76,15 +76,14 @@ describe PkgVersion do
end end
describe "#hash" do describe "#hash" do
let(:p1) { described_class.new(Version.create("1.0"), 1) } let(:version_one_revision_one) { described_class.new(Version.create("1.0"), 1) }
let(:p2) { described_class.new(Version.create("1.0"), 1) } let(:version_one_dot_one_revision_one) { described_class.new(Version.create("1.1"), 1) }
let(:p3) { described_class.new(Version.create("1.1"), 1) } let(:version_one_revision_zero) { described_class.new(Version.create("1.0"), 0) }
let(:p4) { described_class.new(Version.create("1.0"), 0) }
it "returns a hash based on the version and revision" do it "returns a hash based on the version and revision" do
expect(p1.hash).to eq(p2.hash) expect(version_one_revision_one.hash).to eq(described_class.new(Version.create("1.0"), 1).hash)
expect(p1.hash).not_to eq(p3.hash) expect(version_one_revision_one.hash).not_to eq(version_one_dot_one_revision_one.hash)
expect(p1.hash).not_to eq(p4.hash) expect(version_one_revision_one.hash).not_to eq(version_one_revision_zero.hash)
end end
end end

View File

@ -12,13 +12,13 @@ describe Utils::Autoremove do
end end
end end
let(:formula_is_dep1) do let(:first_formula_dep) do
formula "one" do formula "one" do
url "one-1.1" url "one-1.1"
end end
end end
let(:formula_is_dep2) do let(:second_formula_dep) do
formula "two" do formula "two" do
url "two-1.1" url "two-1.1"
end end
@ -33,8 +33,8 @@ describe Utils::Autoremove do
let(:formulae) do let(:formulae) do
[ [
formula_with_deps, formula_with_deps,
formula_is_dep1, first_formula_dep,
formula_is_dep2, second_formula_dep,
formula_is_build_dep, formula_is_build_dep,
] ]
end end
@ -42,9 +42,9 @@ describe Utils::Autoremove do
let(:tab_from_keg) { double } let(:tab_from_keg) { double }
before do before do
allow(formula_with_deps).to receive(:runtime_formula_dependencies).and_return([formula_is_dep1, allow(formula_with_deps).to receive(:runtime_formula_dependencies).and_return([first_formula_dep,
formula_is_dep2]) second_formula_dep])
allow(formula_is_dep1).to receive(:runtime_formula_dependencies).and_return([formula_is_dep2]) allow(first_formula_dep).to receive(:runtime_formula_dependencies).and_return([second_formula_dep])
allow(Tab).to receive(:for_keg).and_return(tab_from_keg) allow(Tab).to receive(:for_keg).and_return(tab_from_keg)
end end
@ -115,28 +115,28 @@ describe Utils::Autoremove do
RUBY RUBY
end end
let(:cask_no_deps1) do let(:first_cask_no_deps) do
Cask::CaskLoader.load(+<<-RUBY) Cask::CaskLoader.load(+<<-RUBY)
cask "green" do cask "green" do
end end
RUBY RUBY
end end
let(:cask_no_deps2) do let(:second_cask_no_deps) do
Cask::CaskLoader.load(+<<-RUBY) Cask::CaskLoader.load(+<<-RUBY)
cask "purple" do cask "purple" do
end end
RUBY RUBY
end end
let(:casks_no_deps) { [cask_no_deps1, cask_no_deps2] } let(:casks_no_deps) { [first_cask_no_deps, second_cask_no_deps] }
let(:casks_one_dep) { [cask_no_deps1, cask_no_deps2, cask_one_dep] } let(:casks_one_dep) { [first_cask_no_deps, second_cask_no_deps, cask_one_dep] }
let(:casks_multiple_deps) { [cask_no_deps1, cask_no_deps2, cask_multiple_deps] } let(:casks_multiple_deps) { [first_cask_no_deps, second_cask_no_deps, cask_multiple_deps] }
before do before do
allow(Formula).to receive("[]").with("zero").and_return(formula_with_deps) allow(Formula).to receive("[]").with("zero").and_return(formula_with_deps)
allow(Formula).to receive("[]").with("one").and_return(formula_is_dep1) allow(Formula).to receive("[]").with("one").and_return(first_formula_dep)
allow(Formula).to receive("[]").with("two").and_return(formula_is_dep2) allow(Formula).to receive("[]").with("two").and_return(second_formula_dep)
end end
end end
@ -150,12 +150,12 @@ describe Utils::Autoremove do
specify "one dependent" do specify "one dependent" do
expect(described_class.send(:formulae_with_cask_dependents, casks_one_dep)) expect(described_class.send(:formulae_with_cask_dependents, casks_one_dep))
.to eq([formula_is_dep2]) .to eq([second_formula_dep])
end end
specify "multiple dependents" do specify "multiple dependents" do
expect(described_class.send(:formulae_with_cask_dependents, casks_multiple_deps)) expect(described_class.send(:formulae_with_cask_dependents, casks_multiple_deps))
.to contain_exactly(formula_with_deps, formula_is_dep1, formula_is_dep2) .to contain_exactly(formula_with_deps, first_formula_dep, second_formula_dep)
end end
end end
end end

View File

@ -46,11 +46,11 @@ describe Utils::Git do
let(:file) { "README.md" } let(:file) { "README.md" }
# Allow instance variables here for a simpler `before do` block. # Allow instance variables here for a simpler `before do` block.
# rubocop:disable RSpec/InstanceVariable # rubocop:disable RSpec/InstanceVariable
let(:file_hash1) { @h1[0..6] } let(:file_hash_one) { @h1[0..6] }
let(:file_hash2) { @h2[0..6] } let(:file_hash_two) { @h2[0..6] }
let(:files) { ["README.md", "LICENSE.txt"] } let(:files) { ["README.md", "LICENSE.txt"] }
let(:files_hash1) { [@h3[0..6], ["LICENSE.txt"]] } let(:files_hash_one) { [@h3[0..6], ["LICENSE.txt"]] }
let(:files_hash2) { [@h2[0..6], ["README.md"]] } let(:files_hash_two) { [@h2[0..6], ["README.md"]] }
let(:cherry_pick_commit) { @cherry_pick_commit[0..6] } let(:cherry_pick_commit) { @cherry_pick_commit[0..6] }
# rubocop:enable RSpec/InstanceVariable # rubocop:enable RSpec/InstanceVariable
@ -62,7 +62,7 @@ describe Utils::Git do
it "aborts when cherry picking an existing hash" do it "aborts when cherry picking an existing hash" do
ENV["GIT_MERGE_VERBOSITY"] = "5" # Consistent output across git versions ENV["GIT_MERGE_VERBOSITY"] = "5" # Consistent output across git versions
expect do expect do
described_class.cherry_pick!(HOMEBREW_CACHE, file_hash1) described_class.cherry_pick!(HOMEBREW_CACHE, file_hash_one)
end.to raise_error(ErrorDuringExecution, /Merge conflict in README.md/) end.to raise_error(ErrorDuringExecution, /Merge conflict in README.md/)
end end
end end
@ -71,26 +71,26 @@ describe Utils::Git do
it "gives last revision commit when before_commit is nil" do it "gives last revision commit when before_commit is nil" do
expect( expect(
described_class.last_revision_commit_of_file(HOMEBREW_CACHE, file), described_class.last_revision_commit_of_file(HOMEBREW_CACHE, file),
).to eq(file_hash1) ).to eq(file_hash_one)
end end
it "gives revision commit based on before_commit when it is not nil" do it "gives revision commit based on before_commit when it is not nil" do
expect( expect(
described_class.last_revision_commit_of_file(HOMEBREW_CACHE, described_class.last_revision_commit_of_file(HOMEBREW_CACHE,
file, file,
before_commit: file_hash2), before_commit: file_hash_two),
).to eq(file_hash2) ).to eq(file_hash_two)
end end
end end
describe "#file_at_commit" do describe "#file_at_commit" do
it "returns file contents when file exists" do it "returns file contents when file exists" do
expect(described_class.file_at_commit(HOMEBREW_CACHE, file, file_hash1)).to eq("README") expect(described_class.file_at_commit(HOMEBREW_CACHE, file, file_hash_one)).to eq("README")
end end
it "returns empty when file doesn't exist" do it "returns empty when file doesn't exist" do
expect(described_class.file_at_commit(HOMEBREW_CACHE, "foo.txt", file_hash1)).to eq("") expect(described_class.file_at_commit(HOMEBREW_CACHE, "foo.txt", file_hash_one)).to eq("")
expect(described_class.file_at_commit(HOMEBREW_CACHE, "LICENSE.txt", file_hash1)).to eq("") expect(described_class.file_at_commit(HOMEBREW_CACHE, "LICENSE.txt", file_hash_one)).to eq("")
end end
end end
@ -99,7 +99,7 @@ describe Utils::Git do
it "gives last revision commit" do it "gives last revision commit" do
expect( expect(
described_class.last_revision_commit_of_files(HOMEBREW_CACHE, files), described_class.last_revision_commit_of_files(HOMEBREW_CACHE, files),
).to eq(files_hash1) ).to eq(files_hash_one)
end end
end end
@ -108,8 +108,8 @@ describe Utils::Git do
expect( expect(
described_class.last_revision_commit_of_files(HOMEBREW_CACHE, described_class.last_revision_commit_of_files(HOMEBREW_CACHE,
files, files,
before_commit: file_hash2), before_commit: file_hash_two),
).to eq(files_hash2) ).to eq(files_hash_two)
end end
end end
end end

View File

@ -107,7 +107,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-capybara-2.18.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-capybara-2.18.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.17.1/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.17.1/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.19.1/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.19.1/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.19.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.20.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.7.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.7.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-macho-3.0.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-macho-3.0.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/ruby-prof-1.4.3") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/ruby-prof-1.4.3")

View File

@ -144,6 +144,12 @@ RSpec/Be:
StyleGuide: https://rspec.rubystyle.guide/#be-matcher StyleGuide: https://rspec.rubystyle.guide/#be-matcher
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Be Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Be
RSpec/BeEmpty:
Description: Prefer using `be_empty` when checking for an empty array.
Enabled: pending
VersionAdded: '2.20'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeEmpty
RSpec/BeEq: RSpec/BeEq:
Description: Check for expectations where `be(...)` can replace `eq(...)`. Description: Check for expectations where `be(...)` can replace `eq(...)`.
Enabled: pending Enabled: pending
@ -202,8 +208,8 @@ RSpec/ClassCheck:
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ClassCheck Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ClassCheck
RSpec/ContainExactly: RSpec/ContainExactly:
Description: Prefer `match_array` when matching array values. Description: Checks where `contain_exactly` is used.
Enabled: true Enabled: pending
VersionAdded: '2.19' VersionAdded: '2.19'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContainExactly Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContainExactly
@ -503,6 +509,13 @@ RSpec/ImplicitSubject:
VersionChanged: '2.13' VersionChanged: '2.13'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject
RSpec/IndexedLet:
Description: Do not set up test data using indexes (e.g., `item_1`, `item_2`).
Enabled: pending
VersionAdded: '2.20'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IndexedLet
Max: 1
RSpec/InstanceSpy: RSpec/InstanceSpy:
Description: Checks for `instance_double` used with `have_received`. Description: Checks for `instance_double` used with `have_received`.
Enabled: true Enabled: true
@ -563,8 +576,8 @@ RSpec/LetSetup:
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetSetup Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetSetup
RSpec/MatchArray: RSpec/MatchArray:
Description: Prefer `contain_exactly` when matching an array literal. Description: Checks where `match_array` is used.
Enabled: true Enabled: pending
VersionAdded: '2.19' VersionAdded: '2.19'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MatchArray Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MatchArray
@ -1048,8 +1061,9 @@ RSpec/Rails/HttpStatus:
SupportedStyles: SupportedStyles:
- numeric - numeric
- symbolic - symbolic
- be_status
VersionAdded: '1.23' VersionAdded: '1.23'
VersionChanged: '2.0' VersionChanged: '2.20'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus
RSpec/Rails/InferredSpecType: RSpec/Rails/InferredSpecType:

View File

@ -0,0 +1,44 @@
# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
# Prefer using `be_empty` when checking for an empty array.
#
# @example
# # bad
# expect(array).to contain_exactly
# expect(array).to match_array([])
#
# # good
# expect(array).to be_empty
#
class BeEmpty < Base
extend AutoCorrector
MSG = 'Use `be_empty` matchers for checking an empty array.'
RESTRICT_ON_SEND = %i[contain_exactly match_array].freeze
# @!method expect_array_matcher?(node)
def_node_matcher :expect_array_matcher?, <<~PATTERN
(send
(send nil? :expect _)
#Runners.all
${
(send nil? :match_array (array))
(send nil? :contain_exactly)
}
)
PATTERN
def on_send(node)
expect_array_matcher?(node.parent) do |expect|
add_offense(expect) do |corrector|
corrector.replace(expect, 'be_empty')
end
end
end
end
end
end
end

View File

@ -57,7 +57,7 @@ module RuboCop
return unless be_nil_matcher?(node) return unless be_nil_matcher?(node)
add_offense(node, message: BE_MSG) do |corrector| add_offense(node, message: BE_MSG) do |corrector|
corrector.replace(node.source_range, 'be(nil)') corrector.replace(node, 'be(nil)')
end end
end end
@ -65,7 +65,7 @@ module RuboCop
return unless nil_value_expectation?(node) return unless nil_value_expectation?(node)
add_offense(node, message: BE_NIL_MSG) do |corrector| add_offense(node, message: BE_NIL_MSG) do |corrector|
corrector.replace(node.source_range, 'be_nil') corrector.replace(node, 'be_nil')
end end
end end
end end

View File

@ -3,7 +3,11 @@
module RuboCop module RuboCop
module Cop module Cop
module RSpec module RSpec
# Prefer `match_array` when matching array values. # Checks where `contain_exactly` is used.
#
# This cop checks for the following:
# - Prefer `match_array` when matching array values.
# - Prefer `be_empty` when using `contain_exactly` with no arguments.
# #
# @example # @example
# # bad # # bad
@ -14,6 +18,7 @@ module RuboCop
# #
# # good # # good
# it { is_expected.to contain_exactly(content, *array) } # it { is_expected.to contain_exactly(content, *array) }
#
class ContainExactly < Base class ContainExactly < Base
extend AutoCorrector extend AutoCorrector
@ -21,21 +26,27 @@ module RuboCop
RESTRICT_ON_SEND = %i[contain_exactly].freeze RESTRICT_ON_SEND = %i[contain_exactly].freeze
def on_send(node) def on_send(node)
return unless node.each_child_node.all?(&:splat_type?) return if node.arguments.empty?
add_offense(node) do |corrector| check_populated_collection(node)
autocorrect(node, corrector)
end
end end
private private
def autocorrect(node, corrector) def check_populated_collection(node)
return unless node.each_child_node.all?(&:splat_type?)
add_offense(node) do |corrector|
autocorrect_for_populated_array(node, corrector)
end
end
def autocorrect_for_populated_array(node, corrector)
arrays = node.arguments.map do |splat_node| arrays = node.arguments.map do |splat_node|
splat_node.children.first splat_node.children.first
end end
corrector.replace( corrector.replace(
node.source_range, node,
"match_array(#{arrays.map(&:source).join(' + ')})" "match_array(#{arrays.map(&:source).join(' + ')})"
) )
end end

View File

@ -22,15 +22,15 @@ module RuboCop
class DescribedClassModuleWrapping < Base class DescribedClassModuleWrapping < Base
MSG = 'Avoid opening modules and defining specs within them.' MSG = 'Avoid opening modules and defining specs within them.'
# @!method find_rspec_blocks(node) # @!method include_rspec_blocks?(node)
def_node_search :find_rspec_blocks, <<~PATTERN def_node_search :include_rspec_blocks?, <<~PATTERN
(block (send #explicit_rspec? #ExampleGroups.all ...) ...) ({block numblock} (send #explicit_rspec? #ExampleGroups.all ...) ...)
PATTERN PATTERN
def on_module(node) def on_module(node)
find_rspec_blocks(node) do return unless include_rspec_blocks?(node)
add_offense(node)
end add_offense(node)
end end
end end
end end

View File

@ -30,7 +30,7 @@ module RuboCop
MSG = 'Add an empty line after `%<example_group>s`.' MSG = 'Add an empty line after `%<example_group>s`.'
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
return unless example_group?(node) return unless spec_group?(node)
missing_separating_line_offense(node) do |method| missing_separating_line_offense(node) do |method|
format(MSG, example_group: method) format(MSG, example_group: method)

View File

@ -93,8 +93,8 @@ module RuboCop
end end
def swap(corrector, actual, expected) def swap(corrector, actual, expected)
corrector.replace(actual.source_range, expected.source) corrector.replace(actual, expected.source)
corrector.replace(expected.source_range, actual.source) corrector.replace(expected, actual.source)
end end
end end
end end

View File

@ -100,10 +100,10 @@ module RuboCop
end end
end end
AMBIGUOUS_TYPES = %i[send pair array and or if].freeze
def ambiguous_without_parentheses?(node) def ambiguous_without_parentheses?(node)
node.parent&.send_type? || node.parent && AMBIGUOUS_TYPES.include?(node.parent.type)
node.parent&.pair_type? ||
node.parent&.array_type?
end end
def remove_parentheses(corrector, node) def remove_parentheses(corrector, node)

View File

@ -0,0 +1,76 @@
# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
# Do not set up test data using indexes (e.g., `item_1`, `item_2`).
#
# It makes reading the test harder because it's not clear what exactly
# is tested by this particular example.
#
# @example `Max: 1 (default)`
# # bad
# let(:item_1) { create(:item) }
# let(:item_2) { create(:item) }
#
# let(:item1) { create(:item) }
# let(:item2) { create(:item) }
#
# # good
#
# let(:visible_item) { create(:item, visible: true) }
# let(:invisible_item) { create(:item, visible: false) }
#
# @example `Max: 2`
# # bad
# let(:item_1) { create(:item) }
# let(:item_2) { create(:item) }
# let(:item_3) { create(:item) }
#
# # good
# let(:item_1) { create(:item) }
# let(:item_2) { create(:item) }
#
class IndexedLet < Base
MSG = 'This `let` statement uses index in its name. Please give it ' \
'a meaningful name.'
# @!method let_name(node)
def_node_matcher :let_name, <<~PATTERN
{
(block (send nil? #Helpers.all ({str sym} $_) ...) ...)
(send nil? #Helpers.all ({str sym} $_) block_pass)
}
PATTERN
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
return unless spec_group?(node)
children = node.body&.child_nodes
return unless children
filter_indexed_lets(children).each do |let_node|
add_offense(let_node)
end
end
private
INDEX_REGEX = /_?\d+/.freeze
def filter_indexed_lets(candidates)
candidates
.filter { |node| indexed_let?(node) }
.group_by { |node| let_name(node).to_s.gsub(INDEX_REGEX, '') }
.values
.filter { |lets| lets.length > cop_config['Max'] }
.flatten
end
def indexed_let?(node)
let?(node) && INDEX_REGEX.match?(let_name(node))
end
end
end
end
end

View File

@ -3,7 +3,11 @@
module RuboCop module RuboCop
module Cop module Cop
module RSpec module RSpec
# Prefer `contain_exactly` when matching an array literal. # Checks where `match_array` is used.
#
# This cop checks for the following:
# - Prefer `contain_exactly` when matching an array with values.
# - Prefer `eq` when using `match_array` with an empty array literal.
# #
# @example # @example
# # bad # # bad
@ -17,20 +21,34 @@ module RuboCop
# #
# # good # # good
# it { is_expected.to match_array(%w(tremble in fear foolish mortals)) } # it { is_expected.to match_array(%w(tremble in fear foolish mortals)) }
#
class MatchArray < Base class MatchArray < Base
extend AutoCorrector extend AutoCorrector
MSG = 'Prefer `contain_exactly` when matching an array literal.' MSG = 'Prefer `contain_exactly` when matching an array literal.'
RESTRICT_ON_SEND = %i[match_array].freeze RESTRICT_ON_SEND = %i[match_array].freeze
# @!method match_array_with_empty_array?(node)
def_node_matcher :match_array_with_empty_array?, <<~PATTERN
(send nil? :match_array (array))
PATTERN
def on_send(node) def on_send(node)
return unless node.first_argument.array_type? return unless node.first_argument.array_type?
return if match_array_with_empty_array?(node)
check_populated_array(node)
end
private
def check_populated_array(node)
return if node.first_argument.percent_literal? return if node.first_argument.percent_literal?
add_offense(node) do |corrector| add_offense(node) do |corrector|
array_contents = node.arguments.flat_map(&:to_a) array_contents = node.arguments.flat_map(&:to_a)
corrector.replace( corrector.replace(
node.source_range, node,
"contain_exactly(#{array_contents.map(&:source).join(', ')})" "contain_exactly(#{array_contents.map(&:source).join(', ')})"
) )
end end

Some files were not shown because too many files have changed in this diff Show More