2017-06-02 19:15:40 +02:00
|
|
|
require "cmd/style"
|
|
|
|
|
|
|
|
describe "brew style" do
|
|
|
|
around(:each) do |example|
|
|
|
|
begin
|
|
|
|
FileUtils.ln_s HOMEBREW_LIBRARY_PATH, HOMEBREW_LIBRARY/"Homebrew"
|
2017-10-09 18:27:02 +02:00
|
|
|
FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop.yml", HOMEBREW_LIBRARY/".rubocop_audit.yml"
|
2017-06-02 19:15:40 +02:00
|
|
|
|
|
|
|
example.run
|
|
|
|
ensure
|
|
|
|
FileUtils.rm_f HOMEBREW_LIBRARY/"Homebrew"
|
2017-10-09 18:27:02 +02:00
|
|
|
FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_audit.yml"
|
2017-06-02 19:15:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "Homebrew::check_style_json" do
|
|
|
|
let(:dir) { mktmpdir }
|
|
|
|
|
|
|
|
it "returns RubocopResults when RuboCop reports offenses" do
|
|
|
|
formula = dir/"my-formula.rb"
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
formula.write <<~'EOS'
|
2017-06-02 19:15:40 +02:00
|
|
|
class MyFormula < Formula
|
|
|
|
|
|
|
|
end
|
|
|
|
EOS
|
|
|
|
|
|
|
|
rubocop_result = Homebrew.check_style_json([formula])
|
|
|
|
|
|
|
|
expect(rubocop_result.file_offenses(formula.realpath.to_s).map(&:message))
|
2018-01-07 15:40:42 +00:00
|
|
|
.to include("Layout/EmptyLinesAroundClassBody: Extra empty line detected at class body beginning.")
|
2017-06-02 19:15:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|