brew/Library/Homebrew/test/rubocops/caveats_spec.rb

47 lines
1.3 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require "rubocops/caveats"
RSpec.describe RuboCop::Cop::FormulaAudit::Caveats do
subject(:cop) { described_class.new }
context "when auditing `caveats`" do
it "reports an offense if `setuid` is mentioned" do
2017-10-21 03:12:50 +02:00
expect_offense(<<~RUBY)
2017-10-15 02:28:32 +02:00
class Foo < Formula
homepage "https://brew.sh/foo"
url "https://brew.sh/foo-1.0.tgz"
2017-10-15 02:28:32 +02:00
def caveats
"setuid"
2024-04-30 11:10:23 +02:00
^^^^^^^^ FormulaAudit/Caveats: Don't recommend `setuid` in the caveats, suggest `sudo` instead.
2017-10-15 02:28:32 +02:00
end
end
2017-10-21 03:12:50 +02:00
RUBY
end
it "reports an offense if an escape character is present" do
expect_offense(<<~RUBY)
class Foo < Formula
homepage "https://brew.sh/foo"
url "https://brew.sh/foo-1.0.tgz"
def caveats
"\\x1B"
^^^^^^ FormulaAudit/Caveats: Don't use ANSI escape codes in the caveats.
end
end
RUBY
expect_offense(<<~RUBY)
class Foo < Formula
homepage "https://brew.sh/foo"
url "https://brew.sh/foo-1.0.tgz"
def caveats
"\\u001b"
^^^^^^^^ FormulaAudit/Caveats: Don't use ANSI escape codes in the caveats.
end
end
RUBY
end
end
end