Fix new RSpec/IndexedLet offenses
This commit is contained in:
parent
7b626d2005
commit
4a87c624d7
@ -4,8 +4,8 @@
|
||||
require "cask/upgrade"
|
||||
|
||||
describe Cask::Upgrade, :cask do
|
||||
let(:version_latest_path_2) { 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_second) { version_latest.config.appdir.join("Caffeine Pro.app") }
|
||||
let(:version_latest_path_first) { version_latest.config.appdir.join("Caffeine Mini.app") }
|
||||
let(:version_latest) { Cask::CaskLoader.load("version-latest") }
|
||||
let(:auto_updates_path) { auto_updates.config.appdir.join("MyFancyApp.app") }
|
||||
let(:auto_updates) { Cask::CaskLoader.load("auto-updates") }
|
||||
@ -108,7 +108,7 @@ describe Cask::Upgrade, :cask do
|
||||
expect(local_transmission.versions).to include("2.60")
|
||||
|
||||
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")
|
||||
# Change download sha so that :latest cask decides to update itself
|
||||
version_latest.download_sha_path.write("fake download sha")
|
||||
@ -129,7 +129,7 @@ describe Cask::Upgrade, :cask do
|
||||
expect(local_transmission.versions).to include("2.61")
|
||||
|
||||
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.outdated_download_sha?).to be(false)
|
||||
end
|
||||
@ -154,8 +154,8 @@ describe Cask::Upgrade, :cask 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_path_1).to be_a_directory
|
||||
expect(version_latest_path_2).to be_a_directory
|
||||
expect(version_latest_path_first).to be_a_directory
|
||||
expect(version_latest_path_second).to be_a_directory
|
||||
expect(version_latest.versions).to include("latest")
|
||||
# Change download sha so that :latest cask decides to update itself
|
||||
version_latest.download_sha_path.write("fake download sha")
|
||||
@ -164,16 +164,16 @@ describe Cask::Upgrade, :cask do
|
||||
described_class.upgrade_casks(version_latest, greedy: true, args: args)
|
||||
|
||||
expect(version_latest).to be_installed
|
||||
expect(version_latest_path_1).to be_a_directory
|
||||
expect(version_latest_path_2).to be_a_directory
|
||||
expect(version_latest_path_first).to be_a_directory
|
||||
expect(version_latest_path_second).to be_a_directory
|
||||
expect(version_latest.versions).to include("latest")
|
||||
expect(version_latest.outdated_download_sha?).to be(false)
|
||||
|
||||
described_class.upgrade_casks(version_latest, greedy: true, args: args)
|
||||
|
||||
expect(version_latest).to be_installed
|
||||
expect(version_latest_path_1).to be_a_directory
|
||||
expect(version_latest_path_2).to be_a_directory
|
||||
expect(version_latest_path_first).to be_a_directory
|
||||
expect(version_latest_path_second).to be_a_directory
|
||||
expect(version_latest.versions).to include("latest")
|
||||
expect(version_latest.outdated_download_sha?).to be(false)
|
||||
end
|
||||
@ -331,8 +331,8 @@ describe Cask::Upgrade, :cask do
|
||||
expect(described_class).not_to receive(:upgrade_cask)
|
||||
|
||||
expect(version_latest).to be_installed
|
||||
expect(version_latest_path_1).to be_a_directory
|
||||
expect(version_latest_path_2).to be_a_directory
|
||||
expect(version_latest_path_first).to be_a_directory
|
||||
expect(version_latest_path_second).to be_a_directory
|
||||
expect(version_latest.versions).to include("latest")
|
||||
# Change download sha so that :latest cask decides to update itself
|
||||
version_latest.download_sha_path.write("fake download sha")
|
||||
@ -341,8 +341,8 @@ describe Cask::Upgrade, :cask do
|
||||
described_class.upgrade_casks(version_latest, dry_run: true, greedy: true, args: args)
|
||||
|
||||
expect(version_latest).to be_installed
|
||||
expect(version_latest_path_1).to be_a_directory
|
||||
expect(version_latest_path_2).to be_a_directory
|
||||
expect(version_latest_path_first).to be_a_directory
|
||||
expect(version_latest_path_second).to be_a_directory
|
||||
expect(version_latest.versions).to include("latest")
|
||||
expect(version_latest.outdated_download_sha?).to be(true)
|
||||
end
|
||||
|
||||
@ -67,11 +67,11 @@ describe Homebrew::Cleanup do
|
||||
end
|
||||
|
||||
context "when it can't remove a keg" do
|
||||
let(:f1) { Class.new(Testball) { version "0.1" }.new }
|
||||
let(:f2) { Class.new(Testball) { version "0.2" }.new }
|
||||
let(:formula_zero_dot_one) { Class.new(Testball) { version "0.1" }.new }
|
||||
let(:formula_zero_dot_two) { Class.new(Testball) { version "0.2" }.new }
|
||||
|
||||
before do
|
||||
[f1, f2].each do |f|
|
||||
[formula_zero_dot_one, formula_zero_dot_two].each do |f|
|
||||
f.brew do
|
||||
f.install
|
||||
end
|
||||
@ -85,13 +85,13 @@ describe Homebrew::Cleanup do
|
||||
end
|
||||
|
||||
it "doesn't remove any kegs" do
|
||||
cleanup.cleanup_formula f2
|
||||
expect(f1.installed_kegs.size).to eq(2)
|
||||
cleanup.cleanup_formula formula_zero_dot_one
|
||||
expect(formula_zero_dot_one.installed_kegs.size).to eq(2)
|
||||
end
|
||||
|
||||
it "lists the unremovable kegs" do
|
||||
cleanup.cleanup_formula f2
|
||||
expect(cleanup.unremovable_kegs).to contain_exactly(f1.installed_kegs[0])
|
||||
cleanup.cleanup_formula formula_zero_dot_two
|
||||
expect(cleanup.unremovable_kegs).to contain_exactly(formula_zero_dot_one.installed_kegs[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -203,10 +203,10 @@ describe "Exception" do
|
||||
end
|
||||
|
||||
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(:hash2) { instance_double(Checksum, to_s: "deadcafe") }
|
||||
let(:expected_checksum) { instance_double(Checksum, to_s: "deadbeef") }
|
||||
let(:actual_checksum) { instance_double(Checksum, to_s: "deadcafe") }
|
||||
|
||||
its(:to_s) { is_expected.to match(/SHA256 mismatch/) }
|
||||
end
|
||||
|
||||
@ -146,16 +146,16 @@ describe "globally-scoped helper methods" do
|
||||
end
|
||||
|
||||
describe "#which_all" do
|
||||
let(:cmd1) { dir/"foo" }
|
||||
let(:cmd2) { dir/"bar/foo" }
|
||||
let(:cmd3) { dir/"bar/baz/foo" }
|
||||
let(:cmd_foo) { dir/"foo" }
|
||||
let(:cmd_foo_bar) { dir/"bar/foo" }
|
||||
let(:cmd_bar_baz_foo) { dir/"bar/baz/foo" }
|
||||
|
||||
before do
|
||||
(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
|
||||
cmd.chmod 0744
|
||||
end
|
||||
@ -167,7 +167,7 @@ describe "globally-scoped helper methods" do
|
||||
"#{dir}/baz:#{dir}",
|
||||
"~baduserpath",
|
||||
].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
|
||||
|
||||
|
||||
@ -77,15 +77,14 @@ describe PkgVersion do
|
||||
end
|
||||
|
||||
describe "#hash" do
|
||||
let(:p1) { described_class.new(Version.create("1.0"), 1) }
|
||||
let(:p2) { described_class.new(Version.create("1.0"), 1) }
|
||||
let(:p3) { described_class.new(Version.create("1.1"), 1) }
|
||||
let(:p4) { described_class.new(Version.create("1.0"), 0) }
|
||||
let(:version_one_revision_one) { described_class.new(Version.create("1.0"), 1) }
|
||||
let(:version_one_dot_one_revision_one) { described_class.new(Version.create("1.1"), 1) }
|
||||
let(:version_one_revision_zero) { described_class.new(Version.create("1.0"), 0) }
|
||||
|
||||
it "returns a hash based on the version and revision" do
|
||||
expect(p1.hash).to eq(p2.hash)
|
||||
expect(p1.hash).not_to eq(p3.hash)
|
||||
expect(p1.hash).not_to eq(p4.hash)
|
||||
expect(version_one_revision_one.hash).to eq(described_class.new(Version.create("1.0"), 1).hash)
|
||||
expect(version_one_revision_one.hash).not_to eq(version_one_dot_one_revision_one.hash)
|
||||
expect(version_one_revision_one.hash).not_to eq(version_one_revision_zero.hash)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -13,13 +13,13 @@ describe Utils::Autoremove do
|
||||
end
|
||||
end
|
||||
|
||||
let(:formula_is_dep1) do
|
||||
let(:first_formula_dep) do
|
||||
formula "one" do
|
||||
url "one-1.1"
|
||||
end
|
||||
end
|
||||
|
||||
let(:formula_is_dep2) do
|
||||
let(:second_formula_dep) do
|
||||
formula "two" do
|
||||
url "two-1.1"
|
||||
end
|
||||
@ -34,8 +34,8 @@ describe Utils::Autoremove do
|
||||
let(:formulae) do
|
||||
[
|
||||
formula_with_deps,
|
||||
formula_is_dep1,
|
||||
formula_is_dep2,
|
||||
first_formula_dep,
|
||||
second_formula_dep,
|
||||
formula_is_build_dep,
|
||||
]
|
||||
end
|
||||
@ -43,9 +43,9 @@ describe Utils::Autoremove do
|
||||
let(:tab_from_keg) { double }
|
||||
|
||||
before do
|
||||
allow(formula_with_deps).to receive(:runtime_formula_dependencies).and_return([formula_is_dep1,
|
||||
formula_is_dep2])
|
||||
allow(formula_is_dep1).to receive(:runtime_formula_dependencies).and_return([formula_is_dep2])
|
||||
allow(formula_with_deps).to receive(:runtime_formula_dependencies).and_return([first_formula_dep,
|
||||
second_formula_dep])
|
||||
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)
|
||||
end
|
||||
@ -116,28 +116,28 @@ describe Utils::Autoremove do
|
||||
RUBY
|
||||
end
|
||||
|
||||
let(:cask_no_deps1) do
|
||||
let(:first_cask_no_deps) do
|
||||
Cask::CaskLoader.load(+<<-RUBY)
|
||||
cask "green" do
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
let(:cask_no_deps2) do
|
||||
let(:second_cask_no_deps) do
|
||||
Cask::CaskLoader.load(+<<-RUBY)
|
||||
cask "purple" do
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
let(:casks_no_deps) { [cask_no_deps1, cask_no_deps2] }
|
||||
let(:casks_one_dep) { [cask_no_deps1, cask_no_deps2, cask_one_dep] }
|
||||
let(:casks_multiple_deps) { [cask_no_deps1, cask_no_deps2, cask_multiple_deps] }
|
||||
let(:casks_no_deps) { [first_cask_no_deps, second_cask_no_deps] }
|
||||
let(:casks_one_dep) { [first_cask_no_deps, second_cask_no_deps, cask_one_dep] }
|
||||
let(:casks_multiple_deps) { [first_cask_no_deps, second_cask_no_deps, cask_multiple_deps] }
|
||||
|
||||
before do
|
||||
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("two").and_return(formula_is_dep2)
|
||||
allow(Formula).to receive("[]").with("one").and_return(first_formula_dep)
|
||||
allow(Formula).to receive("[]").with("two").and_return(second_formula_dep)
|
||||
end
|
||||
end
|
||||
|
||||
@ -151,12 +151,12 @@ describe Utils::Autoremove do
|
||||
|
||||
specify "one dependent" do
|
||||
expect(described_class.send(:formulae_with_cask_dependents, casks_one_dep))
|
||||
.to eq([formula_is_dep2])
|
||||
.to eq([second_formula_dep])
|
||||
end
|
||||
|
||||
specify "multiple dependents" do
|
||||
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
|
||||
|
||||
@ -47,11 +47,11 @@ describe Utils::Git do
|
||||
let(:file) { "README.md" }
|
||||
# Allow instance variables here for a simpler `before do` block.
|
||||
# rubocop:disable RSpec/InstanceVariable
|
||||
let(:file_hash1) { @h1[0..6] }
|
||||
let(:file_hash2) { @h2[0..6] }
|
||||
let(:file_hash_one) { @h1[0..6] }
|
||||
let(:file_hash_two) { @h2[0..6] }
|
||||
let(:files) { ["README.md", "LICENSE.txt"] }
|
||||
let(:files_hash1) { [@h3[0..6], ["LICENSE.txt"]] }
|
||||
let(:files_hash2) { [@h2[0..6], ["README.md"]] }
|
||||
let(:files_hash_one) { [@h3[0..6], ["LICENSE.txt"]] }
|
||||
let(:files_hash_two) { [@h2[0..6], ["README.md"]] }
|
||||
let(:cherry_pick_commit) { @cherry_pick_commit[0..6] }
|
||||
# rubocop:enable RSpec/InstanceVariable
|
||||
|
||||
@ -63,7 +63,7 @@ describe Utils::Git do
|
||||
it "aborts when cherry picking an existing hash" do
|
||||
ENV["GIT_MERGE_VERBOSITY"] = "5" # Consistent output across git versions
|
||||
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
|
||||
end
|
||||
@ -72,26 +72,26 @@ describe Utils::Git do
|
||||
it "gives last revision commit when before_commit is nil" do
|
||||
expect(
|
||||
described_class.last_revision_commit_of_file(HOMEBREW_CACHE, file),
|
||||
).to eq(file_hash1)
|
||||
).to eq(file_hash_one)
|
||||
end
|
||||
|
||||
it "gives revision commit based on before_commit when it is not nil" do
|
||||
expect(
|
||||
described_class.last_revision_commit_of_file(HOMEBREW_CACHE,
|
||||
file,
|
||||
before_commit: file_hash2),
|
||||
).to eq(file_hash2)
|
||||
before_commit: file_hash_two),
|
||||
).to eq(file_hash_two)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#file_at_commit" 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
|
||||
|
||||
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, "LICENSE.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_hash_one)).to eq("")
|
||||
end
|
||||
end
|
||||
|
||||
@ -100,7 +100,7 @@ describe Utils::Git do
|
||||
it "gives last revision commit" do
|
||||
expect(
|
||||
described_class.last_revision_commit_of_files(HOMEBREW_CACHE, files),
|
||||
).to eq(files_hash1)
|
||||
).to eq(files_hash_one)
|
||||
end
|
||||
end
|
||||
|
||||
@ -109,8 +109,8 @@ describe Utils::Git do
|
||||
expect(
|
||||
described_class.last_revision_commit_of_files(HOMEBREW_CACHE,
|
||||
files,
|
||||
before_commit: file_hash2),
|
||||
).to eq(files_hash2)
|
||||
before_commit: file_hash_two),
|
||||
).to eq(files_hash_two)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user