caveats: Add a new line if there isn't one from previous conditions

This commit is contained in:
Issy Long 2023-03-19 18:25:56 +00:00
parent 7bb57612b7
commit f10b88ca85
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
2 changed files with 27 additions and 0 deletions

View File

@ -94,6 +94,7 @@ class Caveats
end
end
end
s << "\n" unless s.end_with?("\n")
s
end

View File

@ -249,6 +249,32 @@ describe Caveats do
expect(caveats).to include("#{f.opt_share}/pkgconfig")
end
end
context "when joining different caveat types together" do
let(:f) do
formula do
url "foo-1.0"
keg_only "some reason"
def caveats
"something else"
end
service do
run [bin/"cmd"]
end
end
end
let(:caveats) { described_class.new(f).caveats }
it "adds the correct amount of new lines to the output" do
expect(caveats).to include("something else")
expect(caveats).to include("keg-only")
expect(caveats).to include("if you don't want/need a background service")
expect(caveats.count("\n")).to eq(9)
end
end
end
describe "shell completions" do