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

rubocop: Enable RSpec/ContextWording cop & fix offenses #10658

Merged
merged 5 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Library/.rubocop_rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ RSpec/SubjectStub:
Enabled: false

# TODO: try to enable these
RSpec/ContextWording:
Enabled: false
RSpec/DescribeClass:
Enabled: false
RSpec/LeakyConstantDeclaration:
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/test/bash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
end
end

context "brew" do
describe "brew" do
subject { HOMEBREW_LIBRARY_PATH.parent.parent/"bin/brew" }

it { is_expected.to have_valid_bash_syntax }
end

context "every `.sh` file" do
describe "every `.sh` file" do
it "has valid Bash syntax" do
Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/**/*.sh").each do |path|
relative_path = path.relative_path_from(HOMEBREW_LIBRARY_PATH)
Expand All @@ -35,13 +35,13 @@
end
end

context "Bash completion" do
describe "Bash completion" do
subject { HOMEBREW_LIBRARY_PATH.parent.parent/"completions/bash/brew" }

it { is_expected.to have_valid_bash_syntax }
end

context "every shim script" do
describe "every shim script" do
it "has valid Bash syntax" do
# These have no file extension, but can be identified by their shebang.
(HOMEBREW_LIBRARY_PATH/"shims").find do |path|
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/build_environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
describe BuildEnvironment::DSL do
subject(:build_environment_dsl) { double.extend(described_class) }

context "single argument" do
context "with a single argument" do
before do
build_environment_dsl.instance_eval do
env :userpaths
Expand All @@ -55,7 +55,7 @@
its(:env) { is_expected.to use_userpaths }
end

context "multiple arguments" do
context "with multiple arguments" do
before do
build_environment_dsl.instance_eval do
env :userpaths, :std
Expand Down
16 changes: 8 additions & 8 deletions Library/Homebrew/test/cache_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
end

describe "#get" do
context "database created" do
context "with a database created" do
let(:db) { double("db", :[] => "bar") }

it "gets value in the `CacheStoreDatabase` corresponding to the key" do
Expand All @@ -44,7 +44,7 @@
end
end

context "database not created" do
context "without a database created" do
let(:db) { double("db", :[] => nil) }

before do
Expand All @@ -64,7 +64,7 @@
end

describe "#delete" do
context "database created" do
context "with a database created" do
let(:db) { double("db", :[] => { foo: "bar" }) }

before do
Expand All @@ -78,7 +78,7 @@
end
end

context "database not created" do
context "without a database created" do
let(:db) { double("db", delete: nil) }

before do
Expand All @@ -94,13 +94,13 @@
end

describe "#write_if_dirty!" do
context "database open" do
context "with an open database" do
it "does not raise an error when `close` is called on the database" do
expect { sample_db.write_if_dirty! }.not_to raise_error(NoMethodError)
end
end

context "database not open" do
context "without an open database" do
before do
sample_db.instance_variable_set(:@db, nil)
end
Expand All @@ -118,7 +118,7 @@
allow(sample_db).to receive(:cache_path).and_return(cache_path)
end

context "`cache_path.exist?` returns `true`" do
context "when `cache_path.exist?` returns `true`" do
before do
allow(cache_path).to receive(:exist?).and_return(true)
end
Expand All @@ -128,7 +128,7 @@
end
end

context "`cache_path.exist?` returns `false`" do
context "when `cache_path.exist?` returns `false`" do
before do
allow(cache_path).to receive(:exist?).and_return(false)
end
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
Expand Up @@ -96,7 +96,7 @@
expect(expected_path.exist?).to be true
end

