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/RepeatedExampleGroupDescription cop & fix offenses #10665

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.
Jump to
Jump to file
Failed to load files.
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 @@ -21,8 +21,6 @@ RSpec/MessageSpies:
Enabled: false
RSpec/RepeatedDescription:
Enabled: false
RSpec/RepeatedExampleGroupDescription:
Enabled: false
RSpec/StubbedMock:
Enabled: false

Expand Down
60 changes: 33 additions & 27 deletions Library/Homebrew/test/download_strategies/curl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,6 @@
expect(strategy.send(:_curl_args)).to eq(["--user", "download:123456"])
end

describe "#cached_location" do
subject(:location) { described_class.new(url, name, version, **specs).cached_location }

context "when URL ends with file" do
it {
expect(location).to eq(
HOMEBREW_CACHE/"downloads/3d1c0ae7da22be9d83fb1eb774df96b7c4da71d3cf07e1cb28555cf9a5e5af70--foo.tar.gz",
)
}
end

context "when URL file is in middle" do
let(:url) { "https://example.com/foo.tar.gz/from/this/mirror" }

it {
expect(location).to eq(
HOMEBREW_CACHE/"downloads/1ab61269ba52c83994510b1e28dd04167a2f2e8393a35a9c50c1f7d33fd8f619--foo.tar.gz",
)
}
end
end

describe "#fetch" do
before do
strategy.temporary_path.dirname.mkpath
Expand Down Expand Up @@ -147,22 +125,48 @@
end

describe "#cached_location" do
subject(:cached_location) { described_class.new(url, name, version, **specs).cached_location }

context "when URL ends with file" do
it {
expect(cached_location).to eq(
HOMEBREW_CACHE/"downloads/3d1c0ae7da22be9d83fb1eb774df96b7c4da71d3cf07e1cb28555cf9a5e5af70--foo.tar.gz",
)
}
end

context "when URL file is in middle" do
let(:url) { "https://example.com/foo.tar.gz/from/this/mirror" }

it {
expect(cached_location).to eq(
HOMEBREW_CACHE/"downloads/1ab61269ba52c83994510b1e28dd04167a2f2e8393a35a9c50c1f7d33fd8f619--foo.tar.gz",
)
}
end

context "with a file name trailing the URL path" do
let(:url) { "https://example.com/cask.dmg" }

its("cached_location.extname") { is_expected.to eq(".dmg") }
it {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it {
it "returns a file with a `.dmg` extension" {

Might be a good idea to add some sort of description like this to the its to it conversions.

Without a description:

CurlDownloadStrategy#cached_location with a file name trailing the URL path is expected to eq ".dmg"

With a description:

CurlDownloadStrategy#cached_location with a file name trailing the URL path returns a file with a `.dmg` extension

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly didn't add descriptions as the other it {s that I moved down didn't have any. 🤷🏻

expect(cached_location.extname).to eq(".dmg")
}
end

context "with a file name trailing the first query parameter" do
let(:url) { "https://example.com/download?file=cask.zip&a=1" }

its("cached_location.extname") { is_expected.to eq(".zip") }
it {
expect(cached_location.extname).to eq(".zip")
}
end

context "with a file name trailing the second query parameter" do
let(:url) { "https://example.com/dl?a=1&file=cask.zip&b=2" }

its("cached_location.extname") { is_expected.to eq(".zip") }
it {
expect(cached_location.extname).to eq(".zip")
}
end

context "with an unusually long query string" do
Expand All @@ -184,8 +188,10 @@
].join
end

its("cached_location.extname") { is_expected.to eq(".zip") }
its("cached_location.to_path.length") { is_expected.to be_between(0, 255) }
it {
expect(cached_location.extname).to eq(".zip")
expect(cached_location.to_path.length).to be_between(0, 255)
}
end
end
end
4 changes: 0 additions & 4 deletions Library/Homebrew/test/os/linux/formula_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@
expect(f.class.stable.deps[1].name).to eq("hello_linux")
expect(f.class.stable.deps[2]).to eq(nil)
end
end

describe "#on_linux" do
it "adds a patch on Linux only" do
f = formula do
homepage "https://brew.sh"
Expand All @@ -81,9 +79,7 @@
expect(f.patchlist.first.strip).to eq(:p1)
expect(f.patchlist.first.url).to eq("patch_linux")
end
end

describe "#on_linux" do
it "uses on_linux within a resource block" do
f = formula do
homepage "https://brew.sh"
Expand Down
4 changes: 0 additions & 4 deletions Library/Homebrew/test/os/mac/formula_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@
expect(f.class.stable.deps[1].name).to eq("hello_macos")
expect(f.class.stable.deps[2]).to eq(nil)
end
end

describe "#on_macos" do
it "adds a patch on Mac only" do
f = formula do
homepage "https://brew.sh"
Expand All @@ -86,9 +84,7 @@
expect(f.patchlist.first.strip).to eq(:p1)
expect(f.patchlist.first.url).to eq("patch_macos")
end
end

describe "#on_macos" do
it "uses on_macos within a resource block" do
f = formula do
homepage "https://brew.sh"
Expand Down