aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/cask/lib/hbc.rb5
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/binary.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/pkg.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cache.rb7
-rw-r--r--Library/Homebrew/cask/lib/hbc/cask.rb5
-rw-r--r--Library/Homebrew/cask/lib/hbc/caskroom.rb15
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli.rb46
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/cleanup.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb63
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/style.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/locations.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/options.rb39
-rw-r--r--Library/Homebrew/cask/lib/hbc/system_command.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/utils.rb37
-rw-r--r--Library/Homebrew/compat/hbc.rb17
-rw-r--r--Library/Homebrew/compat/hbc/cache.rb13
-rw-r--r--Library/Homebrew/compat/hbc/caskroom.rb20
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb1
-rw-r--r--Library/Homebrew/test/cask/artifact/binary_spec.rb16
-rw-r--r--Library/Homebrew/test/cask/cli/cleanup_spec.rb2
-rw-r--r--Library/Homebrew/test/cask/cli/options_spec.rb18
-rw-r--r--Library/Homebrew/test/cask/cli_spec.rb11
23 files changed, 142 insertions, 191 deletions
diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb
index c971cbd58..3cdec07d2 100644
--- a/Library/Homebrew/cask/lib/hbc.rb
+++ b/Library/Homebrew/cask/lib/hbc.rb
@@ -21,7 +21,6 @@ require "hbc/fetcher"
require "hbc/installer"
require "hbc/locations"
require "hbc/macos"
-require "hbc/options"
require "hbc/pkg"
require "hbc/qualified_token"
require "hbc/scopes"
@@ -40,14 +39,10 @@ require "utils"
module Hbc
include Locations
include Scopes
- include Options
include Utils
def self.init
Cache.ensure_cache_exists
- Cache.delete_legacy_cache
-
- Caskroom.migrate_caskroom_from_repo_to_prefix
Caskroom.ensure_caskroom_exists
end
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/binary.rb b/Library/Homebrew/cask/lib/hbc/artifact/binary.rb
index 646e5c3ad..9136d6a2a 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/binary.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/binary.rb
@@ -4,7 +4,7 @@ module Hbc
module Artifact
class Binary < Symlinked
def install_phase
- super unless Hbc.no_binaries
+ super if CLI.binaries?
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
index 6d6362d46..c43481c82 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
@@ -48,7 +48,7 @@ module Hbc
"-pkg", source,
"-target", "/"
]
- args << "-verboseR" if Hbc.verbose
+ args << "-verboseR" if CLI.verbose?
args << "-allowUntrusted" if pkg_install_opts :allow_untrusted
with_choices_file do |choices_path|
args << "-applyChoiceChangesXML" << choices_path if choices_path
diff --git a/Library/Homebrew/cask/lib/hbc/cache.rb b/Library/Homebrew/cask/lib/hbc/cache.rb
index 7b586528e..d2d0222ba 100644
--- a/Library/Homebrew/cask/lib/hbc/cache.rb
+++ b/Library/Homebrew/cask/lib/hbc/cache.rb
@@ -8,12 +8,5 @@ module Hbc
odebug "Creating Cache at #{Hbc.cache}"
Hbc.cache.mkpath
end
-
- def delete_legacy_cache
- return unless Hbc.legacy_cache.exist?
-
- ohai "Deleting legacy cache at #{Hbc.legacy_cache}..."
- FileUtils.remove_entry_secure(Hbc.legacy_cache)
- end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb
index cb0fdb665..52dd676b4 100644
--- a/Library/Homebrew/cask/lib/hbc/cask.rb
+++ b/Library/Homebrew/cask/lib/hbc/cask.rb
@@ -71,7 +71,7 @@ module Hbc
Pathname.glob(metadata_master_container_path.join("*", "*"))
.map { |p| p.relative_path_from(metadata_master_container_path) }
.sort_by(&:basename) # sort by timestamp
- .map(&:split)
+ .map { |p| p.split.map(&:to_s) }
end
def versions
@@ -90,8 +90,7 @@ module Hbc
end
def dumpcask
- return unless Hbc.respond_to?(:debug)
- return unless Hbc.debug
+ return unless CLI.debug?
odebug "Cask instance dumps in YAML:"
odebug "Cask instance toplevel:", to_yaml
diff --git a/Library/Homebrew/cask/lib/hbc/caskroom.rb b/Library/Homebrew/cask/lib/hbc/caskroom.rb
index 255e23888..7f4aab0a9 100644
--- a/Library/Homebrew/cask/lib/hbc/caskroom.rb
+++ b/Library/Homebrew/cask/lib/hbc/caskroom.rb
@@ -2,21 +2,6 @@ module Hbc
module Caskroom
module_function
- def migrate_caskroom_from_repo_to_prefix
- repo_caskroom = HOMEBREW_REPOSITORY.join("Caskroom")
- return if Hbc.caskroom.exist?
- return unless repo_caskroom.directory?
-
- ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"
-
- if Hbc.caskroom.parent.writable?
- FileUtils.mv repo_caskroom, Hbc.caskroom
- else
- opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
- SystemCommand.run("/bin/mv", args: [repo_caskroom, Hbc.caskroom.parent], sudo: true)
- end
- end
-
def ensure_caskroom_exists
return if Hbc.caskroom.exist?
diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb
index 102446ea4..3176489cb 100644
--- a/Library/Homebrew/cask/lib/hbc/cli.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli.rb
@@ -68,13 +68,25 @@ module Hbc
}.freeze
FLAGS = {
- "--no-binaries" => :no_binaries=,
- "--debug" => :debug=,
- "--verbose" => :verbose=,
- "--outdated" => :cleanup_outdated=,
- "--help" => :help=,
+ ["--[no-]binaries", :binaries] => true,
+ ["--debug", :debug] => false,
+ ["--verbose", :verbose] => false,
+ ["--outdated", :outdated] => false,
+ ["--help", :help] => false,
}.freeze
+ FLAGS.each do |(_, method), default_value|
+ instance_variable_set(:"@#{method}", default_value)
+
+ define_singleton_method(:"#{method}=") do |arg|
+ instance_variable_set(:"@#{method}", arg)
+ end
+
+ define_singleton_method(:"#{method}?") do
+ instance_variable_get(:"@#{method}")
+ end
+ end
+
def self.command_classes
@command_classes ||= constants.map(&method(:const_get))
.select { |sym| sym.respond_to?(:run) }
@@ -91,17 +103,6 @@ module Hbc
@lookup.fetch(command_string, command_string)
end
- # modified from Homebrew
- def self.require?(path)
- require path
- true # OK if already loaded
- rescue LoadError => e
- # HACK: :( because we should raise on syntax errors
- # but not if the file doesn't exist.
- # TODO: make robust!
- raise unless e.to_s.include? path
- end
-
def self.should_init?(command)
(command.is_a? Class) && (command < CLI::Base) && command.needs_init?
end
@@ -149,13 +150,13 @@ module Hbc
command_string, *rest = *arguments
rest = process_options(rest)
- command = Hbc.help ? "help" : lookup_command(command_string)
+ command = 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, ArgumentError => e
msg = e.message
- msg << e.backtrace.join("\n") if Hbc.debug
+ msg << e.backtrace.join("\n") if debug?
onoe msg
exit 1
rescue StandardError, ScriptError, NoMemoryError => e
@@ -205,9 +206,9 @@ module Hbc
EOS
end
- FLAGS.each do |flag, method|
- opts.on(flag) do
- Hbc.public_send(method, true)
+ FLAGS.keys.each do |flag, method|
+ opts.on(flag) do |bool|
+ send(:"#{method}=", bool)
end
end
@@ -235,7 +236,8 @@ module Hbc
end
# for compat with Homebrew, not certain if this is desirable
- Hbc.verbose = true if !ENV["VERBOSE"].nil? || !ENV["HOMEBREW_VERBOSE"].nil?
+ self.verbose = true if ARGV.verbose?
+ self.debug = true if ARGV.debug?
remaining
end
diff --git a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
index 2273280b9..9ebccabd0 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
@@ -21,7 +21,7 @@ module Hbc
end
def self.default
- @default ||= new(Hbc.cache, Hbc.cleanup_outdated)
+ @default ||= new(Hbc.cache, CLI.outdated?)
end
attr_reader :cache_location, :outdated_only
@@ -62,7 +62,7 @@ module Hbc
end
def disk_cleanup_size
- Utils.size_in_bytes(cache_files)
+ cache_files.map(&:disk_usage).inject(:+)
end
def remove_cache_files(*tokens)
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb
index d750f5af4..3b46bffe4 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb
@@ -3,40 +3,38 @@ module Hbc
class InternalAuditModifiedCasks < InternalUseBase
RELEVANT_STANZAS = [:version, :sha256, :url, :appcast].freeze
- class << self
- def needs_init?
- true
- end
+ def self.needs_init?
+ true
+ end
- def run(*args)
- commit_range = commit_range(args)
- cleanup = args.any? { |a| a =~ /^-+c(leanup)?$/i }
- new(commit_range, cleanup: cleanup).run
- end
+ def self.run(*args)
+ commit_range = commit_range(args)
+ cleanup = args.any? { |a| a =~ /^-+c(leanup)?$/i }
+ new(commit_range, cleanup: cleanup).run
+ end
- def commit_range(args)
- posargs = args.reject { |a| a.empty? || a.chars.first == "-" }
- odie usage unless posargs.size == 1
- posargs.first
- end
+ def self.commit_range(args)
+ posargs = args.reject { |a| a.empty? || a.chars.first == "-" }
+ odie usage unless posargs.size == 1
+ posargs.first
+ end
- def posargs(args)
- args.reject { |a| a.empty? || a.chars.first == "-" }
- end
+ def self.posargs(args)
+ args.reject { |a| a.empty? || a.chars.first == "-" }
+ end
- def usage
- <<-EOS.undent
- Usage: brew cask _audit_modified_casks [options...] <commit range>
+ def self.usage
+ <<-EOS.undent
+ Usage: brew cask _audit_modified_casks [options...] <commit range>
- Given a range of Git commits, find any Casks that were modified and run `brew
- cask audit' on them. If the `url', `version', or `sha256' stanzas were modified,
- run with the `--download' flag to verify the hash.
+ Given a range of Git commits, find any Casks that were modified and run `brew
+ cask audit' on them. If the `url', `version', or `sha256' stanzas were modified,
+ run with the `--download' flag to verify the hash.
- Options:
- -c, --cleanup
- Remove all cached downloads. Use with care.
- EOS
- end
+ Options:
+ -c, --cleanup
+ Remove all cached downloads. Use with care.
+ EOS
end
def initialize(commit_range, cleanup: false)
@@ -85,7 +83,7 @@ module Hbc
@modified_casks = modified_cask_files.map { |f| Hbc.load(f) }
if @modified_casks.any?
num_modified = @modified_casks.size
- ohai "#{num_modified} modified #{pluralize("cask", num_modified)}: " \
+ ohai "#{num_modified} modified cask#{plural(num_modified)}: " \
"#{@modified_casks.join(" ")}"
end
@modified_casks
@@ -122,15 +120,10 @@ module Hbc
def report_failures
return if failed_casks.empty?
num_failed = failed_casks.size
- cask_pluralized = pluralize("cask", num_failed)
- odie "audit failed for #{num_failed} #{cask_pluralized}: " \
+ odie "audit failed for #{num_failed} cask#{plural(num_failed)}: " \
"#{failed_casks.join(" ")}"
end
- def pluralize(str, num)
- num == 1 ? str : "#{str}s"
- end
-
def cleanup
Cleanup.run if cleanup?
end
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb
index ac1b20493..36a1ca74b 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb
@@ -12,7 +12,7 @@ module Hbc
end
def self.dump_casks(*cask_tokens)
- Hbc.debug = true # Yuck. At the moment this is the only way to make dumps visible
+ CLI.debug = true # Yuck. At the moment this is the only way to make dumps visible
count = 0
cask_tokens.each do |cask_token|
begin
diff --git a/Library/Homebrew/cask/lib/hbc/cli/style.rb b/Library/Homebrew/cask/lib/hbc/cli/style.rb
index a64a1dbe7..f38d785fc 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/style.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/style.rb
@@ -24,7 +24,7 @@ module Hbc
end
def install_rubocop
- Utils.capture_stderr do
+ capture_stderr do
begin
Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop"
rescue SystemExit
diff --git a/Library/Homebrew/cask/lib/hbc/locations.rb b/Library/Homebrew/cask/lib/hbc/locations.rb
index 4fb4a2191..7a0f93851 100644
--- a/Library/Homebrew/cask/lib/hbc/locations.rb
+++ b/Library/Homebrew/cask/lib/hbc/locations.rb
@@ -38,10 +38,6 @@ module Hbc
end
end
- def legacy_cache
- @legacy_cache ||= HOMEBREW_CACHE.join("Casks")
- end
-
attr_writer :cache
def cache
diff --git a/Library/Homebrew/cask/lib/hbc/options.rb b/Library/Homebrew/cask/lib/hbc/options.rb
deleted file mode 100644
index e9ba54ff6..000000000
--- a/Library/Homebrew/cask/lib/hbc/options.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-module Hbc
- module Options
- def self.included(base)
- base.extend(ClassMethods)
- end
-
- module ClassMethods
- attr_writer :no_binaries
-
- def no_binaries
- @no_binaries ||= false
- end
-
- attr_writer :debug
-
- def debug
- @debug ||= false
- end
-
- attr_writer :verbose
-
- def verbose
- @verbose ||= false
- end
-
- attr_writer :cleanup_outdated
-
- def cleanup_outdated
- @cleanup_outdated ||= false
- end
-
- attr_writer :help
-
- def help
- @help ||= false
- end
- end
- end
-end
diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb
index f26be8e62..17658bdfa 100644
--- a/Library/Homebrew/cask/lib/hbc/system_command.rb
+++ b/Library/Homebrew/cask/lib/hbc/system_command.rb
@@ -154,7 +154,7 @@ module Hbc
def self._parse_plist(command, output)
raise CaskError, "Empty plist input" unless output =~ /\S/
output.sub!(/\A(.*?)(<\?\s*xml)/m, '\2')
- _warn_plist_garbage(command, Regexp.last_match[1]) if Hbc.debug
+ _warn_plist_garbage(command, Regexp.last_match[1]) if CLI.debug?
output.sub!(%r{(<\s*/\s*plist\s*>)(.*?)\Z}m, '\1')
_warn_plist_garbage(command, Regexp.last_match[2])
xml = Plist.parse_xml(output)
diff --git a/Library/Homebrew/cask/lib/hbc/utils.rb b/Library/Homebrew/cask/lib/hbc/utils.rb
index ef3e5eda3..3fc817dd5 100644
--- a/Library/Homebrew/cask/lib/hbc/utils.rb
+++ b/Library/Homebrew/cask/lib/hbc/utils.rb
@@ -30,8 +30,7 @@ end
# global methods
def odebug(title, *sput)
- return unless Hbc.respond_to?(:debug)
- return unless Hbc.debug
+ return unless Hbc::CLI.debug?
puts Formatter.headline(title, color: :magenta)
puts sput unless sput.empty?
end
@@ -90,27 +89,6 @@ module Hbc
Etc.getpwuid(Process.euid).name
end
- # paths that "look" descendant (textually) will still
- # return false unless both the given paths exist
- def self.file_is_descendant(file, dir)
- file = Pathname.new(file)
- dir = Pathname.new(dir)
- return false unless file.exist? && dir.exist?
- unless dir.directory?
- onoe "Argument must be a directory: '#{dir}'"
- return false
- end
- unless file.absolute? && dir.absolute?
- onoe "Both arguments must be absolute: '#{file}', '#{dir}'"
- return false
- end
- while file.parent != file
- return true if File.identical?(file, dir)
- file = file.parent
- end
- false
- end
-
def self.path_occupied?(path)
File.exist?(path) || File.symlink?(path)
end
@@ -145,18 +123,5 @@ module Hbc
timestamp.concat(fraction)
container_path.join(timestamp)
end
-
- def self.size_in_bytes(files)
- Array(files).reduce(0) { |acc, elem| acc + (File.size?(elem) || 0) }
- end
-
- def self.capture_stderr
- previous_stderr = $stderr
- $stderr = StringIO.new
- yield
- $stderr.string
- ensure
- $stderr = previous_stderr
- end
end
end
diff --git a/Library/Homebrew/compat/hbc.rb b/Library/Homebrew/compat/hbc.rb
index 179639953..e60bdbc07 100644
--- a/Library/Homebrew/compat/hbc.rb
+++ b/Library/Homebrew/compat/hbc.rb
@@ -1,2 +1,19 @@
require "compat/hbc/cask_loader"
require "compat/hbc/cli/update"
+require "compat/hbc/cache"
+require "compat/hbc/caskroom"
+
+module Hbc
+ class << self
+ prepend(
+ Module.new do
+ def init
+ Cache.delete_legacy_cache
+ Caskroom.migrate_caskroom_from_repo_to_prefix
+
+ super
+ end
+ end,
+ )
+ end
+end
diff --git a/Library/Homebrew/compat/hbc/cache.rb b/Library/Homebrew/compat/hbc/cache.rb
new file mode 100644
index 000000000..34221fcf1
--- /dev/null
+++ b/Library/Homebrew/compat/hbc/cache.rb
@@ -0,0 +1,13 @@
+module Hbc
+ module Cache
+ module_function
+
+ def delete_legacy_cache
+ legacy_cache = HOMEBREW_CACHE.join("Casks")
+ return unless legacy_cache.exist?
+
+ ohai "Deleting legacy cache at #{legacy_cache}"
+ FileUtils.remove_entry_secure(legacy_cache)
+ end
+ end
+end
diff --git a/Library/Homebrew/compat/hbc/caskroom.rb b/Library/Homebrew/compat/hbc/caskroom.rb
new file mode 100644
index 000000000..489c5b224
--- /dev/null
+++ b/Library/Homebrew/compat/hbc/caskroom.rb
@@ -0,0 +1,20 @@
+module Hbc
+ module Caskroom
+ module_function
+
+ def migrate_caskroom_from_repo_to_prefix
+ repo_caskroom = HOMEBREW_REPOSITORY.join("Caskroom")
+ return if Hbc.caskroom.exist?
+ return unless repo_caskroom.directory?
+
+ ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"
+
+ if Hbc.caskroom.parent.writable?
+ FileUtils.mv repo_caskroom, Hbc.caskroom
+ else
+ opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
+ SystemCommand.run("/bin/mv", args: [repo_caskroom, Hbc.caskroom.parent], sudo: true)
+ end
+ end
+ end
+end
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index 619986f76..b11da5607 100644
--- a/Library/Homebrew/dev-cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -437,7 +437,6 @@ module Homebrew
--keep-old was passed but there are changes in:
#{mismatches.join("\n")}
EOS
- odie "--keep-old was passed but there were changes in #{mismatches.join(", ")}!"
end
output = bottle_output bottle
end
diff --git a/Library/Homebrew/test/cask/artifact/binary_spec.rb b/Library/Homebrew/test/cask/artifact/binary_spec.rb
index 1b26773ca..e503a3ebb 100644
--- a/Library/Homebrew/test/cask/artifact/binary_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/binary_spec.rb
@@ -47,15 +47,19 @@ describe Hbc::Artifact::Binary, :cask do
end
it "respects --no-binaries flag" do
- Hbc.no_binaries = true
+ begin
+ Hbc::CLI.binaries = false
- shutup do
- Hbc::Artifact::Binary.new(cask).install_phase
- end
+ expect(Hbc::CLI).not_to be_binaries
- expect(expected_path.exist?).to be false
+ shutup do
+ Hbc::Artifact::Binary.new(cask).install_phase
+ end
- Hbc.no_binaries = false
+ expect(expected_path.exist?).to be false
+ ensure
+ Hbc::CLI.binaries = true
+ end
end
it "creates parent directory if it doesn't exist" do
diff --git a/Library/Homebrew/test/cask/cli/cleanup_spec.rb b/Library/Homebrew/test/cask/cli/cleanup_spec.rb
index f8578e80d..c7ef356c0 100644
--- a/Library/Homebrew/test/cask/cli/cleanup_spec.rb
+++ b/Library/Homebrew/test/cask/cli/cleanup_spec.rb
@@ -19,7 +19,7 @@ describe Hbc::CLI::Cleanup, :cask do
cached_downloads.each(&FileUtils.method(:touch))
- cleanup_size = Hbc::Utils.size_in_bytes(cached_downloads[0])
+ cleanup_size = cached_downloads[0].disk_usage
expect {
subject.cleanup(cleaned_up_cached_download)
diff --git a/Library/Homebrew/test/cask/cli/options_spec.rb b/Library/Homebrew/test/cask/cli/options_spec.rb
index 0f42908bc..44a391b48 100644
--- a/Library/Homebrew/test/cask/cli/options_spec.rb
+++ b/Library/Homebrew/test/cask/cli/options_spec.rb
@@ -122,17 +122,23 @@ describe Hbc::CLI, :cask do
describe "--debug" do
it "sets the Cask debug method to true" do
- Hbc::CLI.process_options %w[help --debug]
- expect(Hbc.debug).to be true
- Hbc.debug = false
+ begin
+ Hbc::CLI.process_options %w[help --debug]
+ expect(Hbc::CLI.debug?).to be true
+ ensure
+ Hbc::CLI.debug = false
+ end
end
end
describe "--help" do
it "sets the Cask help method to true" do
- Hbc::CLI.process_options %w[foo --help]
- expect(Hbc.help).to be true
- Hbc.help = false
+ begin
+ Hbc::CLI.process_options %w[foo --help]
+ expect(Hbc::CLI.help?).to be true
+ ensure
+ Hbc::CLI.help = false
+ end
end
end
end
diff --git a/Library/Homebrew/test/cask/cli_spec.rb b/Library/Homebrew/test/cask/cli_spec.rb
index 1ad6790a3..0a4559ff2 100644
--- a/Library/Homebrew/test/cask/cli_spec.rb
+++ b/Library/Homebrew/test/cask/cli_spec.rb
@@ -32,10 +32,13 @@ describe Hbc::CLI, :cask do
end
it "prints help output when subcommand receives `--help` flag" do
- expect(described_class).to receive(:run_command).with("help")
- described_class.process(%w[noop --help])
- expect(Hbc.help).to eq(true)
- Hbc.help = false
+ begin
+ expect(described_class).to receive(:run_command).with("help")
+ described_class.process(%w[noop --help])
+ expect(Hbc::CLI.help?).to eq(true)
+ ensure
+ Hbc::CLI.help = false
+ end
end
it "respects the env variable when choosing what appdir to create" do