From da520b82f09cc98f42a568bc457c7962d80279fa Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Mon, 13 Jan 2014 17:46:54 -0500 Subject: [PATCH] Numerous additions to "brew cask doctor" New versions, paths, environment variables, and tests. Side effect: release version must be stored in two locations. --- lib/cask/cli/doctor.rb | 36 +++++++++++++++++++++++++++++++----- test/cask/cli/doctor_test.rb | 20 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 test/cask/cli/doctor_test.rb diff --git a/lib/cask/cli/doctor.rb b/lib/cask/cli/doctor.rb index d8db7d297e..4aa115fb3d 100644 --- a/lib/cask/cli/doctor.rb +++ b/lib/cask/cli/doctor.rb @@ -1,11 +1,37 @@ class Cask::CLI::Doctor - def self.run(*_ignored) - ohai "Ruby Version:" + def self.run + ohai 'OS X Version:' + puts MACOS_FULL_VERSION + ohai 'Ruby Version:' puts "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" - ohai "Contents of $LOAD_PATH:" + ohai 'Ruby Path:' + puts RUBY_PATH + ohai 'Homebrew Version:' + puts HOMEBREW_VERSION + ohai 'Homebrew Executable Path:' + puts HOMEBREW_BREW_FILE + ohai 'Homebrew Cellar Path:' + puts HOMEBREW_CELLAR + ohai 'Homebrew-cask Version:' + puts Cask::VERSION + ohai 'Contents of $LOAD_PATH:' puts $LOAD_PATH - ohai "Running As Privileged User:" - puts Process.euid == 0 ? 'Yes' : 'No' + ohai 'Contents of $RUBYLIB Environment Variable:' + puts ENV['RUBYLIB'] + ohai 'Contents of $RUBYOPT Environment Variable:' + puts ENV['RUBYOPT'] + ohai 'Contents of $RUBYPATH Environment Variable:' + puts ENV['RUBYPATH'] + ohai 'Contents of $RBENV_VERSION Environment Variable:' + puts ENV['RBENV_VERSION'] + ohai 'Contents of $GEM_HOME Environment Variable:' + puts ENV['GEM_HOME'] + ohai 'Contents of $GEM_PATH Environment Variable:' + puts ENV['GEM_PATH'] + ohai 'Contents of $BUNDLE_PATH Environment Variable:' + puts ENV['BUNDLE_PATH'] + ohai 'Running As Privileged User:' + puts Process.euid == 0 ? "Yes #{Tty.red}(warning: not recommended)#{Tty.reset}" : 'No' end def self.help diff --git a/test/cask/cli/doctor_test.rb b/test/cask/cli/doctor_test.rb new file mode 100644 index 0000000000..ed48f2e14c --- /dev/null +++ b/test/cask/cli/doctor_test.rb @@ -0,0 +1,20 @@ +require 'test_helper' +require 'cask/version' + +HOMEBREW_BREW_FILE ||= '/usr/local/bin/brew' + +describe Cask::CLI::Doctor do + it 'displays some nice info about the environment' do + out, err = capture_io do + Cask::CLI::Doctor.run + end + # no point in trying to match more of this environment-specific info + out.must_match /\A==> OS X Version:/ + end + + it "raises an exception when arguments are given" do + lambda { + Cask::CLI::Doctor.run('argument') + }.must_raise ArgumentError + end +end