diff options
Diffstat (limited to 'Library/Homebrew/test')
28 files changed, 123 insertions, 279 deletions
| diff --git a/Library/Homebrew/test/.codecov.yml b/Library/Homebrew/test/.codecov.yml index c53d9f9dd..9c75dfe6a 100644 --- a/Library/Homebrew/test/.codecov.yml +++ b/Library/Homebrew/test/.codecov.yml @@ -1,7 +1,4 @@ -comment: false -coverage: -  fixes: -    - "::Library/Homebrew/" -  parsers: -    v1: -      include_full_missed_files: yes +comment: off + +fixes: +  - "::Library/Homebrew/" diff --git a/Library/Homebrew/test/cask/artifact/suite_spec.rb b/Library/Homebrew/test/cask/artifact/suite_spec.rb index 98ae93311..eca6b6f17 100644 --- a/Library/Homebrew/test/cask/artifact/suite_spec.rb +++ b/Library/Homebrew/test/cask/artifact/suite_spec.rb @@ -10,19 +10,6 @@ describe Hbc::Artifact::Suite, :cask do      InstallHelper.install_without_artifacts(cask)    end -  it "moves the suite to the proper directory" do -    skip("flaky test") # FIXME - -    shutup do -      install_phase.call -    end - -    expect(target_path).to be_a_directory -    expect(target_path).to be_a_symlink -    expect(target_path.readlink).to exist -    expect(source_path).not_to exist -  end -    it "creates a suite containing the expected app" do      shutup do        install_phase.call diff --git a/Library/Homebrew/test/cask/cli/audit_spec.rb b/Library/Homebrew/test/cask/cli/audit_spec.rb index 412db1481..01f506c8c 100644 --- a/Library/Homebrew/test/cask/cli/audit_spec.rb +++ b/Library/Homebrew/test/cask/cli/audit_spec.rb @@ -1,5 +1,5 @@  describe Hbc::CLI::Audit, :cask do -  let(:cask) { double } +  let(:cask) { double("cask", token: nil) }    describe "selection of Casks to audit" do      it "audits all Casks if no tokens are given" do diff --git a/Library/Homebrew/test/cask/cli/cat_spec.rb b/Library/Homebrew/test/cask/cli/cat_spec.rb index 28089b2f1..b726a0b36 100644 --- a/Library/Homebrew/test/cask/cli/cat_spec.rb +++ b/Library/Homebrew/test/cask/cli/cat_spec.rb @@ -34,9 +34,9 @@ describe Hbc::CLI::Cat, :cask do    end    it "raises an exception when the Cask does not exist" do -    expect { -      Hbc::CLI::Cat.run("notacask") -    }.to raise_error(Hbc::CaskUnavailableError) +    expect { Hbc::CLI::Cat.run("notacask") } +      .to output(/is unavailable/).to_stderr +      .and raise_error(Hbc::CaskError, "Cat incomplete.")    end    describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/fetch_spec.rb b/Library/Homebrew/test/cask/cli/fetch_spec.rb index 9f3056631..54bdfc0c8 100644 --- a/Library/Homebrew/test/cask/cli/fetch_spec.rb +++ b/Library/Homebrew/test/cask/cli/fetch_spec.rb @@ -54,7 +54,7 @@ describe Hbc::CLI::Fetch, :cask do        shutup do          Hbc::CLI::Fetch.run("notacask")        end -    }.to raise_error(Hbc::CaskUnavailableError) +    }.to raise_error(Hbc::CaskError, "Fetch incomplete.")    end    describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/install_spec.rb b/Library/Homebrew/test/cask/cli/install_spec.rb index b1b26c867..cf69b5d86 100644 --- a/Library/Homebrew/test/cask/cli/install_spec.rb +++ b/Library/Homebrew/test/cask/cli/install_spec.rb @@ -41,7 +41,7 @@ describe Hbc::CLI::Install, :cask do      expect {        Hbc::CLI::Install.run("local-transmission") -    }.to output(/Warning: A Cask for local-transmission is already installed./).to_stderr +    }.to output(/Warning: Cask 'local-transmission' is already installed./).to_stderr    end    it "allows double install with --force" do @@ -70,7 +70,7 @@ describe Hbc::CLI::Install, :cask do        shutup do          Hbc::CLI::Install.run("notacask")        end -    }.to raise_error(Hbc::CaskError) +    }.to raise_error(Hbc::CaskError, "Install incomplete.")    end    it "returns a suggestion for a misspelled Cask" do @@ -80,7 +80,7 @@ describe Hbc::CLI::Install, :cask do        rescue Hbc::CaskError          nil        end -    }.to output(/No available Cask for localcaffeine\. Did you mean:\nlocal-caffeine/).to_stderr +    }.to output(/Cask 'localcaffeine' is unavailable: No Cask with this name exists\. Did you mean:\nlocal-caffeine/).to_stderr    end    it "returns multiple suggestions for a Cask fragment" do @@ -90,7 +90,7 @@ describe Hbc::CLI::Install, :cask do        rescue Hbc::CaskError          nil        end -    }.to output(/No available Cask for local-caf\. Did you mean one of:\nlocal-caffeine/).to_stderr +    }.to output(/Cask 'local-caf' is unavailable: No Cask with this name exists\. Did you mean one of:\nlocal-caffeine/).to_stderr    end    describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/style_spec.rb b/Library/Homebrew/test/cask/cli/style_spec.rb index 7d250c166..640eca5f4 100644 --- a/Library/Homebrew/test/cask/cli/style_spec.rb +++ b/Library/Homebrew/test/cask/cli/style_spec.rb @@ -1,4 +1,3 @@ -require "English"  require "open3"  require "rubygems" @@ -108,7 +107,7 @@ describe Hbc::CLI::Style, :cask do        end        it "tries to find paths for all tokens" do -        expect(Hbc::CaskLoader).to receive(:path).twice +        expect(Hbc::CaskLoader).to receive(:load).twice.and_return(double("cask", sourcefile_path: nil))          subject        end      end diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb index bc1f52613..cc640fad7 100644 --- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb @@ -17,15 +17,15 @@ describe Hbc::CLI::Uninstall, :cask do    end    it "shows an error when a bad Cask is provided" do -    expect { -      Hbc::CLI::Uninstall.run("notacask") -    }.to raise_error(Hbc::CaskUnavailableError) +    expect { Hbc::CLI::Uninstall.run("notacask") } +      .to output(/is unavailable/).to_stderr +      .and raise_error(Hbc::CaskError, "Uninstall incomplete.")    end    it "shows an error when a Cask is provided that's not installed" do -    expect { -      Hbc::CLI::Uninstall.run("local-caffeine") -    }.to raise_error(Hbc::CaskNotInstalledError) +    expect { Hbc::CLI::Uninstall.run("local-caffeine") } +    .to output(/is not installed/).to_stderr +    .and raise_error(Hbc::CaskError, "Uninstall incomplete.")    end    it "tries anyway on a non-present Cask when --force is given" do @@ -89,11 +89,9 @@ describe Hbc::CLI::Uninstall, :cask do      Hbc.appdir.join("MyFancyApp.app").rmtree -    expect { -      shutup do -        Hbc::CLI::Uninstall.run("with-uninstall-script-app") -      end -    }.to raise_error(Hbc::CaskError, /does not exist/) +    expect { shutup { Hbc::CLI::Uninstall.run("with-uninstall-script-app") } } +    .to output(/does not exist/).to_stderr +    .and raise_error(Hbc::CaskError, "Uninstall incomplete.")      expect(cask).to be_installed diff --git a/Library/Homebrew/test/cask/cli/zap_spec.rb b/Library/Homebrew/test/cask/cli/zap_spec.rb index f3af0e66f..e39ca61f8 100644 --- a/Library/Homebrew/test/cask/cli/zap_spec.rb +++ b/Library/Homebrew/test/cask/cli/zap_spec.rb @@ -1,8 +1,8 @@  describe Hbc::CLI::Zap, :cask do    it "shows an error when a bad Cask is provided" do -    expect { -      Hbc::CLI::Zap.run("notacask") -    }.to raise_error(Hbc::CaskUnavailableError) +    expect { Hbc::CLI::Zap.run("notacask") } +      .to output(/is unavailable/).to_stderr +      .and raise_error(Hbc::CaskError, "Zap incomplete.")    end    it "can zap and unlink multiple Casks at once" do diff --git a/Library/Homebrew/test/cask/cli_spec.rb b/Library/Homebrew/test/cask/cli_spec.rb index 569b831de..51258c580 100644 --- a/Library/Homebrew/test/cask/cli_spec.rb +++ b/Library/Homebrew/test/cask/cli_spec.rb @@ -1,10 +1,10 @@  describe Hbc::CLI, :cask do    it "lists the taps for Casks that show up in two taps" do -    listing = Hbc::CLI.nice_listing(%w[ -                                      caskroom/cask/adium -                                      caskroom/cask/google-chrome -                                      passcod/homebrew-cask/adium -                                    ]) +    listing = described_class.nice_listing(%w[ +                                             caskroom/cask/adium +                                             caskroom/cask/google-chrome +                                             passcod/homebrew-cask/adium +                                           ])      expect(listing).to eq(%w[                              caskroom/cask/adium @@ -13,6 +13,13 @@ describe Hbc::CLI, :cask do                            ])    end +  it "ignores the `--language` option, which is handled in `OS::Mac`" do +    cli = described_class.new("--language=en") +    expect(cli).to receive(:detect_command_and_arguments).with(no_args) +    expect(cli).to receive(:exit).with(1) +    shutup { cli.run } +  end +    context "when no option is specified" do      it "--binaries is true by default" do        command = Hbc::CLI::Install.new("some-cask") @@ -41,8 +48,8 @@ describe Hbc::CLI, :cask do      end      it "prints help output when subcommand receives `--help` flag" do -      command = Hbc::CLI.new("noop", "--help") -      expect(described_class).to receive(:run_command).with("help") +      command = described_class.new("noop", "--help") +      expect(described_class).to receive(:run_command).with("help", "noop")        command.run        expect(command.help?).to eq(true)      end @@ -56,7 +63,7 @@ describe Hbc::CLI, :cask do      it "exits with a status of 1 when something goes wrong" do        allow(described_class).to receive(:lookup_command).and_raise(Hbc::CaskError) -      command = Hbc::CLI.new("noop") +      command = described_class.new("noop")        expect(command).to receive(:exit).with(1)        command.run      end diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb index 7eeabcf49..5849f581b 100644 --- a/Library/Homebrew/test/cask/dsl_spec.rb +++ b/Library/Homebrew/test/cask/dsl_spec.rb @@ -57,7 +57,7 @@ describe Hbc::DSL, :cask do        it "raises an error" do          expect {            cask -        }.to raise_error(Hbc::CaskTokenDoesNotMatchError, /Bad header line:.*does not match file name/) +        }.to raise_error(Hbc::CaskTokenMismatchError, /header line does not match the file name/)        end      end diff --git a/Library/Homebrew/test/cask/installer_spec.rb b/Library/Homebrew/test/cask/installer_spec.rb index 0ae7c14a5..8ef82c1d5 100644 --- a/Library/Homebrew/test/cask/installer_spec.rb +++ b/Library/Homebrew/test/cask/installer_spec.rb @@ -37,45 +37,6 @@ describe Hbc::Installer, :cask do        expect(Hbc.appdir.join("container")).to be_a_file      end -    it "works with cab-based Casks" do -      skip("cabextract not installed") if which("cabextract").nil? -      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-cab.rb") - -      allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) - -      shutup do -        Hbc::Installer.new(asset).install -      end - -      expect(Hbc.caskroom.join("container-cab", asset.version)).to be_a_directory -      expect(Hbc.appdir.join("container")).to be_a_file -    end - -    it "works with Adobe AIR-based Casks" do -      skip("Adobe AIR not installed") unless Hbc::Container::Air.installer_exist? -      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-air.rb") - -      shutup do -        Hbc::Installer.new(asset).install -      end - -      expect(Hbc.caskroom.join("container-air", asset.version)).to be_a_directory -      expect(Hbc.appdir.join("container.app")).to be_a_directory -    end - -    it "works with 7z-based Casks" do -      skip("unar not installed") if which("unar").nil? -      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-7z.rb") - -      allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) -      shutup do -        Hbc::Installer.new(asset).install -      end - -      expect(Hbc.caskroom.join("container-7z", asset.version)).to be_a_directory -      expect(Hbc.appdir.join("container")).to be_a_file -    end -      it "works with xar-based Casks" do        asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xar.rb") @@ -87,32 +48,6 @@ describe Hbc::Installer, :cask do        expect(Hbc.appdir.join("container")).to be_a_file      end -    it "works with Stuffit-based Casks" do -      skip("unar not installed") if which("unar").nil? -      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-sit.rb") - -      allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) -      shutup do -        Hbc::Installer.new(asset).install -      end - -      expect(Hbc.caskroom.join("container-sit", asset.version)).to be_a_directory -      expect(Hbc.appdir.join("container")).to be_a_file -    end - -    it "works with RAR-based Casks" do -      skip("unar not installed") if which("unar").nil? -      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-rar.rb") - -      allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) -      shutup do -        Hbc::Installer.new(asset).install -      end - -      expect(Hbc.caskroom.join("container-rar", asset.version)).to be_a_directory -      expect(Hbc.appdir.join("container")).to be_a_file -    end -      it "works with pure bzip2-based Casks" do        asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-bzip2.rb") @@ -135,45 +70,6 @@ describe Hbc::Installer, :cask do        expect(Hbc.appdir.join("container")).to be_a_file      end -    it "works with pure xz-based Casks" do -      skip("unxz not installed") if which("unxz").nil? -      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xz.rb") - -      allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) -      shutup do -        Hbc::Installer.new(asset).install -      end - -      expect(Hbc.caskroom.join("container-xz", asset.version)).to be_a_directory -      expect(Hbc.appdir.join("container-xz--#{asset.version}")).to be_a_file -    end - -    it "works with lzma-based Casks" do -      skip("unlzma not installed") if which("unlzma").nil? -      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-lzma.rb") - -      allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) -      shutup do -        Hbc::Installer.new(asset).install -      end - -      expect(Hbc.caskroom.join("container-lzma", asset.version)).to be_a_directory -      expect(Hbc.appdir.join("container-lzma--#{asset.version}")).to be_a_file -    end - -    it "works with gpg-based Casks" do -      skip("gpg not installed") if which("gpg").nil? -      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-gpg.rb") - -      allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) -      shutup do -        Hbc::Installer.new(asset).install -      end - -      expect(Hbc.caskroom.join("container-gpg", asset.version)).to be_a_directory -      expect(Hbc.appdir.join("container")).to be_a_file -    end -      it "blows up on a bad checksum" do        bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb")        expect { @@ -249,22 +145,6 @@ describe Hbc::Installer, :cask do        expect(with_macosx_dir.staged_path.join("__MACOSX")).not_to be_a_directory      end -    it "installer method raises an exception when already-installed Casks which auto-update are attempted" do -      with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") - -      expect(with_auto_updates).not_to be_installed - -      installer = Hbc::Installer.new(with_auto_updates) - -      shutup do -        installer.install -      end - -      expect { -        installer.install -      }.to raise_error(Hbc::CaskAlreadyInstalledAutoUpdatesError) -    end -      it "allows already-installed Casks which auto-update to be installed if force is provided" do        with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") diff --git a/Library/Homebrew/test/cask/verify/checksum_spec.rb b/Library/Homebrew/test/cask/verify/checksum_spec.rb index 55c0e5f44..4b8543d2b 100644 --- a/Library/Homebrew/test/cask/verify/checksum_spec.rb +++ b/Library/Homebrew/test/cask/verify/checksum_spec.rb @@ -1,5 +1,5 @@  describe Hbc::Verify::Checksum, :cask do -  let(:cask) { double("cask") } +  let(:cask) { double("cask", token: "cask") }    let(:downloaded_path) { double("downloaded_path") }    let(:verification) { described_class.new(cask, downloaded_path) } diff --git a/Library/Homebrew/test/cmd/cask_spec.rb b/Library/Homebrew/test/cmd/cask_spec.rb index fcd7e6a16..3bba5fbf4 100644 --- a/Library/Homebrew/test/cmd/cask_spec.rb +++ b/Library/Homebrew/test/cmd/cask_spec.rb @@ -1,4 +1,4 @@ -describe "brew cask", :integration_test, :needs_macos, :needs_official_cmd_taps do +describe "brew cask", :integration_test, :needs_macos, :needs_network do    describe "list" do      it "returns a list of installed Casks" do        setup_remote_tap("caskroom/cask") diff --git a/Library/Homebrew/test/cmd/services_spec.rb b/Library/Homebrew/test/cmd/services_spec.rb index c456fea17..669e84e5f 100644 --- a/Library/Homebrew/test/cmd/services_spec.rb +++ b/Library/Homebrew/test/cmd/services_spec.rb @@ -1,4 +1,4 @@ -describe "brew services", :integration_test, :needs_macos, :needs_official_cmd_taps do +describe "brew services", :integration_test, :needs_macos, :needs_network do    it "allows controlling services" do      setup_remote_tap "homebrew/services" diff --git a/Library/Homebrew/test/gpg_spec.rb b/Library/Homebrew/test/gpg_spec.rb deleted file mode 100644 index 160e55379..000000000 --- a/Library/Homebrew/test/gpg_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require "gpg" - -describe Gpg do -  subject { described_class } - -  describe "::create_test_key" do -    it "creates a test key in the home directory" do -      skip "GPG Unavailable" unless subject.available? - -      mktmpdir do |dir| -        ENV["HOME"] = dir - -        shutup do -          subject.create_test_key(dir) -        end - -        if subject.version == Version.create("2.0") -          expect(dir/".gnupg/secring.gpg").to be_a_file -        else -          expect(dir/".gnupg/pubring.kbx").to be_a_file -        end -      end -    end -  end -end diff --git a/Library/Homebrew/test/os/mac/diagnostic_spec.rb b/Library/Homebrew/test/os/mac/diagnostic_spec.rb index 787f80fec..d6186e46b 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_spec.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_spec.rb @@ -45,4 +45,17 @@ describe Homebrew::Diagnostic::Checks do      expect(subject.check_homebrew_prefix)        .to match("Your Homebrew's prefix is not /usr/local.")    end + +  specify "#check_ruby_version" do +    allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.13")) +    stub_const("RUBY_VERSION", "2.3.3p222") + +    expect(subject.check_ruby_version) +      .to match <<-EOS.undent +      Ruby version 2.3.3p222 is unsupported on 10.13. Homebrew +      is developed and tested on Ruby 2.0, and may not work correctly +      on other Rubies. Patches are accepted as long as they don't cause breakage +      on supported Rubies. +    EOS +  end  end diff --git a/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb b/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb index f6436d6a3..4e684be46 100644 --- a/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb @@ -3,7 +3,7 @@ require "rubocop/rspec/support"  require_relative "../../extend/string"  require_relative "../../rubocops/formula_desc_cop" -describe RuboCop::Cop::FormulaAuditStrict::Desc do +describe RuboCop::Cop::FormulaAuditStrict::DescLength do    subject(:cop) { described_class.new }    context "When auditing formula desc" do @@ -31,7 +31,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Desc do        source = <<-EOS.undent          class Foo < Formula            url 'http://example.com/foo-1.0.tgz' -          desc '#{"bar" * 30}' +          desc 'Bar#{"bar" * 29}'          end        EOS @@ -55,7 +55,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Desc do        source = <<-EOS.undent          class Foo < Formula            url 'http://example.com/foo-1.0.tgz' -          desc '#{"bar" * 10}'\ +          desc 'Bar#{"bar" * 9}'\              '#{"foo" * 21}'          end        EOS @@ -75,7 +75,13 @@ describe RuboCop::Cop::FormulaAuditStrict::Desc do          expect_offense(expected, actual)        end      end +  end +end +describe RuboCop::Cop::FormulaAuditStrict::Desc do +  subject(:cop) { described_class.new } + +  context "When auditing formula desc" do      it "When wrong \"command-line\" usage in desc" do        source = <<-EOS.undent          class Foo < Formula @@ -104,7 +110,27 @@ describe RuboCop::Cop::FormulaAuditStrict::Desc do          end        EOS -      expected_offenses = [{ message: "Description shouldn't start with an indefinite article (An )", +      expected_offenses = [{ message: "Description shouldn't start with an indefinite article i.e. \"An\"", +                             severity: :convention, +                             line: 3, +                             column: 8, +                             source: source }] + +      inspect_source(cop, source) +      expected_offenses.zip(cop.offenses).each do |expected, actual| +        expect_offense(expected, actual) +      end +    end + +    it "When an lowercase letter starts a desc" do +      source = <<-EOS.undent +        class Foo < Formula +          url 'http://example.com/foo-1.0.tgz' +          desc 'bar' +        end +      EOS + +      expected_offenses = [{ message: "Description should start with a capital letter",                               severity: :convention,                               line: 3,                               column: 8, @@ -136,11 +162,22 @@ describe RuboCop::Cop::FormulaAuditStrict::Desc do        end      end -    def expect_offense(expected, actual) -      expect(actual.message).to eq(expected[:message]) -      expect(actual.severity).to eq(expected[:severity]) -      expect(actual.line).to eq(expected[:line]) -      expect(actual.column).to eq(expected[:column]) +    it "autocorrects all rules" do +      source = <<-EOS.undent +        class Foo < Formula +          url 'http://example.com/foo-1.0.tgz' +          desc ' an bar: commandline foo ' +        end +      EOS +      correct_source = <<-EOS.undent +        class Foo < Formula +          url 'http://example.com/foo-1.0.tgz' +          desc 'an bar: command-line' +        end +      EOS + +      corrected_source = autocorrect_source(cop, source) +      expect(corrected_source).to eq(correct_source)      end    end  end diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index e193b91a0..03b14720b 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -23,6 +23,7 @@ require "test/support/helper/shutup"  require "test/support/helper/fixtures"  require "test/support/helper/formula"  require "test/support/helper/mktmpdir" +require "test/support/helper/rubocop"  require "test/support/helper/spec/shared_context/homebrew_cask" if OS.mac?  require "test/support/helper/spec/shared_context/integration_test" @@ -44,6 +45,7 @@ RSpec.configure do |config|    config.include(Test::Helper::Fixtures)    config.include(Test::Helper::Formula)    config.include(Test::Helper::MkTmpDir) +  config.include(Test::Helper::RuboCop)    config.before(:each, :needs_compat) do      skip "Requires compatibility layer." if ENV["HOMEBREW_NO_COMPAT"] diff --git a/Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.high_sierra.bottle.tar.gz b/Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.high_sierra.bottle.tar.gz new file mode 120000 index 000000000..3e989830b --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.high_sierra.bottle.tar.gz @@ -0,0 +1 @@ +testball_bottle-0.1.yosemite.bottle.tar.gz
\ No newline at end of file diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb deleted file mode 100644 index 5aaf3d53e..000000000 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb +++ /dev/null @@ -1,9 +0,0 @@ -cask 'container-air' do -  version '0.1' -  sha256 '554472e163f8a028629b12b468e29acda9f16b223dff74fcd218bba73cc2365a' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.air" -  homepage 'https://example.com/container-air' - -  app 'container.app' -end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-gpg.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-gpg.rb deleted file mode 100644 index 630527ce2..000000000 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-gpg.rb +++ /dev/null @@ -1,12 +0,0 @@ -cask 'container-gpg' do -  version '1.2.3' -  sha256 :no_check - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.tar.xz.gpg" -  gpg :embedded, key_id: 'B0976E51E5C047AD0FD051294E402EBF7C3C6A71' - -  homepage 'https://example.com/container-gpg' -  depends_on formula: 'gpg' - -  app 'container' -end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb deleted file mode 100644 index 92d2c253e..000000000 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb +++ /dev/null @@ -1,11 +0,0 @@ -cask 'container-lzma' do -  version '1.2.3' -  sha256 '9d7edb32d02ab9bd9749a5bde8756595ea4cfcb1da02ca11c30fb591d4c1ed85' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.lzma" -  homepage 'https://example.com/container-lzma' - -  depends_on formula: 'lzma' - -  app 'container-lzma--1.2.3' -end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb deleted file mode 100644 index 33ea670d1..000000000 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb +++ /dev/null @@ -1,11 +0,0 @@ -cask 'container-rar' do -  version '1.2.3' -  sha256 '419af7864c0e1f125515c49b08bd22e0f7de39f5285897c440fe03c714871763' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.rar" -  homepage 'https://example.com/container-rar' - -  depends_on formula: 'unar' - -  app 'container' -end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb deleted file mode 100644 index 5715795a7..000000000 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb +++ /dev/null @@ -1,11 +0,0 @@ -cask 'container-sit' do -  version '1.2.3' -  sha256 '0d21a64dce625044345c8ecca888e5439feaf254dac7f884917028a744f93cf3' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.sit" -  homepage 'https://example.com/container-sit' - -  depends_on formula: 'unar' - -  app 'container' -end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb deleted file mode 100644 index 3f844af04..000000000 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb +++ /dev/null @@ -1,11 +0,0 @@ -cask 'container-xz' do -  version '1.2.3' -  sha256 '839263f474edde1d54a9101606e6f0dc9d963acc93f6dcc5af8d10ebc3187c02' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.xz" -  homepage 'https://example.com/container-xz' - -  depends_on formula: 'xz' - -  app 'container-xz--1.2.3' -end diff --git a/Library/Homebrew/test/support/helper/rubocop.rb b/Library/Homebrew/test/support/helper/rubocop.rb new file mode 100644 index 000000000..351f2ad82 --- /dev/null +++ b/Library/Homebrew/test/support/helper/rubocop.rb @@ -0,0 +1,13 @@ +module Test +  module Helper +    module RuboCop +      def expect_offense(expected, actual) +        expect(actual).to_not be_nil +        expect(actual.message).to eq(expected[:message]) +        expect(actual.severity).to eq(expected[:severity]) +        expect(actual.line).to eq(expected[:line]) +        expect(actual.column).to eq(expected[:column]) +      end +    end +  end +end diff --git a/Library/Homebrew/test/utils/popen_spec.rb b/Library/Homebrew/test/utils/popen_spec.rb index e3704a876..63bbc7b18 100644 --- a/Library/Homebrew/test/utils/popen_spec.rb +++ b/Library/Homebrew/test/utils/popen_spec.rb @@ -4,7 +4,7 @@ describe Utils do    describe "::popen_read" do      it "reads the standard output of a given command" do        expect(subject.popen_read("sh", "-c", "echo success").chomp).to eq("success") -      expect($?).to be_a_success +      expect($CHILD_STATUS).to be_a_success      end      it "can be given a block to manually read from the pipe" do @@ -13,7 +13,7 @@ describe Utils do            pipe.read.chomp          end,        ).to eq("success") -      expect($?).to be_a_success +      expect($CHILD_STATUS).to be_a_success      end    end @@ -22,7 +22,7 @@ describe Utils do        subject.popen_write("grep", "-q", "success") do |pipe|          pipe.write("success\n")        end -      expect($?).to be_a_success +      expect($CHILD_STATUS).to be_a_success      end    end  end | 