context "binary is inside an app package" do
context "when the binary is inside an app package" do
let(:cask) {
Cask::CaskLoader.load(cask_path("with-embedded-binary")).tap do |cask|
InstallHelper.install_without_artifacts(cask)
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 @@ -11,7 +11,7 @@
describe "#post_uninstall_phase" do
subject(:artifact) { cask.artifacts.find { |a| a.is_a?(described_class) } }

context "using :rmdir" do
context "when using :rmdir" do
let(:fake_system_command) { NeverSudoSystemCommand }
let(:cask) { Cask::CaskLoader.load(cask_path("with-uninstall-rmdir")) }
let(:empty_directory) { Pathname.new("#{TEST_TMPDIR}/empty_directory_path") }
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 @@ -7,7 +7,7 @@
describe "#zap_phase" do
include_examples "#uninstall_phase or #zap_phase"

context "using :rmdir" do
context "when using :rmdir" do
subject(:artifact) { cask.artifacts.find { |a| a.is_a?(described_class) } }

let(:fake_system_command) { NeverSudoSystemCommand }
Expand Down
14 changes: 7 additions & 7 deletions Library/Homebrew/test/cask/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def tmp_cask(name, text)
end
end

context "when cask token is in tap_migrations.json" do
context "when cask token is in tap_migrations.json and" do
let(:cask_token) { "token-migrated" }
let(:tap) { Tap.fetch("homebrew/cask") }

Expand All @@ -324,15 +324,15 @@ def tmp_cask(name, text)
allow(cask).to receive(:tap).and_return(tap)
end

context "and `new_cask` is true" do
context "when `new_cask` is true" do
let(:new_cask) { true }

it "fails" do
expect(run).to fail_with("#{cask_token} is listed in tap_migrations.json")
end
end

context "and `new_cask` is false" do
context "when `new_cask` is false" do
let(:new_cask) { false }

it "does not fail" do
Expand Down Expand Up @@ -688,14 +688,14 @@ def tmp_cask(name, text)
it { is_expected.to pass }
end

context "when the Cask is on the denylist" do
context "and it's in the official Homebrew tap" do
context "when the Cask is on the denylist and" do
context "when it's in the official Homebrew tap" do
let(:cask_token) { "adobe-illustrator" }

it { is_expected.to fail_with(/#{cask_token} is not allowed: \w+/) }
end

context "and it isn't in the official Homebrew tap" do
context "when it isn't in the official Homebrew tap" do
let(:cask_token) { "pharo" }

it { is_expected.to pass }
Expand Down Expand Up @@ -786,7 +786,7 @@ def tmp_cask(name, text)
end

describe "url checks" do
context "given a block" do
context "with a block" do
let(:cask_token) { "booby-trap" }

context "when loading the cask" do
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
Expand Up @@ -6,7 +6,7 @@

context "when multiple versions are installed" do
describe "#versions" do
context "and there are duplicate versions" do
context "when there are duplicate versions" do
it "uses the last unique version" do
allow(cask).to receive(:timestamped_versions).and_return([
["1.2.2", "0999"],
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/test/cask/cmd/upgrade_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
let(:local_caffeine_path) { local_caffeine.config.appdir.join("Caffeine.app") }
let(:local_caffeine) { Cask::CaskLoader.load("local-caffeine") }

context "successful upgrade" do
context "when the upgrade is successful" do
let(:installed) {
[
"outdated/local-caffeine",
Expand Down Expand Up @@ -149,7 +149,7 @@
end
end

context "dry run upgrade" do
context "when the upgrade is a dry run" do
let(:installed) {
[
"outdated/local-caffeine",
Expand Down Expand Up @@ -294,7 +294,7 @@
end
end

context "failed upgrade" do
context "when an upgrade failed" do
let(:installed) {
[
"outdated/bad-checksum",
Expand Down Expand Up @@ -349,7 +349,7 @@
end
end

context "multiple failures" do
context "when there were multiple failures" do
let(:installed) {
[
"outdated/bad-checksum",
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/test/cask/depends_on_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@
end

describe "depends_on macos" do
context "given an array" do
context "with an array" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-macos-array")) }

it "does not raise an error" do
expect { install }.not_to raise_error
end
end

context "given a comparison" do
context "with a comparison" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-macos-comparison")) }

it "does not raise an error" do
expect { install }.not_to raise_error
end
end

context "given a symbol" do
context "with a symbol" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-macos-symbol")) }

it "does not raise an error" do
Expand Down
Loading