diff options
| author | Markus Reiter | 2017-06-02 19:15:40 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-06-04 10:11:59 +0200 |
| commit | 3064b5b3c301897f8229ccc4f3b5922bcae64ddf (patch) | |
| tree | 2be5cd22f67192e696fd9b8c78770953e24d049f | |
| parent | 7c0a3a1233fe41a0a8510e4cd5055a0a4b799ff8 (diff) | |
| download | brew-3064b5b3c301897f8229ccc4f3b5922bcae64ddf.tar.bz2 | |
Add test for `brew style`.
| -rw-r--r-- | Library/Homebrew/test/cmd/style_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Library/Homebrew/test/cmd/style_spec.rb b/Library/Homebrew/test/cmd/style_spec.rb new file mode 100644 index 000000000..3c4c3f809 --- /dev/null +++ b/Library/Homebrew/test/cmd/style_spec.rb @@ -0,0 +1,34 @@ +require "cmd/style" + +describe "brew style" do + around(:each) do |example| + begin + FileUtils.ln_s HOMEBREW_LIBRARY_PATH, HOMEBREW_LIBRARY/"Homebrew" + FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop.yml", HOMEBREW_LIBRARY/".rubocop.yml" + + example.run + ensure + FileUtils.rm_f HOMEBREW_LIBRARY/"Homebrew" + FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop.yml" + end + end + + describe "Homebrew::check_style_json" do + let(:dir) { mktmpdir } + + it "returns RubocopResults when RuboCop reports offenses" do + formula = dir/"my-formula.rb" + + formula.write <<-'EOS'.undent + class MyFormula < Formula + + end + EOS + + rubocop_result = Homebrew.check_style_json([formula]) + + expect(rubocop_result.file_offenses(formula.realpath.to_s).map(&:message)) + .to include("Extra empty line detected at class body beginning.") + end + end +end |
