diff options
Diffstat (limited to 'Library/Homebrew/cask')
251 files changed, 2828 insertions, 4433 deletions
diff --git a/Library/Homebrew/cask/.gitattributes b/Library/Homebrew/cask/.gitattributes deleted file mode 100644 index 176a458f9..000000000 --- a/Library/Homebrew/cask/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto diff --git a/Library/Homebrew/cask/Gemfile b/Library/Homebrew/cask/Gemfile index 5c99338b8..5572387cc 100644 --- a/Library/Homebrew/cask/Gemfile +++ b/Library/Homebrew/cask/Gemfile @@ -1,29 +1,13 @@  source "https://rubygems.org" -gem "rake" - -group :debug do -  gem "pry" -  gem "pry-byebug", platforms: :mri -end -  group :test do -  # This is SimpleCov v0.12.0 with two fixes merged on top, that finally resolve -  # all issues with parallel tests, uncovered files, and tracked files. Switch -  # back to stable as soon as v0.12.1 or v0.13.0 is released. For details, see: -  #  - https://github.com/colszowka/simplecov/pull/513 -  #  - https://github.com/colszowka/simplecov/pull/520 -  gem "simplecov", "0.12.0", -    git: "https://github.com/colszowka/simplecov.git", -    branch: "master", -    ref: "83d8031ddde0927f87ef9327200a98583ca18d77", -    require: false +  gem "simplecov", require: false    gem "codecov", require: false -  gem "minitest", "~> 5.9" +  gem "minitest"    gem "minitest-reporters" -  gem "mocha", "~> 1.1", require: false +  gem "mocha", require: false    gem "parallel_tests" -  gem "rspec", "~> 3.5" +  gem "rspec"    gem "rspec-its", require: false    gem "rspec-wait", require: false  end diff --git a/Library/Homebrew/cask/Gemfile.lock b/Library/Homebrew/cask/Gemfile.lock index 4bdf2d0f6..700f093d1 100644 --- a/Library/Homebrew/cask/Gemfile.lock +++ b/Library/Homebrew/cask/Gemfile.lock @@ -1,49 +1,27 @@ -GIT -  remote: https://github.com/colszowka/simplecov.git -  revision: 83d8031ddde0927f87ef9327200a98583ca18d77 -  ref: 83d8031ddde0927f87ef9327200a98583ca18d77 -  branch: master -  specs: -    simplecov (0.12.0) -      docile (~> 1.1.0) -      json (>= 1.8, < 3) -      simplecov-html (~> 0.10.0) -  GEM    remote: https://rubygems.org/    specs:      ansi (1.5.0) -    builder (3.2.2) -    byebug (9.0.6) -    codecov (0.1.6) +    builder (3.2.3) +    codecov (0.1.9)        json        simplecov        url -    coderay (1.1.1) -    diff-lcs (1.2.5) +    diff-lcs (1.3)      docile (1.1.5) -    json (2.0.2) +    json (2.0.3)      metaclass (0.0.4) -    method_source (0.8.2) -    minitest (5.9.1) -    minitest-reporters (1.1.12) +    minitest (5.10.1) +    minitest-reporters (1.1.14)        ansi        builder        minitest (>= 5.0)        ruby-progressbar      mocha (1.2.1)        metaclass (~> 0.0.1) -    parallel (1.9.0) -    parallel_tests (2.10.0) +    parallel (1.10.0) +    parallel_tests (2.13.0)        parallel -    pry (0.10.4) -      coderay (~> 1.1.0) -      method_source (~> 0.8.1) -      slop (~> 3.4) -    pry-byebug (3.4.0) -      byebug (~> 9.0) -      pry (~> 0.10) -    rake (11.3.0)      rspec (3.5.0)        rspec-core (~> 3.5.0)        rspec-expectations (~> 3.5.0) @@ -63,8 +41,11 @@ GEM      rspec-wait (0.0.9)        rspec (>= 3, < 4)      ruby-progressbar (1.8.1) +    simplecov (0.13.0) +      docile (~> 1.1.0) +      json (>= 1.8, < 3) +      simplecov-html (~> 0.10.0)      simplecov-html (0.10.0) -    slop (3.6.0)      url (0.3.2)  PLATFORMS @@ -72,17 +53,14 @@ PLATFORMS  DEPENDENCIES    codecov -  minitest (~> 5.9) +  minitest    minitest-reporters -  mocha (~> 1.1) +  mocha    parallel_tests -  pry -  pry-byebug -  rake -  rspec (~> 3.5) +  rspec    rspec-its    rspec-wait -  simplecov (= 0.12.0)! +  simplecov  BUNDLED WITH -   1.13.6 +   1.13.7 diff --git a/Library/Homebrew/cask/Rakefile b/Library/Homebrew/cask/Rakefile deleted file mode 100644 index 39398aa19..000000000 --- a/Library/Homebrew/cask/Rakefile +++ /dev/null @@ -1,26 +0,0 @@ -require "rake/testtask" -require "rspec/core/rake_task" - -$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew")) -$LOAD_PATH.unshift(File.expand_path("../lib", __FILE__)) - -namespace :test do -  namespace :coverage do -    desc "Upload coverage to Codecov" -    task :upload do -      require "simplecov" -      require "codecov" -      formatter = SimpleCov::Formatter::Codecov.new -      formatter.format(SimpleCov::ResultMerger.merged_result) -    end -  end -end - -desc "Open a REPL for debugging and experimentation" -task :console do -  require "pry" -  require "pry-byebug" -  require "hbc" -  ARGV.clear -  Hbc.pry -end diff --git a/Library/Homebrew/cask/cmd/brew-cask-tests.rb b/Library/Homebrew/cask/cmd/brew-cask-tests.rb index 43683a263..b27bc2fe7 100755 --- a/Library/Homebrew/cask/cmd/brew-cask-tests.rb +++ b/Library/Homebrew/cask/cmd/brew-cask-tests.rb @@ -10,8 +10,8 @@ def run_tests(executable, files, args = [])    system "bundle", "exec", executable, *opts, "--", *args, "--", *files  end -repo_root = Pathname.new(__FILE__).realpath.parent.parent -repo_root.cd do +cask_root = Pathname.new(__FILE__).realpath.parent.parent +cask_root.cd do    ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"    ENV["HOMEBREW_NO_EMOJI"] = "1"    ENV.delete("HOMEBREW_CASK_OPTS") @@ -21,37 +21,25 @@ repo_root.cd do      system "bundle", "install"    end -  rspec = ARGV.flag?("--rspec") || !ARGV.flag?("--minitest") -  minitest = ARGV.flag?("--minitest") || !ARGV.flag?("--rspec") - -  p [:coverage, ARGV.flag?("--coverage"), ENV["CI"], ENV["TRAVIS"]]    if ARGV.flag?("--coverage")      ENV["HOMEBREW_TESTS_COVERAGE"] = "1"      upload_coverage = ENV["CODECOV_TOKEN"] || ENV["TRAVIS"]    end -  failed = false - -  if rspec -    run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[ -      --color -      --require spec_helper -      --format progress -      --format ParallelTests::RSpec::RuntimeLogger -      --out tmp/parallel_runtime_rspec.log -    ] -    failed ||= !$CHILD_STATUS.success? -  end +  run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[ +    --color +    --require spec_helper +    --format progress +    --format ParallelTests::RSpec::RuntimeLogger +    --out tmp/parallel_runtime_rspec.log +  ] -  if minitest -    run_tests "parallel_test", Dir["test/**/*_test.rb"] -    failed ||= !$CHILD_STATUS.success? +  unless $CHILD_STATUS.success? +    Homebrew.failed = true    end -  Homebrew.failed = failed -    if upload_coverage      puts "Submitting Codecov coverage..." -    system "bundle", "exec", "rake", "test:coverage:upload" +    system "bundle", "exec", "spec/upload_coverage.rb"    end  end diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb index 69b6e8f21..80f1f1da0 100644 --- a/Library/Homebrew/cask/lib/hbc.rb +++ b/Library/Homebrew/cask/lib/hbc.rb @@ -6,6 +6,7 @@ require "hbc/audit"  require "hbc/auditor"  require "hbc/cache"  require "hbc/cask" +require "hbc/cask_loader"  require "hbc/without_source"  require "hbc/caskroom"  require "hbc/checkable" @@ -46,7 +47,7 @@ module Hbc    def self.init      Cache.ensure_cache_exists -    Cache.migrate_legacy_cache +    Cache.delete_legacy_cache      Caskroom.migrate_caskroom_from_repo_to_prefix      Caskroom.ensure_caskroom_exists diff --git a/Library/Homebrew/cask/lib/hbc/artifact.rb b/Library/Homebrew/cask/lib/hbc/artifact.rb index 8b4babdf6..b155a125a 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact.rb @@ -27,41 +27,39 @@ module Hbc    module Artifact      # NOTE: order is important here, since we want to extract nested containers      #       before we handle any other artifacts -    def self.artifacts -      [ -        PreflightBlock, -        NestedContainer, -        Installer, -        App, -        Suite, -        Artifact, # generic 'artifact' stanza -        Colorpicker, -        Pkg, -        Prefpane, -        Qlplugin, -        Dictionary, -        Font, -        Service, -        StageOnly, -        Binary, -        InputMethod, -        InternetPlugin, -        AudioUnitPlugin, -        VstPlugin, -        Vst3Plugin, -        ScreenSaver, -        Uninstall, -        PostflightBlock, -        Zap, -      ] -    end +    TYPES = [ +      PreflightBlock, +      NestedContainer, +      Installer, +      App, +      Suite, +      Artifact, # generic 'artifact' stanza +      Colorpicker, +      Pkg, +      Prefpane, +      Qlplugin, +      Dictionary, +      Font, +      Service, +      StageOnly, +      Binary, +      InputMethod, +      InternetPlugin, +      AudioUnitPlugin, +      VstPlugin, +      Vst3Plugin, +      ScreenSaver, +      Uninstall, +      PostflightBlock, +      Zap, +    ].freeze -    def self.for_cask(cask) +    def self.for_cask(cask, command: SystemCommand, force: false)        odebug "Determining which artifacts are present in Cask #{cask}" -      artifacts.select do |artifact| -        odebug "Checking for artifact class #{artifact}" -        artifact.me?(cask) -      end + +      TYPES +        .select { |klass| klass.me?(cask) } +        .map { |klass| klass.new(cask, command: command, force: force) }      end    end  end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/base.rb b/Library/Homebrew/cask/lib/hbc/artifact/base.rb index b53c13f08..d925ff340 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/base.rb @@ -27,10 +27,6 @@ module Hbc        attr_reader :force -      def zap_phase -        odebug "Nothing to do. The #{self.class.artifact_name} artifact has no zap phase." -      end -        # TODO: this sort of logic would make more sense in dsl.rb, or a        #       constructor called from dsl.rb, so long as that isn't slow.        def self.read_script_arguments(arguments, stanza, default_arguments = {}, override_arguments = {}, key = nil) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb index b64b00fe3..55e8d38c0 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb @@ -3,16 +3,6 @@ require "hbc/artifact/base"  module Hbc    module Artifact      class Installer < Base -      # TODO: for backward compatibility, removeme -      def install -        install_phase -      end - -      # TODO: for backward compatibility, removeme -      def uninstall -        uninstall_phase -      end -        def install_phase          @cask.artifacts[self.class.artifact_dsl_key].each do |artifact|            if artifact.manual @@ -36,10 +26,6 @@ module Hbc            end          end        end - -      def uninstall_phase -        odebug "Nothing to do. The #{self.class.artifact_dsl_key} artifact has no uninstall phase." -      end      end    end  end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb index 107640797..45f23fe37 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb @@ -7,10 +7,6 @@ module Hbc          @cask.artifacts[:nested_container].each { |container| extract(container) }        end -      def uninstall_phase -        # no need to take action; is removed after extraction -      end -        def extract(container_relative_path)          source = @cask.staged_path.join(container_relative_path)          container = Container.for_path(source, @command) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb index 0569d2a86..6d6362d46 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb @@ -36,10 +36,6 @@ module Hbc          @cask.artifacts[:pkg].each { |pkg_description| run_installer(pkg_description) }        end -      def uninstall_phase -        # Do nothing. Must be handled explicitly by a separate :uninstall stanza. -      end -        def run_installer(pkg_description)          load_pkg_description pkg_description          ohai "Running installer for #{@cask}; your password may be necessary." diff --git a/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb b/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb index 594c5bef9..1122c1d02 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb @@ -6,14 +6,6 @@ module Hbc        def self.artifact_dsl_key          :stage_only        end - -      def install_phase -        # do nothing -      end - -      def uninstall_phase -        # do nothing -      end      end    end  end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb index 8b5603064..5a3dc098d 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb @@ -3,6 +3,9 @@ require "hbc/artifact/uninstall_base"  module Hbc    module Artifact      class Uninstall < UninstallBase +      def uninstall_phase +        dispatch_uninstall_directives +      end      end    end  end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb index ccb06a9ab..ce2b1f51a 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb @@ -54,15 +54,7 @@ module Hbc          path_strings - undeletable        end -      def install_phase -        odebug "Nothing to do. The uninstall artifact has no install phase." -      end - -      def uninstall_phase -        dispatch_uninstall_directives -      end - -      def dispatch_uninstall_directives(expand_tilde = true) +      def dispatch_uninstall_directives(expand_tilde: true)          directives_set = @cask.artifacts[stanza]          ohai "Running #{stanza} process for #{@cask}; your password may be necessary" diff --git a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb index 503ea35c4..7793e5772 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb @@ -3,17 +3,8 @@ require "hbc/artifact/uninstall_base"  module Hbc    module Artifact      class Zap < UninstallBase -      def install_phase -        odebug "Nothing to do. The zap artifact has no install phase." -      end - -      def uninstall_phase -        odebug "Nothing to do. The zap artifact has no uninstall phase." -      end -        def zap_phase -        expand_tilde = true -        dispatch_uninstall_directives(expand_tilde) +        dispatch_uninstall_directives(expand_tilde: true)        end      end    end diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index 955ecdbb0..12cefb939 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -133,20 +133,19 @@ module Hbc      def check_appcast_checkpoint_accuracy        odebug "Verifying appcast checkpoint is accurate" -      result = @command.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, cask.appcast], print_stderr: false) -      if result.success? -        processed_appcast_text = result.stdout.gsub(%r{<pubDate>[^<]*</pubDate>}, "") -        # This step is necessary to replicate running `sed` from the command line -        processed_appcast_text << "\n" unless processed_appcast_text.end_with?("\n") +      result = cask.appcast.calculate_checkpoint + +      actual_checkpoint = result[:checkpoint] + +      if actual_checkpoint.nil? +        add_warning "error retrieving appcast: #{result[:command_result].stderr}" +      else          expected = cask.appcast.checkpoint -        actual = Digest::SHA2.hexdigest(processed_appcast_text) -        add_warning <<-EOS.undent unless expected == actual +        add_warning <<-EOS.undent unless expected == actual_checkpoint            appcast checkpoint mismatch            Expected: #{expected} -          Actual: #{actual} +          Actual: #{actual_checkpoint}          EOS -      else -        add_warning "error retrieving appcast: #{result.stderr}"        end      end diff --git a/Library/Homebrew/cask/lib/hbc/cache.rb b/Library/Homebrew/cask/lib/hbc/cache.rb index e343da3fa..7b586528e 100644 --- a/Library/Homebrew/cask/lib/hbc/cache.rb +++ b/Library/Homebrew/cask/lib/hbc/cache.rb @@ -9,27 +9,10 @@ module Hbc        Hbc.cache.mkpath      end -    def migrate_legacy_cache +    def delete_legacy_cache        return unless Hbc.legacy_cache.exist? -      ohai "Migrating cached files to #{Hbc.cache}..." -      Hbc.legacy_cache.children.select(&:symlink?).each do |symlink| -        file = symlink.readlink - -        new_name = file.basename -                       .sub(/\-((?:(\d|#{DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$/x, -                            '--\1') - -        renamed_file = Hbc.cache.join(new_name) - -        if file.exist? -          puts "#{file} -> #{renamed_file}" -          FileUtils.mv(file, renamed_file) -        end - -        FileUtils.rm(symlink) -      end - +      ohai "Deleting legacy cache at #{Hbc.legacy_cache}..."        FileUtils.remove_entry_secure(Hbc.legacy_cache)      end    end diff --git a/Library/Homebrew/cask/lib/hbc/cask_loader.rb b/Library/Homebrew/cask/lib/hbc/cask_loader.rb index 3875b30df..3fe02d7e1 100644 --- a/Library/Homebrew/cask/lib/hbc/cask_loader.rb +++ b/Library/Homebrew/cask/lib/hbc/cask_loader.rb @@ -32,22 +32,12 @@ module Hbc      end      def cask(header_token, &block) -      @klass = Cask -      build_cask(header_token, &block) -    end - -    def test_cask(header_token, &block) -      @klass = TestCask -      build_cask(header_token, &block) -    end - -    def build_cask(header_token, &block)        raise CaskTokenDoesNotMatchError.new(@token, header_token) unless @token == header_token        if @path.nil? -        @klass.new(@token, &block) +        Cask.new(@token, &block)        else -        @klass.new(@token, sourcefile_path: @path, &block) +        Cask.new(@token, sourcefile_path: @path, &block)        end      end    end diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index 42c3982ba..73ab121d2 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -23,6 +23,7 @@ require "hbc/cli/zap"  require "hbc/cli/internal_use_base"  require "hbc/cli/internal_audit_modified_casks" +require "hbc/cli/internal_appcast_checkpoint"  require "hbc/cli/internal_checkurl"  require "hbc/cli/internal_dump"  require "hbc/cli/internal_help" @@ -141,13 +142,17 @@ module Hbc      end      def self.process(arguments) +      unless ENV["MACOS_VERSION"].nil? +        MacOS.full_version = ENV["MACOS_VERSION"] +      end +        command_string, *rest = *arguments        rest = process_options(rest)        command = Hbc.help ? "help" : lookup_command(command_string)        Hbc.default_tap.install unless Hbc.default_tap.installed?        Hbc.init if should_init?(command)        run_command(command, *rest) -    rescue CaskError, CaskSha256MismatchError => e +    rescue CaskError, CaskSha256MismatchError, ArgumentError => e        msg = e.message        msg << e.backtrace.join("\n") if Hbc.debug        onoe msg diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index 84d8e1ebc..6b2f4caab 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -2,116 +2,39 @@ module Hbc    class CLI      class Doctor < Base        def self.run -        ohai "macOS Release:", render_with_none_as_error(MacOS.full_version) -        ohai "Hardware Architecture:", render_with_none_as_error("#{Hardware::CPU.type}-#{Hardware::CPU.bits}") -        ohai "Ruby Version:", render_with_none_as_error("#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}") -        ohai "Ruby Path:", render_with_none_as_error(RbConfig.ruby) -        # TODO: consider removing most Homebrew constants from doctor output -        ohai "Homebrew Version:", render_with_none_as_error(homebrew_version) -        ohai "Homebrew Executable Path:", render_with_none_as_error(HOMEBREW_BREW_FILE) -        ohai "Homebrew Cellar Path:", render_with_none_as_error(homebrew_cellar) -        ohai "Homebrew Repository Path:", render_with_none_as_error(HOMEBREW_REPOSITORY) -        ohai "Homebrew Origin:", render_with_none_as_error(homebrew_origin) -        ohai "Homebrew-Cask Version:", render_with_none_as_error(Hbc.full_version) -        ohai "Homebrew-Cask Install Location:", render_install_location -        ohai "Homebrew-Cask Staging Location:", render_staging_location(Hbc.caskroom) -        ohai "Homebrew-Cask Cached Downloads:", render_cached_downloads -        ohai "Homebrew-Cask Default Tap Path:", render_tap_paths(Hbc.default_tap.path) -        ohai "Homebrew-Cask Alternate Cask Taps:", render_tap_paths(alt_taps) -        ohai "Homebrew-Cask Default Tap Cask Count:", render_with_none_as_error(default_cask_count) -        ohai "Contents of $LOAD_PATH:", render_load_path($LOAD_PATH) -        ohai "Contents of $RUBYLIB Environment Variable:", render_env_var("RUBYLIB") -        ohai "Contents of $RUBYOPT Environment Variable:", render_env_var("RUBYOPT") -        ohai "Contents of $RUBYPATH Environment Variable:", render_env_var("RUBYPATH") -        ohai "Contents of $RBENV_VERSION Environment Variable:", render_env_var("RBENV_VERSION") -        ohai "Contents of $CHRUBY_VERSION Environment Variable:", render_env_var("CHRUBY_VERSION") -        ohai "Contents of $GEM_HOME Environment Variable:", render_env_var("GEM_HOME") -        ohai "Contents of $GEM_PATH Environment Variable:", render_env_var("GEM_PATH") -        ohai "Contents of $BUNDLE_PATH Environment Variable:", render_env_var("BUNDLE_PATH") -        ohai "Contents of $PATH Environment Variable:", render_env_var("PATH") -        ohai "Contents of $SHELL Environment Variable:", render_env_var("SHELL") -        ohai "Contents of Locale Environment Variables:", render_with_none(locale_variables) -      end - -      def self.alt_taps -        Tap.select { |t| t.cask_dir && t != Hbc.default_tap } -           .map(&:path) -      end - -      def self.default_cask_count -        Hbc.default_tap.cask_files.count -      rescue StandardError -        "0 #{error_string "Error reading #{Hbc.default_tap.path}"}" -      end - -      def self.homebrew_origin -        homebrew_origin = notfound_string -        begin -          Dir.chdir(HOMEBREW_REPOSITORY) do -            homebrew_origin = SystemCommand.run("/usr/bin/git", -                                                     args:         %w[config --get remote.origin.url], -                                                     print_stderr: false).stdout.strip -          end -          if homebrew_origin !~ /\S/ -            homebrew_origin = "#{none_string} #{error_string}" -          elsif homebrew_origin !~ %r{(mxcl|Homebrew)/(home)?brew(\.git)?\Z} -            homebrew_origin.concat " #{error_string "warning: nonstandard origin"}" -          end -        rescue StandardError -          homebrew_origin = error_string "Not Found - Error running git" -        end -        homebrew_origin -      end - -      def self.homebrew_cellar -        homebrew_constants("cellar") -      end - -      def self.homebrew_version -        homebrew_constants("version") -      end - -      def self.homebrew_taps -        Tap::TAP_DIRECTORY -      end - -      def self.homebrew_constants(name) -        @homebrew_constants ||= {} -        return @homebrew_constants[name] if @homebrew_constants.key?(name) -        @homebrew_constants[name] = notfound_string -        begin -          @homebrew_constants[name] = SystemCommand.run!(HOMEBREW_BREW_FILE, -                                                         args:         ["--#{name}"], -                                                         print_stderr: false) -                                                   .stdout -                                                   .strip -          if @homebrew_constants[name] !~ /\S/ -            @homebrew_constants[name] = "#{none_string} #{error_string}" -          end -          path = Pathname.new(@homebrew_constants[name]) -          @homebrew_constants[name] = path if path.exist? -        rescue StandardError -          @homebrew_constants[name] = error_string "Not Found - Error running brew" -        end -        @homebrew_constants[name] +        ohai "Homebrew-Cask Version", Hbc.full_version +        ohai "Homebrew-Cask Install Location", render_install_location +        ohai "Homebrew-Cask Staging Location", render_staging_location(Hbc.caskroom) +        ohai "Homebrew-Cask Cached Downloads", render_cached_downloads +        ohai "Homebrew-Cask Taps:" +        puts render_taps(Hbc.default_tap, *alt_taps) +        ohai "Contents of $LOAD_PATH", render_load_path($LOAD_PATH) +        ohai "Environment Variables" + +        environment_variables = [ +          "RUBYLIB", +          "RUBYOPT", +          "RUBYPATH", +          "RBENV_VERSION", +          "CHRUBY_VERSION", +          "GEM_HOME", +          "GEM_PATH", +          "BUNDLE_PATH", +          "PATH", +          "SHELL", +        ] + +        (locale_variables + environment_variables).sort.each(&method(:render_env_var))        end        def self.locale_variables -        ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).collect { |v| %Q(#{v}="#{ENV[v]}") }.sort.join("\n") +        ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).sort        end        def self.none_string          "<NONE>"        end -      def self.legacy_tap_pattern -        /phinze/ -      end - -      def self.notfound_string -        Formatter.error("Not Found - Unknown Error") -      end -        def self.error_string(string = "Error")          Formatter.error("(#{string})")        end @@ -121,37 +44,42 @@ module Hbc          none_string        end -      def self.render_with_none_as_error(string) -        return string if !string.nil? && string.respond_to?(:to_s) && !string.to_s.empty? -        "#{none_string} #{error_string}" +      def self.alt_taps +        Tap.select { |t| t.cask_dir && t != Hbc.default_tap }        end -      def self.render_tap_paths(paths) -        paths = [paths] unless paths.respond_to?(:each) -        paths.collect do |dir| -          if dir.nil? || dir.to_s.empty? +      def self.cask_count_for_tap(tap) +        count = tap.cask_files.count +        "#{count} #{count == 1 ? "cask" : "casks"}" +      rescue StandardError +        "0 #{error_string "error reading #{tap.path}"}" +      end + +      def self.render_taps(*taps) +        taps.collect do |tap| +          if tap.path.nil? || tap.path.to_s.empty?              none_string -          elsif dir.to_s.match(legacy_tap_pattern) -            dir.to_s.concat(" #{error_string "Warning: legacy tap path"}")            else -            dir.to_s +            "#{tap.path} (#{cask_count_for_tap(tap)})"            end          end        end        def self.render_env_var(var) -        if ENV.key?(var) -          %Q(#{var}="#{ENV[var]}") -        else -          none_string -        end +        return unless ENV.key?(var) +        var = %Q(#{var}="#{ENV[var]}") +        puts user_tilde(var) +      end + +      def self.user_tilde(path) +        path.gsub(ENV["HOME"], "~")        end        # This could be done by calling into Homebrew, but the situation        # where "doctor" is needed is precisely the situation where such        # things are less dependable.        def self.render_install_location -        locations = Dir.glob(Pathname.new(homebrew_cellar).join("brew-cask", "*")).reverse +        locations = Dir.glob(HOMEBREW_CELLAR.join("brew-cask", "*")).reverse          if locations.empty?            none_string          else @@ -162,7 +90,7 @@ module Hbc        end        def self.render_staging_location(path) -        path = Pathname.new(path) +        path = Pathname.new(user_tilde(path.to_s))          if !path.exist?            "#{path} #{error_string "error: path does not exist"}}"          elsif !path.writable? @@ -173,19 +101,18 @@ module Hbc        end        def self.render_load_path(paths) +        paths.map(&method(:user_tilde))          return "#{none_string} #{error_string}" if [*paths].empty?          paths        end        def self.render_cached_downloads          cleanup = CLI::Cleanup.default -        files = cleanup.cache_files -        count = files.count +        count = cleanup.cache_files.count          size = cleanup.disk_cleanup_size -        size_msg = "#{number_readable(count)} files, #{disk_usage_readable(size)}" -        warn_msg = error_string('warning: run "brew cask cleanup"') -        size_msg << " #{warn_msg}" if count > 0 -        [Hbc.cache, size_msg] +        msg = user_tilde(Hbc.cache.to_s) +        msg << " (#{number_readable(count)} files, #{disk_usage_readable(size)})" unless count.zero? +        msg        end        def self.help diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb new file mode 100644 index 000000000..790e917b2 --- /dev/null +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -0,0 +1,61 @@ +module Hbc +  class CLI +    class InternalAppcastCheckpoint < InternalUseBase +      def self.run(*args) +        calculate = args.include? "--calculate" +        cask_tokens = cask_tokens_from(args) +        raise CaskUnspecifiedError if cask_tokens.empty? + +        if cask_tokens.all? { |t| t =~ %r{^https?://} && t !~ /\.rb$/ } +          appcask_checkpoint_for_url(cask_tokens) +        else +          appcask_checkpoint(cask_tokens, calculate) +        end +      end + +      def self.appcask_checkpoint_for_url(urls) +        urls.each do |url| +          appcast = DSL::Appcast.new(url) +          puts appcast.calculate_checkpoint[:checkpoint] +        end +      end + +      def self.appcask_checkpoint(cask_tokens, calculate) +        count = 0 + +        cask_tokens.each do |cask_token| +          cask = Hbc.load(cask_token) + +          if cask.appcast.nil? +            opoo "Cask '#{cask}' is missing an `appcast` stanza." +          else +            if calculate +              result = cask.appcast.calculate_checkpoint + +              checkpoint = result[:checkpoint] +            else +              checkpoint = cask.appcast.checkpoint +            end + +            if checkpoint.nil? +              onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}" +            else +              puts cask_tokens.count > 1 ? "#{checkpoint}  #{cask}": checkpoint +              count += 1 +            end +          end +        end + +        count == cask_tokens.count +      end + +      def self.help +        "prints or calculates a given Cask's or URL's appcast checkpoint" +      end + +      def self.needs_init? +        true +      end +    end +  end +end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb index af1494e5f..ac1b20493 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb @@ -27,7 +27,7 @@ module Hbc        end        def self.help -        "Dump the given Cask in YAML format" +        "dump the given Cask in YAML format"        end      end    end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb index 6c646cfd7..0908ee05e 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb @@ -16,7 +16,7 @@ module Hbc        end        def self.help -        "Print help strings for unstable internal-use commands" +        "print help strings for unstable internal-use commands"        end      end    end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index e5c04ee51..c54db8795 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -44,18 +44,20 @@ module Hbc          :stage_only,          :nested_container,          :uninstall, -        :postflight, -        :uninstall_postflight,          :preflight, +        :postflight, +        :uninstall_preflight,          :uninstall_postflight,        ] -      def self.run(*arguments) -        table = arguments.include? "--table" -        quiet = arguments.include? "--quiet" -        format = :to_yaml if arguments.include? "--yaml" -        format = :inspect if arguments.include? "--inspect" -        cask_tokens = arguments.reject { |arg| arg.chars.first == "-" } +      def self.run(*args) +        raise ArgumentError, "No stanza given." if args.empty? + +        table = args.include? "--table" +        quiet = args.include? "--quiet" +        format = :to_yaml if args.include? "--yaml" +        format = :inspect if args.include? "--inspect" +        cask_tokens = cask_tokens_from(args)          stanza = cask_tokens.shift.to_sym          cask_tokens = Hbc.all_tokens if cask_tokens.empty? @@ -125,7 +127,7 @@ module Hbc        end        def self.help -        "Extract and render a specific stanza for the given Casks" +        "extract and render a specific stanza for the given Casks"        end      end    end diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb index 4094b3d38..e100fbd83 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/list.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb @@ -55,7 +55,7 @@ module Hbc        def self.list_artifacts(cask)          Artifact.for_cask(cask).each do |artifact| -          summary = artifact.new(cask).summary +          summary = artifact.summary            ohai summary[:english_description], summary[:contents] unless summary.empty?          end        end diff --git a/Library/Homebrew/cask/lib/hbc/container.rb b/Library/Homebrew/cask/lib/hbc/container.rb index e31fbc8fb..fc7246f3d 100644 --- a/Library/Homebrew/cask/lib/hbc/container.rb +++ b/Library/Homebrew/cask/lib/hbc/container.rb @@ -16,7 +16,6 @@ require "hbc/container/tar"  require "hbc/container/ttf"  require "hbc/container/rar"  require "hbc/container/xar" -require "hbc/container/xip"  require "hbc/container/xz"  require "hbc/container/zip" @@ -34,7 +33,6 @@ module Hbc          Sit,          Rar,          Zip, -        Xip,   # needs to be before xar as this is a cpio inside a gzip inside a xar          Xar,   # need to be before tar as tar can also list xar          Tar,   # or compressed tar (bzip2/gzip/lzma/xz)          Bzip2, # pure bzip2 diff --git a/Library/Homebrew/cask/lib/hbc/container/dmg.rb b/Library/Homebrew/cask/lib/hbc/container/dmg.rb index 987455ad7..815f8f010 100644 --- a/Library/Homebrew/cask/lib/hbc/container/dmg.rb +++ b/Library/Homebrew/cask/lib/hbc/container/dmg.rb @@ -43,11 +43,16 @@ module Hbc            next unless mountpath.exist?            begin -            tries ||= 2 -            @command.run("/usr/sbin/diskutil", -                         args:         ["eject", mountpath], -                         print_stderr: false) - +            tries ||= 3 +            if tries > 1 +              @command.run("/usr/sbin/diskutil", +                           args:         ["eject", mountpath], +                           print_stderr: false) +            else +              @command.run("/usr/sbin/diskutil", +                           args:         ["unmount", "force", mountpath], +                           print_stderr: false) +            end              raise CaskError, "Failed to eject #{mountpath}" if mountpath.exist?            rescue CaskError => e              raise e if (tries -= 1).zero? diff --git a/Library/Homebrew/cask/lib/hbc/container/xip.rb b/Library/Homebrew/cask/lib/hbc/container/xip.rb deleted file mode 100644 index 982402e4e..000000000 --- a/Library/Homebrew/cask/lib/hbc/container/xip.rb +++ /dev/null @@ -1,29 +0,0 @@ -require "tmpdir" - -module Hbc -  class Container -    class Xip < Base -      def self.me?(criteria) -        criteria.magic_number(/^xar!/n) && -          IO.popen(["/usr/bin/xar", "-t", "-f", criteria.path.to_s], err: "/dev/null") { |io| io.read =~ /\AContent\nMetadata\n\Z/ } -      end - -      def extract -        Dir.mktmpdir do |unpack_dir| -          begin -            ohai "Verifying signature for #{@path.basename}" -            @command.run!("/usr/sbin/pkgutil", args: ["--check-signature", @path]) -          rescue -            raise "Signature check failed." -          end - -          @command.run!("/usr/bin/xar", args: ["-x", "-f", @path, "Content", "-C", unpack_dir]) - -          Dir.chdir(@cask.staged_path) do -            @command.run!("/usr/bin/cpio", args: ["--quiet", "-i", "-I", Pathname(unpack_dir).join("Content")]) -          end -        end -      end -    end -  end -end diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb index c62873665..4707ae76a 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl.rb @@ -270,14 +270,17 @@ module Hbc      ORDINARY_ARTIFACT_TYPES.each do |type|        define_method(type) do |*args| -        if type == :stage_only && args != [true] -          raise CaskInvalidError.new(token, "'stage_only' takes a single argument: true") -        end -        artifacts[type] << args -        if artifacts.key?(:stage_only) && artifacts.keys.count > 1 && -           !(artifacts.keys & ACTIVATABLE_ARTIFACT_TYPES).empty? -          raise CaskInvalidError.new(token, "'stage_only' must be the only activatable artifact") +        if type == :stage_only +          if args != [true] +            raise CaskInvalidError.new(token, "'stage_only' takes a single argument: true") +          end + +          unless (artifacts.keys & ACTIVATABLE_ARTIFACT_TYPES).empty? +            raise CaskInvalidError.new(token, "'stage_only' must be the only activatable artifact") +          end          end + +        artifacts[type].add(args)        end      end diff --git a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb index 2f1245d3d..e27870622 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb @@ -1,3 +1,5 @@ +require "hbc/system_command" +  module Hbc    class DSL      class Appcast @@ -9,6 +11,20 @@ module Hbc          @checkpoint     = @parameters[:checkpoint]        end +      def calculate_checkpoint +        result = SystemCommand.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, @uri], print_stderr: false) + +        checkpoint = if result.success? +          processed_appcast_text = result.stdout.gsub(%r{<pubDate>[^<]*</pubDate>}m, "") +          Digest::SHA2.hexdigest(processed_appcast_text) +        end + +        { +          checkpoint: checkpoint, +          command_result: result, +        } +      end +        def to_yaml          [@uri, @parameters].to_yaml        end diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 3875e1c8f..cafc9d8b9 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -133,22 +133,23 @@ module Hbc      def install_artifacts        already_installed_artifacts = [] -      options = { command: @command, force: force }        odebug "Installing artifacts" -      artifacts = Artifact.for_cask(@cask) +      artifacts = Artifact.for_cask(@cask, command: @command, force: force)        odebug "#{artifacts.length} artifact/s defined", artifacts        artifacts.each do |artifact| -        odebug "Installing artifact of class #{artifact}" +        next unless artifact.respond_to?(:install_phase) +        odebug "Installing artifact of class #{artifact.class}" +        artifact.install_phase          already_installed_artifacts.unshift(artifact) -        artifact.new(@cask, options).install_phase        end      rescue StandardError => e        begin          already_installed_artifacts.each do |artifact| -          odebug "Reverting installation of artifact of class #{artifact}" -          artifact.new(@cask, options).uninstall_phase +          next unless artifact.respond_to?(:uninstall_phase) +          odebug "Reverting installation of artifact of class #{artifact.class}" +          artifact.uninstall_phase          end        ensure          purge_versioned_files @@ -316,12 +317,12 @@ module Hbc      def uninstall_artifacts        odebug "Un-installing artifacts" -      artifacts = Artifact.for_cask(@cask) +      artifacts = Artifact.for_cask(@cask, command: @command, force: force)        odebug "#{artifacts.length} artifact/s defined", artifacts        artifacts.each do |artifact| -        odebug "Un-installing artifact of class #{artifact}" -        options = { command: @command, force: force } -        artifact.new(@cask, options).uninstall_phase +        next unless artifact.respond_to?(:uninstall_phase) +        odebug "Un-installing artifact of class #{artifact.class}" +        artifact.uninstall_phase        end      end diff --git a/Library/Homebrew/cask/lib/hbc/pkg.rb b/Library/Homebrew/cask/lib/hbc/pkg.rb index 2fb634f24..39252b48a 100644 --- a/Library/Homebrew/cask/lib/hbc/pkg.rb +++ b/Library/Homebrew/cask/lib/hbc/pkg.rb @@ -26,6 +26,7 @@ module Hbc        _deepest_path_first(pkgutil_bom_dirs).each do |dir|          next unless dir.exist? && !MacOS.undeletable?(dir)          _with_full_permissions(dir) do +          _delete_broken_file_dir(dir) && next            _clean_broken_symlinks(dir)            _clean_ds_store(dir)            _rmdir(dir) @@ -97,6 +98,13 @@ module Hbc        end      end +    # Some pkgs incorrectly report files (generally nibs) +    # as directories; we remove these as files instead. +    def _delete_broken_file_dir(path) +      return unless path.file? && !path.symlink? +      @command.run!("/bin/rm", args: ["-f", "--", path], sudo: true) +    end +      # Some pkgs leave broken symlinks hanging around; we clean them out before      # attempting to rmdir to prevent extra cruft from lying around after      # uninstall diff --git a/Library/Homebrew/cask/lib/hbc/staged.rb b/Library/Homebrew/cask/lib/hbc/staged.rb index dcc05ef5d..c1aa01b29 100644 --- a/Library/Homebrew/cask/lib/hbc/staged.rb +++ b/Library/Homebrew/cask/lib/hbc/staged.rb @@ -27,7 +27,7 @@ module Hbc        full_paths = remove_nonexistent(paths)        return if full_paths.empty?        @command.run!("/bin/chmod", args: ["-R", "--", permissions_str] + full_paths, -                                  sudo: true) +                                  sudo: false)      end      def set_ownership(paths, user: current_user, group: "staff") diff --git a/Library/Homebrew/cask/spec/cask/accessibility_spec.rb b/Library/Homebrew/cask/spec/cask/accessibility_spec.rb new file mode 100644 index 000000000..8787a2c6d --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/accessibility_spec.rb @@ -0,0 +1,82 @@ +require "spec_helper" + +# TODO: this test should be named after the corresponding class, once +#       that class is abstracted from installer.rb. +describe "Accessibility Access" do +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-accessibility-access.rb") } +  let(:fake_system_command) { class_double(Hbc::SystemCommand) } +  let(:installer) { Hbc::Installer.new(cask, command: fake_system_command) } + +  before(:each) do +    allow(MacOS).to receive(:version).and_return(MacOS::Version.new(macos_version)) +    allow(installer).to receive(:bundle_identifier).and_return("com.example.BasicCask") +  end + +  context "on MacOS 10.8 and below" do +    let(:macos_version) { "10.8" } + +    it "can enable accessibility access in macOS releases prior to Mavericks" do +      expect(fake_system_command).to receive(:run!).with( +        "/usr/bin/touch", +        args: [Hbc.pre_mavericks_accessibility_dotfile], +        sudo: true +      ) + +      shutup do +        installer.enable_accessibility_access +      end +    end + +    it "warns about disabling accessibility access on old macOS releases" do +      expect { +        installer.disable_accessibility_access +      }.to output(/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./).to_stderr +    end +  end + +  context "on MacOS 10.9" do +    let(:macos_version) { "10.9" } + +    it "can enable accessibility access" do +      expect(fake_system_command).to receive(:run!).with( +        "/usr/bin/sqlite3", +        args: [Hbc.tcc_db, "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);"], +        sudo: true +      ) + +      shutup do +        installer.enable_accessibility_access +      end +    end + +    it "can disable accessibility access" do +      expect(fake_system_command).to receive(:run!).with( +        "/usr/bin/sqlite3", +        args: [Hbc.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"], +        sudo: true +      ) + +      shutup do +        installer.disable_accessibility_access +      end +    end +  end + +  context "on MacOS 10.12 and above" do +    let(:macos_version) { "10.12" } + +    it "warns about enabling accessibility access on new macOS releases" do +      expect { +        expect { +          installer.enable_accessibility_access +        }.to output.to_stdout +      }.to output(/Warning: Accessibility access cannot be enabled automatically on this version of macOS\./).to_stderr +    end + +    it "warns about disabling accessibility access on new macOS releases" do +      expect { +        installer.disable_accessibility_access +      }.to output(/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./).to_stderr +    end +  end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb b/Library/Homebrew/cask/spec/cask/artifact/alt_target_spec.rb index d1fe26eaa..9a57a9878 100644 --- a/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/alt_target_spec.rb @@ -1,8 +1,8 @@ -require "test_helper" +require "spec_helper"  describe Hbc::Artifact::App do    describe "activate to alternate target" do -    let(:cask) { Hbc.load("with-alt-target") } +    let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-alt-target.rb") }      let(:install_phase) {        -> { Hbc::Artifact::App.new(cask).install_phase } @@ -12,19 +12,19 @@ describe Hbc::Artifact::App do      let(:target_path) { Hbc.appdir.join("AnotherName.app") }      before do -      TestHelper.install_without_artifacts(cask) +      InstallHelper.install_without_artifacts(cask)      end      it "installs the given apps using the proper target directory" do -      source_path.must_be :directory? -      target_path.wont_be :exist? +      expect(source_path).to be_a_directory +      expect(target_path).not_to exist        shutup do          install_phase.call        end -      target_path.must_be :directory? -      source_path.wont_be :exist? +      expect(target_path).to be_a_directory +      expect(source_path).not_to exist      end      describe "when app is in a subdirectory" do @@ -46,8 +46,8 @@ describe Hbc::Artifact::App do            install_phase.call          end -        target_path.must_be :directory? -        appsubdir.join("Caffeine.app").wont_be :exist? +        expect(target_path).to be_a_directory +        expect(appsubdir.join("Caffeine.app")).not_to exist        end      end @@ -59,23 +59,21 @@ describe Hbc::Artifact::App do          install_phase.call        end -      target_path.must_be :directory? -      source_path.wont_be :exist? +      expect(target_path).to be_a_directory +      expect(source_path).not_to exist -      Hbc.appdir.join("Caffeine Deluxe.app").wont_be :exist? -      cask.staged_path.join("Caffeine Deluxe.app").must_be :directory? +      expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist +      expect(cask.staged_path.join("Caffeine Deluxe.app")).to be_a_directory      end      it "avoids clobbering an existing app by moving over it" do        target_path.mkpath -      err = install_phase.must_raise(Hbc::CaskError) +      expect(install_phase).to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.") -      err.message.must_equal("It seems there is already an App at '#{target_path}'.") - -      source_path.must_be :directory? -      target_path.must_be :directory? -      File.identical?(source_path, target_path).must_equal false +      expect(source_path).to be_a_directory +      expect(target_path).to be_a_directory +      expect(File.identical?(source_path, target_path)).to be false      end    end  end diff --git a/Library/Homebrew/cask/test/cask/artifact/app_test.rb b/Library/Homebrew/cask/spec/cask/artifact/app_spec.rb index 3eeeb729f..b3877f000 100644 --- a/Library/Homebrew/cask/test/cask/artifact/app_test.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/app_spec.rb @@ -1,7 +1,7 @@ -require "test_helper" +require "spec_helper"  describe Hbc::Artifact::App do -  let(:cask) { Hbc.load("local-caffeine") } +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") }    let(:command) { Hbc::SystemCommand }    let(:force) { false }    let(:app) { Hbc::Artifact::App.new(cask, command: command, force: force) } @@ -12,8 +12,8 @@ describe Hbc::Artifact::App do    let(:install_phase) { -> { app.install_phase } }    let(:uninstall_phase) { -> { app.uninstall_phase } } -  before do -    TestHelper.install_without_artifacts(cask) +  before(:each) do +    InstallHelper.install_without_artifacts(cask)    end    describe "install_phase" do @@ -22,8 +22,8 @@ describe Hbc::Artifact::App do          install_phase.call        end -      target_path.must_be :directory? -      source_path.wont_be :exist? +      expect(target_path).to be_a_directory +      expect(source_path).not_to exist      end      describe "when app is in a subdirectory" do @@ -45,8 +45,8 @@ describe Hbc::Artifact::App do            install_phase.call          end -        target_path.must_be :directory? -        appsubdir.join("Caffeine.app").wont_be :exist? +        expect(target_path).to be_a_directory +        expect(appsubdir.join("Caffeine.app")).not_to exist        end      end @@ -58,36 +58,34 @@ describe Hbc::Artifact::App do          install_phase.call        end -      target_path.must_be :directory? -      source_path.wont_be :exist? +      expect(target_path).to be_a_directory +      expect(source_path).not_to exist -      Hbc.appdir.join("Caffeine Deluxe.app").wont_be :exist? -      cask.staged_path.join("Caffeine Deluxe.app").must_be :exist? +      expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist +      expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist      end      describe "when the target already exists" do -      before do +      before(:each) do          target_path.mkpath        end        it "avoids clobbering an existing app" do -        err = install_phase.must_raise(Hbc::CaskError) +        expect(install_phase).to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.") -        err.message.must_equal("It seems there is already an App at '#{target_path}'.") - -        source_path.must_be :directory? -        target_path.must_be :directory? -        File.identical?(source_path, target_path).must_equal false +        expect(source_path).to be_a_directory +        expect(target_path).to be_a_directory +        expect(File.identical?(source_path, target_path)).to be false          contents_path = target_path.join("Contents/Info.plist") -        contents_path.wont_be :exist? +        expect(contents_path).not_to exist        end        describe "given the force option" do          let(:force) { true } -        before do -          Hbc::Utils.stubs(current_user: "fake_user") +        before(:each) do +          allow(Hbc::Utils).to receive(:current_user).and_return("fake_user")          end          describe "target is both writable and user-owned" do @@ -101,40 +99,31 @@ describe Hbc::Artifact::App do                Warning: It seems there is already an App at '#{target_path}'; overwriting.              EOS -            install_phase.must_output(stdout, stderr) +            expect { +              expect(install_phase).to output(stdout).to_stdout +            }.to output(stderr).to_stderr -            source_path.wont_be :exist? -            target_path.must_be :directory? +            expect(source_path).not_to exist +            expect(target_path).to be_a_directory              contents_path = target_path.join("Contents/Info.plist") -            contents_path.must_be :exist? +            expect(contents_path).to exist            end          end          describe "target is user-owned but contains read-only files" do -          let(:command) { Hbc::FakeSystemCommand } - -          let(:chmod_cmd) { -            ["/bin/chmod", "-R", "--", "u+rwx", target_path] -          } - -          let(:chmod_n_cmd) { -            ["/bin/chmod", "-R", "-N", target_path] -          } - -          let(:chflags_cmd) { -            ["/usr/bin/chflags", "-R", "--", "000", target_path] -          } - -          before do +          before(:each) do              system "/usr/bin/touch", "--", "#{target_path}/foo"              system "/bin/chmod", "--", "0555", target_path            end            it "overwrites the existing app" do -            command.expect_and_pass_through(chflags_cmd) -            command.expect_and_pass_through(chmod_cmd) -            command.expect_and_pass_through(chmod_n_cmd) +            expect(command).to receive(:run).with("/bin/chmod", args: ["-R", "--", "u+rwx", target_path], must_succeed: false) +              .and_call_original +            expect(command).to receive(:run).with("/bin/chmod", args: ["-R", "-N", target_path], must_succeed: false) +              .and_call_original +            expect(command).to receive(:run).with("/usr/bin/chflags", args: ["-R", "--", "000", target_path], must_succeed: false) +              .and_call_original              stdout = <<-EOS.undent                ==> Removing App: '#{target_path}' @@ -145,16 +134,18 @@ describe Hbc::Artifact::App do                Warning: It seems there is already an App at '#{target_path}'; overwriting.              EOS -            install_phase.must_output(stdout, stderr) +            expect { +              expect(install_phase).to output(stdout).to_stdout +            }.to output(stderr).to_stderr -            source_path.wont_be :exist? -            target_path.must_be :directory? +            expect(source_path).not_to exist +            expect(target_path).to be_a_directory              contents_path = target_path.join("Contents/Info.plist") -            contents_path.must_be :exist? +            expect(contents_path).to exist            end -          after do +          after(:each) do              system "/bin/chmod", "--", "0755", target_path            end          end @@ -164,18 +155,15 @@ describe Hbc::Artifact::App do      describe "when the target is a broken symlink" do        let(:deleted_path) { cask.staged_path.join("Deleted.app") } -      before do +      before(:each) do          deleted_path.mkdir          File.symlink(deleted_path, target_path)          deleted_path.rmdir        end        it "leaves the target alone" do -        err = install_phase.must_raise(Hbc::CaskError) - -        err.message.must_equal("It seems there is already an App at '#{target_path}'.") - -        File.symlink?(target_path).must_equal true +        expect(install_phase).to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.") +        expect(target_path).to be_a_symlink        end        describe "given the force option" do @@ -191,13 +179,15 @@ describe Hbc::Artifact::App do              Warning: It seems there is already an App at '#{target_path}'; overwriting.            EOS -          install_phase.must_output(stdout, stderr) +          expect { +            expect(install_phase).to output(stdout).to_stdout +          }.to output(stderr).to_stderr -          source_path.wont_be :exist? -          target_path.must_be :directory? +          expect(source_path).not_to exist +          expect(target_path).to be_a_directory            contents_path = target_path.join("Contents/Info.plist") -          contents_path.must_be :exist? +          expect(contents_path).to exist          end        end      end @@ -207,26 +197,23 @@ describe Hbc::Artifact::App do        message = "It seems the App source is not there: '#{source_path}'" -      error = install_phase.must_raise(Hbc::CaskError) -      error.message.must_equal message +      expect(install_phase).to raise_error(Hbc::CaskError, message)      end    end    describe "uninstall_phase" do -    before do +    it "deletes managed apps" do        shutup do          install_phase.call        end -    end -    it "deletes managed apps" do -      target_path.must_be :exist? +      expect(target_path).to exist        shutup do          uninstall_phase.call        end -      target_path.wont_be :exist? +      expect(target_path).not_to exist      end    end @@ -235,25 +222,23 @@ describe Hbc::Artifact::App do      let(:contents) { app.summary[:contents] }      it "returns the correct english_description" do -      description.must_equal "Apps" +      expect(description).to eq("Apps")      end      describe "app is correctly installed" do -      before do +      it "returns the path to the app" do          shutup do            install_phase.call          end -      end -      it "returns the path to the app" do -        contents.must_equal ["#{target_path} (#{target_path.abv})"] +        expect(contents).to eq(["#{target_path} (#{target_path.abv})"])        end      end      describe "app is missing" do        it "returns a warning and the supposed path to the app" do -        contents.size.must_equal 1 -        contents[0].must_match(/.*Missing App.*: #{target_path}/) +        expect(contents.size).to eq(1) +        expect(contents[0]).to match(/.*Missing App.*: #{target_path}/)        end      end    end diff --git a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb index fbb117f67..c27dcc8f0 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb @@ -1,6 +1,6 @@  describe Hbc::Artifact::Binary do    let(:cask) { -    Hbc.load("with-binary").tap do |cask| +    Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb").tap do |cask|        shutup do          InstallHelper.install_without_artifacts(cask)        end @@ -20,7 +20,8 @@ describe Hbc::Artifact::Binary do      shutup do        Hbc::Artifact::Binary.new(cask).install_phase      end -    expect(FileHelper.valid_alias?(expected_path)).to be true +    expect(expected_path).to be_a_symlink +    expect(expected_path.readlink).to exist    end    it "avoids clobbering an existing binary by linking over it" do @@ -69,7 +70,7 @@ describe Hbc::Artifact::Binary do    context "binary is inside an app package" do      let(:cask) { -      Hbc.load("with-embedded-binary").tap do |cask| +      Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-embedded-binary.rb").tap do |cask|          shutup do            InstallHelper.install_without_artifacts(cask)          end @@ -82,7 +83,8 @@ describe Hbc::Artifact::Binary do          Hbc::Artifact::Binary.new(cask).install_phase        end -      expect(FileHelper.valid_alias?(expected_path)).to be true +      expect(expected_path).to be_a_symlink +      expect(expected_path.readlink).to exist      end    end  end diff --git a/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb new file mode 100644 index 000000000..7d9128c0e --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb @@ -0,0 +1,47 @@ +require "spec_helper" + +describe Hbc::Artifact::Artifact do +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") } + +  let(:install_phase) { +    -> { Hbc::Artifact::Artifact.new(cask).install_phase } +  } + +  let(:source_path) { cask.staged_path.join("Caffeine.app") } +  let(:target_path) { Hbc.appdir.join("Caffeine.app") } + +  before do +    InstallHelper.install_without_artifacts(cask) +  end + +  describe "with no target" do +    let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact-no-target.rb") } + +    it "fails to install with no target" do +      expect(install_phase).to raise_error(Hbc::CaskInvalidError) +    end +  end + +  it "moves the artifact to the proper directory" do +    shutup do +      install_phase.call +    end + +    expect(target_path).to be_a_directory +    expect(source_path).not_to exist +  end + +  it "avoids clobbering an existing artifact" do +    target_path.mkpath + +    expect { +      shutup do +        install_phase.call +      end +    }.to raise_error(Hbc::CaskError) + +    expect(source_path).to be_a_directory +    expect(target_path).to be_a_directory +    expect(File.identical?(source_path, target_path)).to be false +  end +end diff --git a/Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb new file mode 100644 index 000000000..31a1cb5eb --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb @@ -0,0 +1,17 @@ +require "spec_helper" + +describe Hbc::Artifact::NestedContainer do +  describe "install" do +    it "extracts the specified paths as containers" do +      cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb").tap do |c| +        InstallHelper.install_without_artifacts(c) +      end + +      shutup do +        Hbc::Artifact::NestedContainer.new(cask).install_phase +      end + +      expect(cask.staged_path.join("MyNestedApp.app")).to be_a_directory +    end +  end +end diff --git a/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb new file mode 100644 index 000000000..d4d69ea66 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb @@ -0,0 +1,71 @@ +require "spec_helper" + +describe Hbc::Artifact::Pkg do +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } +  let(:fake_system_command) { class_double(Hbc::SystemCommand) } + +  before(:each) do +    shutup do +      InstallHelper.install_without_artifacts(cask) +    end +  end + +  describe "install_phase" do +    it "runs the system installer on the specified pkgs" do +      pkg = Hbc::Artifact::Pkg.new(cask, command: fake_system_command) + +      expect(fake_system_command).to receive(:run!).with( +        "/usr/sbin/installer", +        args: ["-pkg", cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/"], +        sudo: true, +        print_stdout: true +      ) + +      shutup do +        pkg.install_phase +      end +    end +  end + +  describe "choices" do +    let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb") } + +    it "passes the choice changes xml to the system installer" do +      pkg = Hbc::Artifact::Pkg.new(cask, command: fake_system_command) + +      file = double(path: Pathname.new("/tmp/choices.xml")) + +      expect(file).to receive(:write).with(<<-EOS.undent) +        <?xml version="1.0" encoding="UTF-8"?> +        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +        <plist version="1.0"> +        <array> +        \t<dict> +        \t\t<key>attributeSetting</key> +        \t\t<integer>1</integer> +        \t\t<key>choiceAttribute</key> +        \t\t<string>selected</string> +        \t\t<key>choiceIdentifier</key> +        \t\t<string>choice1</string> +        \t</dict> +        </array> +        </plist> +      EOS + +      expect(file).to receive(:close) +      expect(file).to receive(:unlink) +      expect(Tempfile).to receive(:open).and_yield(file) + +      expect(fake_system_command).to receive(:run!).with( +        "/usr/sbin/installer", +        args: ["-pkg", cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/", "-applyChoiceChangesXML", cask.staged_path.join("/tmp/choices.xml")], +        sudo: true, +        print_stdout: true +      ) + +      shutup do +        pkg.install_phase +      end +    end +  end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/postflight_block_test.rb b/Library/Homebrew/cask/spec/cask/artifact/postflight_block_spec.rb index 47dcdd905..6f58afb2a 100644 --- a/Library/Homebrew/cask/test/cask/artifact/postflight_block_test.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/postflight_block_spec.rb @@ -1,9 +1,9 @@ -require "test_helper" +require "spec_helper"  describe Hbc::Artifact::PostflightBlock do    describe "install_phase" do      it "calls the specified block after installing, passing a Cask mini-dsl" do -      called      = false +      called = false        yielded_arg = nil        cask = Hbc::Cask.new("with-postflight") do @@ -13,16 +13,16 @@ describe Hbc::Artifact::PostflightBlock do          end        end -      Hbc::Artifact::PostflightBlock.new(cask).install_phase +      described_class.new(cask).install_phase -      called.must_equal true -      yielded_arg.must_be_kind_of Hbc::DSL::Postflight +      expect(called).to be true +      expect(yielded_arg).to be_kind_of(Hbc::DSL::Postflight)      end    end    describe "uninstall_phase" do      it "calls the specified block after uninstalling, passing a Cask mini-dsl" do -      called      = false +      called = false        yielded_arg = nil        cask = Hbc::Cask.new("with-uninstall-postflight") do @@ -32,10 +32,10 @@ describe Hbc::Artifact::PostflightBlock do          end        end -      Hbc::Artifact::PostflightBlock.new(cask).uninstall_phase +      described_class.new(cask).uninstall_phase -      called.must_equal true -      yielded_arg.must_be_kind_of Hbc::DSL::UninstallPostflight +      expect(called).to be true +      expect(yielded_arg).to be_kind_of(Hbc::DSL::UninstallPostflight)      end    end  end diff --git a/Library/Homebrew/cask/test/cask/artifact/preflight_block_test.rb b/Library/Homebrew/cask/spec/cask/artifact/preflight_block_spec.rb index 440b1db3a..ac5313bca 100644 --- a/Library/Homebrew/cask/test/cask/artifact/preflight_block_test.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/preflight_block_spec.rb @@ -1,9 +1,9 @@ -require "test_helper" +require "spec_helper"  describe Hbc::Artifact::PreflightBlock do    describe "install_phase" do      it "calls the specified block before installing, passing a Cask mini-dsl" do -      called      = false +      called = false        yielded_arg = nil        cask = Hbc::Cask.new("with-preflight") do @@ -13,16 +13,16 @@ describe Hbc::Artifact::PreflightBlock do          end        end -      Hbc::Artifact::PreflightBlock.new(cask).install_phase +      described_class.new(cask).install_phase -      called.must_equal true -      yielded_arg.must_be_kind_of Hbc::DSL::Preflight +      expect(called).to be true +      expect(yielded_arg).to be_kind_of Hbc::DSL::Preflight      end    end    describe "uninstall_phase" do      it "calls the specified block before uninstalling, passing a Cask mini-dsl" do -      called      = false +      called = false        yielded_arg = nil        cask = Hbc::Cask.new("with-uninstall-preflight") do @@ -32,10 +32,10 @@ describe Hbc::Artifact::PreflightBlock do          end        end -      Hbc::Artifact::PreflightBlock.new(cask).uninstall_phase +      described_class.new(cask).uninstall_phase -      called.must_equal true -      yielded_arg.must_be_kind_of Hbc::DSL::UninstallPreflight +      expect(called).to be true +      expect(yielded_arg).to be_kind_of Hbc::DSL::UninstallPreflight      end    end  end diff --git a/Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb new file mode 100644 index 000000000..79ca0546c --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb @@ -0,0 +1,49 @@ +require "spec_helper" + +describe Hbc::Artifact::Suite do +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-suite.rb") } + +  let(:install_phase) { -> { Hbc::Artifact::Suite.new(cask).install_phase } } + +  let(:target_path) { Hbc.appdir.join("Caffeine") } +  let(:source_path) { cask.staged_path.join("Caffeine") } + +  before(:each) 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 +    end + +    expect(target_path.join("Caffeine.app")).to exist +  end + +  it "avoids clobbering an existing suite by moving over it" do +    target_path.mkpath + +    expect { +      shutup do +        install_phase.call +      end +    }.to raise_error(Hbc::CaskError) + +    expect(source_path).to be_a_directory +    expect(target_path).to be_a_directory +    expect(File.identical?(source_path, target_path)).to be false +  end +end diff --git a/Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb new file mode 100644 index 000000000..7fa44dbce --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb @@ -0,0 +1,93 @@ +require "spec_helper" + +describe Hbc::Artifact::App do +  describe "multiple apps" do +    let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-correct.rb") } + +    let(:install_phase) { +      -> { Hbc::Artifact::App.new(cask).install_phase } +    } + +    let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") } +    let(:target_path_mini) { Hbc.appdir.join("Caffeine Mini.app") } + +    let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") } +    let(:target_path_pro) { Hbc.appdir.join("Caffeine Pro.app") } + +    before(:each) do +      InstallHelper.install_without_artifacts(cask) +    end + +    it "installs both apps using the proper target directory" do +      shutup do +        install_phase.call +      end + +      expect(target_path_mini).to be_a_directory +      expect(source_path_mini).not_to exist + +      expect(target_path_pro).to be_a_directory +      expect(source_path_pro).not_to exist +    end + +    describe "when apps are in a subdirectory" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-subdir.rb") } + +      it "installs both apps using the proper target directory" do +        shutup do +          install_phase.call +        end + +        expect(target_path_mini).to be_a_directory +        expect(source_path_mini).not_to exist + +        expect(target_path_pro).to be_a_directory +        expect(source_path_pro).not_to exist +      end +    end + +    it "only uses apps when they are specified" do +      FileUtils.cp_r source_path_mini, source_path_mini.sub("Caffeine Mini.app", "Caffeine Deluxe.app") + +      shutup do +        install_phase.call +      end + +      expect(target_path_mini).to be_a_directory +      expect(source_path_mini).not_to exist + +      expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist +      expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist +    end + +    describe "avoids clobbering an existing app" do +      it "when the first app of two already exists" do +        target_path_mini.mkpath + +        expect { +          expect(install_phase).to output(<<-EOS.undent).to_stdout +            ==> Moving App 'Caffeine Pro.app' to '#{target_path_pro}' +          EOS +        }.to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path_mini}'.") + +        expect(source_path_mini).to be_a_directory +        expect(target_path_mini).to be_a_directory +        expect(File.identical?(source_path_mini, target_path_mini)).to be false +      end + +      it "when the second app of two already exists" do +        target_path_pro.mkpath + +        expect { +          expect(install_phase).to output(<<-EOS.undent).to_stdout +            ==> Moving App 'Caffeine Mini.app' to '#{target_path_mini}' +          EOS +        }.to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path_pro}'.") + +        expect(source_path_pro).to be_a_directory +        expect(target_path_pro).to be_a_directory +        expect(File.identical?(source_path_pro, target_path_pro)).to be false +      end +    end +  end +end diff --git a/Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb new file mode 100644 index 000000000..0aa38d910 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb @@ -0,0 +1,11 @@ +require "spec_helper" + +describe Hbc::Artifact::App do +  # FIXME: Doesn't actually raise because the `app` stanza is not evaluated on load. +  # it "must raise" do +  #   lambda { +  #     Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-incorrect.rb") +  #   }.must_raise +  #   # TODO: later give the user a nice exception for this case and check for it here +  # end +end diff --git a/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb new file mode 100644 index 000000000..3150b50be --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb @@ -0,0 +1,21 @@ +require "spec_helper" + +describe Hbc::Artifact::Zap do +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } + +  let(:zap_artifact) { +    Hbc::Artifact::Zap.new(cask) +  } + +  before do +    shutup do +      InstallHelper.install_without_artifacts(cask) +    end +  end + +  describe "#uninstall_phase" do +    subject { zap_artifact } + +    it { is_expected.not_to respond_to(:uninstall_phase) } +  end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb index b09d39833..008e2ad2a 100644 --- a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb @@ -1,43 +1,27 @@ -require "test_helper" +require "spec_helper"  describe Hbc::Artifact::Uninstall do -  let(:cask) { Hbc.load("with-installable") } +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") }    let(:uninstall_artifact) {      Hbc::Artifact::Uninstall.new(cask, command: Hbc::FakeSystemCommand)    } -  before do +  before(:each) do      shutup do -      TestHelper.install_without_artifacts(cask) -    end -  end - -  describe "install_phase" do -    it "does nothing, because the install_phase method is a no-op" do -      shutup do -        uninstall_artifact.install_phase -      end -    end -  end - -  describe "zap_phase" do -    it "does nothing, because the zap_phase method is a no-op" do -      shutup do -        uninstall_artifact.zap_phase -      end +      InstallHelper.install_without_artifacts(cask)      end    end    describe "uninstall_phase" do -    subject do +    subject {        shutup do          uninstall_artifact.uninstall_phase        end -    end +    } -    describe "when using launchctl" do -      let(:cask) { Hbc.load("with-uninstall-launchctl") } +    context "when using launchctl" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-launchctl.rb") }        let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] }        let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] }        let(:unknown_response) { "launchctl list returned unknown response\n" } @@ -56,7 +40,7 @@ describe Hbc::Artifact::Uninstall do          EOS        } -      describe "when launchctl job is owned by user" do +      context "when launchctl job is owned by user" do          it "can uninstall" do            Hbc::FakeSystemCommand.stubs_command(              launchctl_list_cmd, @@ -74,7 +58,7 @@ describe Hbc::Artifact::Uninstall do          end        end -      describe "when launchctl job is owned by system" do +      context "when launchctl job is owned by system" do          it "can uninstall" do            Hbc::FakeSystemCommand.stubs_command(              launchctl_list_cmd, @@ -93,8 +77,8 @@ describe Hbc::Artifact::Uninstall do        end      end -    describe "when using pkgutil" do -      let(:cask) { Hbc.load("with-uninstall-pkgutil") } +    context "when using pkgutil" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-pkgutil.rb") }        let(:main_pkg_id) { "my.fancy.package.main" }        let(:agent_pkg_id) { "my.fancy.package.agent" }        let(:main_files) { @@ -179,8 +163,8 @@ describe Hbc::Artifact::Uninstall do        end      end -    describe "when using kext" do -      let(:cask) { Hbc.load("with-uninstall-kext") } +    context "when using kext" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-kext.rb") }        let(:kext_id) { "my.fancy.package.kernelextension" }        it "can uninstall" do @@ -204,8 +188,8 @@ describe Hbc::Artifact::Uninstall do        end      end -    describe "when using quit" do -      let(:cask) { Hbc.load("with-uninstall-quit") } +    context "when using quit" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-quit.rb") }        let(:bundle_id) { "my.fancy.package.app" }        let(:quit_application_script) {          %Q(tell application id "#{bundle_id}" to quit) @@ -224,8 +208,8 @@ describe Hbc::Artifact::Uninstall do        end      end -    describe "when using signal" do -      let(:cask) { Hbc.load("with-uninstall-signal") } +    context "when using signal" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-signal.rb") }        let(:bundle_id) { "my.fancy.package.app" }        let(:signals) { %w[TERM KILL] }        let(:unix_pids) { [12_345, 67_890] } @@ -236,15 +220,15 @@ describe Hbc::Artifact::Uninstall do          )          signals.each do |signal| -          Process.expects(:kill).with(signal, *unix_pids) +          expect(Process).to receive(:kill).with(signal, *unix_pids)          end          subject        end      end -    describe "when using delete" do -      let(:cask) { Hbc.load("with-uninstall-delete") } +    context "when using delete" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-delete.rb") }        it "can uninstall" do          Hbc::FakeSystemCommand.expects_command( @@ -257,8 +241,8 @@ describe Hbc::Artifact::Uninstall do        end      end -    describe "when using trash" do -      let(:cask) { Hbc.load("with-uninstall-trash") } +    context "when using trash" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-trash.rb") }        it "can uninstall" do          Hbc::FakeSystemCommand.expects_command( @@ -271,8 +255,8 @@ describe Hbc::Artifact::Uninstall do        end      end -    describe "when using rmdir" do -      let(:cask) { Hbc.load("with-uninstall-rmdir") } +    context "when using rmdir" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-rmdir.rb") }        let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") }        it "can uninstall" do @@ -288,8 +272,8 @@ describe Hbc::Artifact::Uninstall do        end      end -    describe "when using script" do -      let(:cask) { Hbc.load("with-uninstall-script") } +    context "when using script" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script.rb") }        let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }        it "can uninstall" do @@ -303,8 +287,8 @@ describe Hbc::Artifact::Uninstall do        end      end -    describe "when using early_script" do -      let(:cask) { Hbc.load("with-uninstall-early-script") } +    context "when using early_script" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-early-script.rb") }        let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }        it "can uninstall" do @@ -318,8 +302,8 @@ describe Hbc::Artifact::Uninstall do        end      end -    describe "when using login_item" do -      let(:cask) { Hbc.load("with-uninstall-login-item") } +    context "when using login_item" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-login-item.rb") }        it "can uninstall" do          Hbc::FakeSystemCommand.expects_command( diff --git a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb index b65b0bf5c..bd14cd6de 100644 --- a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb @@ -1,44 +1,28 @@ -require "test_helper" +require "spec_helper"  # TODO: test that zap removes an alternate version of the same Cask  describe Hbc::Artifact::Zap do -  let(:cask) { Hbc.load("with-installable") } +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") }    let(:zap_artifact) {      Hbc::Artifact::Zap.new(cask, command: Hbc::FakeSystemCommand)    } -  before do +  before(:each) do      shutup do -      TestHelper.install_without_artifacts(cask) +      InstallHelper.install_without_artifacts(cask)      end    end -  describe "install_phase" do -    it "does nothing, because the install_phase method is a no-op" do -      shutup do -        zap_artifact.install_phase -      end -    end -  end - -  describe "uninstall_phase" do -    it "does nothing, because the uninstall_phase method is a no-op" do -      shutup do -        zap_artifact.uninstall_phase -      end -    end -  end - -  describe "zap_phase" do -    subject do +  describe "#zap_phase" do +    subject {        shutup do          zap_artifact.zap_phase        end -    end +    } -    describe "when using launchctl" do -      let(:cask) { Hbc.load("with-zap-launchctl") } +    context "when using launchctl" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-launchctl.rb") }        let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] }        let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] }        let(:unknown_response) { "launchctl list returned unknown response\n" } @@ -57,7 +41,7 @@ describe Hbc::Artifact::Zap do          EOS        } -      describe "when launchctl job is owned by user" do +      context "when launchctl job is owned by user" do          it "can zap" do            Hbc::FakeSystemCommand.stubs_command(              launchctl_list_cmd, @@ -94,8 +78,8 @@ describe Hbc::Artifact::Zap do        end      end -    describe "when using pkgutil" do -      let(:cask) { Hbc.load("with-zap-pkgutil") } +    context "when using pkgutil" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-pkgutil.rb") }        let(:main_pkg_id) { "my.fancy.package.main" }        let(:agent_pkg_id) { "my.fancy.package.agent" }        let(:main_files) { @@ -180,8 +164,8 @@ describe Hbc::Artifact::Zap do        end      end -    describe "when using kext" do -      let(:cask) { Hbc.load("with-zap-kext") } +    context "when using kext" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-kext.rb") }        let(:kext_id) { "my.fancy.package.kernelextension" }        it "can zap" do @@ -205,8 +189,8 @@ describe Hbc::Artifact::Zap do        end      end -    describe "when using quit" do -      let(:cask) { Hbc.load("with-zap-quit") } +    context "when using quit" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-quit.rb") }        let(:bundle_id) { "my.fancy.package.app" }        let(:quit_application_script) {          %Q(tell application id "#{bundle_id}" to quit) @@ -225,8 +209,8 @@ describe Hbc::Artifact::Zap do        end      end -    describe "when using signal" do -      let(:cask) { Hbc.load("with-zap-signal") } +    context "when using signal" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-signal.rb") }        let(:bundle_id) { "my.fancy.package.app" }        let(:signals) { %w[TERM KILL] }        let(:unix_pids) { [12_345, 67_890] } @@ -237,15 +221,15 @@ describe Hbc::Artifact::Zap do          )          signals.each do |signal| -          Process.expects(:kill).with(signal, *unix_pids) +          expect(Process).to receive(:kill).with(signal, *unix_pids)          end          subject        end      end -    describe "when using delete" do -      let(:cask) { Hbc.load("with-zap-delete") } +    context "when using delete" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-delete.rb") }        it "can zap" do          Hbc::FakeSystemCommand.expects_command( @@ -258,8 +242,8 @@ describe Hbc::Artifact::Zap do        end      end -    describe "when using trash" do -      let(:cask) { Hbc.load("with-zap-trash") } +    context "when using trash" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-trash.rb") }        it "can zap" do          Hbc::FakeSystemCommand.expects_command( @@ -272,8 +256,8 @@ describe Hbc::Artifact::Zap do        end      end -    describe "when using rmdir" do -      let(:cask) { Hbc.load("with-zap-rmdir") } +    context "when using rmdir" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-rmdir.rb") }        let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") }        it "can zap" do @@ -289,8 +273,8 @@ describe Hbc::Artifact::Zap do        end      end -    describe "when using script" do -      let(:cask) { Hbc.load("with-zap-script") } +    context "when using script" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-script.rb") }        let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }        it "can zap" do @@ -304,8 +288,8 @@ describe Hbc::Artifact::Zap do        end      end -    describe "when using early_script" do -      let(:cask) { Hbc.load("with-zap-early-script") } +    context "when using early_script" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-early-script.rb") }        let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }        it "can zap" do @@ -319,8 +303,8 @@ describe Hbc::Artifact::Zap do        end      end -    describe "when using login_item" do -      let(:cask) { Hbc.load("with-zap-login-item") } +    context "when using login_item" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-login-item.rb") }        it "can zap" do          Hbc::FakeSystemCommand.expects_command( diff --git a/Library/Homebrew/cask/spec/cask/audit_spec.rb b/Library/Homebrew/cask/spec/cask/audit_spec.rb index c12063a1d..9eb9f0136 100644 --- a/Library/Homebrew/cask/spec/cask/audit_spec.rb +++ b/Library/Homebrew/cask/spec/cask/audit_spec.rb @@ -1,6 +1,5 @@  describe Hbc::Audit do    include AuditMatchers -  include Sha256Helper    let(:cask) { instance_double(Hbc::Cask) }    let(:download) { false } @@ -162,7 +161,7 @@ describe Hbc::Audit do          before do            allow(audit).to receive(:check_appcast_http_code) -          allow(fake_system_command).to receive(:run).and_return(fake_curl_result) +          allow(Hbc::SystemCommand).to receive(:run).and_return(fake_curl_result)            allow(fake_curl_result).to receive(:success?).and_return(success)          end @@ -178,7 +177,7 @@ describe Hbc::Audit do            end            context "when appcast checkpoint is out of date" do -            let(:actual_checkpoint) { random_sha256 } +            let(:actual_checkpoint) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" }              it { is_expected.to warn_with(mismatch_msg) }              it { should_not warn_with(curl_error_msg) }            end diff --git a/Library/Homebrew/cask/spec/cask/cask_spec.rb b/Library/Homebrew/cask/spec/cask/cask_spec.rb index d470c6ec3..32f3d8258 100644 --- a/Library/Homebrew/cask/spec/cask/cask_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cask_spec.rb @@ -20,4 +20,73 @@ describe Hbc::Cask do        end      end    end + +  describe "load" do +    let(:hbc_relative_tap_path) { "../../Taps/caskroom/homebrew-cask" } + +    it "returns an instance of the Cask for the given token" do +      c = Hbc.load("adium") +      expect(c).to be_kind_of(Hbc::Cask) +      expect(c.token).to eq("adium") +    end + +    it "returns an instance of the Cask from a specific file location" do +      location = File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb") +      c = Hbc.load(location) +      expect(c).to be_kind_of(Hbc::Cask) +      expect(c.token).to eq("dia") +    end + +    it "returns an instance of the Cask from a url" do +      url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb") +      c = shutup do +        Hbc.load(url) +      end +      expect(c).to be_kind_of(Hbc::Cask) +      expect(c.token).to eq("dia") +    end + +    it "raises an error when failing to download a Cask from a url" do +      expect { +        url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb") +        shutup do +          Hbc.load(url) +        end +      }.to raise_error(Hbc::CaskUnavailableError) +    end + +    it "returns an instance of the Cask from a relative file location" do +      c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb") +      expect(c).to be_kind_of(Hbc::Cask) +      expect(c.token).to eq("bbedit") +    end + +    it "uses exact match when loading by token" do +      expect(Hbc.load("test-opera").token).to eq("test-opera") +      expect(Hbc.load("test-opera-mail").token).to eq("test-opera-mail") +    end + +    it "raises an error when attempting to load a Cask that doesn't exist" do +      expect { +        Hbc.load("notacask") +      }.to raise_error(Hbc::CaskUnavailableError) +    end +  end + +  describe "all_tokens" do +    it "returns a token for every Cask" do +      all_cask_tokens = Hbc.all_tokens +      expect(all_cask_tokens.count).to be > 20 +      all_cask_tokens.each { |token| expect(token).to be_kind_of(String) } +    end +  end + +  describe "metadata" do +    it "proposes a versioned metadata directory name for each instance" do +      cask_token = "adium" +      c = Hbc.load(cask_token) +      metadata_path = Hbc.caskroom.join(cask_token, ".metadata", c.version) +      expect(c.metadata_versioned_container_path.to_s).to eq(metadata_path.to_s) +    end +  end  end diff --git a/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb b/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb new file mode 100644 index 000000000..b520a88df --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb @@ -0,0 +1,61 @@ +require "spec_helper" + +describe Hbc::CLI::Audit do +  let(:auditor) { double } +  let(:cask) { double } + +  describe "selection of Casks to audit" do +    it "audits all Casks if no tokens are given" do +      allow(Hbc).to receive(:all).and_return([cask, cask]) + +      expect(auditor).to receive(:audit).twice + +      run_audit([], auditor) +    end + +    it "audits specified Casks if tokens are given" do +      cask_token = "nice-app" +      expect(Hbc).to receive(:load).with(cask_token).and_return(cask) + +      expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false) + +      run_audit([cask_token], auditor) +    end +  end + +  describe "rules for downloading a Cask" do +    it "does not download the Cask per default" do +      allow(Hbc).to receive(:load).and_return(cask) +      expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false) + +      run_audit(["casktoken"], auditor) +    end + +    it "download a Cask if --download flag is set" do +      allow(Hbc).to receive(:load).and_return(cask) +      expect(auditor).to receive(:audit).with(cask, audit_download: true, check_token_conflicts: false) + +      run_audit(["casktoken", "--download"], auditor) +    end +  end + +  describe "rules for checking token conflicts" do +    it "does not check for token conflicts per default" do +      allow(Hbc).to receive(:load).and_return(cask) +      expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false) + +      run_audit(["casktoken"], auditor) +    end + +    it "checks for token conflicts if --token-conflicts flag is set" do +      allow(Hbc).to receive(:load).and_return(cask) +      expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: true) + +      run_audit(["casktoken", "--token-conflicts"], auditor) +    end +  end + +  def run_audit(args, auditor) +    Hbc::CLI::Audit.new(args, auditor).run +  end +end diff --git a/Library/Homebrew/cask/test/cask/cli/cat_test.rb b/Library/Homebrew/cask/spec/cask/cli/cat_spec.rb index df49efda0..7517c1b5c 100644 --- a/Library/Homebrew/cask/test/cask/cli/cat_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/cat_spec.rb @@ -1,10 +1,10 @@ -require "test_helper" +require "spec_helper"  describe Hbc::CLI::Cat do    describe "given a basic Cask" do -    before do -      @expected_output = <<-EOS.undent -        test_cask 'basic-cask' do +    let(:expected_output) { +      <<-EOS.undent +        cask 'basic-cask' do            version '1.2.3'            sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' @@ -14,46 +14,46 @@ describe Hbc::CLI::Cat do            app 'TestCask.app'          end        EOS -    end +    }      it "displays the Cask file content about the specified Cask" do -      lambda { +      expect {          Hbc::CLI::Cat.run("basic-cask") -      }.must_output(@expected_output) +      }.to output(expected_output).to_stdout      end      it "throws away additional Cask arguments and uses the first" do -      lambda { +      expect {          Hbc::CLI::Cat.run("basic-cask", "local-caffeine") -      }.must_output(@expected_output) +      }.to output(expected_output).to_stdout      end      it "throws away stray options" do -      lambda { +      expect {          Hbc::CLI::Cat.run("--notavalidoption", "basic-cask") -      }.must_output(@expected_output) +      }.to output(expected_output).to_stdout      end    end    it "raises an exception when the Cask does not exist" do -    lambda { +    expect {        Hbc::CLI::Cat.run("notacask") -    }.must_raise Hbc::CaskUnavailableError +    }.to raise_error(Hbc::CaskUnavailableError)    end    describe "when no Cask is specified" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Cat.run -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end    describe "when no Cask is specified, but an invalid option" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Cat.run("--notavalidoption") -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end  end diff --git a/Library/Homebrew/cask/test/cask/cli/create_test.rb b/Library/Homebrew/cask/spec/cask/cli/create_spec.rb index f09c91e8e..e3d484d87 100644 --- a/Library/Homebrew/cask/test/cask/cli/create_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/create_spec.rb @@ -1,4 +1,4 @@ -require "test_helper" +require "spec_helper"  # monkeypatch for testing  module Hbc @@ -20,11 +20,11 @@ module Hbc  end  describe Hbc::CLI::Create do -  before do +  before(:each) do      Hbc::CLI::Create.reset!    end -  after do +  after(:each) do      %w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask|        path = Hbc.path(cask)        path.delete if path.exist? @@ -33,7 +33,7 @@ describe Hbc::CLI::Create do    it "opens the editor for the specified Cask" do      Hbc::CLI::Create.run("new-cask") -    Hbc::CLI::Create.editor_commands.must_equal [ +    expect(Hbc::CLI::Create.editor_commands).to eq [        [Hbc.path("new-cask")],      ]    end @@ -41,7 +41,7 @@ describe Hbc::CLI::Create do    it "drops a template down for the specified Cask" do      Hbc::CLI::Create.run("new-cask")      template = File.read(Hbc.path("new-cask")) -    template.must_equal <<-EOS.undent +    expect(template).to eq <<-EOS.undent        cask 'new-cask' do          version ''          sha256 '' @@ -57,44 +57,44 @@ describe Hbc::CLI::Create do    it "throws away additional Cask arguments and uses the first" do      Hbc::CLI::Create.run("additional-cask", "another-cask") -    Hbc::CLI::Create.editor_commands.must_equal [ +    expect(Hbc::CLI::Create.editor_commands).to eq [        [Hbc.path("additional-cask")],      ]    end    it "throws away stray options" do      Hbc::CLI::Create.run("--notavalidoption", "yet-another-cask") -    Hbc::CLI::Create.editor_commands.must_equal [ +    expect(Hbc::CLI::Create.editor_commands).to eq [        [Hbc.path("yet-another-cask")],      ]    end    it "raises an exception when the Cask already exists" do -    lambda { +    expect {        Hbc::CLI::Create.run("basic-cask") -    }.must_raise Hbc::CaskAlreadyCreatedError +    }.to raise_error(Hbc::CaskAlreadyCreatedError)    end    it "allows creating Casks that are substrings of existing Casks" do      Hbc::CLI::Create.run("local-caff") -    Hbc::CLI::Create.editor_commands.must_equal [ +    expect(Hbc::CLI::Create.editor_commands).to eq [        [Hbc.path("local-caff")],      ]    end    describe "when no Cask is specified" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Create.run -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end    describe "when no Cask is specified, but an invalid option" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Create.run("--notavalidoption") -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end  end diff --git a/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb b/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb index 38f8b50ac..ff1cf5706 100644 --- a/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb @@ -4,7 +4,7 @@ describe Hbc::CLI::Doctor do    it "displays some nice info about the environment" do      expect {        Hbc::CLI::Doctor.run -    }.to output(/\A==> macOS Release:/).to_stdout +    }.to output(/\A==> Homebrew-Cask Version/).to_stdout    end    it "raises an exception when arguments are given" do diff --git a/Library/Homebrew/cask/test/cask/cli/edit_test.rb b/Library/Homebrew/cask/spec/cask/cli/edit_spec.rb index 6eb2289c0..5ddf27a48 100644 --- a/Library/Homebrew/cask/test/cask/cli/edit_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/edit_spec.rb @@ -1,4 +1,4 @@ -require "test_helper" +require "spec_helper"  # monkeypatch for testing  module Hbc @@ -20,43 +20,43 @@ module Hbc  end  describe Hbc::CLI::Edit do -  before do +  before(:each) do      Hbc::CLI::Edit.reset!    end    it "opens the editor for the specified Cask" do -    Hbc::CLI::Edit.run("alfred") -    Hbc::CLI::Edit.editor_commands.must_equal [ -      [Hbc.path("alfred")], +    Hbc::CLI::Edit.run("local-caffeine") +    expect(Hbc::CLI::Edit.editor_commands).to eq [ +      [Hbc.path("local-caffeine")],      ]    end    it "throws away additional arguments and uses the first" do -    Hbc::CLI::Edit.run("adium", "alfred") -    Hbc::CLI::Edit.editor_commands.must_equal [ -      [Hbc.path("adium")], +    Hbc::CLI::Edit.run("local-caffeine", "local-transmission") +    expect(Hbc::CLI::Edit.editor_commands).to eq [ +      [Hbc.path("local-caffeine")],      ]    end    it "raises an exception when the Cask doesnt exist" do -    lambda { +    expect {        Hbc::CLI::Edit.run("notacask") -    }.must_raise Hbc::CaskUnavailableError +    }.to raise_error(Hbc::CaskUnavailableError)    end    describe "when no Cask is specified" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Edit.run -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end    describe "when no Cask is specified, but an invalid option" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Edit.run("--notavalidoption") -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end  end diff --git a/Library/Homebrew/cask/test/cask/cli/fetch_test.rb b/Library/Homebrew/cask/spec/cask/cli/fetch_spec.rb index 70c25646d..bb8133453 100644 --- a/Library/Homebrew/cask/test/cask/cli/fetch_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/fetch_spec.rb @@ -1,20 +1,20 @@ -require "test_helper" +require "spec_helper"  describe Hbc::CLI::Fetch do    let(:local_transmission) { -    Hbc.load("local-transmission") +    Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")    }    let(:local_caffeine) { -    Hbc.load("local-caffeine") +    Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")    }    it "allows download the installer of a Cask" do      shutup do        Hbc::CLI::Fetch.run("local-transmission", "local-caffeine")      end -    Hbc::CurlDownloadStrategy.new(local_transmission).cached_location.must_be :exist? -    Hbc::CurlDownloadStrategy.new(local_caffeine).cached_location.must_be :exist? +    expect(Hbc::CurlDownloadStrategy.new(local_transmission).cached_location).to exist +    expect(Hbc::CurlDownloadStrategy.new(local_caffeine).cached_location).to exist    end    it "prevents double fetch (without nuking existing installation)" do @@ -30,7 +30,7 @@ describe Hbc::CLI::Fetch do      end      new_ctime = File.stat(download_stategy.cached_location).ctime -    old_ctime.to_i.must_equal new_ctime.to_i +    expect(old_ctime.to_i).to eq(new_ctime.to_i)    end    it "allows double fetch with --force" do @@ -48,31 +48,30 @@ describe Hbc::CLI::Fetch do      download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission)      new_ctime = File.stat(download_stategy.cached_location).ctime -    # new_ctime.to_i.must_be :>, old_ctime.to_i -    new_ctime.to_i.must_be :>, old_ctime.to_i +    expect(new_ctime.to_i).to be > old_ctime.to_i    end    it "properly handles Casks that are not present" do -    lambda { +    expect {        shutup do          Hbc::CLI::Fetch.run("notacask")        end -    }.must_raise Hbc::CaskUnavailableError +    }.to raise_error(Hbc::CaskUnavailableError)    end    describe "when no Cask is specified" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Fetch.run -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end    describe "when no Cask is specified, but an invalid option" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Fetch.run("--notavalidoption") -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end  end diff --git a/Library/Homebrew/cask/test/cask/cli/home_test.rb b/Library/Homebrew/cask/spec/cask/cli/home_spec.rb index 67bcb024a..a2b49b433 100644 --- a/Library/Homebrew/cask/test/cask/cli/home_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/home_spec.rb @@ -1,4 +1,4 @@ -require "test_helper" +require "spec_helper"  # monkeypatch for testing  module Hbc @@ -25,23 +25,23 @@ describe Hbc::CLI::Home do    end    it "opens the homepage for the specified Cask" do -    Hbc::CLI::Home.run("alfred") -    Hbc::CLI::Home.system_commands.must_equal [ -      ["/usr/bin/open", "--", "https://www.alfredapp.com/"], +    Hbc::CLI::Home.run("local-caffeine") +    expect(Hbc::CLI::Home.system_commands).to eq [ +      ["/usr/bin/open", "--", "http://example.com/local-caffeine"],      ]    end    it "works for multiple Casks" do -    Hbc::CLI::Home.run("alfred", "adium") -    Hbc::CLI::Home.system_commands.must_equal [ -      ["/usr/bin/open", "--", "https://www.alfredapp.com/"], -      ["/usr/bin/open", "--", "https://www.adium.im/"], +    Hbc::CLI::Home.run("local-caffeine", "local-transmission") +    expect(Hbc::CLI::Home.system_commands).to eq [ +      ["/usr/bin/open", "--", "http://example.com/local-caffeine"], +      ["/usr/bin/open", "--", "http://example.com/local-transmission"],      ]    end    it "opens the project page when no Cask is specified" do      Hbc::CLI::Home.run -    Hbc::CLI::Home.system_commands.must_equal [ +    expect(Hbc::CLI::Home.system_commands).to eq [        ["/usr/bin/open", "--", "http://caskroom.io/"],      ]    end diff --git a/Library/Homebrew/cask/test/cask/cli/info_test.rb b/Library/Homebrew/cask/spec/cask/cli/info_spec.rb index 767a594e8..6977f81c3 100644 --- a/Library/Homebrew/cask/test/cask/cli/info_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/info_spec.rb @@ -1,14 +1,14 @@ -require "test_helper" +require "spec_helper"  describe Hbc::CLI::Info do    it "displays some nice info about the specified Cask" do -    lambda { +    expect {        Hbc::CLI::Info.run("local-caffeine") -    }.must_output <<-EOS.undent +    }.to output(<<-EOS.undent).to_stdout        local-caffeine: 1.2.3        http://example.com/local-caffeine        Not installed -      From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-caffeine.rb +      From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb        ==> Name        None        ==> Artifacts @@ -17,12 +17,12 @@ describe Hbc::CLI::Info do    end    describe "given multiple Casks" do -    before do -      @expected_output = <<-EOS.undent +    let(:expected_output) { +      <<-EOS.undent          local-caffeine: 1.2.3          http://example.com/local-caffeine          Not installed -        From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-caffeine.rb +        From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb          ==> Name          None          ==> Artifacts @@ -30,35 +30,35 @@ describe Hbc::CLI::Info do          local-transmission: 2.61          http://example.com/local-transmission          Not installed -        From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-transmission.rb +        From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-transmission.rb          ==> Name          None          ==> Artifacts          Transmission.app (app)        EOS -    end +    }      it "displays the info" do -      lambda { +      expect {          Hbc::CLI::Info.run("local-caffeine", "local-transmission") -      }.must_output(@expected_output) +      }.to output(expected_output).to_stdout      end      it "throws away stray options" do -      lambda { +      expect {          Hbc::CLI::Info.run("--notavalidoption", "local-caffeine", "local-transmission") -      }.must_output(@expected_output) +      }.to output(expected_output).to_stdout      end    end    it "should print caveats if the Cask provided one" do -    lambda { +    expect {        Hbc::CLI::Info.run("with-caveats") -    }.must_output <<-EOS.undent +    }.to output(<<-EOS.undent).to_stdout        with-caveats: 1.2.3        http://example.com/local-caffeine        Not installed -      From: https://github.com/caskroom/homebrew-test/blob/master/Casks/with-caveats.rb +      From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-caveats.rb        ==> Name        None        ==> Artifacts @@ -78,13 +78,13 @@ describe Hbc::CLI::Info do    end    it 'should not print "Caveats" section divider if the caveats block has no output' do -    lambda { +    expect {        Hbc::CLI::Info.run("with-conditional-caveats") -    }.must_output <<-EOS.undent +    }.to output(<<-EOS.undent).to_stdout        with-conditional-caveats: 1.2.3        http://example.com/local-caffeine        Not installed -      From: https://github.com/caskroom/homebrew-test/blob/master/Casks/with-conditional-caveats.rb +      From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-conditional-caveats.rb        ==> Name        None        ==> Artifacts @@ -94,17 +94,17 @@ describe Hbc::CLI::Info do    describe "when no Cask is specified" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Info.run -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end    describe "when no Cask is specified, but an invalid option" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Info.run("--notavalidoption") -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end  end diff --git a/Library/Homebrew/cask/test/cask/cli/install_test.rb b/Library/Homebrew/cask/spec/cask/cli/install_spec.rb index eef3f2e5b..07aa78aa3 100644 --- a/Library/Homebrew/cask/test/cask/cli/install_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/install_spec.rb @@ -1,4 +1,4 @@ -require "test_helper" +require "spec_helper"  describe Hbc::CLI::Install do    it "allows staging and activation of multiple Casks at once" do @@ -6,10 +6,10 @@ describe Hbc::CLI::Install do        Hbc::CLI::Install.run("local-transmission", "local-caffeine")      end -    Hbc.load("local-transmission").must_be :installed? -    Hbc.appdir.join("Transmission.app").must_be :directory? -    Hbc.load("local-caffeine").must_be :installed? -    Hbc.appdir.join("Caffeine.app").must_be :directory? +    expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed +    expect(Hbc.appdir.join("Transmission.app")).to be_a_directory +    expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")).to be_installed +    expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory    end    it "skips double install (without nuking existing installation)" do @@ -19,7 +19,7 @@ describe Hbc::CLI::Install do      shutup do        Hbc::CLI::Install.run("local-transmission")      end -    Hbc.load("local-transmission").must_be :installed? +    expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed    end    it "prints a warning message on double install" do @@ -27,9 +27,9 @@ describe Hbc::CLI::Install do        Hbc::CLI::Install.run("local-transmission")      end -    lambda { +    expect {        Hbc::CLI::Install.run("local-transmission", "") -    }.must_output nil, /Warning: A Cask for local-transmission is already installed./ +    }.to output(/Warning: A Cask for local-transmission is already installed./).to_stderr    end    it "allows double install with --force" do @@ -37,54 +37,56 @@ describe Hbc::CLI::Install do        Hbc::CLI::Install.run("local-transmission")      end -    lambda { -      Hbc::CLI::Install.run("local-transmission", "--force") -    }.must_output(/local-transmission was successfully installed!/) +    expect { +      expect { +        Hbc::CLI::Install.run("local-transmission", "--force") +      }.to output(/It seems there is already an App at.*overwriting\./).to_stderr +    }.to output(/local-transmission was successfully installed!/).to_stdout    end    it "skips dependencies with --skip-cask-deps" do      shutup do        Hbc::CLI::Install.run("with-depends-on-cask-multiple", "--skip-cask-deps")      end -    Hbc.load("with-depends-on-cask-multiple").must_be :installed? -    Hbc.load("local-caffeine").wont_be :installed? -    Hbc.load("local-transmission").wont_be :installed? +    expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb")).to be_installed +    expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")).not_to be_installed +    expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed    end    it "properly handles Casks that are not present" do -    lambda { +    expect {        shutup do          Hbc::CLI::Install.run("notacask")        end -    }.must_raise Hbc::CaskError +    }.to raise_error(Hbc::CaskError)    end    it "returns a suggestion for a misspelled Cask" do -    lambda { +    expect {        begin          Hbc::CLI::Install.run("googlechrome")        rescue Hbc::CaskError          nil        end -    }.must_output(nil, /No available Cask for googlechrome\. Did you mean:\ngoogle-chrome/) +    }.to output(/No available Cask for googlechrome\. Did you mean:\ngoogle-chrome/).to_stderr    end    it "returns multiple suggestions for a Cask fragment" do -    lambda { +    expect {        begin          Hbc::CLI::Install.run("google")        rescue Hbc::CaskError          nil        end -    }.must_output(nil, /No available Cask for google\. Did you mean one of:\ngoogle/) +    }.to output(/No available Cask for google\. Did you mean one of:\ngoogle/).to_stderr    end    describe "when no Cask is specified" do      with_options = lambda do |options|        it "raises an exception" do -        lambda { +        expect {            Hbc::CLI::Install.run(*options) -        }.must_raise Hbc::CaskUnspecifiedError +        }.to raise_error(Hbc::CaskUnspecifiedError)        end      end diff --git a/Library/Homebrew/cask/test/cask/cli/list_test.rb b/Library/Homebrew/cask/spec/cask/cli/list_spec.rb index 4220ea510..49c06c521 100644 --- a/Library/Homebrew/cask/test/cask/cli/list_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/list_spec.rb @@ -1,16 +1,16 @@ -require "test_helper" +require "spec_helper"  describe Hbc::CLI::List do    it "lists the installed Casks in a pretty fashion" do      casks = %w[local-caffeine local-transmission].map { |c| Hbc.load(c) }      casks.each do |c| -      TestHelper.install_with_caskfile(c) +      InstallHelper.install_with_caskfile(c)      end -    lambda { +    expect {        Hbc::CLI::List.run -    }.must_output <<-EOS.undent +    }.to output(<<-EOS.undent).to_stdout        local-caffeine        local-transmission      EOS @@ -18,7 +18,7 @@ describe Hbc::CLI::List do    describe "lists versions" do      let(:casks) { ["local-caffeine", "local-transmission"] } -    let(:output) { +    let(:expected_output) {        <<-EOS.undent          local-caffeine 1.2.3          local-transmission 2.61 @@ -26,19 +26,19 @@ describe Hbc::CLI::List do      }      before(:each) do -      casks.map(&Hbc.method(:load)).each(&TestHelper.method(:install_with_caskfile)) +      casks.map(&Hbc.method(:load)).each(&InstallHelper.method(:install_with_caskfile))      end      it "of all installed Casks" do -      lambda { +      expect {          Hbc::CLI::List.run("--versions") -      }.must_output(output) +      }.to output(expected_output).to_stdout      end      it "of given Casks" do -      lambda { +      expect {          Hbc::CLI::List.run("--versions", "local-caffeine", "local-transmission") -      }.must_output(output) +      }.to output(expected_output).to_stdout      end    end @@ -50,34 +50,30 @@ describe Hbc::CLI::List do        staged_path.mkpath      end -    after do -      caskroom_path.rmtree -    end -      it "lists installed Casks without backing ruby files (due to renames or otherwise)" do -      lambda { +      expect {          Hbc::CLI::List.run -      }.must_output <<-EOS.undent +      }.to output(<<-EOS.undent).to_stdout          ive-been-renamed (!)        EOS      end    end    describe "given a set of installed Casks" do -    let(:caffeine) { Hbc.load("local-caffeine") } -    let(:transmission) { Hbc.load("local-transmission") } +    let(:caffeine) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") } +    let(:transmission) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") }      let(:casks) { [caffeine, transmission] }      it "lists the installed files for those Casks" do -      casks.each(&TestHelper.method(:install_without_artifacts_with_caskfile)) +      casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile))        shutup do          Hbc::Artifact::App.new(transmission).install_phase        end -      lambda { +      expect {          Hbc::CLI::List.run("local-transmission", "local-caffeine") -      }.must_output <<-EOS.undent +      }.to output(<<-EOS.undent).to_stdout          ==> Apps          #{Hbc.appdir.join("Transmission.app")} (#{Hbc.appdir.join("Transmission.app").abv})          ==> Apps diff --git a/Library/Homebrew/cask/test/cask/cli/options_test.rb b/Library/Homebrew/cask/spec/cask/cli/options_spec.rb index d49e7827b..a4381213a 100644 --- a/Library/Homebrew/cask/test/cask/cli/options_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/options_spec.rb @@ -1,10 +1,10 @@ -require "test_helper" +require "spec_helper"  describe Hbc::CLI do    it "supports setting the appdir" do      Hbc::CLI.process_options %w[help --appdir=/some/path/foo] -    Hbc.appdir.must_equal Pathname("/some/path/foo") +    expect(Hbc.appdir).to eq(Pathname.new("/some/path/foo"))    end    it "supports setting the appdir from ENV" do @@ -12,13 +12,13 @@ describe Hbc::CLI do      Hbc::CLI.process_options %w[help] -    Hbc.appdir.must_equal Pathname("/some/path/bar") +    expect(Hbc.appdir).to eq(Pathname.new("/some/path/bar"))    end    it "supports setting the prefpanedir" do      Hbc::CLI.process_options %w[help --prefpanedir=/some/path/foo] -    Hbc.prefpanedir.must_equal Pathname("/some/path/foo") +    expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/foo"))    end    it "supports setting the prefpanedir from ENV" do @@ -26,13 +26,13 @@ describe Hbc::CLI do      Hbc::CLI.process_options %w[help] -    Hbc.prefpanedir.must_equal Pathname("/some/path/bar") +    expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/bar"))    end    it "supports setting the qlplugindir" do      Hbc::CLI.process_options %w[help --qlplugindir=/some/path/foo] -    Hbc.qlplugindir.must_equal Pathname("/some/path/foo") +    expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/foo"))    end    it "supports setting the qlplugindir from ENV" do @@ -40,13 +40,13 @@ describe Hbc::CLI do      Hbc::CLI.process_options %w[help] -    Hbc.qlplugindir.must_equal Pathname("/some/path/bar") +    expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/bar"))    end    it "supports setting the colorpickerdir" do      Hbc::CLI.process_options %w[help --colorpickerdir=/some/path/foo] -    Hbc.colorpickerdir.must_equal Pathname("/some/path/foo") +    expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/foo"))    end    it "supports setting the colorpickerdir from ENV" do @@ -54,13 +54,13 @@ describe Hbc::CLI do      Hbc::CLI.process_options %w[help] -    Hbc.colorpickerdir.must_equal Pathname("/some/path/bar") +    expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/bar"))    end    it "supports setting the dictionarydir" do      Hbc::CLI.process_options %w[help --dictionarydir=/some/path/foo] -    Hbc.dictionarydir.must_equal Pathname("/some/path/foo") +    expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/foo"))    end    it "supports setting the dictionarydir from ENV" do @@ -68,13 +68,13 @@ describe Hbc::CLI do      Hbc::CLI.process_options %w[help] -    Hbc.dictionarydir.must_equal Pathname("/some/path/bar") +    expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/bar"))    end    it "supports setting the fontdir" do      Hbc::CLI.process_options %w[help --fontdir=/some/path/foo] -    Hbc.fontdir.must_equal Pathname("/some/path/foo") +    expect(Hbc.fontdir).to eq(Pathname.new("/some/path/foo"))    end    it "supports setting the fontdir from ENV" do @@ -82,13 +82,13 @@ describe Hbc::CLI do      Hbc::CLI.process_options %w[help] -    Hbc.fontdir.must_equal Pathname("/some/path/bar") +    expect(Hbc.fontdir).to eq(Pathname.new("/some/path/bar"))    end    it "supports setting the servicedir" do      Hbc::CLI.process_options %w[help --servicedir=/some/path/foo] -    Hbc.servicedir.must_equal Pathname("/some/path/foo") +    expect(Hbc.servicedir).to eq(Pathname.new("/some/path/foo"))    end    it "supports setting the servicedir from ENV" do @@ -96,36 +96,36 @@ describe Hbc::CLI do      Hbc::CLI.process_options %w[help] -    Hbc.servicedir.must_equal Pathname("/some/path/bar") +    expect(Hbc.servicedir).to eq(Pathname.new("/some/path/bar"))    end    it "allows additional options to be passed through" do      rest = Hbc::CLI.process_options %w[edit foo --create --appdir=/some/path/qux] -    Hbc.appdir.must_equal Pathname("/some/path/qux") -    rest.must_equal %w[edit foo --create] +    expect(Hbc.appdir).to eq(Pathname.new("/some/path/qux")) +    expect(rest).to eq(%w[edit foo --create])    end    describe "when a mandatory argument is missing" do      it "shows a user-friendly error message" do -      lambda { +      expect {          Hbc::CLI.process_options %w[install -f] -      }.must_raise Hbc::CaskError +      }.to raise_error(Hbc::CaskError)      end    end    describe "given an ambiguous option" do      it "shows a user-friendly error message" do -      lambda { +      expect {          Hbc::CLI.process_options %w[edit -c] -      }.must_raise Hbc::CaskError +      }.to raise_error(Hbc::CaskError)      end    end    describe "--debug" do      it "sets the Cask debug method to true" do        Hbc::CLI.process_options %w[help --debug] -      Hbc.debug.must_equal true +      expect(Hbc.debug).to be true        Hbc.debug = false      end    end @@ -133,12 +133,8 @@ describe Hbc::CLI do    describe "--help" do      it "sets the Cask help method to true" do        Hbc::CLI.process_options %w[foo --help] -      Hbc.help.must_equal true +      expect(Hbc.help).to be true        Hbc.help = false      end    end - -  after do -    ENV["HOMEBREW_CASK_OPTS"] = nil -  end  end diff --git a/Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb b/Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb new file mode 100644 index 000000000..df83c53e2 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb @@ -0,0 +1,24 @@ +require "spec_helper" + +describe Hbc::CLI::Reinstall do +  it "allows reinstalling a Cask" do +    shutup do +      Hbc::CLI::Install.run("local-transmission") +    end +    expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + +    shutup do +      Hbc::CLI::Reinstall.run("local-transmission") +    end +    expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed +  end + +  it "allows reinstalling a non installed Cask" do +    expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed + +    shutup do +      Hbc::CLI::Reinstall.run("local-transmission") +    end +    expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed +  end +end diff --git a/Library/Homebrew/cask/spec/cask/cli/search_spec.rb b/Library/Homebrew/cask/spec/cask/cli/search_spec.rb new file mode 100644 index 000000000..fe669dd3e --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/search_spec.rb @@ -0,0 +1,61 @@ +require "spec_helper" + +describe Hbc::CLI::Search do +  it "lists the available Casks that match the search term" do +    expect { +      Hbc::CLI::Search.run("photoshop") +    }.to output(<<-EOS.undent).to_stdout +      ==> Partial matches +      adobe-photoshop-cc +      adobe-photoshop-lightroom +    EOS +  end + +  it "shows that there are no Casks matching a search term that did not result in anything" do +    expect { +      Hbc::CLI::Search.run("foo-bar-baz") +    }.to output("No Cask found for \"foo-bar-baz\".\n").to_stdout +  end + +  it "lists all available Casks with no search term" do +    expect { +      Hbc::CLI::Search.run +    }.to output(/google-chrome/).to_stdout +  end + +  it "ignores hyphens in search terms" do +    expect { +      Hbc::CLI::Search.run("goo-gle-chrome") +    }.to output(/google-chrome/).to_stdout +  end + +  it "ignores hyphens in Cask tokens" do +    expect { +      Hbc::CLI::Search.run("googlechrome") +    }.to output(/google-chrome/).to_stdout +  end + +  it "accepts multiple arguments" do +    expect { +      Hbc::CLI::Search.run("google chrome") +    }.to output(/google-chrome/).to_stdout +  end + +  it "accepts a regexp argument" do +    expect { +      Hbc::CLI::Search.run("/^google-c[a-z]rome$/") +    }.to output("==> Regexp matches\ngoogle-chrome\n").to_stdout +  end + +  it "Returns both exact and partial matches" do +    expect { +      Hbc::CLI::Search.run("mnemosyne") +    }.to output(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/).to_stdout +  end + +  it "does not search the Tap name" do +    expect { +      Hbc::CLI::Search.run("caskroom") +    }.to output(/^No Cask found for "caskroom"\.\n/).to_stdout +  end +end diff --git a/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb index 0368ad87c..be0aa31b6 100644 --- a/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb @@ -1,44 +1,44 @@ -require "test_helper" +require "spec_helper"  describe Hbc::CLI::Uninstall do    it "shows an error when a bad Cask is provided" do -    lambda { +    expect {        Hbc::CLI::Uninstall.run("notacask") -    }.must_raise Hbc::CaskUnavailableError +    }.to raise_error(Hbc::CaskUnavailableError)    end    it "shows an error when a Cask is provided that's not installed" do -    lambda { +    expect {        Hbc::CLI::Uninstall.run("anvil") -    }.must_raise Hbc::CaskNotInstalledError +    }.to raise_error(Hbc::CaskNotInstalledError)    end    it "tries anyway on a non-present Cask when --force is given" do -    lambda do +    expect {        Hbc::CLI::Uninstall.run("anvil", "--force") -    end # wont_raise +    }.not_to raise_error    end    it "can uninstall and unlink multiple Casks at once" do -    caffeine = Hbc.load("local-caffeine") -    transmission = Hbc.load("local-transmission") +    caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") +    transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")      shutup do        Hbc::Installer.new(caffeine).install        Hbc::Installer.new(transmission).install      end -    caffeine.must_be :installed? -    transmission.must_be :installed? +    expect(caffeine).to be_installed +    expect(transmission).to be_installed      shutup do        Hbc::CLI::Uninstall.run("local-caffeine", "local-transmission")      end -    caffeine.wont_be :installed? -    Hbc.appdir.join("Transmission.app").wont_be :exist? -    transmission.wont_be :installed? -    Hbc.appdir.join("Caffeine.app").wont_be :exist? +    expect(caffeine).not_to be_installed +    expect(Hbc.appdir.join("Transmission.app")).not_to exist +    expect(transmission).not_to be_installed +    expect(Hbc.appdir.join("Caffeine.app")).not_to exist    end    describe "when multiple versions of a cask are installed" do @@ -67,34 +67,29 @@ describe Hbc::CLI::Uninstall do        end      end -    after(:each) do -      caskroom_path.rmtree if caskroom_path.exist? -    end -      it "uninstalls one version at a time" do        shutup do          Hbc::CLI::Uninstall.run("versioned-cask")        end -      caskroom_path.join(first_installed_version).must_be :exist? -      caskroom_path.join(last_installed_version).wont_be :exist? -      caskroom_path.must_be :exist? +      expect(caskroom_path.join(first_installed_version)).to exist +      expect(caskroom_path.join(last_installed_version)).not_to exist +      expect(caskroom_path).to exist        shutup do          Hbc::CLI::Uninstall.run("versioned-cask")        end -      caskroom_path.join(first_installed_version).wont_be :exist? -      caskroom_path.wont_be :exist? +      expect(caskroom_path.join(first_installed_version)).not_to exist +      expect(caskroom_path).not_to exist      end      it "displays a message when versions remain installed" do -      out, err = capture_io do -        Hbc::CLI::Uninstall.run("versioned-cask") -      end - -      out.must_match(/#{token} #{first_installed_version} is still installed./) -      err.must_be :empty? +      expect { +        expect { +          Hbc::CLI::Uninstall.run("versioned-cask") +        }.not_to output.to_stderr +      }.to output(/#{token} #{first_installed_version} is still installed./).to_stdout      end    end @@ -121,34 +116,29 @@ describe Hbc::CLI::Uninstall do        EOS      end -    after do -      app.rmtree if app.exist? -      caskroom_path.rmtree if caskroom_path.exist? -    end -      it "can still uninstall those Casks" do        shutup do          Hbc::CLI::Uninstall.run("ive-been-renamed")        end -      app.wont_be :exist? -      caskroom_path.wont_be :exist? +      expect(app).not_to exist +      expect(caskroom_path).not_to exist      end    end    describe "when no Cask is specified" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Uninstall.run -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end    describe "when no Cask is specified, but an invalid option" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Uninstall.run("--notavalidoption") -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end  end diff --git a/Library/Homebrew/cask/spec/cask/cli/version_spec.rb b/Library/Homebrew/cask/spec/cask/cli/version_spec.rb new file mode 100644 index 000000000..e6fcf4850 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/version_spec.rb @@ -0,0 +1,11 @@ +require "spec_helper" + +describe "brew cask --version" do +  it "respects the --version argument" do +    expect { +      expect { +        Hbc::CLI::NullCommand.new("--version").run +      }.not_to output.to_stderr +    }.to output(Hbc.full_version).to_stdout +  end +end diff --git a/Library/Homebrew/cask/test/cask/cli/zap_test.rb b/Library/Homebrew/cask/spec/cask/cli/zap_spec.rb index a9e862b11..d26114567 100644 --- a/Library/Homebrew/cask/test/cask/cli/zap_test.rb +++ b/Library/Homebrew/cask/spec/cask/cli/zap_spec.rb @@ -1,33 +1,33 @@ -require "test_helper" +require "spec_helper"  describe Hbc::CLI::Zap do    it "shows an error when a bad Cask is provided" do -    lambda { +    expect {        Hbc::CLI::Zap.run("notacask") -    }.must_raise Hbc::CaskUnavailableError +    }.to raise_error(Hbc::CaskUnavailableError)    end    it "can zap and unlink multiple Casks at once" do -    caffeine = Hbc.load("local-caffeine") -    transmission = Hbc.load("local-transmission") +    caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") +    transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")      shutup do        Hbc::Installer.new(caffeine).install        Hbc::Installer.new(transmission).install      end -    caffeine.must_be :installed? -    transmission.must_be :installed? +    expect(caffeine).to be_installed +    expect(transmission).to be_installed      shutup do        Hbc::CLI::Zap.run("--notavalidoption",                          "local-caffeine", "local-transmission")      end -    caffeine.wont_be :installed? -    Hbc.appdir.join("Transmission.app").wont_be :symlink? -    transmission.wont_be :installed? -    Hbc.appdir.join("Caffeine.app").wont_be :symlink? +    expect(caffeine).not_to be_installed +    expect(Hbc.appdir.join("Caffeine.app")).not_to be_a_symlink +    expect(transmission).not_to be_installed +    expect(Hbc.appdir.join("Transmission.app")).not_to be_a_symlink    end    # TODO: Explicit test that both zap and uninstall directives get dispatched. @@ -59,17 +59,17 @@ describe Hbc::CLI::Zap do    describe "when no Cask is specified" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Zap.run -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end    describe "when no Cask is specified, but an invalid option" do      it "raises an exception" do -      lambda { +      expect {          Hbc::CLI::Zap.run("--notavalidoption") -      }.must_raise Hbc::CaskUnspecifiedError +      }.to raise_error(Hbc::CaskUnspecifiedError)      end    end  end diff --git a/Library/Homebrew/cask/spec/cask/cli_spec.rb b/Library/Homebrew/cask/spec/cask/cli_spec.rb index 9964275f1..6b2313a41 100644 --- a/Library/Homebrew/cask/spec/cask/cli_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli_spec.rb @@ -39,17 +39,17 @@ describe Hbc::CLI do      end      it "respects the env variable when choosing what appdir to create" do -      with_environment "HOMEBREW_CASK_OPTS" => "--appdir=/custom/appdir" do -        expect(Hbc).to receive(:appdir=).with(Pathname("/custom/appdir")) -        described_class.process("noop") -      end +      allow(ENV).to receive(:[]) +      allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--appdir=/custom/appdir") +      expect(Hbc).to receive(:appdir=).with(Pathname.new("/custom/appdir")) +      described_class.process("noop")      end      it "respects the env variable when choosing a non-default Caskroom location" do -      with_environment "HOMEBREW_CASK_OPTS" => "--caskroom=/custom/caskdir" do -        expect(Hbc).to receive(:caskroom=).with(Pathname("/custom/caskdir")) -        described_class.process("noop") -      end +      allow(ENV).to receive(:[]) +      allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--caskroom=/custom/caskdir") +      expect(Hbc).to receive(:caskroom=).with(Pathname.new("/custom/caskdir")) +      described_class.process("noop")      end      it "exits with a status of 1 when something goes wrong" do diff --git a/Library/Homebrew/cask/test/cask/container/dmg_test.rb b/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb index 2c33b88b6..af42d89b1 100644 --- a/Library/Homebrew/cask/test/cask/container/dmg_test.rb +++ b/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb @@ -1,9 +1,9 @@ -require "test_helper" +require "spec_helper"  describe Hbc::Container::Dmg do -  describe "mount!" do +  describe "#mount!" do      it "does not store nil mounts for dmgs with extra data" do -      transmission = Hbc.load("local-transmission") +      transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")        dmg = Hbc::Container::Dmg.new(          transmission, @@ -13,7 +13,7 @@ describe Hbc::Container::Dmg do        begin          dmg.mount! -        dmg.mounts.wont_include nil +        expect(dmg.mounts).not_to include nil        ensure          dmg.eject!        end diff --git a/Library/Homebrew/cask/test/cask/container/naked_test.rb b/Library/Homebrew/cask/spec/cask/container/naked_spec.rb index d40c16de5..ee4102eca 100644 --- a/Library/Homebrew/cask/test/cask/container/naked_test.rb +++ b/Library/Homebrew/cask/spec/cask/container/naked_spec.rb @@ -1,4 +1,4 @@ -require "test_helper" +require "spec_helper"  describe Hbc::Container::Naked do    it "saves files with spaces in them from uris with encoded spaces" do @@ -13,8 +13,13 @@ describe Hbc::Container::Naked do      Hbc::FakeSystemCommand.stubs_command(expected_command)      container = Hbc::Container::Naked.new(cask, path, Hbc::FakeSystemCommand) -    container.extract -    Hbc::FakeSystemCommand.system_calls[expected_command].must_equal 1 +    expect { +      shutup do +        container.extract +      end +    }.not_to raise_error + +    expect(Hbc::FakeSystemCommand.system_calls[expected_command]).to eq(1)    end  end diff --git a/Library/Homebrew/cask/spec/cask/depends_on_spec.rb b/Library/Homebrew/cask/spec/cask/depends_on_spec.rb new file mode 100644 index 000000000..078a2bce7 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/depends_on_spec.rb @@ -0,0 +1,92 @@ +require "spec_helper" + +# TODO: this test should be named after the corresponding class, once +#       that class is abstracted from installer.rb +describe "Satisfy Dependencies and Requirements" do +  subject { +    lambda do +      shutup do +        Hbc::Installer.new(cask).install +      end +    end +  } + +  describe "depends_on cask" do +    context "when depends_on cask is cyclic" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-cyclic.rb") } +      it { is_expected.to raise_error(Hbc::CaskCyclicCaskDependencyError) } +    end + +    context do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask.rb") } +      let(:dependency) { Hbc.load(cask.depends_on.cask.first) } + +      it "installs the dependency of a Cask and the Cask itself" do +        expect(subject).not_to raise_error +        expect(cask).to be_installed +        expect(dependency).to be_installed +      end +    end +  end + +  describe "depends_on macos" do +    context "given an array" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-array.rb") } +      it { is_expected.not_to raise_error } +    end + +    context "given a comparisson" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-comparison.rb") } +      it { is_expected.not_to raise_error } +    end + +    context "given a string" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-string.rb") } +      it { is_expected.not_to raise_error } +    end + +    context "given a symbol" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-symbol.rb") } +      it { is_expected.not_to raise_error } +    end + +    context "when not satisfied" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-failure.rb") } +      it { is_expected.to raise_error(Hbc::CaskError) } +    end +  end + +  describe "depends_on arch" do +    context "when satisfied" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-arch.rb") } +      it { is_expected.not_to raise_error } +    end +  end + +  describe "depends_on x11" do +    before(:each) do +      allow(MacOS::X11).to receive(:installed?).and_return(x11_installed) +    end + +    context "when satisfied" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") } +      let(:x11_installed) { true } + +      it { is_expected.not_to raise_error } +    end + +    context "when not satisfied" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") } +      let(:x11_installed) { false } + +      it { is_expected.to raise_error(Hbc::CaskX11DependencyError) } +    end + +    context "when depends_on x11: false" do +      let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11-false.rb") } +      let(:x11_installed) { false } + +      it { is_expected.not_to raise_error } +    end +  end +end diff --git a/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb b/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb index d0c7eef34..777491d66 100644 --- a/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb +++ b/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb @@ -1,7 +1,7 @@ -require "test_helper" +require "spec_helper"  describe Hbc::DSL::Caveats do -  let(:cask) { Hbc.load("basic-cask") } +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }    let(:dsl) { Hbc::DSL::Caveats.new(cask) }    it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb b/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb index c5e80b6d0..116a7c8a8 100644 --- a/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb +++ b/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb @@ -1,7 +1,7 @@ -require "test_helper" +require "spec_helper"  describe Hbc::DSL::Postflight do -  let(:cask) { Hbc.load("basic-cask") } +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }    let(:dsl) { Hbc::DSL::Postflight.new(cask, Hbc::FakeSystemCommand) }    it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb b/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb index 1c49a62ad..90d2634db 100644 --- a/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb +++ b/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb @@ -1,7 +1,7 @@ -require "test_helper" +require "spec_helper"  describe Hbc::DSL::Preflight do -  let(:cask) { Hbc.load("basic-cask") } +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }    let(:dsl) { Hbc::DSL::Preflight.new(cask, Hbc::FakeSystemCommand) }    it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb b/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb index c704706ad..4b7dd7557 100644 --- a/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb +++ b/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb @@ -1,7 +1,7 @@ -require "test_helper" +require "spec_helper"  describe Hbc::DSL::UninstallPostflight do -  let(:cask) { Hbc.load("basic-cask") } +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }    let(:dsl) { Hbc::DSL::UninstallPostflight.new(cask, Hbc::FakeSystemCommand) }    it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb b/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb index f6ab36b60..a4930e99e 100644 --- a/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb +++ b/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb @@ -1,7 +1,7 @@ -require "test_helper" +require "spec_helper"  describe Hbc::DSL::UninstallPreflight do -  let(:cask) { Hbc.load("basic-cask") } +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }    let(:dsl) { Hbc::DSL::UninstallPreflight.new(cask, Hbc::FakeSystemCommand) }    it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/cask/spec/cask/dsl_spec.rb b/Library/Homebrew/cask/spec/cask/dsl_spec.rb new file mode 100644 index 000000000..99525cc20 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/dsl_spec.rb @@ -0,0 +1,548 @@ +require "spec_helper" + +describe Hbc::DSL do +  let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/#{token}.rb") } +  let(:token) { "basic-cask" } + +  context "stanzas" do +    it "lets you set url, homepage, and version" do +      expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg") +      expect(cask.homepage).to eq("http://example.com/") +      expect(cask.version.to_s).to eq("1.2.3") +    end +  end + +  describe "when a Cask includes an unknown method" do +    let(:attempt_unknown_method) { +      lambda do +        Hbc::Cask.new("unexpected-method-cask") do +          future_feature :not_yet_on_your_machine +        end +      end +    } + +    it "prints a warning that it has encountered an unexpected method" do +      expected = Regexp.compile(<<-EOS.undent.lines.map(&:chomp).join("")) +        (?m) +        Warning: +        .* +        Unexpected method 'future_feature' called on Cask unexpected-method-cask\\. +        .* +        https://github.com/caskroom/homebrew-cask/blob/master/doc/reporting_bugs/pre_bug_report.md +        .* +        https://github.com/caskroom/homebrew-cask#reporting-bugs +      EOS + +      expect { +        expect(attempt_unknown_method).not_to output.to_stdout +      }.to output(expected).to_stderr +    end + +    it "will simply warn, not throw an exception" do +      expect { +        shutup do +          attempt_unknown_method.call +        end +      }.not_to raise_error +    end +  end + +  describe "header line" do +    context "when invalid" do +      let(:token) { "invalid/invalid-header-format" } +      it "raises an error" do +        expect { cask }.to raise_error(SyntaxError) +      end +    end + +    context "when token does not match the file name" do +      let(:token) { "invalid/invalid-header-token-mismatch" } + +      it "raises an error" do +        expect { +          cask +        }.to raise_error(Hbc::CaskTokenDoesNotMatchError, /Bad header line:.*does not match file name/) +      end +    end + +    context "when it contains no DSL version" do +      let(:token) { "no-dsl-version" } + +      it "does not require a DSL version in the header" do +        expect(cask.token).to eq("no-dsl-version") +        expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg") +        expect(cask.homepage).to eq("http://example.com/") +        expect(cask.version.to_s).to eq("1.2.3") +      end +    end + +    context "when it contains a deprecated DSL version" do +      let(:token) { "with-dsl-version" } + +      it "may use deprecated DSL version hash syntax" do +        allow(ENV).to receive(:[]).with("HOMEBREW_DEVELOPER").and_return(nil) + +        shutup do +          expect(cask.token).to eq("with-dsl-version") +          expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg") +          expect(cask.homepage).to eq("http://example.com/") +          expect(cask.version.to_s).to eq("1.2.3") +        end +      end +    end +  end + +  describe "name stanza" do +    it "lets you set the full name via a name stanza" do +      cask = Hbc::Cask.new("name-cask") do +        name "Proper Name" +      end + +      expect(cask.name).to eq([ +                                "Proper Name", +                              ]) +    end + +    it "Accepts an array value to the name stanza" do +      cask = Hbc::Cask.new("array-name-cask") do +        name ["Proper Name", "Alternate Name"] +      end + +      expect(cask.name).to eq([ +                                "Proper Name", +                                "Alternate Name", +                              ]) +    end + +    it "Accepts multiple name stanzas" do +      cask = Hbc::Cask.new("multi-name-cask") do +        name "Proper Name" +        name "Alternate Name" +      end + +      expect(cask.name).to eq([ +                                "Proper Name", +                                "Alternate Name", +                              ]) +    end +  end + +  describe "sha256 stanza" do +    it "lets you set checksum via sha256" do +      cask = Hbc::Cask.new("checksum-cask") do +        sha256 "imasha2" +      end + +      expect(cask.sha256).to eq("imasha2") +    end +  end + +  describe "language stanza" do +    it "allows multilingual casks" do +      cask = lambda do +        Hbc::Cask.new("cask-with-apps") do +          language "zh" do +            sha256 "abc123" +            "zh-CN" +          end + +          language "en-US", default: true do +            sha256 "xyz789" +            "en-US" +          end + +          url "https://example.org/#{language}.zip" +        end +      end + +      allow(MacOS).to receive(:languages).and_return(["zh"]) +      expect(cask.call.language).to eq("zh-CN") +      expect(cask.call.sha256).to eq("abc123") +      expect(cask.call.url.to_s).to eq("https://example.org/zh-CN.zip") + +      allow(MacOS).to receive(:languages).and_return(["zh-XX"]) +      expect(cask.call.language).to eq("zh-CN") +      expect(cask.call.sha256).to eq("abc123") +      expect(cask.call.url.to_s).to eq("https://example.org/zh-CN.zip") + +      allow(MacOS).to receive(:languages).and_return(["en"]) +      expect(cask.call.language).to eq("en-US") +      expect(cask.call.sha256).to eq("xyz789") +      expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip") + +      allow(MacOS).to receive(:languages).and_return(["xx-XX"]) +      expect(cask.call.language).to eq("en-US") +      expect(cask.call.sha256).to eq("xyz789") +      expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip") + +      allow(MacOS).to receive(:languages).and_return(["xx-XX", "zh", "en"]) +      expect(cask.call.language).to eq("zh-CN") +      expect(cask.call.sha256).to eq("abc123") +      expect(cask.call.url.to_s).to eq("https://example.org/zh-CN.zip") + +      allow(MacOS).to receive(:languages).and_return(["xx-XX", "en-US", "zh"]) +      expect(cask.call.language).to eq("en-US") +      expect(cask.call.sha256).to eq("xyz789") +      expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip") +    end +  end + +  describe "app stanza" do +    it "allows you to specify app stanzas" do +      cask = Hbc::Cask.new("cask-with-apps") do +        app "Foo.app" +        app "Bar.app" +      end + +      expect(Array(cask.artifacts[:app])).to eq([["Foo.app"], ["Bar.app"]]) +    end + +    it "allow app stanzas to be empty" do +      cask = Hbc::Cask.new("cask-with-no-apps") +      expect(Array(cask.artifacts[:app])).to eq([]) +    end +  end + +  describe "caveats stanza" do +    it "allows caveats to be specified via a method define" do +      cask = Hbc::Cask.new("plain-cask") + +      expect(cask.caveats).to be_empty + +      cask = Hbc::Cask.new("cask-with-caveats") do +        def caveats; <<-EOS.undent +          When you install this Cask, you probably want to know this. +          EOS +        end +      end + +      expect(cask.caveats).to eq("When you install this Cask, you probably want to know this.\n") +    end +  end + +  describe "pkg stanza" do +    it "allows installable pkgs to be specified" do +      cask = Hbc::Cask.new("cask-with-pkgs") do +        pkg "Foo.pkg" +        pkg "Bar.pkg" +      end + +      expect(Array(cask.artifacts[:pkg])).to eq([["Foo.pkg"], ["Bar.pkg"]]) +    end +  end + +  describe "url stanza" do +    let(:token) { "invalid/invalid-two-url" } + +    it "prevents defining multiple urls" do +      expect { cask }.to raise_error(Hbc::CaskInvalidError, /'url' stanza may only appear once/) +    end +  end + +  describe "homepage stanza" do +    let(:token) { "invalid/invalid-two-homepage" } + +    it "prevents defining multiple homepages" do +      expect { cask }.to raise_error(Hbc::CaskInvalidError, /'homepage' stanza may only appear once/) +    end +  end + +  describe "version stanza" do +    let(:token) { "invalid/invalid-two-version" } +    it "prevents defining multiple versions" do +      expect { cask }.to raise_error(Hbc::CaskInvalidError, /'version' stanza may only appear once/) +    end +  end + +  describe "appcast stanza" do +    let(:token) { "with-appcast" } + +    it "allows appcasts to be specified" do +      expect(cask.appcast.to_s).to match(/^http/) +    end + +    context "when multiple appcasts are defined" do +      let(:token) { "invalid/invalid-appcast-multiple" } + +      it "raises an error" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError, /'appcast' stanza may only appear once/) +      end +    end + +    context "when appcast URL is invalid" do +      let(:token) { "invalid/invalid-appcast-url" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError) +      end +    end +  end + +  describe "GPG stanza" do +    context "valid" do +      let(:token) { "with-gpg" } + +      it "is allowed to be specified" do +        expect(cask.gpg.to_s).to match(/\S/) +      end +    end + +    context "with :key_url" do +      let(:token) { "with-gpg-key-url" } +      it "is allowed to be specified" do +        expect(cask.gpg.to_s).to match(/\S/) +      end +    end + +    context "specifying mmultiple times" do +      let(:token) { "invalid/invalid-gpg-multiple-stanzas" } + +      it "is not allowed" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError, /'gpg' stanza may only appear once/) +      end +    end + +    context "missing GPG key parameters" do +      let(:token) { "invalid/invalid-gpg-missing-key" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError, /'gpg' stanza must include exactly one/) +      end +    end + +    context "conflicting GPG key parameters" do +      let(:token) { "invalid/invalid-gpg-conflicting-keys" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError, /'gpg' stanza must include exactly one/) +      end +    end + +    context "invalid GPG signature URLs" do +      let(:token) { "invalid/invalid-gpg-signature-url" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError) +      end +    end + +    context "invalid GPG key URLs" do +      let(:token) { "invalid/invalid-gpg-key-url" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError) +      end +    end + +    context "invalid GPG key IDs" do +      let(:token) { "invalid/invalid-gpg-key-id" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError) +      end +    end + +    context "GPG parameter is unknown" do +      let(:token) { "invalid/invalid-gpg-parameter" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError) +      end +    end +  end + +  describe "depends_on stanza" do +    let(:token) { "invalid/invalid-depends-on-key" } + +    it "refuses to load with an invalid depends_on key" do +      expect { cask }.to raise_error(Hbc::CaskInvalidError) +    end +  end + +  describe "depends_on formula" do +    context "with one Formula" do +      let(:token) { "with-depends-on-formula" } + +      it "allows depends_on formula to be specified" do +        expect(cask.depends_on.formula).not_to be nil +      end +    end + +    context "with multiple Formulae" do +      let(:token) { "with-depends-on-formula-multiple" } + +      it "allows multiple depends_on formula to be specified" do +        expect(cask.depends_on.formula).not_to be nil +      end +    end +  end + +  describe "depends_on cask" do +    context "specifying one" do +      let(:token) { "with-depends-on-cask" } +      it "is allowed" do +        expect(cask.depends_on.cask).not_to be nil +      end +    end + +    context "specifying multiple" do +      let(:token) { "with-depends-on-cask-multiple" } + +      it "is allowed" do +        expect(cask.depends_on.cask).not_to be nil +      end +    end +  end + +  describe "depends_on macos" do +    context "valid" do +      let(:token) { "with-depends-on-macos-string" } + +      it "allows depends_on macos to be specified" do +        expect(cask.depends_on.macos).not_to be nil +      end +    end + +    context "invalid depends_on macos value" do +      let(:token) { "invalid/invalid-depends-on-macos-bad-release" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError) +      end +    end + +    context "conflicting depends_on macos forms" do +      let(:token) { "invalid/invalid-depends-on-macos-conflicting-forms" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError) +      end +    end +  end + +  describe "depends_on arch" do +    context "valid" do +      let(:token) { "with-depends-on-arch" } + +      it "is allowed to be specified" do +        expect(cask.depends_on.arch).not_to be nil +      end +    end + +    context "invalid depends_on arch value" do +      let(:token) { "invalid/invalid-depends-on-arch-value" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError) +      end +    end +  end + +  describe "depends_on x11" do +    context "valid" do +      let(:token) { "with-depends-on-x11" } + +      it "is allowed to be specified" do +        expect(cask.depends_on.x11).not_to be nil +      end +    end + +    context "invalid depends_on x11 value" do +      let(:token) { "invalid/invalid-depends-on-x11-value" } + +      it "refuses to load" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError) +      end +    end +  end + +  describe "conflicts_with stanza" do +    context "valid" do +      let(:token) { "with-conflicts-with" } + +      it "allows conflicts_with stanza to be specified" do +        expect(cask.conflicts_with.formula).not_to be nil +      end +    end + +    context "invalid conflicts_with key" do +      let(:token) { "invalid/invalid-conflicts-with-key" } + +      it "refuses to load invalid conflicts_with key" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError) +      end +    end +  end + +  describe "installer stanza" do +    context "script" do +      let(:token) { "with-installer-script" } + +      it "allows installer script to be specified" do +        expect(cask.artifacts[:installer].first.script[:executable]).to eq("/usr/bin/true") +        expect(cask.artifacts[:installer].first.script[:args]).to eq(["--flag"]) +        expect(cask.artifacts[:installer].to_a[1].script[:executable]).to eq("/usr/bin/false") +        expect(cask.artifacts[:installer].to_a[1].script[:args]).to eq(["--flag"]) +      end +    end + +    context "manual" do +      let(:token) { "with-installer-manual" } + +      it "allows installer manual to be specified" do +        expect(cask.artifacts[:installer].first.manual).to eq("Caffeine.app") +      end +    end +  end + +  describe "stage_only stanza" do +    context "when there is no other activatable artifact" do +      let(:token) { "stage-only" } + +      it "allows stage_only stanza to be specified" do +        expect(cask.artifacts[:stage_only].first).to eq([true]) +      end +    end + +    context "when there is are activatable artifacts" do +      let(:token) { "invalid/invalid-stage-only-conflict" } + +      it "prevents specifying stage_only" do +        expect { cask }.to raise_error(Hbc::CaskInvalidError, /'stage_only' must be the only activatable artifact/) +      end +    end +  end + +  describe "auto_updates stanza" do +    let(:token) { "auto-updates" } + +    it "allows auto_updates stanza to be specified" do +      expect(cask.auto_updates).to be true +    end +  end + +  describe "appdir" do +    context "interpolation of the appdir in stanzas" do +      let(:token) { "appdir-interpolation" } + +      it "is allowed" do +        expect(cask.artifacts[:binary].first).to eq(["#{Hbc.appdir}/some/path"]) +      end +    end + +    it "does not include a trailing slash" do +      begin +        original_appdir = Hbc.appdir +        Hbc.appdir = "#{original_appdir}/" + +        cask = Hbc::Cask.new("appdir-trailing-slash") do +          binary "#{appdir}/some/path" +        end + +        expect(cask.artifacts[:binary].first).to eq(["#{original_appdir}/some/path"]) +      ensure +        Hbc.appdir = original_appdir +      end +    end +  end +end diff --git a/Library/Homebrew/cask/spec/cask/installer_spec.rb b/Library/Homebrew/cask/spec/cask/installer_spec.rb new file mode 100644 index 000000000..c0148c387 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/installer_spec.rb @@ -0,0 +1,398 @@ +require "spec_helper" + +describe Hbc::Installer do +  describe "install" do +    let(:empty_depends_on_stub) { +      double(formula: [], cask: [], macos: nil, arch: nil, x11: nil) +    } + +    it "downloads and installs a nice fresh Cask" do +      caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + +      shutup do +        Hbc::Installer.new(caffeine).install +      end + +      expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory +      expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory +    end + +    it "works with dmg-based Casks" do +      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-dmg.rb") + +      shutup do +        Hbc::Installer.new(asset).install +      end + +      expect(Hbc.caskroom.join("container-dmg", asset.version)).to be_a_directory +      expect(Hbc.appdir.join("container")).to be_a_file +    end + +    it "works with tar-gz-based Casks" do +      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-tar-gz.rb") + +      shutup do +        Hbc::Installer.new(asset).install +      end + +      expect(Hbc.caskroom.join("container-tar-gz", asset.version)).to be_a_directory +      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") + +      shutup do +        Hbc::Installer.new(asset).install +      end + +      expect(Hbc.caskroom.join("container-xar", asset.version)).to be_a_directory +      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") + +      shutup do +        Hbc::Installer.new(asset).install +      end + +      expect(Hbc.caskroom.join("container-bzip2", asset.version)).to be_a_directory +      expect(Hbc.appdir.join("container-bzip2--#{asset.version}")).to be_a_file +    end + +    it "works with pure gzip-based Casks" do +      asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-gzip.rb") + +      shutup do +        Hbc::Installer.new(asset).install +      end + +      expect(Hbc.caskroom.join("container-gzip", asset.version)).to be_a_directory +      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 "blows up on a bad checksum" do +      bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb") +      expect { +        shutup do +          Hbc::Installer.new(bad_checksum).install +        end +      }.to raise_error(Hbc::CaskSha256MismatchError) +    end + +    it "blows up on a missing checksum" do +      missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb") +      expect { +        shutup do +          Hbc::Installer.new(missing_checksum).install +        end +      }.to raise_error(Hbc::CaskSha256MissingError) +    end + +    it "installs fine if sha256 :no_check is used" do +      no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") + +      shutup do +        Hbc::Installer.new(no_checksum).install +      end + +      expect(no_checksum).to be_installed +    end + +    it "fails to install if sha256 :no_check is used with --require-sha" do +      no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") +      expect { +        Hbc::Installer.new(no_checksum, require_sha: true).install +      }.to raise_error(Hbc::CaskNoShasumError) +    end + +    it "installs fine if sha256 :no_check is used with --require-sha and --force" do +      no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") + +      shutup do +        Hbc::Installer.new(no_checksum, require_sha: true, force: true).install +      end + +      expect(no_checksum).to be_installed +    end + +    it "prints caveats if they're present" do +      with_caveats = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-caveats.rb") + +      expect { +        Hbc::Installer.new(with_caveats).install +      }.to output(/Here are some things you might want to know/).to_stdout + +      expect(with_caveats).to be_installed +    end + +    it "prints installer :manual instructions when present" do +      with_installer_manual = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb") + +      expect { +        Hbc::Installer.new(with_installer_manual).install +      }.to output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n  '#{with_installer_manual.staged_path.join('Caffeine.app')}'/).to_stdout + +      expect(with_installer_manual).to be_installed +    end + +    it "does not extract __MACOSX directories from zips" do +      with_macosx_dir = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-macosx-dir.rb") + +      shutup do +        Hbc::Installer.new(with_macosx_dir).install +      end + +      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") + +      expect(with_auto_updates).not_to be_installed + +      shutup do +        Hbc::Installer.new(with_auto_updates).install +      end + +      expect { +        shutup do +          Hbc::Installer.new(with_auto_updates, force: true).install +        end +      }.not_to raise_error +    end + +    # unlike the CLI, the internal interface throws exception on double-install +    it "installer method raises an exception when already-installed Casks are attempted" do +      transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + +      expect(transmission).not_to be_installed + +      installer = Hbc::Installer.new(transmission) + +      shutup do +        installer.install +      end + +      expect { +        installer.install +      }.to raise_error(Hbc::CaskAlreadyInstalledError) +    end + +    it "allows already-installed Casks to be installed if force is provided" do +      transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + +      expect(transmission).not_to be_installed + +      shutup do +        Hbc::Installer.new(transmission).install +      end + +      shutup do +        Hbc::Installer.new(transmission, force: true).install +      end # wont_raise +    end + +    it "works naked-pkg-based Casks" do +      naked_pkg = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-pkg.rb") + +      shutup do +        Hbc::Installer.new(naked_pkg).install +      end + +      expect(Hbc.caskroom.join("container-pkg", naked_pkg.version, "container.pkg")).to be_a_file +    end + +    it "works properly with an overridden container :type" do +      naked_executable = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/naked-executable.rb") + +      shutup do +        Hbc::Installer.new(naked_executable).install +      end + +      expect(Hbc.caskroom.join("naked-executable", naked_executable.version, "naked_executable")).to be_a_file +    end + +    it "works fine with a nested container" do +      nested_app = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb") + +      shutup do +        Hbc::Installer.new(nested_app).install +      end + +      expect(Hbc.appdir.join("MyNestedApp.app")).to be_a_directory +    end + +    it "generates and finds a timestamped metadata directory for an installed Cask" do +      caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + +      shutup do +        Hbc::Installer.new(caffeine).install +      end + +      m_path = caffeine.metadata_path(:now, true) +      expect(caffeine.metadata_path(:now, false)).to eq(m_path) +      expect(caffeine.metadata_path(:latest)).to eq(m_path) +    end + +    it "generates and finds a metadata subdirectory for an installed Cask" do +      caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + +      shutup do +        Hbc::Installer.new(caffeine).install +      end + +      subdir_name = "Casks" +      m_subdir = caffeine.metadata_subdir(subdir_name, :now, true) +      expect(caffeine.metadata_subdir(subdir_name, :now, false)).to eq(m_subdir) +      expect(caffeine.metadata_subdir(subdir_name, :latest)).to eq(m_subdir) +    end +  end + +  describe "uninstall" do +    it "fully uninstalls a Cask" do +      caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") +      installer = Hbc::Installer.new(caffeine) + +      shutup do +        installer.install +        installer.uninstall +      end + +      expect(Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app")).not_to be_a_directory +      expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory +      expect(Hbc.caskroom.join("local-caffeine")).not_to be_a_directory +    end + +    it "uninstalls all versions if force is set" do +      caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") +      mutated_version = caffeine.version + ".1" + +      shutup do +        Hbc::Installer.new(caffeine).install +      end + +      expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory +      expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory +      FileUtils.mv(Hbc.caskroom.join("local-caffeine", caffeine.version), Hbc.caskroom.join("local-caffeine", mutated_version)) +      expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory +      expect(Hbc.caskroom.join("local-caffeine", mutated_version)).to be_a_directory + +      shutup do +        Hbc::Installer.new(caffeine, force: true).uninstall +      end + +      expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory +      expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory +      expect(Hbc.caskroom.join("local-caffeine")).not_to be_a_directory +    end +  end +end diff --git a/Library/Homebrew/cask/spec/cask/pkg_spec.rb b/Library/Homebrew/cask/spec/cask/pkg_spec.rb new file mode 100644 index 000000000..2f0ba0839 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/pkg_spec.rb @@ -0,0 +1,114 @@ +require "spec_helper" + +describe Hbc::Pkg do +  describe "uninstall" do +    let(:fake_system_command) { Hbc::NeverSudoSystemCommand } +    let(:empty_response) { double(stdout: "") } +    let(:pkg) { described_class.new("my.fake.pkg", fake_system_command) } + +    it "removes files and dirs referenced by the pkg" do +      some_files = Array.new(3) { Pathname.new(Tempfile.new("testfile").path) } +      allow(pkg).to receive(:pkgutil_bom_files).and_return(some_files) + +      some_specials = Array.new(3) { Pathname.new(Tempfile.new("testfile").path) } +      allow(pkg).to receive(:pkgutil_bom_specials).and_return(some_specials) + +      some_dirs = Array.new(3) { Pathname.new(Dir.mktmpdir) } +      allow(pkg).to receive(:pkgutil_bom_dirs).and_return(some_dirs) + +      allow(pkg).to receive(:forget) + +      pkg.uninstall + +      some_files.each do |file| +        expect(file).not_to exist +      end + +      some_dirs.each do |dir| +        expect(dir).not_to exist +      end +    end + +    context "pkgutil" do +      let(:fake_system_command) { class_double(Hbc::SystemCommand) } + +      it "forgets the pkg" do +        allow(fake_system_command).to receive(:run!).with( +          "/usr/sbin/pkgutil", +          args: ["--only-files", "--files", "my.fake.pkg"] +        ).and_return(empty_response) + +        allow(fake_system_command).to receive(:run!).with( +          "/usr/sbin/pkgutil", +          args: ["--only-dirs", "--files", "my.fake.pkg"] +        ).and_return(empty_response) + +        allow(fake_system_command).to receive(:run!).with( +          "/usr/sbin/pkgutil", +          args: ["--files", "my.fake.pkg"] +        ).and_return(empty_response) + +        expect(fake_system_command).to receive(:run!).with( +          "/usr/sbin/pkgutil", +          args: ["--forget", "my.fake.pkg"], +          sudo: true +        ) + +        pkg.uninstall +      end +    end + +    it "removes broken symlinks" do +      fake_dir  = Pathname.new(Dir.mktmpdir) +      fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) } + +      intact_symlink = fake_dir.join("intact_symlink").tap { |path| path.make_symlink(fake_file) } +      broken_symlink = fake_dir.join("broken_symlink").tap { |path| path.make_symlink("im_nota_file") } + +      allow(pkg).to receive(:pkgutil_bom_specials).and_return([]) +      allow(pkg).to receive(:pkgutil_bom_files).and_return([]) +      allow(pkg).to receive(:pkgutil_bom_dirs).and_return([fake_dir]) +      allow(pkg).to receive(:forget) + +      pkg.uninstall + +      expect(intact_symlink).to exist +      expect(broken_symlink).not_to exist +      expect(fake_dir).to exist +    end + +    it "removes files incorrectly reportes as directories" do +      fake_dir  = Pathname.new(Dir.mktmpdir) +      fake_file = fake_dir.join("ima_file_pretending_to_be_a_dir").tap { |path| FileUtils.touch(path) } + +      allow(pkg).to receive(:pkgutil_bom_specials).and_return([]) +      allow(pkg).to receive(:pkgutil_bom_files).and_return([]) +      allow(pkg).to receive(:pkgutil_bom_dirs).and_return([fake_file, fake_dir]) +      allow(pkg).to receive(:forget) + +      pkg.uninstall + +      expect(fake_file).not_to exist +      expect(fake_dir).not_to exist +    end + +    it "snags permissions on ornery dirs, but returns them afterwards" do +      fake_dir = Pathname.new(Dir.mktmpdir) +      fake_file = fake_dir.join("ima_installed_file").tap { |path| FileUtils.touch(path) } +      fake_dir.chmod(0000) + +      allow(pkg).to receive(:pkgutil_bom_specials).and_return([]) +      allow(pkg).to receive(:pkgutil_bom_files).and_return([fake_file]) +      allow(pkg).to receive(:pkgutil_bom_dirs).and_return([fake_dir]) +      allow(pkg).to receive(:forget) + +      shutup do +        pkg.uninstall +      end + +      expect(fake_dir).to be_a_directory +      expect(fake_file).not_to be_a_file +      expect((fake_dir.stat.mode % 01000).to_s(8)).to eq("0") +    end +  end +end diff --git a/Library/Homebrew/cask/spec/cask/scopes_spec.rb b/Library/Homebrew/cask/spec/cask/scopes_spec.rb index 12c1a697f..abf4b6401 100644 --- a/Library/Homebrew/cask/spec/cask/scopes_spec.rb +++ b/Library/Homebrew/cask/spec/cask/scopes_spec.rb @@ -1,39 +1,31 @@  describe Hbc::Scopes do    describe "installed" do -    let(:fake_caskroom) { Pathname(Dir.mktmpdir) } - -    before do -      allow(Hbc).to receive(:caskroom) { fake_caskroom } -    end - -    after do -      fake_caskroom.rmtree -    end -      it "returns a list installed Casks by loading Casks for all the dirs that exist in the caskroom" do        allow(Hbc).to receive(:load) { |token| "loaded-#{token}" } -      fake_caskroom.join("cask-bar").mkdir -      fake_caskroom.join("cask-foo").mkdir +      Hbc.caskroom.join("cask-bar").mkpath +      Hbc.caskroom.join("cask-foo").mkpath        installed_casks = Hbc.installed        expect(Hbc).to have_received(:load).with("cask-bar")        expect(Hbc).to have_received(:load).with("cask-foo") -      expect(installed_casks).to eq(%w[ -                                      loaded-cask-bar -                                      loaded-cask-foo -                                    ]) +      expect(installed_casks).to eq( +        %w[ +          loaded-cask-bar +          loaded-cask-foo +        ] +      )      end      it "optimizes performance by resolving to a fully qualified path before calling Hbc.load" do -      fake_tapped_cask_dir = Pathname(Dir.mktmpdir).join("Casks") +      fake_tapped_cask_dir = Pathname.new(Dir.mktmpdir).join("Casks")        absolute_path_to_cask = fake_tapped_cask_dir.join("some-cask.rb")        allow(Hbc).to receive(:load)        allow(Hbc).to receive(:all_tapped_cask_dirs) { [fake_tapped_cask_dir] } -      fake_caskroom.join("some-cask").mkdir +      Hbc.caskroom.join("some-cask").mkdir        fake_tapped_cask_dir.mkdir        FileUtils.touch(absolute_path_to_cask) diff --git a/Library/Homebrew/cask/test/cask/staged_test.rb b/Library/Homebrew/cask/spec/cask/staged_spec.rb index fe3bf2339..10f1cbb47 100644 --- a/Library/Homebrew/cask/test/cask/staged_test.rb +++ b/Library/Homebrew/cask/spec/cask/staged_spec.rb @@ -1,18 +1,18 @@ -require "test_helper" +require "spec_helper"  # TODO: this test should be named after the corresponding class, once  #       that class is abstracted from installer.rb.  It makes little sense  #       to be invoking bundle_identifier off of the installer instance.  describe "Operations on staged Casks" do    describe "bundle ID" do +    let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") } +    let(:installer) { Hbc::Installer.new(cask) }      it "fetches the bundle ID from a staged cask" do -      transmission_cask = Hbc.load("local-transmission") -      tr_installer = Hbc::Installer.new(transmission_cask) -        shutup do -        tr_installer.install +        installer.install        end -      tr_installer.bundle_identifier.must_equal("org.m0k.transmission") + +      expect(installer.bundle_identifier).to eq("org.m0k.transmission")      end    end  end diff --git a/Library/Homebrew/cask/spec/cask/url_checker_spec.rb b/Library/Homebrew/cask/spec/cask/url_checker_spec.rb new file mode 100644 index 000000000..3b46bc587 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/url_checker_spec.rb @@ -0,0 +1,44 @@ +require "spec_helper" + +describe Hbc::UrlChecker do +  describe "request processing" do +    let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } +    let(:checker) { Hbc::UrlChecker.new(cask) } + +    before(:each) do +      allow(Hbc::Fetcher).to receive(:head).and_return(response) +      checker.run +    end + +    context "with an empty response" do +      let(:response) { "" } + +      it "adds an error" do +        expect(checker.errors).to include("timeout while requesting #{cask.url}") +      end +    end + +    context "with a valid http response" do +      let(:response) { +        <<-EOS.undent +          HTTP/1.1 200 OK +          Content-Type: application/x-apple-diskimage +          ETag: "b4208f3e84967be4b078ecaa03fba941" +          Content-Length: 23726161 +          Last-Modified: Sun, 12 Aug 2012 21:17:21 GMT +        EOS +      } + +      it "properly populates the response code and headers" do +        expect(checker.errors).to be_empty +        expect(checker.response_status).to eq("HTTP/1.1 200 OK") +        expect(checker.headers).to eq( +          "Content-Type"   => "application/x-apple-diskimage", +          "ETag"           => '"b4208f3e84967be4b078ecaa03fba941"', +          "Content-Length" => "23726161", +          "Last-Modified"  => "Sun, 12 Aug 2012 21:17:21 GMT" +        ) +      end +    end +  end +end diff --git a/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb b/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb index a379dafb9..d803c566d 100644 --- a/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb +++ b/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb @@ -1,6 +1,4 @@  describe Hbc::Verify::Checksum do -  include Sha256Helper -    let(:cask) { double("cask") }    let(:downloaded_path) { double("downloaded_path") }    let(:verification) { described_class.new(cask, downloaded_path) } @@ -35,7 +33,7 @@ describe Hbc::Verify::Checksum do      end      context "sha256 is a valid shasum" do -      let(:sha256) { random_sha256 } +      let(:sha256) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" }        it { is_expected.to be true }      end @@ -44,7 +42,7 @@ describe Hbc::Verify::Checksum do    describe "#verify" do      subject { verification.verify } -    let(:computed) { random_sha256 } +    let(:computed) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" }      before do        allow(verification).to receive(:computed).and_return(computed) @@ -67,7 +65,7 @@ describe Hbc::Verify::Checksum do      end      context "sha256 does not match computed" do -      let(:sha256) { random_sha256 } +      let(:sha256) { "d3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33f" }        it "raises an error" do          expect { subject }.to raise_error(Hbc::CaskSha256MismatchError) diff --git a/Library/Homebrew/cask/spec/plist/parser_spec.rb b/Library/Homebrew/cask/spec/plist/parser_spec.rb new file mode 100644 index 000000000..9d4a59fdc --- /dev/null +++ b/Library/Homebrew/cask/spec/plist/parser_spec.rb @@ -0,0 +1,75 @@ +require "spec_helper" + +describe Plist do +  subject { described_class.parse_xml(input) } + +  describe "::parse_xml" do +    context "given a hdiutil output as input" do +      let(:input) { +        <<-EOS.undent +          <?xml version="1.0" encoding="UTF-8"?> +          <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +          <plist version="1.0"> +          <dict> +            <key>system-entities</key> +            <array> +              <dict> +                <key>content-hint</key> +                <string>Apple_partition_map</string> +                <key>dev-entry</key> +                <string>/dev/disk3s1</string> +                <key>potentially-mountable</key> +                <false/> +                <key>unmapped-content-hint</key> +                <string>Apple_partition_map</string> +              </dict> +              <dict> +                <key>content-hint</key> +                <string>Apple_partition_scheme</string> +                <key>dev-entry</key> +                <string>/dev/disk3</string> +                <key>potentially-mountable</key> +                <false/> +                <key>unmapped-content-hint</key> +                <string>Apple_partition_scheme</string> +              </dict> +              <dict> +                <key>content-hint</key> +                <string>Apple_HFS</string> +                <key>dev-entry</key> +                <string>/dev/disk3s2</string> +                <key>mount-point</key> +                <string>/private/tmp/dmg.BhfS2g</string> +                <key>potentially-mountable</key> +                <true/> +                <key>unmapped-content-hint</key> +                <string>Apple_HFS</string> +                <key>volume-kind</key> +                <string>hfs</string> +              </dict> +            </array> +          </dict> +          </plist> +        EOS +      } + +      it "successfully parses it" do +        expect(subject.keys).to eq(["system-entities"]) +        expect(subject["system-entities"].length).to eq(3) +        expect(subject["system-entities"].map { |e| e["dev-entry"] }).to eq( +          %w[ +            /dev/disk3s1 +            /dev/disk3 +            /dev/disk3s2 +          ] +        ) +      end +    end + +    context "given an empty input" do +      let(:input) { "" } + +      it { is_expected.to be_nil } +    end +  end +end diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index 458fe00f4..ea6a87f41 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -15,17 +15,12 @@ require "global"  # add Homebrew-Cask to load path  $LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s) -require "test/support/helper/env"  require "test/support/helper/shutup" -Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).each(&method(:require)) +Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "**", "*.rb")).each(&method(:require))  require "hbc" -module Hbc -  class TestCask < Cask; end -end -  # create and override default directories  Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath)  Hbc.cache.mkpath @@ -33,11 +28,42 @@ Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath)  Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|    # link test casks    FileUtils.mkdir_p tap.path.dirname -  FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), tap.path +  FileUtils.ln_s TEST_FIXTURE_DIR.join("cask"), tap.path  end +# pretend that the caskroom/cask Tap is installed +FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path + +HOMEBREW_CASK_DIRS = [ +  :appdir, +  :caskroom, +  :prefpanedir, +  :qlplugindir, +  :servicedir, +  :binarydir, +].freeze +  RSpec.configure do |config|    config.order = :random -  config.include(Test::Helper::Env)    config.include(Test::Helper::Shutup) +  config.around(:each) do |example| +    begin +      @__dirs = HOMEBREW_CASK_DIRS.map { |dir| +        Pathname.new(TEST_TMPDIR).join(dir.to_s).tap { |path| +          path.mkpath +          Hbc.public_send("#{dir}=", path) +        } +      } + +      @__argv = ARGV.dup +      @__env = ENV.to_hash # dup doesn't work on ENV + +      example.run +    ensure +      ARGV.replace(@__argv) +      ENV.replace(@__env) + +      FileUtils.rm_rf @__dirs.map(&:children) +    end +  end  end diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-checkpoint-sha256-for-empty-string.rb b/Library/Homebrew/cask/spec/support/Casks/appcast-checkpoint-sha256-for-empty-string.rb deleted file mode 100644 index f40f244f2..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/appcast-checkpoint-sha256-for-empty-string.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'appcast-checkpoint-sha256-for-empty-string' do -  appcast 'http://localhost/appcast.xml', -          checkpoint: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-invalid-checkpoint.rb b/Library/Homebrew/cask/spec/support/Casks/appcast-invalid-checkpoint.rb deleted file mode 100644 index e182c2389..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/appcast-invalid-checkpoint.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'appcast-invalid-checkpoint' do -  appcast 'http://localhost/appcast.xml', -          checkpoint: 'not a valid shasum' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-missing-checkpoint.rb b/Library/Homebrew/cask/spec/support/Casks/appcast-missing-checkpoint.rb deleted file mode 100644 index 5ab2c0665..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/appcast-missing-checkpoint.rb +++ /dev/null @@ -1,3 +0,0 @@ -test_cask 'appcast-missing-checkpoint' do -  appcast 'http://localhost/appcast.xml' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-valid-checkpoint.rb b/Library/Homebrew/cask/spec/support/Casks/appcast-valid-checkpoint.rb deleted file mode 100644 index 96d7edbba..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/appcast-valid-checkpoint.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'appcast-valid-checkpoint' do -  appcast 'http://localhost/appcast.xml', -          checkpoint: 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/booby-trap.rb b/Library/Homebrew/cask/spec/support/Casks/booby-trap.rb deleted file mode 100644 index 21bd97952..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/booby-trap.rb +++ /dev/null @@ -1,8 +0,0 @@ -cask 'booby-trap' do -  version '0.0.7' - -  url do -    # to be lazily evaluated -    fail 'Boom' -  end -end diff --git a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-absolute-target.rb b/Library/Homebrew/cask/spec/support/Casks/generic-artifact-absolute-target.rb deleted file mode 100644 index 475fb055f..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-absolute-target.rb +++ /dev/null @@ -1,3 +0,0 @@ -test_cask 'generic-artifact-absolute-target' do -  artifact 'Caffeine.app', target: "#{Hbc.appdir}/Caffeine.app" -end diff --git a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb b/Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb deleted file mode 100644 index f7657dbb5..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb +++ /dev/null @@ -1,3 +0,0 @@ -test_cask 'generic-artifact-no-target' do -  artifact 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-relative-target.rb b/Library/Homebrew/cask/spec/support/Casks/generic-artifact-relative-target.rb deleted file mode 100644 index f97441751..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-relative-target.rb +++ /dev/null @@ -1,3 +0,0 @@ -test_cask 'generic-artifact-relative-target' do -  artifact 'Caffeine.app', target: 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/invalid-sha256.rb b/Library/Homebrew/cask/spec/support/Casks/invalid-sha256.rb deleted file mode 100644 index aac00f495..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/invalid-sha256.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'invalid-sha256' do -  version '1.2.3' -  sha256 'not a valid shasum' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-homepage.rb b/Library/Homebrew/cask/spec/support/Casks/missing-homepage.rb deleted file mode 100644 index ff924541d..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-homepage.rb +++ /dev/null @@ -1,5 +0,0 @@ -test_cask 'missing-homepage' do -  version '1.2.3' - -  url 'http://localhost/something.dmg' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-name.rb b/Library/Homebrew/cask/spec/support/Casks/missing-name.rb deleted file mode 100644 index a5265b379..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-name.rb +++ /dev/null @@ -1,5 +0,0 @@ -test_cask 'missing-name' do -  version '1.2.3' - -  url 'http://localhost/something.dmg' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-sha256.rb b/Library/Homebrew/cask/spec/support/Casks/missing-sha256.rb deleted file mode 100644 index 7f8027907..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-sha256.rb +++ /dev/null @@ -1,5 +0,0 @@ -test_cask 'missing-sha256' do -  version '1.2.3' - -  url 'http://localhost/something.dmg' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-url.rb b/Library/Homebrew/cask/spec/support/Casks/missing-url.rb deleted file mode 100644 index 1b3e76b9c..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-url.rb +++ /dev/null @@ -1,5 +0,0 @@ -test_cask 'missing-url' do -  version '1.2.3' - -  homepage 'http://example.com' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-version.rb b/Library/Homebrew/cask/spec/support/Casks/missing-version.rb deleted file mode 100644 index da2160bce..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-version.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'missing-version' do -  url 'http://localhost/something.dmg' -  homepage 'http://example.com' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/osdn-correct-url-format.rb b/Library/Homebrew/cask/spec/support/Casks/osdn-correct-url-format.rb deleted file mode 100644 index da6ff0fcd..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/osdn-correct-url-format.rb +++ /dev/null @@ -1,6 +0,0 @@ -test_cask 'osdn-correct-url-format' do -  version '1.2.3' - -  url 'http://user.dl.osdn.jp/something/id/Something-1.2.3.dmg' -  homepage 'http://osdn.jp/projects/something/' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/osdn-incorrect-url-format.rb b/Library/Homebrew/cask/spec/support/Casks/osdn-incorrect-url-format.rb deleted file mode 100644 index 8400159a1..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/osdn-incorrect-url-format.rb +++ /dev/null @@ -1,6 +0,0 @@ -test_cask 'osdn-incorrect-url-format' do -  version '1.2.3' - -  url 'http://osdn.jp/projects/something/files/Something-1.2.3.dmg/download' -  homepage 'http://osdn.jp/projects/something/' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/sha256-for-empty-string.rb b/Library/Homebrew/cask/spec/support/Casks/sha256-for-empty-string.rb deleted file mode 100644 index b97764071..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/sha256-for-empty-string.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'sha256-for-empty-string' do -  version '1.2.3' -  sha256 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/sourceforge-correct-url-format.rb b/Library/Homebrew/cask/spec/support/Casks/sourceforge-correct-url-format.rb deleted file mode 100644 index 41ef73500..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/sourceforge-correct-url-format.rb +++ /dev/null @@ -1,6 +0,0 @@ -test_cask 'sourceforge-correct-url-format' do -  version '1.2.3' - -  url 'https://downloads.sourceforge.net/something/Something-1.2.3.dmg' -  homepage 'https://sourceforge.net/projects/something/' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/sourceforge-incorrect-url-format.rb b/Library/Homebrew/cask/spec/support/Casks/sourceforge-incorrect-url-format.rb deleted file mode 100644 index 27b5490b7..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/sourceforge-incorrect-url-format.rb +++ /dev/null @@ -1,6 +0,0 @@ -test_cask 'sourceforge-incorrect-url-format' do -  version '1.2.3' - -  url 'http://sourceforge.net/projects/something/files/Something-1.2.3.dmg/download' -  homepage 'http://sourceforge.net/projects/something/' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/sourceforge-version-latest-correct-url-format.rb b/Library/Homebrew/cask/spec/support/Casks/sourceforge-version-latest-correct-url-format.rb deleted file mode 100644 index d9546c5e1..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/sourceforge-version-latest-correct-url-format.rb +++ /dev/null @@ -1,6 +0,0 @@ -test_cask 'sourceforge-version-latest-correct-url-format' do -  version :latest - -  url 'https://sourceforge.net/projects/something/files/latest/download' -  homepage 'https://sourceforge.net/projects/something/' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/version-latest-string.rb b/Library/Homebrew/cask/spec/support/Casks/version-latest-string.rb deleted file mode 100644 index 3b4723f45..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/version-latest-string.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'version-latest-string' do -  version 'latest' -  sha256 :no_check -end diff --git a/Library/Homebrew/cask/spec/support/Casks/version-latest-with-checksum.rb b/Library/Homebrew/cask/spec/support/Casks/version-latest-with-checksum.rb deleted file mode 100644 index 884ddff90..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/version-latest-with-checksum.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'version-latest-with-checksum' do -  version :latest -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/with-binary.rb b/Library/Homebrew/cask/spec/support/Casks/with-binary.rb deleted file mode 100644 index d8cede7aa..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/with-binary.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-binary' do -  version '1.2.3' -  sha256 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2' - -  url "file://#{TEST_FIXTURE_DIR}/cask/AppWithBinary.zip" -  homepage 'http://example.com/with-binary' - -  app 'App.app' -  binary 'binary' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/with-embedded-binary.rb b/Library/Homebrew/cask/spec/support/Casks/with-embedded-binary.rb deleted file mode 100644 index 107c6cbe2..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/with-embedded-binary.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-embedded-binary' do -  version '1.2.3' -  sha256 'fe052d3e77d92676775fd916ddb8942e72a565b844ea7f6d055474c99bb4e47b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/AppWithEmbeddedBinary.zip" -  homepage 'http://example.com/with-binary' - -  app 'App.app' -  binary "#{appdir}/App.app/Contents/MacOS/App/binary" -end diff --git a/Library/Homebrew/cask/test/support/fake_system_command.rb b/Library/Homebrew/cask/spec/support/fake_system_command.rb index 97efd0761..b9390d482 100644 --- a/Library/Homebrew/cask/test/support/fake_system_command.rb +++ b/Library/Homebrew/cask/spec/support/fake_system_command.rb @@ -1,3 +1,7 @@ +def sudo(*args) +  %w[/usr/bin/sudo -E --] + args.flatten +end +  module Hbc    class FakeSystemCommand      def self.responses @@ -42,6 +46,7 @@ module Hbc      def self.run(command_string, options = {})        command = Hbc::SystemCommand.new(command_string, options).command +      puts command        unless responses.key?(command)          raise("no response faked for #{command.inspect}, faked responses are: #{responses.inspect}")        end @@ -61,17 +66,12 @@ module Hbc    end  end -module FakeSystemCommandHooks -  def after_teardown -    super -    Hbc::FakeSystemCommand.verify_expectations! -  ensure -    Hbc::FakeSystemCommand.clear -  end -end - -module MiniTest -  class Spec -    include FakeSystemCommandHooks +RSpec.configure do |config| +  config.after(:each) do +    begin +      Hbc::FakeSystemCommand.verify_expectations! +    ensure +      Hbc::FakeSystemCommand.clear +    end    end  end diff --git a/Library/Homebrew/cask/spec/support/file_helper.rb b/Library/Homebrew/cask/spec/support/file_helper.rb deleted file mode 100644 index abe7b2618..000000000 --- a/Library/Homebrew/cask/spec/support/file_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -module FileHelper -  module_function - -  def valid_alias?(candidate) -    return false unless candidate.symlink? -    candidate.readlink.exist? -  end -end diff --git a/Library/Homebrew/cask/spec/support/install_helper.rb b/Library/Homebrew/cask/spec/support/install_helper.rb index c8023c66b..d91b9ea57 100644 --- a/Library/Homebrew/cask/spec/support/install_helper.rb +++ b/Library/Homebrew/cask/spec/support/install_helper.rb @@ -1,10 +1,42 @@  module InstallHelper -  class << self -    def install_without_artifacts(cask) -      Hbc::Installer.new(cask).tap do |i| +  module_function + +  require "test/support/helper/shutup" +  extend Test::Helper::Shutup + +  def self.install_without_artifacts(cask) +    Hbc::Installer.new(cask).tap do |i| +      shutup do          i.download          i.extract_primary_container        end      end    end + +  def self.install_without_artifacts_with_caskfile(cask) +    Hbc::Installer.new(cask).tap do |i| +      shutup do +        i.download +        i.extract_primary_container +        i.save_caskfile +      end +    end +  end + +  def install_without_artifacts(cask) +    Hbc::Installer.new(cask).tap do |i| +      shutup do +        i.download +        i.extract_primary_container +      end +    end +  end + +  def install_with_caskfile(cask) +    Hbc::Installer.new(cask).tap do |i| +      shutup do +        i.save_caskfile +      end +    end +  end  end diff --git a/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb b/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb deleted file mode 100644 index b5c84869b..000000000 --- a/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Kernel -  alias real_at_exit at_exit - -  def at_exit(&block) -    real_at_exit(&block) unless ENV["DISABLE_AT_EXIT"] -  end - -  def with_disabled_at_exit -    ENV["DISABLE_AT_EXIT"] = "1" -    yield -    ENV.delete("DISABLE_AT_EXIT") -  end -end diff --git a/Library/Homebrew/cask/test/support/never_sudo_system_command.rb b/Library/Homebrew/cask/spec/support/never_sudo_system_command.rb index 8a370df44..eb8b677f2 100644 --- a/Library/Homebrew/cask/test/support/never_sudo_system_command.rb +++ b/Library/Homebrew/cask/spec/support/never_sudo_system_command.rb @@ -1,3 +1,5 @@ +require "hbc/system_command" +  module Hbc    class NeverSudoSystemCommand < SystemCommand      def self.run(command, options = {}) diff --git a/Library/Homebrew/cask/spec/support/sha256_helper.rb b/Library/Homebrew/cask/spec/support/sha256_helper.rb deleted file mode 100644 index 14f2a2519..000000000 --- a/Library/Homebrew/cask/spec/support/sha256_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -require"digest" - -module Sha256Helper -  def random_sha256 -    seed = "--#{rand(10_000)}--#{Time.now}--" -    Digest::SHA2.hexdigest(seed) -  end -end diff --git a/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb b/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb new file mode 100644 index 000000000..400ff40f6 --- /dev/null +++ b/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb @@ -0,0 +1,23 @@ +require "hbc/dsl/base" + +shared_examples Hbc::DSL::Base do +  it "supports the token method" do +    expect(dsl.token).to eq(cask.token) +  end + +  it "supports the version method" do +    expect(dsl.version).to eq(cask.version) +  end + +  it "supports the caskroom_path method" do +    expect(dsl.caskroom_path).to eq(cask.caskroom_path) +  end + +  it "supports the staged_path method" do +    expect(dsl.staged_path).to eq(cask.staged_path) +  end + +  it "supports the appdir method" do +    expect(dsl.appdir).to eq(cask.appdir) +  end +end diff --git a/Library/Homebrew/cask/spec/support/shared_examples/staged.rb b/Library/Homebrew/cask/spec/support/shared_examples/staged.rb new file mode 100644 index 000000000..f791696ac --- /dev/null +++ b/Library/Homebrew/cask/spec/support/shared_examples/staged.rb @@ -0,0 +1,143 @@ +require "spec_helper" + +require "hbc/staged" + +shared_examples Hbc::Staged do +  let(:fake_pathname_exists) { +    fake_pathname = Pathname.new("/path/to/file/that/exists") +    allow(fake_pathname).to receive(:exist?).and_return(true) +    allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname) +    fake_pathname +  } + +  let(:fake_pathname_does_not_exist) { +    fake_pathname = Pathname.new("/path/to/file/that/does/not/exist") +    allow(fake_pathname).to receive(:exist?).and_return(false) +    allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname) +    fake_pathname +  } + +  it "can run system commands with list-form arguments" do +    Hbc::FakeSystemCommand.expects_command( +      ["echo", "homebrew-cask", "rocks!"] +    ) + +    shutup do +      staged.system_command("echo", args: ["homebrew-cask", "rocks!"]) +    end +  end + +  it "can get the Info.plist file for the primary app" do +    expect(staged.info_plist_file.to_s).to include Hbc.appdir.join("TestCask.app/Contents/Info.plist") +  end + +  it "can execute commands on the Info.plist file" do +    allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask") + +    Hbc::FakeSystemCommand.expects_command( +      ["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file] +    ) + +    shutup do +      staged.plist_exec("Print CFBundleIdentifier") +    end +  end + +  it "can set a key in the Info.plist file" do +    allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask") + +    Hbc::FakeSystemCommand.expects_command( +      ["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file] +    ) + +    shutup do +      staged.plist_set(":JVMOptions:JVMVersion", "1.6+") +    end +  end + +  it "can set the permissions of a file" do +    fake_pathname = fake_pathname_exists +    allow(staged).to receive(:Pathname).and_return(fake_pathname) + +    Hbc::FakeSystemCommand.expects_command( +      ["/bin/chmod", "-R", "--", "777", fake_pathname] +    ) + +    shutup do +      staged.set_permissions(fake_pathname.to_s, "777") +    end +  end + +  it "can set the permissions of multiple files" do +    fake_pathname = fake_pathname_exists +    allow(staged).to receive(:Pathname).and_return(fake_pathname) + +    Hbc::FakeSystemCommand.expects_command( +      ["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname] +    ) + +    shutup do +      staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777") +    end +  end + +  it "cannot set the permissions of a file that does not exist" do +    fake_pathname = fake_pathname_does_not_exist +    allow(staged).to receive(:Pathname).and_return(fake_pathname) +    staged.set_permissions(fake_pathname.to_s, "777") +  end + +  it "can set the ownership of a file" do +    fake_pathname = fake_pathname_exists + +    allow(staged).to receive(:current_user).and_return("fake_user") +    allow(staged).to receive(:Pathname).and_return(fake_pathname) + +    Hbc::FakeSystemCommand.expects_command( +      ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname] +    ) + +    shutup do +      staged.set_ownership(fake_pathname.to_s) +    end +  end + +  it "can set the ownership of multiple files" do +    fake_pathname = fake_pathname_exists + +    allow(staged).to receive(:current_user).and_return("fake_user") +    allow(staged).to receive(:Pathname).and_return(fake_pathname) + +    Hbc::FakeSystemCommand.expects_command( +      ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname] +    ) + +    shutup do +      staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s]) +    end +  end + +  it "can set the ownership of a file with a different user and group" do +    fake_pathname = fake_pathname_exists + +    allow(staged).to receive(:Pathname).and_return(fake_pathname) + +    Hbc::FakeSystemCommand.expects_command( +      ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname] +    ) + +    shutup do +      staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group") +    end +  end + +  it "cannot set the ownership of a file that does not exist" do +    allow(staged).to receive(:current_user).and_return("fake_user") +    fake_pathname = fake_pathname_does_not_exist +    allow(staged).to receive(:Pathname).and_return(fake_pathname) + +    shutup do +      staged.set_ownership(fake_pathname.to_s) +    end +  end +end diff --git a/Library/Homebrew/cask/spec/upload_coverage.rb b/Library/Homebrew/cask/spec/upload_coverage.rb new file mode 100755 index 000000000..06d38157d --- /dev/null +++ b/Library/Homebrew/cask/spec/upload_coverage.rb @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +require "simplecov" +require "codecov" + +formatter = SimpleCov::Formatter::Codecov.new +formatter.format SimpleCov::ResultMerger.merged_result diff --git a/Library/Homebrew/cask/test/README.md b/Library/Homebrew/cask/test/README.md deleted file mode 100644 index 4b73af8c4..000000000 --- a/Library/Homebrew/cask/test/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Naming - -Only files matching `*_test.rb` will be executed as tests. diff --git a/Library/Homebrew/cask/test/cask/accessibility_test.rb b/Library/Homebrew/cask/test/cask/accessibility_test.rb deleted file mode 100644 index 7c6484dd4..000000000 --- a/Library/Homebrew/cask/test/cask/accessibility_test.rb +++ /dev/null @@ -1,77 +0,0 @@ -require "test_helper" - -# TODO: this test should be named after the corresponding class, once -#       that class is abstracted from installer.rb. -describe "Accessibility Access" do -  let(:cask) { Hbc.load("with-accessibility-access") } -  let(:with_fake_command) { { command: Hbc::FakeSystemCommand } } -  let(:installer) { Hbc::Installer.new(cask, with_fake_command) } - -  describe "install" do -    it "can enable accessibility access" do -      MacOS.stub :version, MacOS::Version.new("10.9") do -        installer.stub :bundle_identifier, "com.example.BasicCask" do -          Hbc::FakeSystemCommand.expects_command( -            ["/usr/bin/sudo", "-E", "--", "/usr/bin/sqlite3", Hbc.tcc_db, "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);"] -          ) -          shutup do -            installer.enable_accessibility_access -          end -        end -      end -    end - -    it "can enable accessibility access in macOS releases prior to Mavericks" do -      MacOS.stub :version, MacOS::Version.new("10.8") do -        Hbc::FakeSystemCommand.expects_command( -          ["/usr/bin/sudo", "-E", "--", "/usr/bin/touch", Hbc.pre_mavericks_accessibility_dotfile] -        ) -        shutup do -          installer.enable_accessibility_access -        end -      end -    end - -    it "warns about enabling accessibility access on new macOS releases" do -      MacOS.stub :version, MacOS::Version.new("10.12") do -        installer.stub :bundle_identifier, "com.example.BasicCask" do -          capture_io { installer.enable_accessibility_access }[1] -            .must_match("Warning: Accessibility access cannot be enabled automatically on this version of macOS.") -        end -      end -    end -  end - -  describe "uninstall" do -    it "can disable accessibility access" do -      MacOS.stub :version, MacOS::Version.new("10.9") do -        installer.stub :bundle_identifier, "com.example.BasicCask" do -          Hbc::FakeSystemCommand.expects_command( -            ["/usr/bin/sudo", "-E", "--", "/usr/bin/sqlite3", Hbc.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"] -          ) -          shutup do -            installer.disable_accessibility_access -          end -        end -      end -    end - -    it "warns about disabling accessibility access on old macOS releases" do -      MacOS.stub :version, MacOS::Version.new("10.8") do -        installer.stub :bundle_identifier, "com.example.BasicCask" do -          capture_io { installer.disable_accessibility_access }[1] -            .must_match("Warning: Accessibility access cannot be disabled automatically on this version of macOS.") -        end -      end -    end - -    it "warns about disabling accessibility access on new macOS releases" do -      MacOS.stub :version, MacOS::Version.new("10.12") do -        installer.stub :bundle_identifier, "com.example.BasicCask" do -          capture_io { installer.disable_accessibility_access }[1] -            .must_match("Warning: Accessibility access cannot be disabled automatically on this version of macOS.") -        end -      end -    end -  end -end diff --git a/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb b/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb deleted file mode 100644 index 42740cd44..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::Artifact do -  let(:cask) { Hbc.load("with-generic-artifact") } - -  let(:install_phase) { -    -> { Hbc::Artifact::Artifact.new(cask).install_phase } -  } - -  let(:source_path) { cask.staged_path.join("Caffeine.app") } -  let(:target_path) { Hbc.appdir.join("Caffeine.app") } - -  before do -    TestHelper.install_without_artifacts(cask) -  end - -  describe "with no target" do -    let(:cask) { Hbc.load("with-generic-artifact-no-target") } - -    it "fails to install with no target" do -      install_phase.must_raise Hbc::CaskInvalidError -    end -  end - -  it "moves the artifact to the proper directory" do -    shutup do -      install_phase.call -    end - -    target_path.must_be :directory? -    source_path.wont_be :exist? -  end - -  it "avoids clobbering an existing artifact" do -    target_path.mkpath - -    assert_raises Hbc::CaskError do -      shutup do -        install_phase.call -      end -    end - -    source_path.must_be :directory? -    target_path.must_be :directory? -    File.identical?(source_path, target_path).must_equal false -  end -end diff --git a/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb b/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb deleted file mode 100644 index b771ba345..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::NestedContainer do -  describe "install" do -    it "extracts the specified paths as containers" do -      cask = Hbc.load("nested-app").tap do |c| -        TestHelper.install_without_artifacts(c) -      end - -      shutup do -        Hbc::Artifact::NestedContainer.new(cask).install_phase -      end - -      cask.staged_path.join("MyNestedApp.app").must_be :directory? -    end -  end -end diff --git a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb b/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb deleted file mode 100644 index 3ed427763..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb +++ /dev/null @@ -1,74 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::Pkg do -  before do -    @cask = Hbc.load("with-installable") -    shutup do -      TestHelper.install_without_artifacts(@cask) -    end -  end - -  describe "install_phase" do -    it "runs the system installer on the specified pkgs" do -      pkg = Hbc::Artifact::Pkg.new(@cask, -                                   command: Hbc::FakeSystemCommand) - -      Hbc::FakeSystemCommand.expects_command(["/usr/bin/sudo", "-E", "--", "/usr/sbin/installer", "-pkg", @cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/"]) - -      shutup do -        pkg.install_phase -      end -    end -  end - -  describe "uninstall_phase" do -    it "does nothing, because the uninstall_phase method is a no-op" do -      pkg = Hbc::Artifact::Pkg.new(@cask, -                                   command: Hbc::FakeSystemCommand) -      shutup do -        pkg.uninstall_phase -      end -    end -  end - -  describe "choices" do -    before do -      @cask = Hbc.load("with-choices") -      shutup do -        TestHelper.install_without_artifacts(@cask) -      end -    end - -    it "passes the choice changes xml to the system installer" do -      pkg = Hbc::Artifact::Pkg.new(@cask, command: Hbc::FakeSystemCommand) - -      file = mock -      file.expects(:write).with <<-EOS.undent -        <?xml version="1.0" encoding="UTF-8"?> -        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -        <plist version="1.0"> -        <array> -        \t<dict> -        \t\t<key>attributeSetting</key> -        \t\t<integer>1</integer> -        \t\t<key>choiceAttribute</key> -        \t\t<string>selected</string> -        \t\t<key>choiceIdentifier</key> -        \t\t<string>choice1</string> -        \t</dict> -        </array> -        </plist> -      EOS -      file.stubs path: Pathname.new("/tmp/choices.xml") -      file.expects(:close) -      file.expects(:unlink) -      Tempfile.expects(:open).yields file - -      Hbc::FakeSystemCommand.expects_command(["/usr/bin/sudo", "-E", "--", "/usr/sbin/installer", "-pkg", @cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/", "-applyChoiceChangesXML", @cask.staged_path.join("/tmp/choices.xml")]) - -      shutup do -        pkg.install_phase -      end -    end -  end -end diff --git a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb deleted file mode 100644 index b2949950e..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::Suite do -  let(:cask) { Hbc.load("with-suite") } - -  let(:install_phase) { -> { Hbc::Artifact::Suite.new(cask).install_phase } } - -  let(:target_path) { Hbc.appdir.join("Caffeine") } -  let(:source_path) { cask.staged_path.join("Caffeine") } - -  before do -    TestHelper.install_without_artifacts(cask) -  end - -  it "moves the suite to the proper directory" do -    shutup do -      install_phase.call -    end - -    target_path.must_be :directory? -    TestHelper.valid_alias?(target_path).must_equal false -    source_path.wont_be :exist? -  end - -  it "creates a suite containing the expected app" do -    shutup do -      install_phase.call -    end - -    target_path.join("Caffeine.app").must_be :exist? -  end - -  it "avoids clobbering an existing suite by moving over it" do -    target_path.mkpath - -    assert_raises Hbc::CaskError do -      shutup do -        install_phase.call -      end -    end - -    source_path.must_be :directory? -    target_path.must_be :directory? -    File.identical?(source_path, target_path).must_equal false -  end -end diff --git a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb b/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb deleted file mode 100644 index c699d247f..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb +++ /dev/null @@ -1,97 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::App do -  describe "multiple apps" do -    let(:cask) { Hbc.load("with-two-apps-correct") } - -    let(:install_phase) { -      -> { Hbc::Artifact::App.new(cask).install_phase } -    } - -    let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") } -    let(:target_path_mini) { Hbc.appdir.join("Caffeine Mini.app") } - -    let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") } -    let(:target_path_pro) { Hbc.appdir.join("Caffeine Pro.app") } - -    before do -      TestHelper.install_without_artifacts(cask) -    end - -    it "installs both apps using the proper target directory" do -      shutup do -        install_phase.call -      end - -      target_path_mini.must_be :directory? -      source_path_mini.wont_be :exist? - -      target_path_pro.must_be :directory? -      source_path_pro.wont_be :exist? -    end - -    describe "when apps are in a subdirectory" do -      let(:cask) { Hbc.load("with-two-apps-subdir") } - -      it "installs both apps using the proper target directory" do -        shutup do -          install_phase.call -        end - -        target_path_mini.must_be :directory? -        source_path_mini.wont_be :exist? - -        target_path_pro.must_be :directory? -        source_path_pro.wont_be :exist? -      end -    end - -    it "only uses apps when they are specified" do -      FileUtils.cp_r source_path_mini, source_path_mini.sub("Caffeine Mini.app", "Caffeine Deluxe.app") - -      shutup do -        install_phase.call -      end - -      target_path_mini.must_be :directory? -      source_path_mini.wont_be :exist? - -      Hbc.appdir.join("Caffeine Deluxe.app").wont_be :exist? -      cask.staged_path.join("Caffeine Deluxe.app").must_be :exist? -    end - -    describe "avoids clobbering an existing app" do -      it "when the first app of two already exists" do -        target_path_mini.mkpath - -        err = assert_raises Hbc::CaskError do -          install_phase.must_output <<-EOS.undent -            ==> Moving App 'Caffeine Pro.app' to '#{target_path_pro}' -          EOS -        end - -        err.message.must_equal("It seems there is already an App at '#{target_path_mini}'.") - -        source_path_mini.must_be :directory? -        target_path_mini.must_be :directory? -        File.identical?(source_path_mini, target_path_mini).must_equal false -      end - -      it "when the second app of two already exists" do -        target_path_pro.mkpath - -        err = assert_raises Hbc::CaskError do -          install_phase.must_output <<-EOS.undent -            ==> Moving App 'Caffeine Mini.app' to '#{target_path_mini}' -          EOS -        end - -        err.message.must_equal("It seems there is already an App at '#{target_path_pro}'.") - -        source_path_pro.must_be :directory? -        target_path_pro.must_be :directory? -        File.identical?(source_path_pro, target_path_pro).must_equal false -      end -    end -  end -end diff --git a/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb b/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb deleted file mode 100644 index a89a94fba..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::App do -  it "must raise" do -    exception_raised = begin -                         Hbc.load("two-apps-incorrect") -                         false -                       rescue -                         true -                       end -    # TODO: later give the user a nice exception for this case and check for it here -    assert exception_raised -  end -end diff --git a/Library/Homebrew/cask/test/cask/cli/audit_test.rb b/Library/Homebrew/cask/test/cask/cli/audit_test.rb deleted file mode 100644 index 89a7d140a..000000000 --- a/Library/Homebrew/cask/test/cask/cli/audit_test.rb +++ /dev/null @@ -1,64 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Audit do -  let(:auditor) { mock } -  let(:cask) { mock } - -  describe "selection of Casks to audit" do -    it "audits all Casks if no tokens are given" do -      Hbc.stub :all, [cask, cask] do -        auditor.expects(:audit).times(2) - -        run_audit([], auditor) -      end -    end - -    it "audits specified Casks if tokens are given" do -      cask_token = "nice-app" -      Hbc.expects(:load).with(cask_token).returns(cask) -      auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false) - -      run_audit([cask_token], auditor) -    end -  end - -  describe "rules for downloading a Cask" do -    it "does not download the Cask per default" do -      Hbc.stub :load, cask do -        auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false) - -        run_audit(["casktoken"], auditor) -      end -    end - -    it "download a Cask if --download flag is set" do -      Hbc.stub :load, cask do -        auditor.expects(:audit).with(cask, audit_download: true, check_token_conflicts: false) - -        run_audit(["casktoken", "--download"], auditor) -      end -    end -  end - -  describe "rules for checking token conflicts" do -    it "does not check for token conflicts per default" do -      Hbc.stub :load, cask do -        auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false) - -        run_audit(["casktoken"], auditor) -      end -    end - -    it "checks for token conflicts if --token-conflicts flag is set" do -      Hbc.stub :load, cask do -        auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: true) - -        run_audit(["casktoken", "--token-conflicts"], auditor) -      end -    end -  end - -  def run_audit(args, auditor) -    Hbc::CLI::Audit.new(args, auditor).run -  end -end diff --git a/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb b/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb deleted file mode 100644 index 02cdeb763..000000000 --- a/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Reinstall do -  it "allows reinstalling a Cask" do -    shutup do -      Hbc::CLI::Install.run("local-transmission") -    end -    Hbc.load("local-transmission").must_be :installed? - -    shutup do -      Hbc::CLI::Reinstall.run("local-transmission") -    end -    Hbc.load("local-transmission").must_be :installed? -  end - -  it "allows reinstalling a non installed Cask" do -    Hbc.load("local-transmission").wont_be :installed? - -    shutup do -      Hbc::CLI::Reinstall.run("local-transmission") -    end -    Hbc.load("local-transmission").must_be :installed? -  end -end diff --git a/Library/Homebrew/cask/test/cask/cli/search_test.rb b/Library/Homebrew/cask/test/cask/cli/search_test.rb deleted file mode 100644 index 6eb6badb9..000000000 --- a/Library/Homebrew/cask/test/cask/cli/search_test.rb +++ /dev/null @@ -1,59 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Search do -  it "lists the available Casks that match the search term" do -    lambda { -      Hbc::CLI::Search.run("photoshop") -    }.must_output <<-EOS.undent -      ==> Partial matches -      adobe-photoshop-cc -      adobe-photoshop-lightroom -    EOS -  end - -  it "shows that there are no Casks matching a search term that did not result in anything" do -    lambda { -      Hbc::CLI::Search.run("foo-bar-baz") -    }.must_output("No Cask found for \"foo-bar-baz\".\n") -  end - -  it "lists all available Casks with no search term" do -    out = capture_io { Hbc::CLI::Search.run }[0] -    out.must_match(/google-chrome/) -    out.length.must_be :>, 1000 -  end - -  it "ignores hyphens in search terms" do -    out = capture_io { Hbc::CLI::Search.run("goo-gle-chrome") }[0] -    out.must_match(/google-chrome/) -    out.length.must_be :<, 100 -  end - -  it "ignores hyphens in Cask tokens" do -    out = capture_io { Hbc::CLI::Search.run("googlechrome") }[0] -    out.must_match(/google-chrome/) -    out.length.must_be :<, 100 -  end - -  it "accepts multiple arguments" do -    out = capture_io { Hbc::CLI::Search.run("google chrome") }[0] -    out.must_match(/google-chrome/) -    out.length.must_be :<, 100 -  end - -  it "accepts a regexp argument" do -    lambda { -      Hbc::CLI::Search.run("/^google-c[a-z]rome$/") -    }.must_output "==> Regexp matches\ngoogle-chrome\n" -  end - -  it "Returns both exact and partial matches" do -    out = capture_io { Hbc::CLI::Search.run("mnemosyne") }[0] -    out.must_match(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/) -  end - -  it "does not search the Tap name" do -    out = capture_io { Hbc::CLI::Search.run("caskroom") }[0] -    out.must_match(/^No Cask found for "caskroom"\.\n/) -  end -end diff --git a/Library/Homebrew/cask/test/cask/cli/version_test.rb b/Library/Homebrew/cask/test/cask/cli/version_test.rb deleted file mode 100644 index 60e6d22ae..000000000 --- a/Library/Homebrew/cask/test/cask/cli/version_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "test_helper" - -describe "brew cask --version" do -  it "respects the --version argument" do -    lambda { -      Hbc::CLI::NullCommand.new("--version").run -    }.must_output Hbc.full_version -  end -end diff --git a/Library/Homebrew/cask/test/cask/depends_on_test.rb b/Library/Homebrew/cask/test/cask/depends_on_test.rb deleted file mode 100644 index 4516dad37..000000000 --- a/Library/Homebrew/cask/test/cask/depends_on_test.rb +++ /dev/null @@ -1,113 +0,0 @@ -require "test_helper" - -# TODO: this test should be named after the corresponding class, once -#       that class is abstracted from installer.rb -describe "Satisfy Dependencies and Requirements" do -  # TODO: test that depends_on formula invokes Homebrew -  # -  # describe "depends_on formula" do -  #   it "" do -  #   end -  # end -  # - -  describe "depends_on cask" do -    it "raises an exception when depends_on cask is cyclic" do -      dep_cask = Hbc.load("with-depends-on-cask-cyclic") -      lambda { -        shutup do -          Hbc::Installer.new(dep_cask).install -        end -      }.must_raise(Hbc::CaskCyclicCaskDependencyError) -    end - -    it "installs the dependency of a Cask and the Cask itself" do -      csk = Hbc.load("with-depends-on-cask") -      dependency = Hbc.load(csk.depends_on.cask.first) -      shutup do -        Hbc::Installer.new(csk).install -      end - -      csk.must_be :installed? -      dependency.must_be :installed? -    end -  end - -  describe "depends_on macos" do -    it "understands depends_on macos: <array>" do -      macos_cask = Hbc.load("with-depends-on-macos-array") -      shutup do -        Hbc::Installer.new(macos_cask).install -      end -    end - -    it "understands depends_on macos: <comparison>" do -      macos_cask = Hbc.load("with-depends-on-macos-comparison") -      shutup do -        Hbc::Installer.new(macos_cask).install -      end -    end - -    it "understands depends_on macos: <string>" do -      macos_cask = Hbc.load("with-depends-on-macos-string") -      shutup do -        Hbc::Installer.new(macos_cask).install -      end -    end - -    it "understands depends_on macos: <symbol>" do -      macos_cask = Hbc.load("with-depends-on-macos-symbol") -      shutup do -        Hbc::Installer.new(macos_cask).install -      end -    end - -    it "raises an exception when depends_on macos is not satisfied" do -      macos_cask = Hbc.load("with-depends-on-macos-failure") -      lambda { -        shutup do -          Hbc::Installer.new(macos_cask).install -        end -      }.must_raise(Hbc::CaskError) -    end -  end - -  describe "depends_on arch" do -    it "succeeds when depends_on arch is satisfied" do -      arch_cask = Hbc.load("with-depends-on-arch") -      shutup do -        Hbc::Installer.new(arch_cask).install -      end -    end -  end - -  describe "depends_on x11" do -    it "succeeds when depends_on x11 is satisfied" do -      x11_cask = Hbc.load("with-depends-on-x11") -      MacOS::X11.stubs(:installed?).returns(true) -      shutup do -        Hbc::Installer.new(x11_cask).install -      end -    end - -    it "raises an exception when depends_on x11 is not satisfied" do -      x11_cask = Hbc.load("with-depends-on-x11") -      MacOS::X11.stubs(:installed?).returns(false) -      lambda { -        shutup do -          Hbc::Installer.new(x11_cask).install -        end -      }.must_raise(Hbc::CaskX11DependencyError) -    end - -    it "never raises when depends_on x11: false" do -      x11_cask = Hbc.load("with-depends-on-x11-false") -      MacOS::X11.stubs(:installed?).returns(false) -      lambda do -        shutup do -          Hbc::Installer.new(x11_cask).install -        end -      end # won't raise -    end -  end -end diff --git a/Library/Homebrew/cask/test/cask/dsl_test.rb b/Library/Homebrew/cask/test/cask/dsl_test.rb deleted file mode 100644 index 96d24a1a1..000000000 --- a/Library/Homebrew/cask/test/cask/dsl_test.rb +++ /dev/null @@ -1,475 +0,0 @@ -require "test_helper" - -describe Hbc::DSL do -  it "lets you set url, homepage, and version" do -    test_cask = Hbc.load("basic-cask") -    test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg" -    test_cask.homepage.must_equal "http://example.com/" -    test_cask.version.to_s.must_equal "1.2.3" -  end - -  describe "when a Cask includes an unknown method" do -    attempt_unknown_method = nil - -    before do -      attempt_unknown_method = lambda do -        Hbc::Cask.new("unexpected-method-cask") do -          future_feature :not_yet_on_your_machine -        end -      end -    end - -    it "prints a warning that it has encountered an unexpected method" do -      expected = Regexp.compile(<<-EOS.undent.lines.map(&:chomp).join("")) -        (?m) -        Warning: -        .* -        Unexpected method 'future_feature' called on Cask unexpected-method-cask\\. -        .* -        https://github.com/caskroom/homebrew-cask/blob/master/doc/reporting_bugs/pre_bug_report.md -        .* -        https://github.com/caskroom/homebrew-cask#reporting-bugs -      EOS - -      attempt_unknown_method.must_output nil, expected -    end - -    it "will simply warn, not throw an exception" do -      begin -        shutup do -          attempt_unknown_method.call -        end -      rescue StandardError => e -        flunk("Wanted unexpected method to simply warn, but got exception #{e}") -      end -    end -  end - -  describe "header line" do -    it "requires a valid header format" do -      lambda { -        Hbc.load("invalid/invalid-header-format") -      }.must_raise(SyntaxError) -    end - -    it "requires the header token to match the file name" do -      err = lambda { -        Hbc.load("invalid/invalid-header-token-mismatch") -      }.must_raise(Hbc::CaskTokenDoesNotMatchError) -      err.message.must_include "Bad header line:" -      err.message.must_include "does not match file name" -    end - -    it "does not require a DSL version in the header" do -      test_cask = Hbc.load("no-dsl-version") -      test_cask.token.must_equal "no-dsl-version" -      test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg" -      test_cask.homepage.must_equal "http://example.com/" -      test_cask.version.to_s.must_equal "1.2.3" -    end - -    it "may use deprecated DSL version hash syntax" do -      with_environment "HOMEBREW_DEVELOPER" => nil do -        shutup do -          test_cask = Hbc.load("with-dsl-version") -          test_cask.token.must_equal "with-dsl-version" -          test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg" -          test_cask.homepage.must_equal "http://example.com/" -          test_cask.version.to_s.must_equal "1.2.3" -        end -      end -    end -  end - -  describe "name stanza" do -    it "lets you set the full name via a name stanza" do -      cask = Hbc::Cask.new("name-cask") do -        name "Proper Name" -      end - -      cask.name.must_equal [ -        "Proper Name", -      ] -    end - -    it "Accepts an array value to the name stanza" do -      cask = Hbc::Cask.new("array-name-cask") do -        name ["Proper Name", "Alternate Name"] -      end - -      cask.name.must_equal [ -        "Proper Name", -        "Alternate Name", -      ] -    end - -    it "Accepts multiple name stanzas" do -      cask = Hbc::Cask.new("multi-name-cask") do -        name "Proper Name" -        name "Alternate Name" -      end - -      cask.name.must_equal [ -        "Proper Name", -        "Alternate Name", -      ] -    end -  end - -  describe "sha256 stanza" do -    it "lets you set checksum via sha256" do -      cask = Hbc::Cask.new("checksum-cask") do -        sha256 "imasha2" -      end - -      cask.sha256.must_equal "imasha2" -    end -  end - -  describe "language stanza" do -    it "allows multilingual casks" do -      cask = lambda do -        Hbc::Cask.new("cask-with-apps") do -          language "zh" do -            sha256 "abc123" -            "zh-CN" -          end - -          language "en-US", default: true do -            sha256 "xyz789" -            "en-US" -          end - -          url "https://example.org/#{language}.zip" -        end -      end - -      MacOS.stub :languages, ["zh"] do -        cask.call.language.must_equal "zh-CN" -        cask.call.sha256.must_equal "abc123" -        cask.call.url.to_s.must_equal "https://example.org/zh-CN.zip" -      end - -      MacOS.stub :languages, ["zh-XX"] do -        cask.call.language.must_equal "zh-CN" -        cask.call.sha256.must_equal "abc123" -        cask.call.url.to_s.must_equal "https://example.org/zh-CN.zip" -      end - -      MacOS.stub :languages, ["en"] do -        cask.call.language.must_equal "en-US" -        cask.call.sha256.must_equal "xyz789" -        cask.call.url.to_s.must_equal "https://example.org/en-US.zip" -      end - -      MacOS.stub :languages, ["xx-XX"] do -        cask.call.language.must_equal "en-US" -        cask.call.sha256.must_equal "xyz789" -        cask.call.url.to_s.must_equal "https://example.org/en-US.zip" -      end - -      MacOS.stub :languages, ["xx-XX", "zh", "en"] do -        cask.call.language.must_equal "zh-CN" -        cask.call.sha256.must_equal "abc123" -        cask.call.url.to_s.must_equal "https://example.org/zh-CN.zip" -      end - -      MacOS.stub :languages, ["xx-XX", "en-US", "zh"] do -        cask.call.language.must_equal "en-US" -        cask.call.sha256.must_equal "xyz789" -        cask.call.url.to_s.must_equal "https://example.org/en-US.zip" -      end -    end -  end - -  describe "app stanza" do -    it "allows you to specify app stanzas" do -      cask = Hbc::Cask.new("cask-with-apps") do -        app "Foo.app" -        app "Bar.app" -      end - -      Array(cask.artifacts[:app]).must_equal [["Foo.app"], ["Bar.app"]] -    end - -    it "allow app stanzas to be empty" do -      cask = Hbc::Cask.new("cask-with-no-apps") -      Array(cask.artifacts[:app]).must_equal %w[] -    end -  end - -  describe "caveats stanza" do -    it "allows caveats to be specified via a method define" do -      cask = Hbc::Cask.new("plain-cask") - -      cask.caveats.must_be :empty? - -      cask = Hbc::Cask.new("cask-with-caveats") do -        def caveats; <<-EOS.undent -          When you install this Cask, you probably want to know this. -          EOS -        end -      end - -      cask.caveats.must_equal "When you install this Cask, you probably want to know this.\n" -    end -  end - -  describe "pkg stanza" do -    it "allows installable pkgs to be specified" do -      cask = Hbc::Cask.new("cask-with-pkgs") do -        pkg "Foo.pkg" -        pkg "Bar.pkg" -      end - -      Array(cask.artifacts[:pkg]).must_equal [["Foo.pkg"], ["Bar.pkg"]] -    end -  end - -  describe "url stanza" do -    it "prevents defining multiple urls" do -      err = lambda { -        Hbc.load("invalid/invalid-two-url") -      }.must_raise(Hbc::CaskInvalidError) -      err.message.must_include "'url' stanza may only appear once" -    end -  end - -  describe "homepage stanza" do -    it "prevents defining multiple homepages" do -      err = lambda { -        Hbc.load("invalid/invalid-two-homepage") -      }.must_raise(Hbc::CaskInvalidError) -      err.message.must_include "'homepage' stanza may only appear once" -    end -  end - -  describe "version stanza" do -    it "prevents defining multiple versions" do -      err = lambda { -        Hbc.load("invalid/invalid-two-version") -      }.must_raise(Hbc::CaskInvalidError) -      err.message.must_include "'version' stanza may only appear once" -    end -  end - -  describe "appcast stanza" do -    it "allows appcasts to be specified" do -      cask = Hbc.load("with-appcast") -      cask.appcast.to_s.must_match(/^http/) -    end - -    it "prevents defining multiple appcasts" do -      err = lambda { -        Hbc.load("invalid/invalid-appcast-multiple") -      }.must_raise(Hbc::CaskInvalidError) -      err.message.must_include "'appcast' stanza may only appear once" -    end - -    it "refuses to load invalid appcast URLs" do -      lambda { -        Hbc.load("invalid/invalid-appcast-url") -      }.must_raise(Hbc::CaskInvalidError) -    end -  end - -  describe "gpg stanza" do -    it "allows gpg stanza to be specified" do -      cask = Hbc.load("with-gpg") -      cask.gpg.to_s.must_match(/\S/) -    end - -    it "allows gpg stanza to be specified with :key_url" do -      cask = Hbc.load("with-gpg-key-url") -      cask.gpg.to_s.must_match(/\S/) -    end - -    it "prevents specifying gpg stanza multiple times" do -      err = lambda { -        Hbc.load("invalid/invalid-gpg-multiple-stanzas") -      }.must_raise(Hbc::CaskInvalidError) -      err.message.must_include "'gpg' stanza may only appear once" -    end - -    it "prevents missing gpg key parameters" do -      err = lambda { -        Hbc.load("invalid/invalid-gpg-missing-key") -      }.must_raise(Hbc::CaskInvalidError) -      err.message.must_include "'gpg' stanza must include exactly one" -    end - -    it "prevents conflicting gpg key parameters" do -      err = lambda { -        Hbc.load("invalid/invalid-gpg-conflicting-keys") -      }.must_raise(Hbc::CaskInvalidError) -      err.message.must_include "'gpg' stanza must include exactly one" -    end - -    it "refuses to load invalid gpg signature URLs" do -      lambda { -        Hbc.load("invalid/invalid-gpg-signature-url") -      }.must_raise(Hbc::CaskInvalidError) -    end - -    it "refuses to load invalid gpg key URLs" do -      lambda { -        Hbc.load("invalid/invalid-gpg-key-url") -      }.must_raise(Hbc::CaskInvalidError) -    end - -    it "refuses to load invalid gpg key IDs" do -      lambda { -        Hbc.load("invalid/invalid-gpg-key-id") -      }.must_raise(Hbc::CaskInvalidError) -    end - -    it "refuses to load if gpg parameter is unknown" do -      lambda { -        Hbc.load("invalid/invalid-gpg-parameter") -      }.must_raise(Hbc::CaskInvalidError) -    end -  end - -  describe "depends_on stanza" do -    it "refuses to load with an invalid depends_on key" do -      lambda { -        Hbc.load("invalid/invalid-depends-on-key") -      }.must_raise(Hbc::CaskInvalidError) -    end -  end - -  describe "depends_on formula" do -    it "allows depends_on formula to be specified" do -      cask = Hbc.load("with-depends-on-formula") -      cask.depends_on.formula.wont_be_nil -    end - -    it "allows multiple depends_on formula to be specified" do -      cask = Hbc.load("with-depends-on-formula-multiple") -      cask.depends_on.formula.wont_be_nil -    end -  end - -  describe "depends_on cask" do -    it "allows depends_on cask to be specified" do -      cask = Hbc.load("with-depends-on-cask") -      cask.depends_on.cask.wont_be_nil -    end - -    it "allows multiple depends_on cask to be specified" do -      cask = Hbc.load("with-depends-on-cask-multiple") -      cask.depends_on.cask.wont_be_nil -    end -  end - -  describe "depends_on macos" do -    it "allows depends_on macos to be specified" do -      cask = Hbc.load("with-depends-on-macos-string") -      cask.depends_on.macos.wont_be_nil -    end -    it "refuses to load with an invalid depends_on macos value" do -      lambda { -        Hbc.load("invalid/invalid-depends-on-macos-bad-release") -      }.must_raise(Hbc::CaskInvalidError) -    end -    it "refuses to load with conflicting depends_on macos forms" do -      lambda { -        Hbc.load("invalid/invalid-depends-on-macos-conflicting-forms") -      }.must_raise(Hbc::CaskInvalidError) -    end -  end - -  describe "depends_on arch" do -    it "allows depends_on arch to be specified" do -      cask = Hbc.load("with-depends-on-arch") -      cask.depends_on.arch.wont_be_nil -    end -    it "refuses to load with an invalid depends_on arch value" do -      lambda { -        Hbc.load("invalid/invalid-depends-on-arch-value") -      }.must_raise(Hbc::CaskInvalidError) -    end -  end - -  describe "depends_on x11" do -    it "allows depends_on x11 to be specified" do -      cask = Hbc.load("with-depends-on-x11") -      cask.depends_on.x11.wont_be_nil -    end -    it "refuses to load with an invalid depends_on x11 value" do -      lambda { -        Hbc.load("invalid/invalid-depends-on-x11-value") -      }.must_raise(Hbc::CaskInvalidError) -    end -  end - -  describe "conflicts_with stanza" do -    it "allows conflicts_with stanza to be specified" do -      cask = Hbc.load("with-conflicts-with") -      cask.conflicts_with.formula.wont_be_nil -    end - -    it "refuses to load invalid conflicts_with key" do -      lambda { -        Hbc.load("invalid/invalid-conflicts-with-key") -      }.must_raise(Hbc::CaskInvalidError) -    end -  end - -  describe "installer stanza" do -    it "allows installer script to be specified" do -      cask = Hbc.load("with-installer-script") -      cask.artifacts[:installer].first.script[:executable].must_equal "/usr/bin/true" -      cask.artifacts[:installer].first.script[:args].must_equal ["--flag"] -      cask.artifacts[:installer].to_a[1].script[:executable].must_equal "/usr/bin/false" -      cask.artifacts[:installer].to_a[1].script[:args].must_equal ["--flag"] -    end -    it "allows installer manual to be specified" do -      cask = Hbc.load("with-installer-manual") -      cask.artifacts[:installer].first.manual.must_equal "Caffeine.app" -    end -  end - -  describe "stage_only stanza" do -    it "allows stage_only stanza to be specified" do -      cask = Hbc.load("stage-only") -      cask.artifacts[:stage_only].first.must_equal [true] -    end - -    it "prevents specifying stage_only with other activatables" do -      err = lambda { -        Hbc.load("invalid/invalid-stage-only-conflict") -      }.must_raise(Hbc::CaskInvalidError) -      err.message.must_include "'stage_only' must be the only activatable artifact" -    end -  end - -  describe "auto_updates stanza" do -    it "allows auto_updates stanza to be specified" do -      cask = Hbc.load("auto-updates") -      cask.auto_updates.must_equal true -    end -  end - -  describe "appdir" do -    it "allows interpolation of the appdir value in stanzas" do -      cask = Hbc.load("appdir-interpolation") -      cask.artifacts[:binary].first.must_equal ["#{Hbc.appdir}/some/path"] -    end - -    it "does not include a trailing slash" do -      original_appdir = Hbc.appdir -      Hbc.appdir = "#{original_appdir}/" - -      begin -        cask = Hbc::Cask.new("appdir-trailing-slash") do -          binary "#{appdir}/some/path" -        end - -        cask.artifacts[:binary].first.must_equal ["#{original_appdir}/some/path"] -      ensure -        Hbc.appdir = original_appdir -      end -    end -  end -end diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb deleted file mode 100644 index d76411ae6..000000000 --- a/Library/Homebrew/cask/test/cask/installer_test.rb +++ /dev/null @@ -1,422 +0,0 @@ -require "test_helper" - -describe Hbc::Installer do -  describe "install" do -    let(:empty_depends_on_stub) { -      stub(formula: [], cask: [], macos: nil, arch: nil, x11: nil) -    } - -    it "downloads and installs a nice fresh Cask" do -      caffeine = Hbc.load("local-caffeine") - -      shutup do -        Hbc::Installer.new(caffeine).install -      end - -      dest_path = Hbc.caskroom.join("local-caffeine", caffeine.version) -      dest_path.must_be :directory? -      application = Hbc.appdir.join("Caffeine.app") -      application.must_be :directory? -    end - -    it "works with dmg-based Casks" do -      asset = Hbc.load("container-dmg") - -      shutup do -        Hbc::Installer.new(asset).install -      end - -      dest_path = Hbc.caskroom.join("container-dmg", asset.version) -      dest_path.must_be :directory? -      file = Hbc.appdir.join("container") -      file.must_be :file? -    end - -    it "works with tar-gz-based Casks" do -      asset = Hbc.load("container-tar-gz") - -      shutup do -        Hbc::Installer.new(asset).install -      end - -      dest_path = Hbc.caskroom.join("container-tar-gz", asset.version) -      dest_path.must_be :directory? -      application = Hbc.appdir.join("container") -      application.must_be :file? -    end - -    it "works with cab-based Casks" do -      skip("cabextract not installed") if which("cabextract").nil? -      asset = Hbc.load("container-cab") - -      asset.stub :depends_on, empty_depends_on_stub do -        shutup do -          Hbc::Installer.new(asset).install -        end -      end - -      dest_path = Hbc.caskroom.join("container-cab", asset.version) -      dest_path.must_be :directory? -      application = Hbc.appdir.join("container") -      application.must_be :file? -    end - -    it "works with Adobe AIR-based Casks" do -      skip("Adobe AIR not installed") unless Hbc::Container::Air.installer_exist? -      asset = Hbc.load("container-air") - -      shutup do -        Hbc::Installer.new(asset).install -      end - -      dest_path = Hbc.caskroom.join("container-air", asset.version) -      dest_path.must_be :directory? -      application = Hbc.appdir.join("container.app") -      application.must_be :directory? -    end - -    it "works with 7z-based Casks" do -      skip("unar not installed") if which("unar").nil? -      asset = Hbc.load("container-7z") - -      asset.stub :depends_on, empty_depends_on_stub do -        shutup do -          Hbc::Installer.new(asset).install -        end -      end - -      dest_path = Hbc.caskroom.join("container-7z", asset.version) -      dest_path.must_be :directory? -      file = Hbc.appdir.join("container") -      file.must_be :file? -    end - -    it "works with xar-based Casks" do -      asset = Hbc.load("container-xar") - -      shutup do -        Hbc::Installer.new(asset).install -      end - -      dest_path = Hbc.caskroom.join("container-xar", asset.version) -      dest_path.must_be :directory? -      file = Hbc.appdir.join("container") -      file.must_be :file? -    end - -    it "works with Stuffit-based Casks" do -      skip("unar not installed") if which("unar").nil? -      asset = Hbc.load("container-sit") - -      asset.stub :depends_on, empty_depends_on_stub do -        shutup do -          Hbc::Installer.new(asset).install -        end -      end - -      dest_path = Hbc.caskroom.join("container-sit", asset.version) -      dest_path.must_be :directory? -      application = Hbc.appdir.join("container") -      application.must_be :file? -    end - -    it "works with RAR-based Casks" do -      skip("unar not installed") if which("unar").nil? -      asset = Hbc.load("container-rar") - -      asset.stub :depends_on, empty_depends_on_stub do -        shutup do -          Hbc::Installer.new(asset).install -        end -      end - -      dest_path = Hbc.caskroom.join("container-rar", asset.version) -      dest_path.must_be :directory? -      application = Hbc.appdir.join("container") -      application.must_be :file? -    end - -    it "works with pure bzip2-based Casks" do -      asset = Hbc.load("container-bzip2") - -      shutup do -        Hbc::Installer.new(asset).install -      end - -      dest_path = Hbc.caskroom.join("container-bzip2", asset.version) -      dest_path.must_be :directory? -      file = Hbc.appdir.join("container-bzip2--#{asset.version}") -      file.must_be :file? -    end - -    it "works with pure gzip-based Casks" do -      asset = Hbc.load("container-gzip") - -      shutup do -        Hbc::Installer.new(asset).install -      end - -      dest_path = Hbc.caskroom.join("container-gzip", asset.version) -      dest_path.must_be :directory? -      file = Hbc.appdir.join("container") -      file.must_be :file? -    end - -    it "works with pure xz-based Casks" do -      skip("unxz not installed") if which("unxz").nil? -      asset = Hbc.load("container-xz") - -      asset.stub :depends_on, empty_depends_on_stub do -        shutup do -          Hbc::Installer.new(asset).install -        end -      end - -      dest_path = Hbc.caskroom.join("container-xz", asset.version) -      dest_path.must_be :directory? -      file = Hbc.appdir.join("container-xz--#{asset.version}") -      file.must_be :file? -    end - -    it "works with lzma-based Casks" do -      skip("unlzma not installed") if which("unlzma").nil? -      asset = Hbc.load("container-lzma") - -      asset.stub :depends_on, empty_depends_on_stub do -        shutup do -          Hbc::Installer.new(asset).install -        end -      end - -      dest_path = Hbc.caskroom.join("container-lzma", asset.version) -      dest_path.must_be :directory? -      file = Hbc.appdir.join("container-lzma--#{asset.version}") -      file.must_be :file? -    end - -    it "blows up on a bad checksum" do -      bad_checksum = Hbc.load("bad-checksum") -      lambda { -        shutup do -          Hbc::Installer.new(bad_checksum).install -        end -      }.must_raise(Hbc::CaskSha256MismatchError) -    end - -    it "blows up on a missing checksum" do -      missing_checksum = Hbc.load("missing-checksum") -      lambda { -        shutup do -          Hbc::Installer.new(missing_checksum).install -        end -      }.must_raise(Hbc::CaskSha256MissingError) -    end - -    it "installs fine if sha256 :no_check is used" do -      no_checksum = Hbc.load("no-checksum") - -      shutup do -        Hbc::Installer.new(no_checksum).install -      end - -      no_checksum.must_be :installed? -    end - -    it "fails to install if sha256 :no_check is used with --require-sha" do -      no_checksum = Hbc.load("no-checksum") -      lambda { -        Hbc::Installer.new(no_checksum, require_sha: true).install -      }.must_raise(Hbc::CaskNoShasumError) -    end - -    it "installs fine if sha256 :no_check is used with --require-sha and --force" do -      no_checksum = Hbc.load("no-checksum") - -      shutup do -        Hbc::Installer.new(no_checksum, require_sha: true, force: true).install -      end - -      no_checksum.must_be :installed? -    end - -    it "prints caveats if they're present" do -      with_caveats = Hbc.load("with-caveats") -      lambda { -        Hbc::Installer.new(with_caveats).install -      }.must_output(/Here are some things you might want to know/) -      with_caveats.must_be :installed? -    end - -    it "prints installer :manual instructions when present" do -      with_installer_manual = Hbc.load("with-installer-manual") -      lambda { -        Hbc::Installer.new(with_installer_manual).install -      }.must_output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n  '#{with_installer_manual.staged_path.join('Caffeine.app')}'/) -      with_installer_manual.must_be :installed? -    end - -    it "does not extract __MACOSX directories from zips" do -      with_macosx_dir = Hbc.load("with-macosx-dir") - -      shutup do -        Hbc::Installer.new(with_macosx_dir).install -      end - -      with_macosx_dir.staged_path.join("__MACOSX").wont_be :directory? -    end - -    it "installer method raises an exception when already-installed Casks which auto-update are attempted" do -      auto_updates = Hbc.load("auto-updates") -      auto_updates.installed?.must_equal false -      installer = Hbc::Installer.new(auto_updates) - -      shutup do -        installer.install -      end - -      lambda { -        installer.install -      }.must_raise(Hbc::CaskAlreadyInstalledAutoUpdatesError) -    end - -    it "allows already-installed Casks which auto-update to be installed if force is provided" do -      auto_updates = Hbc.load("auto-updates") -      auto_updates.installed?.must_equal false - -      shutup do -        Hbc::Installer.new(auto_updates).install -      end - -      shutup do -        Hbc::Installer.new(auto_updates, force: true).install -      end # wont_raise -    end - -    # unlike the CLI, the internal interface throws exception on double-install -    it "installer method raises an exception when already-installed Casks are attempted" do -      transmission = Hbc.load("local-transmission") -      transmission.installed?.must_equal false -      installer = Hbc::Installer.new(transmission) - -      shutup do -        installer.install -      end - -      lambda { -        installer.install -      }.must_raise(Hbc::CaskAlreadyInstalledError) -    end - -    it "allows already-installed Casks to be installed if force is provided" do -      transmission = Hbc.load("local-transmission") -      transmission.installed?.must_equal false - -      shutup do -        Hbc::Installer.new(transmission).install -      end - -      shutup do -        Hbc::Installer.new(transmission, force: true).install -      end # wont_raise -    end - -    it "works naked-pkg-based Casks" do -      naked_pkg = Hbc.load("container-pkg") - -      shutup do -        Hbc::Installer.new(naked_pkg).install -      end - -      dest_path = Hbc.caskroom.join("container-pkg", naked_pkg.version) -      pkg = dest_path.join("container.pkg") -      pkg.must_be :file? -    end - -    it "works properly with an overridden container :type" do -      naked_executable = Hbc.load("naked-executable") - -      shutup do -        Hbc::Installer.new(naked_executable).install -      end - -      dest_path = Hbc.caskroom.join("naked-executable", naked_executable.version) -      executable = dest_path.join("naked_executable") -      executable.must_be :file? -    end - -    it "works fine with a nested container" do -      nested_app = Hbc.load("nested-app") - -      shutup do -        Hbc::Installer.new(nested_app).install -      end - -      dest_path = Hbc.appdir.join("MyNestedApp.app") -      dest_path.must_be :directory? -    end - -    it "generates and finds a timestamped metadata directory for an installed Cask" do -      caffeine = Hbc.load("local-caffeine") - -      shutup do -        Hbc::Installer.new(caffeine).install -      end - -      m_path = caffeine.metadata_path(:now, true) -      caffeine.metadata_path(:now, false).must_equal(m_path) -      caffeine.metadata_path(:latest).must_equal(m_path) -    end - -    it "generates and finds a metadata subdirectory for an installed Cask" do -      caffeine = Hbc.load("local-caffeine") - -      shutup do -        Hbc::Installer.new(caffeine).install -      end - -      subdir_name = "Casks" -      m_subdir = caffeine.metadata_subdir(subdir_name, :now, true) -      caffeine.metadata_subdir(subdir_name, :now, false).must_equal(m_subdir) -      caffeine.metadata_subdir(subdir_name, :latest).must_equal(m_subdir) -    end -  end - -  describe "uninstall" do -    it "fully uninstalls a Cask" do -      caffeine = Hbc.load("local-caffeine") -      installer = Hbc::Installer.new(caffeine) - -      shutup do -        installer.install -        installer.uninstall -      end - -      Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app").wont_be :directory? -      Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory? -      Hbc.caskroom.join("local-caffeine").wont_be :directory? -    end - -    it "uninstalls all versions if force is set" do -      caffeine = Hbc.load("local-caffeine") -      mutated_version = caffeine.version + ".1" - -      shutup do -        Hbc::Installer.new(caffeine).install -      end - -      Hbc.caskroom.join("local-caffeine", caffeine.version).must_be :directory? -      Hbc.caskroom.join("local-caffeine", mutated_version).wont_be  :directory? -      FileUtils.mv(Hbc.caskroom.join("local-caffeine", caffeine.version), Hbc.caskroom.join("local-caffeine", mutated_version)) -      Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory? -      Hbc.caskroom.join("local-caffeine", mutated_version).must_be  :directory? - -      shutup do -        Hbc::Installer.new(caffeine, force: true).uninstall -      end - -      Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory? -      Hbc.caskroom.join("local-caffeine", mutated_version).wont_be  :directory? -      Hbc.caskroom.join("local-caffeine").wont_be :directory? -    end -  end -end diff --git a/Library/Homebrew/cask/test/cask/pkg_test.rb b/Library/Homebrew/cask/test/cask/pkg_test.rb deleted file mode 100644 index 85a42356e..000000000 --- a/Library/Homebrew/cask/test/cask/pkg_test.rb +++ /dev/null @@ -1,94 +0,0 @@ -require "test_helper" - -describe Hbc::Pkg do -  describe "uninstall" do -    it "removes files and dirs referenced by the pkg" do -      pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - -      some_files = Array.new(3) { Pathname(Tempfile.new("testfile").path) } -      pkg.stubs(:pkgutil_bom_files).returns some_files - -      some_specials = Array.new(3) { Pathname(Tempfile.new("testfile").path) } -      pkg.stubs(:pkgutil_bom_specials).returns some_specials - -      some_dirs = Array.new(3) { Pathname(Dir.mktmpdir) } -      pkg.stubs(:pkgutil_bom_dirs).returns some_dirs - -      pkg.stubs(:forget) - -      pkg.uninstall - -      some_files.each do |file| -        file.wont_be :exist? -      end - -      some_dirs.each do |dir| -        dir.wont_be :exist? -      end -    end - -    it "forgets the pkg" do -      pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::FakeSystemCommand) - -      Hbc::FakeSystemCommand.stubs_command( -        ["/usr/sbin/pkgutil", "--only-files", "--files", "my.fake.pkg"] -      ) -      Hbc::FakeSystemCommand.stubs_command( -        ["/usr/sbin/pkgutil", "--only-dirs", "--files", "my.fake.pkg"] -      ) -      Hbc::FakeSystemCommand.stubs_command( -        ["/usr/sbin/pkgutil",                "--files", "my.fake.pkg"] -      ) - -      Hbc::FakeSystemCommand.expects_command( -        ["/usr/bin/sudo", "-E", "--", "/usr/sbin/pkgutil", "--forget", "my.fake.pkg"] -      ) - -      pkg.uninstall -    end - -    it "cleans broken symlinks, but leaves AOK symlinks" do -      pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - -      fake_dir  = Pathname(Dir.mktmpdir) -      fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) } - -      intact_symlink = fake_dir.join("intact_symlink").tap { |path| path.make_symlink(fake_file) } -      broken_symlink = fake_dir.join("broken_symlink").tap { |path| path.make_symlink("im_nota_file") } - -      pkg.stubs(:pkgutil_bom_specials).returns([]) -      pkg.stubs(:pkgutil_bom_files).returns([]) -      pkg.stubs(:pkgutil_bom_dirs).returns([fake_dir]) -      pkg.stubs(:forget) - -      pkg.uninstall - -      intact_symlink.must_be :exist? -      broken_symlink.wont_be :exist? -      fake_dir.must_be :exist? -    end - -    it "snags permissions on ornery dirs, but returns them afterwords" do -      pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - -      fake_dir = Pathname(Dir.mktmpdir) - -      fake_file = fake_dir.join("ima_installed_file").tap { |path| FileUtils.touch(path) } - -      fake_dir.chmod(0000) - -      pkg.stubs(:pkgutil_bom_specials).returns([]) -      pkg.stubs(:pkgutil_bom_files).returns([fake_file]) -      pkg.stubs(:pkgutil_bom_dirs).returns([fake_dir]) -      pkg.stubs(:forget) - -      shutup do -        pkg.uninstall -      end - -      fake_dir.must_be :directory? -      fake_file.wont_be :file? -      (fake_dir.stat.mode % 01000).to_s(8).must_equal "0" -    end -  end -end diff --git a/Library/Homebrew/cask/test/cask/url_checker_test.rb b/Library/Homebrew/cask/test/cask/url_checker_test.rb deleted file mode 100644 index 199182bf2..000000000 --- a/Library/Homebrew/cask/test/cask/url_checker_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -require "test_helper" - -describe Hbc::UrlChecker do -  describe "request processing" do -    let(:cask) { Hbc.load("basic-cask") } -    let(:checker) { Hbc::UrlChecker.new(cask) } -    let(:with_stubbed_fetcher) { -      lambda { |&block| -        Hbc::Fetcher.stub(:head, response) do -          checker.run -          instance_eval(&block) -        end -      } -    } - -    describe "with an empty response" do -      let(:response) { "" } - -      it "adds an error" do -        with_stubbed_fetcher.call do -          expect(checker.errors).must_include("timeout while requesting #{cask.url}") -        end -      end -    end - -    describe "with a valid http response" do -      let(:response) { -        <<-EOS.undent -          HTTP/1.1 200 OK -          Content-Type: application/x-apple-diskimage -          ETag: "b4208f3e84967be4b078ecaa03fba941" -          Content-Length: 23726161 -          Last-Modified: Sun, 12 Aug 2012 21:17:21 GMT -        EOS -      } - -      it "properly populates the response code and headers" do -        with_stubbed_fetcher.call do -          expect(checker.errors).must_be_empty -          expect(checker.response_status).must_equal("HTTP/1.1 200 OK") -          expect(checker.headers).must_equal( -            "Content-Type"   => "application/x-apple-diskimage", -            "ETag"           => '"b4208f3e84967be4b078ecaa03fba941"', -            "Content-Length" => "23726161", -            "Last-Modified"  => "Sun, 12 Aug 2012 21:17:21 GMT" -          ) -        end -      end -    end -  end -end diff --git a/Library/Homebrew/cask/test/cask_test.rb b/Library/Homebrew/cask/test/cask_test.rb deleted file mode 100644 index 64fc21965..000000000 --- a/Library/Homebrew/cask/test/cask_test.rb +++ /dev/null @@ -1,71 +0,0 @@ -require "test_helper" - -describe "Cask" do -  hbc_relative_tap_path = "../../Taps/caskroom/homebrew-cask" -  describe "load" do -    it "returns an instance of the Cask for the given token" do -      c = Hbc.load("adium") -      c.must_be_kind_of(Hbc::Cask) -      c.token.must_equal("adium") -    end - -    it "returns an instance of the Cask from a specific file location" do -      location = File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb") -      c = Hbc.load(location) -      c.must_be_kind_of(Hbc::Cask) -      c.token.must_equal("dia") -    end - -    it "returns an instance of the Cask from a url" do -      url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb") -      c = shutup do -        Hbc.load(url) -      end -      c.must_be_kind_of(Hbc::Cask) -      c.token.must_equal("dia") -    end - -    it "raises an error when failing to download a Cask from a url" do -      lambda { -        url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb") -        shutup do -          Hbc.load(url) -        end -      }.must_raise(Hbc::CaskUnavailableError) -    end - -    it "returns an instance of the Cask from a relative file location" do -      c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb") -      c.must_be_kind_of(Hbc::Cask) -      c.token.must_equal("bbedit") -    end - -    it "uses exact match when loading by token" do -      Hbc.load("test-opera").token.must_equal("test-opera") -      Hbc.load("test-opera-mail").token.must_equal("test-opera-mail") -    end - -    it "raises an error when attempting to load a Cask that doesn't exist" do -      lambda { -        Hbc.load("notacask") -      }.must_raise(Hbc::CaskUnavailableError) -    end -  end - -  describe "all_tokens" do -    it "returns a token for every Cask" do -      all_cask_tokens = Hbc.all_tokens -      all_cask_tokens.count.must_be :>, 20 -      all_cask_tokens.each { |token| token.must_be_kind_of String } -    end -  end - -  describe "metadata" do -    it "proposes a versioned metadata directory name for each instance" do -      cask_token = "adium" -      c = Hbc.load(cask_token) -      metadata_path = Hbc.caskroom.join(cask_token, ".metadata", c.version) -      c.metadata_versioned_container_path.to_s.must_equal(metadata_path.to_s) -    end -  end -end diff --git a/Library/Homebrew/cask/test/plist/parser_test.rb b/Library/Homebrew/cask/test/plist/parser_test.rb deleted file mode 100644 index 7f844e377..000000000 --- a/Library/Homebrew/cask/test/plist/parser_test.rb +++ /dev/null @@ -1,65 +0,0 @@ -require "test_helper" - -describe Plist do -  it "parses some hdiutil output okay" do -    hdiutil_output = <<-EOS.undent -      <?xml version="1.0" encoding="UTF-8"?> -      <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -      <plist version="1.0"> -      <dict> -        <key>system-entities</key> -        <array> -          <dict> -            <key>content-hint</key> -            <string>Apple_partition_map</string> -            <key>dev-entry</key> -            <string>/dev/disk3s1</string> -            <key>potentially-mountable</key> -            <false/> -            <key>unmapped-content-hint</key> -            <string>Apple_partition_map</string> -          </dict> -          <dict> -            <key>content-hint</key> -            <string>Apple_partition_scheme</string> -            <key>dev-entry</key> -            <string>/dev/disk3</string> -            <key>potentially-mountable</key> -            <false/> -            <key>unmapped-content-hint</key> -            <string>Apple_partition_scheme</string> -          </dict> -          <dict> -            <key>content-hint</key> -            <string>Apple_HFS</string> -            <key>dev-entry</key> -            <string>/dev/disk3s2</string> -            <key>mount-point</key> -            <string>/private/tmp/dmg.BhfS2g</string> -            <key>potentially-mountable</key> -            <true/> -            <key>unmapped-content-hint</key> -            <string>Apple_HFS</string> -            <key>volume-kind</key> -            <string>hfs</string> -          </dict> -        </array> -      </dict> -      </plist> -    EOS - -    parsed = Plist.parse_xml(hdiutil_output) - -    parsed.keys.must_equal ["system-entities"] -    parsed["system-entities"].length.must_equal 3 -    parsed["system-entities"].map { |e| e["dev-entry"] }.must_equal %w[ -      /dev/disk3s1 -      /dev/disk3 -      /dev/disk3s2 -    ] -  end - -  it "does not choke on empty input" do -    Plist.parse_xml("").must_equal {} -  end -end diff --git a/Library/Homebrew/cask/test/support/Casks/appdir-interpolation.rb b/Library/Homebrew/cask/test/support/Casks/appdir-interpolation.rb deleted file mode 100644 index fdc09ef5a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/appdir-interpolation.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'appdir-interpolation' do -  version '2.61' -  sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - -  url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" -  homepage 'http://example.com/appdir-interpolation' - -  binary "#{appdir}/some/path" -end diff --git a/Library/Homebrew/cask/test/support/Casks/auto-updates.rb b/Library/Homebrew/cask/test/support/Casks/auto-updates.rb deleted file mode 100644 index 0fcdb991a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/auto-updates.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'auto-updates' do -  version '2.61' -  sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - -  url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" -  homepage 'http://example.com/auto-updates' - -  auto_updates true - -  app 'Transmission.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/bad-checksum.rb b/Library/Homebrew/cask/test/support/Casks/bad-checksum.rb deleted file mode 100644 index 79e5f24c9..000000000 --- a/Library/Homebrew/cask/test/support/Casks/bad-checksum.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'bad-checksum' do -  version '1.2.3' -  sha256 'badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/basic-cask.rb b/Library/Homebrew/cask/test/support/Casks/basic-cask.rb deleted file mode 100644 index d3aaa283e..000000000 --- a/Library/Homebrew/cask/test/support/Casks/basic-cask.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'basic-cask' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url 'http://example.com/TestCask.dmg' -  homepage 'http://example.com/' - -  app 'TestCask.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-7z.rb b/Library/Homebrew/cask/test/support/Casks/container-7z.rb deleted file mode 100644 index 7dd01eee4..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-7z.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'container-7z' do -  version '1.2.3' -  sha256 '3f9542ace85ed5f88549e2d0ea82210f8ddc87e0defbb78469d3aed719b3c964' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.7z" -  homepage 'https://example.com/container-7z' - -  depends_on formula: 'unar' - -  app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-air.rb b/Library/Homebrew/cask/test/support/Casks/container-air.rb deleted file mode 100644 index c310e0a6f..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-air.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_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/cask/test/support/Casks/container-bzip2.rb b/Library/Homebrew/cask/test/support/Casks/container-bzip2.rb deleted file mode 100644 index 9d9bdff98..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-bzip2.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-bzip2' do -  version '1.2.3' -  sha256 'eaf67b3a62cb9275f96e45d05c70b94bef9ef1dae344083e93eda6b0b388a61c' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.bz2" -  homepage 'https://example.com/container-bzip2' - -  app 'container-bzip2--1.2.3' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-cab.rb b/Library/Homebrew/cask/test/support/Casks/container-cab.rb deleted file mode 100644 index ebc7a544e..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-cab.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'container-cab' do -  version '1.2.3' -  sha256 'c267f5cebb14814c8e612a8b7d2bda02aec913f869509b6f1d3883427c0f552b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.cab" -  homepage 'https://example.com/container-cab' - -  depends_on formula: 'cabextract' - -  app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-dmg.rb b/Library/Homebrew/cask/test/support/Casks/container-dmg.rb deleted file mode 100644 index d63596f42..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-dmg.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-dmg' do -  version '1.2.3' -  sha256 '74d89d4fa5cef175cf43666ce11fefa3741aa1522114042ac75e656be37141a1' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.dmg" -  homepage 'https://example.com/container-dmg' - -  app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-gzip.rb b/Library/Homebrew/cask/test/support/Casks/container-gzip.rb deleted file mode 100644 index c2ab00384..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-gzip.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-gzip' do -  version '1.2.3' -  sha256 'fa4ebb5246583c4b6e62e1df4e3b71b4e38a1d7d91c025665827195d36214b20' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.gz" -  homepage 'https://example.com/container-gzip' - -  app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-lzma.rb b/Library/Homebrew/cask/test/support/Casks/container-lzma.rb deleted file mode 100644 index d5f708523..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-lzma.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_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/cask/test/support/Casks/container-pkg.rb b/Library/Homebrew/cask/test/support/Casks/container-pkg.rb deleted file mode 100644 index 959caaa08..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-pkg.rb +++ /dev/null @@ -1,7 +0,0 @@ -test_cask 'container-pkg' do -  version '1.2.3' -  sha256 '611c50c8a2a2098951d2cd0fd54787ed81b92cd97b4b08bd7cba17f1e1d8e40b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.pkg" -  homepage 'https://example.com/container-pkg' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-rar.rb b/Library/Homebrew/cask/test/support/Casks/container-rar.rb deleted file mode 100644 index 7186577a2..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-rar.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_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/cask/test/support/Casks/container-sit.rb b/Library/Homebrew/cask/test/support/Casks/container-sit.rb deleted file mode 100644 index 3a0faad97..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-sit.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_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/cask/test/support/Casks/container-tar-gz.rb b/Library/Homebrew/cask/test/support/Casks/container-tar-gz.rb deleted file mode 100644 index 58e1d82fd..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-tar-gz.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-tar-gz' do -  version '1.2.3' -  sha256 'fab685fabf73d5a9382581ce8698fce9408f5feaa49fa10d9bc6c510493300f5' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.tar.gz" -  homepage 'https://example.com/container-tar-gz' - -  app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-xar.rb b/Library/Homebrew/cask/test/support/Casks/container-xar.rb deleted file mode 100644 index 35e01d0a8..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-xar.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-xar' do -  version '1.2.3' -  sha256 '5bb8e09a6fc630ebeaf266b1fd2d15e2ae7d32d7e4da6668a8093426fa1ba509' - -  url "file://#{TEST_FIXTURE_DIR}/cask/container.xar" -  homepage 'https://example.com/container-xar' - -  app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-xz.rb b/Library/Homebrew/cask/test/support/Casks/container-xz.rb deleted file mode 100644 index b27e908ae..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-xz.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_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/cask/test/support/Casks/invalid/invalid-appcast-multiple.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-multiple.rb deleted file mode 100644 index db2621074..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-multiple.rb +++ /dev/null @@ -1,13 +0,0 @@ -test_cask 'invalid-appcast-multiple' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  appcast 'http://example.com/appcast1.xml', -          checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' -  appcast 'http://example.com/appcast2.xml', -          checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' -  homepage 'http://example.com/invalid-appcast-multiple' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-url.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-url.rb deleted file mode 100644 index b4c11b1be..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-url.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-appcast-url' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  appcast 1, -          checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' -  homepage 'http://example.com/invalid-appcast-url' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-conflicts-with-key.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-conflicts-with-key.rb deleted file mode 100644 index d39d124b0..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-conflicts-with-key.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-conflicts-with-key' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-conflicts-with-key' - -  conflicts_with no_such_key: 'unar' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-arch-value.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-arch-value.rb deleted file mode 100644 index b0c919a9b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-arch-value.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-depends-on-arch-value' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-depends-on-arch-value' - -  depends_on arch: :no_such_arch - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-key.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-key.rb deleted file mode 100644 index 05304e806..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-key.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-depends-on-key' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-depends-on-key' - -  depends_on no_such_key: 'unar' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-bad-release.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-bad-release.rb deleted file mode 100644 index 183dd5d91..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-bad-release.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-depends-on-macos-bad-release' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-depends-on-macos-bad-release' - -  depends_on macos: :no_such_release - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb deleted file mode 100644 index b1f763d76..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'invalid-depends-on-macos-conflicting-forms' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-depends-on-macos-conflicting-forms' - -  depends_on macos: :yosemite -  depends_on macos: '>= :mavericks' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-x11-value.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-x11-value.rb deleted file mode 100644 index eefd3ac40..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-x11-value.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-depends-on-x11-value' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-depends-on-x11-value' - -  depends_on x11: :no_such_value - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-conflicting-keys.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-conflicting-keys.rb deleted file mode 100644 index bf14d372b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-conflicting-keys.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'invalid-gpg-conflicting-keys' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-gpg-conflicting-keys' -  gpg 'http://example.com/gpg-signature.asc', -      key_id:  '01234567', -      key_url: 'http://example.com/gpg-key-url' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-id.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-id.rb deleted file mode 100644 index 626e02a47..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-id.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-gpg-key-id' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-gpg-key-id' -  gpg 'http://example.com/gpg-signature.asc', -      key_id: '012' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-url.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-url.rb deleted file mode 100644 index 77d41ed6b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-url.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-gpg-key-url' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-gpg-key-url' -  gpg 'http://example.com/gpg-signature.asc', -      key_url: 1 - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-missing-key.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-missing-key.rb deleted file mode 100644 index 460bcd532..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-missing-key.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-gpg-missing-key' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-gpg-missing-keys' -  gpg 'http://example.com/gpg-signature.asc' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-multiple-stanzas.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-multiple-stanzas.rb deleted file mode 100644 index 8abc89486..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-multiple-stanzas.rb +++ /dev/null @@ -1,13 +0,0 @@ -test_cask 'invalid-gpg-multiple-stanzas' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-gpg-multiple-stanzas' -  gpg 'http://example.com/gpg-signature.asc', -      key_id: '01234567' -  gpg 'http://example.com/gpg-signature.asc', -      key_id: '01234567' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-parameter.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-parameter.rb deleted file mode 100644 index f1abc9225..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-parameter.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-gpg-parameter' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-gpg-type' -  gpg 'http://example.com/gpg-signature.asc', -      no_such_parameter: :value - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-signature-url.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-signature-url.rb deleted file mode 100644 index 1b9e7362f..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-signature-url.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-gpg-signature-url' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-gpg-signature-url' -  gpg 1, -      key_id: '01234567' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-type.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-type.rb deleted file mode 100644 index 266047617..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-type.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-gpg-type' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/invalid-gpg-type' -  gpg 'http://example.com/gpg-signature.asc', -      no_such_parameter: :value - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-format.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-format.rb deleted file mode 100644 index a8159c979..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-format.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask => 'invalid-header-format' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb deleted file mode 100644 index 2b8ad5619..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'invalid-header-token-mismatch-this-text-does-not-belong' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-version.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-version.rb deleted file mode 100644 index 47851c0e0..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-version.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'invalid-header-version' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-stage-only-conflict.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-stage-only-conflict.rb deleted file mode 100644 index 84510ac24..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-stage-only-conflict.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-stage-only-conflict' do -  version '2.61' -  sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - -  url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" -  homepage 'http://example.com/invalid-stage-only-conflict' - -  app 'Transmission.app' -  stage_only true -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-homepage.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-homepage.rb deleted file mode 100644 index d4e5ff4a9..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-homepage.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-two-homepage' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' -  homepage 'http://www.example.com/local-caffeine' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-url.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-url.rb deleted file mode 100644 index 49e470788..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-url.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-two-url' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  url 'http://example.com/caffeine.zip' -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-version.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-version.rb deleted file mode 100644 index c9fe37772..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-version.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-two-version' do -  version '1.2.3' -  version '2.0' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/local-caffeine.rb b/Library/Homebrew/cask/test/support/Casks/local-caffeine.rb deleted file mode 100644 index 2be9b4397..000000000 --- a/Library/Homebrew/cask/test/support/Casks/local-caffeine.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'local-caffeine' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/local-transmission.rb b/Library/Homebrew/cask/test/support/Casks/local-transmission.rb deleted file mode 100644 index f5244d0a5..000000000 --- a/Library/Homebrew/cask/test/support/Casks/local-transmission.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'local-transmission' do -  version '2.61' -  sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - -  url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" -  homepage 'http://example.com/local-transmission' - -  app 'Transmission.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/missing-checksum.rb b/Library/Homebrew/cask/test/support/Casks/missing-checksum.rb deleted file mode 100644 index 5e1886a57..000000000 --- a/Library/Homebrew/cask/test/support/Casks/missing-checksum.rb +++ /dev/null @@ -1,8 +0,0 @@ -test_cask 'missing-checksum' do -  version '1.2.3' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/naked-executable.rb b/Library/Homebrew/cask/test/support/Casks/naked-executable.rb deleted file mode 100644 index 619c7a5fb..000000000 --- a/Library/Homebrew/cask/test/support/Casks/naked-executable.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'naked-executable' do -  version '1.2.3' -  sha256 '306c6ca7407560340797866e077e053627ad409277d1b9da58106fce4cf717cb' - -  url "file://#{TEST_FIXTURE_DIR}/cask/naked_executable" -  homepage 'http://example.com/naked-executable' - -  container type: :naked -end diff --git a/Library/Homebrew/cask/test/support/Casks/nested-app.rb b/Library/Homebrew/cask/test/support/Casks/nested-app.rb deleted file mode 100644 index 526c7414a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/nested-app.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'nested-app' do -  version '1.2.3' -  sha256 '1866dfa833b123bb8fe7fa7185ebf24d28d300d0643d75798bc23730af734216' - -  url "file://#{TEST_FIXTURE_DIR}/cask/NestedApp.dmg.zip" -  homepage 'http://example.com/nested-app' - -  container nested: 'NestedApp.dmg' - -  app 'MyNestedApp.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/no-checksum.rb b/Library/Homebrew/cask/test/support/Casks/no-checksum.rb deleted file mode 100644 index d9ba354f5..000000000 --- a/Library/Homebrew/cask/test/support/Casks/no-checksum.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'no-checksum' do -  version '1.2.3' -  sha256 :no_check - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/no-dsl-version.rb b/Library/Homebrew/cask/test/support/Casks/no-dsl-version.rb deleted file mode 100644 index ee557b1e4..000000000 --- a/Library/Homebrew/cask/test/support/Casks/no-dsl-version.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'no-dsl-version' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url 'http://example.com/TestCask.dmg' -  homepage 'http://example.com/' - -  app 'TestCask.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/stage-only.rb b/Library/Homebrew/cask/test/support/Casks/stage-only.rb deleted file mode 100644 index b52b5d3d2..000000000 --- a/Library/Homebrew/cask/test/support/Casks/stage-only.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'stage-only' do -  version '2.61' -  sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - -  url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" -  homepage 'http://example.com/stage-only' - -  stage_only true -end diff --git a/Library/Homebrew/cask/test/support/Casks/test-opera-mail.rb b/Library/Homebrew/cask/test/support/Casks/test-opera-mail.rb deleted file mode 100644 index afc8387c7..000000000 --- a/Library/Homebrew/cask/test/support/Casks/test-opera-mail.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'test-opera-mail' do -  version '1.0' -  sha256 'afd192e308f8ea8ddb3d426fd6663d97078570417ee78b8e1fa15f515ae3d677' - -  url 'http://get-ash-1.opera.com/pub/opera/mail/1.0/mac/Opera-Mail-1.0-1040.i386.dmg' -  homepage 'http://www.opera.com/computer/mail' - -  app 'Opera Mail.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/test-opera.rb b/Library/Homebrew/cask/test/support/Casks/test-opera.rb deleted file mode 100644 index ec32828f7..000000000 --- a/Library/Homebrew/cask/test/support/Casks/test-opera.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'test-opera' do -  version '19.0.1326.47' -  sha256 '7b91f20ab754f7b3fef8dc346e0393917e11676b74c8f577408841619f76040a' - -  url 'http://get.geo.opera.com/pub/opera/desktop/19.0.1326.47/mac/Opera_19.0.1326.47_Setup.dmg' -  homepage 'http://www.opera.com/' - -  app 'Opera.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-accessibility-access.rb b/Library/Homebrew/cask/test/support/Casks/with-accessibility-access.rb deleted file mode 100644 index 1aa7bc8f7..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-accessibility-access.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-accessibility-access' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url 'http://example.com/TestCask.dmg' -  homepage 'http://example.com/' - -  accessibility_access true - -  app 'TestCask.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-alt-target.rb b/Library/Homebrew/cask/test/support/Casks/with-alt-target.rb deleted file mode 100644 index b75ff320c..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-alt-target.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-alt-target' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app', target: 'AnotherName.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-appcast.rb b/Library/Homebrew/cask/test/support/Casks/with-appcast.rb deleted file mode 100644 index f99f7a93c..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-appcast.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-appcast' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  appcast 'http://example.com/appcast.xml', -          checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' -  homepage 'http://example.com/with-appcast' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-caveats.rb b/Library/Homebrew/cask/test/support/Casks/with-caveats.rb deleted file mode 100644 index 30d3a49b3..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-caveats.rb +++ /dev/null @@ -1,23 +0,0 @@ -test_cask 'with-caveats' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' - -  # simple string is evaluated at compile-time -  caveats <<-EOS.undent -    Here are some things you might want to know. -  EOS -  # do block is evaluated at install-time -  caveats do -    "Cask token: #{token}" -  end -  # a do block may print and use a DSL -  caveats do -    puts 'Custom text via puts followed by DSL-generated text:' -    path_environment_variable('/custom/path/bin') -  end -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-choices.rb b/Library/Homebrew/cask/test/support/Casks/with-choices.rb deleted file mode 100644 index 1871efab3..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-choices.rb +++ /dev/null @@ -1,16 +0,0 @@ -test_cask 'with-choices' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg', -      choices: [ -                 { -                   'choiceIdentifier' => 'choice1', -                   'choiceAttribute'  => 'selected', -                   'attributeSetting' => 1, -                 }, -               ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-conditional-caveats.rb b/Library/Homebrew/cask/test/support/Casks/with-conditional-caveats.rb deleted file mode 100644 index d8a3836b8..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-conditional-caveats.rb +++ /dev/null @@ -1,14 +0,0 @@ -test_cask 'with-conditional-caveats' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app' - -  # a do block may print and use a DSL -  caveats do -    puts 'This caveat is conditional' if false # rubocop:disable Lint/LiteralInCondition -  end -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-conflicts-with.rb b/Library/Homebrew/cask/test/support/Casks/with-conflicts-with.rb deleted file mode 100644 index a20d932ba..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-conflicts-with.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-conflicts-with' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-conflicts-with' - -  conflicts_with formula: 'unar' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb deleted file mode 100644 index e0c4e3fa7..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-arch' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-arch' - -  # covers all known hardware; always succeeds -  depends_on arch: :intel - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic-helper.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic-helper.rb deleted file mode 100644 index 327fc4000..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic-helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-cask-cyclic-helper' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-cask-cyclic-helper' - -  depends_on cask: 'with-depends-on-cask-cyclic' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic.rb deleted file mode 100644 index f74d860bf..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-cask-cyclic' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-cask-cyclic' - -  depends_on cask: 'local-caffeine' -  depends_on cask: 'with-depends-on-cask-cyclic-helper' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-multiple.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-multiple.rb deleted file mode 100644 index bb69b7506..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-multiple.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-cask-multiple' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-cask-multiple' - -  depends_on cask: 'local-caffeine' -  depends_on cask: 'local-transmission' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask.rb deleted file mode 100644 index 05a180560..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-cask' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-cask' - -  depends_on cask: 'local-transmission' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula-multiple.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula-multiple.rb deleted file mode 100644 index c99d2dee1..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula-multiple.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-formula-multiple' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-formula-multiple' - -  depends_on formula: 'unar' -  depends_on formula: 'fileutils' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula.rb deleted file mode 100644 index b0339e68c..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-formula' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-formula' - -  depends_on formula: 'unar' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-array.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-array.rb deleted file mode 100644 index cae16704c..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-array.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-macos-array' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-macos-array' - -  # since all OS releases are included, this should always pass -  depends_on macos: ['10.4', '10.5', '10.6', '10.7', '10.8', '10.9', '10.10', MacOS.version.to_s] - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-comparison.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-comparison.rb deleted file mode 100644 index 7f14dd84f..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-comparison.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-macos-comparison' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-macos-comparison' - -  depends_on macos: '>= 10.4' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-failure.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-failure.rb deleted file mode 100644 index ecefff362..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-failure.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-macos-failure' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-macos-failure' - -  # guarantee a mismatched release -  depends_on macos: MacOS.version.to_s == '10.4' ? '10.5' : '10.4' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-string.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-string.rb deleted file mode 100644 index 6e370d46a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-string.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-macos-string' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-macos-string' - -  depends_on macos: MacOS.version.to_s - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-symbol.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-symbol.rb deleted file mode 100644 index 7f11b6e64..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-symbol.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-macos-symbol' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-macos-symbol' - -  depends_on macos: MacOS.version.to_sym - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11-false.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11-false.rb deleted file mode 100644 index fc84f2daa..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11-false.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-x11-false' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-x11-false' - -  depends_on x11: false - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11.rb deleted file mode 100644 index b1a7bad2b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-x11' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-depends-on-x11' - -  depends_on x11: true - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-dsl-version.rb b/Library/Homebrew/cask/test/support/Casks/with-dsl-version.rb deleted file mode 100644 index c16343c4b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-dsl-version.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask :v1 => 'with-dsl-version' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url 'http://example.com/TestCask.dmg' -  homepage 'http://example.com/' - -  app 'TestCask.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact-no-target.rb b/Library/Homebrew/cask/test/support/Casks/with-generic-artifact-no-target.rb deleted file mode 100644 index a7d347fb5..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact-no-target.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-generic-artifact-no-target' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-generic-artifact' - -  artifact 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact.rb b/Library/Homebrew/cask/test/support/Casks/with-generic-artifact.rb deleted file mode 100644 index e718b994b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-generic-artifact' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-generic-artifact' - -  artifact 'Caffeine.app', target: "#{Hbc.appdir}/Caffeine.app" -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-gpg-key-url.rb b/Library/Homebrew/cask/test/support/Casks/with-gpg-key-url.rb deleted file mode 100644 index 6aa735e1f..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-gpg-key-url.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-gpg-key-url' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-gpg-key-url' -  gpg 'http://example.com/gpg-signature.asc', -      key_url: 'http://example.com/gpg-key-url' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-gpg.rb b/Library/Homebrew/cask/test/support/Casks/with-gpg.rb deleted file mode 100644 index 1f7042515..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-gpg.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-gpg' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-gpg' -  gpg 'http://example.com/gpg-signature.asc', -      key_id: '01234567' - -  app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-installable.rb b/Library/Homebrew/cask/test/support/Casks/with-installable.rb deleted file mode 100644 index d1105b50e..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-installable.rb +++ /dev/null @@ -1,20 +0,0 @@ -test_cask 'with-installable' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  uninstall script:     { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] }, -            quit:       'my.fancy.package.app', -            login_item: 'Fancy', -            delete:     [ -                          '/permissible/absolute/path', -                          '~/permissible/path/with/tilde', -                          'impermissible/relative/path', -                          '/another/impermissible/../relative/path', -                        ], -            rmdir:      "#{TEST_FIXTURE_DIR}/cask/empty_directory" -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-installer-manual.rb b/Library/Homebrew/cask/test/support/Casks/with-installer-manual.rb deleted file mode 100644 index 92e2e09df..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-installer-manual.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-installer-manual' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  installer manual: 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-installer-script.rb b/Library/Homebrew/cask/test/support/Casks/with-installer-script.rb deleted file mode 100644 index 5e98eab48..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-installer-script.rb +++ /dev/null @@ -1,15 +0,0 @@ -test_cask 'with-installer-script' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/with-install-script' - -  installer script: '/usr/bin/true', -            args:   ['--flag'] -  # acceptable alternate form -  installer script: { -                      executable: '/usr/bin/false', -                      args:       ['--flag'], -                    } -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-macosx-dir.rb b/Library/Homebrew/cask/test/support/Casks/with-macosx-dir.rb deleted file mode 100644 index 837627119..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-macosx-dir.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-macosx-dir' do -  version '1.2.3' -  sha256 '5633c3a0f2e572cbf021507dec78c50998b398c343232bdfc7e26221d0a5db4d' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip" -  homepage 'http://example.com/MyFancyApp' - -  app 'MyFancyApp/MyFancyApp.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-pkgutil-zap.rb b/Library/Homebrew/cask/test/support/Casks/with-pkgutil-zap.rb deleted file mode 100644 index 8bb42c447..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-pkgutil-zap.rb +++ /dev/null @@ -1,13 +0,0 @@ -test_cask 'with-pkgutil-zap' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'Fancy.pkg' - -  zap pkgutil:   'my.fancy.package.*', -      kext:      'my.fancy.package.kernelextension', -      launchctl: 'my.fancy.package.service' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-suite.rb b/Library/Homebrew/cask/test/support/Casks/with-suite.rb deleted file mode 100644 index c36151d52..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-suite.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-suite' do -  version '1.2.3' -  sha256 'd95dcc12d4e5be0bc3cb9793c4b7e7f69a25f0b3c7418494b0c883957e6eeae4' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine-suite.zip" -  name 'Caffeine' -  homepage 'http://example.com/with-suite' - -  suite 'Caffeine' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-two-apps-correct.rb b/Library/Homebrew/cask/test/support/Casks/with-two-apps-correct.rb deleted file mode 100644 index 8eb68d88a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-two-apps-correct.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-two-apps-correct' do -  version '1.2.3' -  sha256 '3178fbfd1ea5d87a2a0662a4eb599ebc9a03888e73f37538d9f3f6ee69d2368e' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeines.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine Mini.app' -  app 'Caffeine Pro.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-two-apps-incorrect.rb b/Library/Homebrew/cask/test/support/Casks/with-two-apps-incorrect.rb deleted file mode 100644 index 6bd316dfe..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-two-apps-incorrect.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-two-apps-incorrect' do -  version '1.2.3' -  sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeine.app', 'Caffeine.app/Contents/MacOS/Caffeine' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-two-apps-subdir.rb b/Library/Homebrew/cask/test/support/Casks/with-two-apps-subdir.rb deleted file mode 100644 index 202423691..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-two-apps-subdir.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-two-apps-subdir' do -  version '1.2.3' -  sha256 'd687c22a21c02bd8f07da9302c8292b93a04df9a929e3f04d09aea6c76f75c65' - -  url "file://#{TEST_FIXTURE_DIR}/cask/caffeines-subdir.zip" -  homepage 'http://example.com/local-caffeine' - -  app 'Caffeines/Caffeine Mini.app' -  app 'Caffeines/Caffeine Pro.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-delete.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-delete.rb deleted file mode 100644 index 203f18405..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-delete.rb +++ /dev/null @@ -1,16 +0,0 @@ -test_cask 'with-uninstall-delete' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'Fancy.pkg' - -  uninstall delete: [ -                      '/permissible/absolute/path', -                      '~/permissible/path/with/tilde', -                      'impermissible/relative/path', -                      '/another/impermissible/../relative/path', -                    ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-early-script.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-early-script.rb deleted file mode 100644 index a26abab1c..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-early-script.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-early-script' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  uninstall early_script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-kext.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-kext.rb deleted file mode 100644 index fa54c7e1f..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-kext.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-kext' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'Fancy.pkg' - -  uninstall kext: 'my.fancy.package.kernelextension' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-launchctl.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-launchctl.rb deleted file mode 100644 index 51ad45a09..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-launchctl.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-launchctl' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip" -  homepage 'http://example.com/fancy' - -  app 'Fancy.app' - -  uninstall launchctl: 'my.fancy.package.service' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-login-item.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-login-item.rb deleted file mode 100644 index 26dca6f1a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-login-item.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-login-item' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  uninstall login_item: 'Fancy' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-pkgutil.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-pkgutil.rb deleted file mode 100644 index db77a460b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-pkgutil.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-pkgutil' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'Fancy.pkg' - -  uninstall pkgutil: 'my.fancy.package.*' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-quit.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-quit.rb deleted file mode 100644 index 19337b18a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-quit.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-quit' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  uninstall quit: 'my.fancy.package.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-rmdir.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-rmdir.rb deleted file mode 100644 index 88142ea71..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-rmdir.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-rmdir' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  uninstall rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-script.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-script.rb deleted file mode 100644 index d2e0d6167..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-script.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-script' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  uninstall script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-signal.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-signal.rb deleted file mode 100644 index cc32b888a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-signal.rb +++ /dev/null @@ -1,14 +0,0 @@ -test_cask 'with-uninstall-signal' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  uninstall signal: [ -                      ['TERM', 'my.fancy.package.app'], -                      ['KILL', 'my.fancy.package.app'], -                    ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-trash.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-trash.rb deleted file mode 100644 index 4fe58a19a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-trash.rb +++ /dev/null @@ -1,16 +0,0 @@ -test_cask 'with-uninstall-trash' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'Fancy.pkg' - -  uninstall trash: [ -                     '/permissible/absolute/path', -                     '~/permissible/path/with/tilde', -                     'impermissible/relative/path', -                     '/another/impermissible/../relative/path', -                   ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-delete.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-delete.rb deleted file mode 100644 index c76a9acb0..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-delete.rb +++ /dev/null @@ -1,16 +0,0 @@ -test_cask 'with-zap-delete' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'Fancy.pkg' - -  zap delete: [ -                '/permissible/absolute/path', -                '~/permissible/path/with/tilde', -                'impermissible/relative/path', -                '/another/impermissible/../relative/path', -              ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-early-script.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-early-script.rb deleted file mode 100644 index d35c1809e..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-early-script.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-early-script' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  zap early_script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-kext.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-kext.rb deleted file mode 100644 index 463fe8133..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-kext.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-kext' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'Fancy.pkg' - -  zap kext: 'my.fancy.package.kernelextension' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-launchctl.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-launchctl.rb deleted file mode 100644 index aab285672..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-launchctl.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-launchctl' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip" -  homepage 'http://example.com/fancy' - -  app 'Fancy.app' - -  zap launchctl: 'my.fancy.package.service' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-login-item.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-login-item.rb deleted file mode 100644 index d7ba9a65b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-login-item.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-login-item' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  zap login_item: 'Fancy' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-pkgutil.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-pkgutil.rb deleted file mode 100644 index 17a667000..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-pkgutil.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-pkgutil' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'Fancy.pkg' - -  zap pkgutil: 'my.fancy.package.*' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-quit.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-quit.rb deleted file mode 100644 index 21f824ae9..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-quit.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-quit' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  zap quit: 'my.fancy.package.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-rmdir.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-rmdir.rb deleted file mode 100644 index eac02ad0e..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-rmdir.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-rmdir' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  zap rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-script.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-script.rb deleted file mode 100644 index f8646a267..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-script.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-script' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  zap script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-signal.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-signal.rb deleted file mode 100644 index 5accd8337..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-signal.rb +++ /dev/null @@ -1,14 +0,0 @@ -test_cask 'with-zap-signal' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  zap signal: [ -                ['TERM', 'my.fancy.package.app'], -                ['KILL', 'my.fancy.package.app'], -              ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-trash.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-trash.rb deleted file mode 100644 index aef4e0eab..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-trash.rb +++ /dev/null @@ -1,16 +0,0 @@ -test_cask 'with-zap-trash' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'Fancy.pkg' - -  zap trash: [ -               '/permissible/absolute/path', -               '~/permissible/path/with/tilde', -               'impermissible/relative/path', -               '/another/impermissible/../relative/path', -             ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap.rb b/Library/Homebrew/cask/test/support/Casks/with-zap.rb deleted file mode 100644 index 056c90671..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap.rb +++ /dev/null @@ -1,19 +0,0 @@ -test_cask 'with-zap' do -  version '1.2.3' -  sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - -  url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" -  homepage 'http://example.com/fancy-pkg' - -  pkg 'MyFancyPkg/Fancy.pkg' - -  uninstall quit: 'my.fancy.package.app.from.uninstall' - -  zap script:     { -                    executable: 'MyFancyPkg/FancyUninstaller.tool', -                    args:       %w[--please], -                  }, -      quit:       'my.fancy.package.app', -      login_item: 'Fancy', -      delete:     '~/Library/Preferences/my.fancy.app.plist' -end diff --git a/Library/Homebrew/cask/test/support/cleanup.rb b/Library/Homebrew/cask/test/support/cleanup.rb deleted file mode 100644 index c31a74be2..000000000 --- a/Library/Homebrew/cask/test/support/cleanup.rb +++ /dev/null @@ -1,10 +0,0 @@ -module MiniTest -  class Spec -    def after_teardown -      super -      Hbc.installed.each do |cask| -        Hbc::Installer.new(cask).purge_versioned_files -      end -    end -  end -end diff --git a/Library/Homebrew/cask/test/support/fake_dirs.rb b/Library/Homebrew/cask/test/support/fake_dirs.rb deleted file mode 100644 index ea7acc685..000000000 --- a/Library/Homebrew/cask/test/support/fake_dirs.rb +++ /dev/null @@ -1,31 +0,0 @@ -# wire in a set of fake link dirs per-test -module FakeDirHooks -  DIRS = [:appdir, :qlplugindir, :binarydir].freeze - -  def before_setup -    super - -    @canned_dirs = {} - -    DIRS.each do |dir_name| -      dir = HOMEBREW_PREFIX.join("#{dir_name}-#{Time.now.to_i}-#{rand(1024)}") -      dir.mkpath -      Hbc.send("#{dir_name}=", dir) -      @canned_dirs[:dir_name] = dir -    end -  end - -  def after_teardown -    super - -    @canned_dirs.each_value do |dir| -      dir.rmtree if dir.exist? -    end -  end -end - -module MiniTest -  class Spec -    include FakeDirHooks -  end -end diff --git a/Library/Homebrew/cask/test/support/shared_examples.rb b/Library/Homebrew/cask/test/support/shared_examples.rb deleted file mode 100644 index 594ca81c1..000000000 --- a/Library/Homebrew/cask/test/support/shared_examples.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Adapted from https://gist.github.com/jodosha/1560208 -MiniTest::Spec.class_eval do -  def self.shared_examples -    @shared_examples ||= {} -  end -end - -module MiniTest -  class Spec -    module SharedExamples -      def shared_examples_for(desc, &block) -        MiniTest::Spec.shared_examples[desc] = block -      end - -      def it_behaves_like(desc, *args, &block) -        instance_exec(*args, &MiniTest::Spec.shared_examples[desc]) -        instance_eval(&block) if block_given? -      end -    end -  end -end - -Object.class_eval do -  include(MiniTest::Spec::SharedExamples) -end diff --git a/Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb b/Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb deleted file mode 100644 index 28115bb4b..000000000 --- a/Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "test_helper" - -shared_examples_for Hbc::DSL::Base do -  it "supports the token method" do -    dsl.token.must_equal cask.token -  end - -  it "supports the version method" do -    dsl.version.must_equal cask.version -  end - -  it "supports the caskroom_path method" do -    dsl.caskroom_path.must_equal cask.caskroom_path -  end - -  it "supports the staged_path method" do -    dsl.staged_path.must_equal cask.staged_path -  end - -  it "supports the appdir method" do -    dsl.appdir.must_equal cask.appdir -  end -end diff --git a/Library/Homebrew/cask/test/support/shared_examples/staged.rb b/Library/Homebrew/cask/test/support/shared_examples/staged.rb deleted file mode 100644 index ef4ff0341..000000000 --- a/Library/Homebrew/cask/test/support/shared_examples/staged.rb +++ /dev/null @@ -1,109 +0,0 @@ -require "test_helper" - -shared_examples_for Hbc::Staged do -  let(:fake_pathname_exists) { -    fake_pathname = Pathname("/path/to/file/that/exists") -    fake_pathname.stubs(exist?: true, expand_path: fake_pathname) -    fake_pathname -  } - -  let(:fake_pathname_does_not_exist) { -    fake_pathname = Pathname("/path/to/file/that/does/not/exist") -    fake_pathname.stubs(exist?: false, expand_path: fake_pathname) -    fake_pathname -  } - -  it "can run system commands with list-form arguments" do -    Hbc::FakeSystemCommand.expects_command( -      ["echo", "homebrew-cask", "rocks!"] -    ) -    staged.system_command("echo", args: ["homebrew-cask", "rocks!"]) -  end - -  it "can get the Info.plist file for the primary app" do -    staged.info_plist_file.to_s.must_include Hbc.appdir.join("TestCask.app/Contents/Info.plist") -  end - -  it "can execute commands on the Info.plist file" do -    staged.stubs(bundle_identifier: "com.example.BasicCask") - -    Hbc::FakeSystemCommand.expects_command( -      ["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file] -    ) -    staged.plist_exec("Print CFBundleIdentifier") -  end - -  it "can set a key in the Info.plist file" do -    staged.stubs(bundle_identifier: "com.example.BasicCask") - -    Hbc::FakeSystemCommand.expects_command( -      ["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file] -    ) -    staged.plist_set(":JVMOptions:JVMVersion", "1.6+") -  end - -  it "can set the permissions of a file" do -    fake_pathname = fake_pathname_exists -    staged.stubs(Pathname: fake_pathname) - -    Hbc::FakeSystemCommand.expects_command( -      ["/usr/bin/sudo", "-E", "--", "/bin/chmod", "-R", "--", "777", fake_pathname] -    ) -    staged.set_permissions(fake_pathname.to_s, "777") -  end - -  it "can set the permissions of multiple files" do -    fake_pathname = fake_pathname_exists -    staged.stubs(:Pathname).returns(fake_pathname) - -    Hbc::FakeSystemCommand.expects_command( -      ["/usr/bin/sudo", "-E", "--", "/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname] -    ) -    staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777") -  end - -  it "cannot set the permissions of a file that does not exist" do -    fake_pathname = fake_pathname_does_not_exist -    staged.stubs(Pathname: fake_pathname) -    staged.set_permissions(fake_pathname.to_s, "777") -  end - -  it "can set the ownership of a file" do -    staged.stubs(current_user: "fake_user") -    fake_pathname = fake_pathname_exists -    staged.stubs(Pathname: fake_pathname) - -    Hbc::FakeSystemCommand.expects_command( -      ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname] -    ) -    staged.set_ownership(fake_pathname.to_s) -  end - -  it "can set the ownership of multiple files" do -    staged.stubs(current_user: "fake_user") -    fake_pathname = fake_pathname_exists -    staged.stubs(Pathname: fake_pathname) - -    Hbc::FakeSystemCommand.expects_command( -      ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname] -    ) -    staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s]) -  end - -  it "can set the ownership of a file with a different user and group" do -    fake_pathname = fake_pathname_exists -    staged.stubs(Pathname: fake_pathname) - -    Hbc::FakeSystemCommand.expects_command( -      ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname] -    ) -    staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group") -  end - -  it "cannot set the ownership of a file that does not exist" do -    staged.stubs(current_user: "fake_user") -    fake_pathname = fake_pathname_does_not_exist -    staged.stubs(Pathname: fake_pathname) -    staged.set_ownership(fake_pathname.to_s) -  end -end diff --git a/Library/Homebrew/cask/test/syntax_test.rb b/Library/Homebrew/cask/test/syntax_test.rb deleted file mode 100644 index 0ea832bde..000000000 --- a/Library/Homebrew/cask/test/syntax_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "test_helper" - -describe "Syntax check" do -  project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../")) -  backend_files = Dir[project_root.join("**", "*.rb")].reject { |f| f.match %r{/vendor/|/Casks/} } -  interpreter = RUBY_PATH -  flags = %w[-c] -  flags.unshift "--disable-all" -  backend_files.each do |file| -    it "#{file} is valid Ruby" do -      args = flags + ["--", file] -      shutup do -        raise SyntaxError, "#{file} failed syntax check" unless system(interpreter, *args) -      end -    end -  end -end diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb deleted file mode 100644 index 275ede304..000000000 --- a/Library/Homebrew/cask/test/test_helper.rb +++ /dev/null @@ -1,110 +0,0 @@ -require "bundler" -require "bundler/setup" -require "pathname" - -require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] - -# add Homebrew to load path -$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew")) -$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew/test/support/lib")) - -require "global" - -# add Homebrew-Cask to load path -$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s) - -require "test/support/helper/env" -require "test/support/helper/shutup" -include Test::Helper::Env -include Test::Helper::Shutup - -def sudo(*args) -  %w[/usr/bin/sudo -E --] + args.flatten -end - -# must be called after testing_env so at_exit hooks are in proper order -require "minitest/autorun" -require "minitest/reporters" -Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true) - -require "parallel_tests/test/runtime_logger" - -# Force mocha to patch MiniTest since we have both loaded thanks to homebrew's testing_env -require "mocha/api" -require "mocha/integration/mini_test" -Mocha::Integration::MiniTest.activate - -# our baby -require "hbc" - -module Hbc -  class TestCask < Cask; end -end - -# create and override default directories -Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath) -Hbc.cache.mkpath -Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath) -Hbc.default_tap = Tap.fetch("caskroom", "test").tap do |tap| -  # link test casks -  FileUtils.mkdir_p tap.path.dirname -  FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), tap.path -end - -# pretend that the caskroom/cask Tap is installed -FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path - -class TestHelper -  # helpers for test Casks to reference local files easily -  def self.local_binary_path(name) -    File.expand_path(File.join(File.dirname(__FILE__), "support", "binaries", name)) -  end - -  def self.local_binary_url(name) -    "file://" + local_binary_path(name) -  end - -  def self.valid_alias?(candidate) -    return false unless candidate.symlink? -    candidate.readlink.exist? -  end - -  def self.install_without_artifacts(cask) -    Hbc::Installer.new(cask).tap do |i| -      shutup do -        i.download -        i.extract_primary_container -      end -    end -  end - -  def self.install_with_caskfile(cask) -    Hbc::Installer.new(cask).tap do |i| -      shutup do -        i.save_caskfile -      end -    end -  end - -  def self.install_without_artifacts_with_caskfile(cask) -    Hbc::Installer.new(cask).tap do |i| -      shutup do -        i.download -        i.extract_primary_container -        i.save_caskfile -      end -    end -  end -end - -# Extend MiniTest API with support for RSpec-style shared examples -require "support/shared_examples" -require "support/shared_examples/dsl_base.rb" -require "support/shared_examples/staged.rb" - -require "support/fake_dirs" -require "support/fake_system_command" -require "support/cleanup" -require "support/never_sudo_system_command" -require "tmpdir" -require "tempfile"  | 
