Add a failing test for comments moving with the alphabetization

This commit is contained in:
Issy Long 2024-01-14 21:32:50 +00:00
parent 2c9e6e425b
commit e4b4af4c45
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -123,4 +123,46 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do
end end
CASK CASK
end end
it "ignores `uninstall` methods with commands" do
expect_no_offenses(<<~CASK)
cask "foo" do
url "https://example.com/foo.zip"
uninstall script: {
args: ["--mode=something", "--another-mode"],
executable: "thing",
}
end
CASK
end
focus it "moves comments when autocorrecting" do
expect_offense(<<~CASK)
cask "foo" do
url "https://example.com/foo.zip"
zap trash: [
^ The array elements should be ordered alphabetically
# overall comment, shouldn't move
"~/Library/Application Support/Foo",
"~/Library/Application Support/Bar",
"~/Library/Application Support/Baz", # in-line comment
]
end
CASK
expect_correction(<<~CASK)
cask "foo" do
url "https://example.com/foo.zip"
zap trash: [
# overall comment, shouldn't move
"~/Library/Application Support/Bar",
"~/Library/Application Support/Baz", # in-line comment
"~/Library/Application Support/Foo",
]
end
CASK
end
end end