From 4f5643a67681f399dbabaeefb758a9c871ba513f Mon Sep 17 00:00:00 2001 From: constXife Date: Tue, 6 Jun 2017 13:45:09 +0700 Subject: [PATCH 1/2] Fix undefined variable ruby_version --- Library/Homebrew/extend/os/mac/diagnostic.rb | 3 ++- Library/Homebrew/test/os/mac/diagnostic_spec.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 58d8c633d4..913a5762b3 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -195,7 +195,8 @@ module Homebrew end def check_ruby_version - return if RUBY_VERSION[/\d\.\d/] == "2.0" + ruby_version = "2.0" + return if RUBY_VERSION[/\d\.\d/] == ruby_version <<-EOS.undent Ruby version #{RUBY_VERSION} is unsupported on #{MacOS.version}. Homebrew diff --git a/Library/Homebrew/test/os/mac/diagnostic_spec.rb b/Library/Homebrew/test/os/mac/diagnostic_spec.rb index 787f80fece..19682e0c78 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_spec.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_spec.rb @@ -45,4 +45,18 @@ describe Homebrew::Diagnostic::Checks do expect(subject.check_homebrew_prefix) .to match("Your Homebrew's prefix is not /usr/local.") end + + specify "#check_ruby_version" do + expected_string = <<-EXPECTED +Ruby version 2.3.3p222 is unsupported on 10.13. Homebrew +is developed and tested on Ruby 2.0, and may not work correctly +on other Rubies. Patches are accepted as long as they don't cause breakage +on supported Rubies. + EXPECTED + allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.13")) + stub_const("RUBY_VERSION", "2.3.3p222") + + expect(subject.check_ruby_version) + .to match(expected_string) + end end From 24d39430b50b8d9dfc4591bbf177c839f856bc6f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 6 Jun 2017 08:03:06 +0100 Subject: [PATCH 2/2] diagnostic_spec: tweak_formatting. --- Library/Homebrew/test/os/mac/diagnostic_spec.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/test/os/mac/diagnostic_spec.rb b/Library/Homebrew/test/os/mac/diagnostic_spec.rb index 19682e0c78..d6186e46bb 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_spec.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_spec.rb @@ -47,16 +47,15 @@ describe Homebrew::Diagnostic::Checks do end specify "#check_ruby_version" do - expected_string = <<-EXPECTED -Ruby version 2.3.3p222 is unsupported on 10.13. Homebrew -is developed and tested on Ruby 2.0, and may not work correctly -on other Rubies. Patches are accepted as long as they don't cause breakage -on supported Rubies. - EXPECTED allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.13")) stub_const("RUBY_VERSION", "2.3.3p222") expect(subject.check_ruby_version) - .to match(expected_string) + .to match <<-EOS.undent + Ruby version 2.3.3p222 is unsupported on 10.13. Homebrew + is developed and tested on Ruby 2.0, and may not work correctly + on other Rubies. Patches are accepted as long as they don't cause breakage + on supported Rubies. + EOS end end