From bcaa13b7507afaf7f957a2d815884a8263461d31 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 12:37:45 +0100 Subject: [PATCH] Convert List test to spec. --- .../cask/cli/list_spec.rb} | 34 ++++++++--------- .../cask/spec/support/install_helper.rb | 38 +++++++++++++++++-- 2 files changed, 50 insertions(+), 22 deletions(-) rename Library/Homebrew/cask/{test/cask/cli/list_test.rb => spec/cask/cli/list_spec.rb} (76%) diff --git a/Library/Homebrew/cask/test/cask/cli/list_test.rb b/Library/Homebrew/cask/spec/cask/cli/list_spec.rb similarity index 76% rename from Library/Homebrew/cask/test/cask/cli/list_test.rb rename to Library/Homebrew/cask/spec/cask/cli/list_spec.rb index 9acf37efee..49c06c5210 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,14 +50,10 @@ 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 @@ -69,15 +65,15 @@ describe Hbc::CLI::List do 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/spec/support/install_helper.rb b/Library/Homebrew/cask/spec/support/install_helper.rb index c8023c66b3..d91b9ea572 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