From d025e0e7ab690db01b1bf99540c3564ab753d8c6 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 24 May 2017 20:16:09 +0200 Subject: [PATCH 1/2] Fix `--binaries` not using default value. --- Library/Homebrew/cask/lib/hbc/cli/options.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/cask/lib/hbc/cli/options.rb b/Library/Homebrew/cask/lib/hbc/cli/options.rb index 84126caa56..75dd772120 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/options.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/options.rb @@ -24,10 +24,12 @@ module Hbc if [true, false].include?(default_value) define_method(:"#{method}?") do + return default_value unless instance_variable_defined?(:"@#{method}") instance_variable_get(:"@#{method}") == true end else define_method(:"#{method}") do + return default_value unless instance_variable_defined?(:"@#{method}") instance_variable_get(:"@#{method}") end end From b91d0254bbd07b7b0ddf3906cb6c08684ebc07ef Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 24 May 2017 20:34:20 +0200 Subject: [PATCH 2/2] Add test for `--binaries` default value. --- Library/Homebrew/test/cask/cli_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Library/Homebrew/test/cask/cli_spec.rb b/Library/Homebrew/test/cask/cli_spec.rb index d5bfba754d..baad160c32 100644 --- a/Library/Homebrew/test/cask/cli_spec.rb +++ b/Library/Homebrew/test/cask/cli_spec.rb @@ -13,6 +13,13 @@ describe Hbc::CLI, :cask do ]) end + context "when no option is specified" do + it "--binaries is true by default" do + command = Hbc::CLI::Install.new("some-cask") + expect(command.binaries?).to be true + end + end + context "::run" do let(:noop_command) { double("CLI::Noop") }