aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-08 12:37:45 +0100
committerMarkus Reiter2017-02-10 17:19:19 +0100
commitbcaa13b7507afaf7f957a2d815884a8263461d31 (patch)
tree83cf3d55a19f2dd9892921b427bb4cac716fbfdb /Library
parentcd4705b7bca5f266907ea6424d721190617edbcd (diff)
downloadbrew-bcaa13b7507afaf7f957a2d815884a8263461d31.tar.bz2
Convert List test to spec.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/list_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/list_test.rb)34
-rw-r--r--Library/Homebrew/cask/spec/support/install_helper.rb38
2 files changed, 50 insertions, 22 deletions
diff --git a/Library/Homebrew/cask/test/cask/cli/list_test.rb b/Library/Homebrew/cask/spec/cask/cli/list_spec.rb
index 9acf37efe..49c06c521 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 c8023c66b..d91b9ea57 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