From c1b00297e0556197a21155a44876e3422e8f4b1e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 1 Dec 2019 15:04:30 +0000 Subject: [PATCH] cask/cmd/style_spec: add rubocop test. This verifies the cask configuration hasn't been broken. --- Library/Homebrew/test/cask/cmd/style_spec.rb | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Library/Homebrew/test/cask/cmd/style_spec.rb b/Library/Homebrew/test/cask/cmd/style_spec.rb index 447a465f58..5767740cb2 100644 --- a/Library/Homebrew/test/cask/cmd/style_spec.rb +++ b/Library/Homebrew/test/cask/cmd/style_spec.rb @@ -10,6 +10,36 @@ describe Cask::Cmd::Style, :cask do it_behaves_like "a command that handles invalid options" + describe ".rubocop" do + subject { described_class.rubocop(cask_path) } + + around do |example| + FileUtils.ln_s HOMEBREW_LIBRARY_PATH, HOMEBREW_LIBRARY/"Homebrew" + FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop_cask.yml", HOMEBREW_LIBRARY/".rubocop_cask.yml" + FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop_shared.yml", HOMEBREW_LIBRARY/".rubocop_shared.yml" + + example.run + ensure + FileUtils.rm_f HOMEBREW_LIBRARY/"Homebrew" + FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_cask.yml" + FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_shared.yml" + end + + before do + allow(Homebrew).to receive(:install_bundler_gems!) + end + + context "with a valid Cask" do + let(:cask_path) do + Pathname.new("#{HOMEBREW_LIBRARY}/Homebrew/test/support/fixtures/cask/Casks/version-latest.rb") + end + + it "returns true" do + expect(subject.success?).to be true + end + end + end + describe "#cask_paths" do subject { cli.cask_paths }