tests: add test for test calls audit cop

This commit is contained in:
Jonathan Chang 2018-08-15 19:43:57 -04:00
parent 2487345460
commit 5f981a8722

View File

@ -48,6 +48,36 @@ describe RuboCop::Cop::FormulaAudit::ClassName do
end
end
describe RuboCop::Cop::FormulaAudit::TestCalls do
subject(:cop) { described_class.new }
it "reports an offense when /usr/local/bin is found in test calls" do
expect_offense(<<~RUBY)
class Foo < Formula
url 'https://example.com/foo-1.0.tgz'
test do
system "/usr/local/bin/test"
^^^^^^^^^^^^^^^^^^^^^ use \#{bin} instead of /usr/local/bin in system
end
end
RUBY
end
it "reports an offense when passing 0 as the second parameter to shell_output" do
expect_offense(<<~RUBY)
class Foo < Formula
url 'https://example.com/foo-1.0.tgz'
test do
shell_output("\#{bin}/test", 0)
^ Passing 0 to shell_output() is redundant
end
end
RUBY
end
end
describe RuboCop::Cop::FormulaAuditStrict::Test do
subject(:cop) { described_class.new }