Silence all specs by default.

This commit is contained in:
Markus Reiter 2017-07-29 19:55:05 +02:00
parent e48a6736b8
commit 2ad3a87045
74 changed files with 361 additions and 795 deletions

View File

@ -20,9 +20,7 @@ describe "Accessibility Access", :cask do
sudo: true, sudo: true,
) )
shutup do installer.enable_accessibility_access
installer.enable_accessibility_access
end
end end
it "warns about disabling accessibility access on old macOS releases" do it "warns about disabling accessibility access on old macOS releases" do
@ -42,9 +40,7 @@ describe "Accessibility Access", :cask do
sudo: true, sudo: true,
) )
shutup do installer.enable_accessibility_access
installer.enable_accessibility_access
end
end end
it "can disable accessibility access" do it "can disable accessibility access" do
@ -54,9 +50,7 @@ describe "Accessibility Access", :cask do
sudo: true, sudo: true,
) )
shutup do installer.disable_accessibility_access
installer.disable_accessibility_access
end
end end
end end

View File

@ -17,9 +17,7 @@ describe Hbc::Artifact::App, :cask do
expect(source_path).to be_a_directory expect(source_path).to be_a_directory
expect(target_path).not_to exist expect(target_path).not_to exist
shutup do install_phase.call
install_phase.call
end
expect(target_path).to be_a_directory expect(target_path).to be_a_directory
expect(source_path).not_to exist expect(source_path).not_to exist
@ -40,9 +38,7 @@ describe Hbc::Artifact::App, :cask do
appsubdir = cask.staged_path.join("subdir").tap(&:mkpath) appsubdir = cask.staged_path.join("subdir").tap(&:mkpath)
FileUtils.mv(source_path, appsubdir) FileUtils.mv(source_path, appsubdir)
shutup do install_phase.call
install_phase.call
end
expect(target_path).to be_a_directory expect(target_path).to be_a_directory
expect(appsubdir.join("Caffeine.app")).not_to exist expect(appsubdir.join("Caffeine.app")).not_to exist
@ -53,9 +49,7 @@ describe Hbc::Artifact::App, :cask do
staged_app_copy = source_path.sub("Caffeine.app", "Caffeine Deluxe.app") staged_app_copy = source_path.sub("Caffeine.app", "Caffeine Deluxe.app")
FileUtils.cp_r source_path, staged_app_copy FileUtils.cp_r source_path, staged_app_copy
shutup do install_phase.call
install_phase.call
end
expect(target_path).to be_a_directory expect(target_path).to be_a_directory
expect(source_path).not_to exist expect(source_path).not_to exist

View File

@ -16,9 +16,7 @@ describe Hbc::Artifact::App, :cask do
describe "install_phase" do describe "install_phase" do
it "installs the given app using the proper target directory" do it "installs the given app using the proper target directory" do
shutup do install_phase
install_phase
end
expect(target_path).to be_a_directory expect(target_path).to be_a_directory
expect(source_path).not_to exist expect(source_path).not_to exist
@ -39,9 +37,7 @@ describe Hbc::Artifact::App, :cask do
appsubdir = cask.staged_path.join("subdir").tap(&:mkpath) appsubdir = cask.staged_path.join("subdir").tap(&:mkpath)
FileUtils.mv(source_path, appsubdir) FileUtils.mv(source_path, appsubdir)
shutup do install_phase
install_phase
end
expect(target_path).to be_a_directory expect(target_path).to be_a_directory
expect(appsubdir.join("Caffeine.app")).not_to exist expect(appsubdir.join("Caffeine.app")).not_to exist
@ -52,9 +48,7 @@ describe Hbc::Artifact::App, :cask do
staged_app_copy = source_path.sub("Caffeine.app", "Caffeine Deluxe.app") staged_app_copy = source_path.sub("Caffeine.app", "Caffeine Deluxe.app")
FileUtils.cp_r source_path, staged_app_copy FileUtils.cp_r source_path, staged_app_copy
shutup do install_phase
install_phase
end
expect(target_path).to be_a_directory expect(target_path).to be_a_directory
expect(source_path).not_to exist expect(source_path).not_to exist
@ -201,15 +195,11 @@ describe Hbc::Artifact::App, :cask do
describe "uninstall_phase" do describe "uninstall_phase" do
it "deletes managed apps" do it "deletes managed apps" do
shutup do install_phase
install_phase
end
expect(target_path).to exist expect(target_path).to exist
shutup do uninstall_phase
uninstall_phase
end
expect(target_path).not_to exist expect(target_path).not_to exist
end end
@ -225,9 +215,7 @@ describe Hbc::Artifact::App, :cask do
describe "app is correctly installed" do describe "app is correctly installed" do
it "returns the path to the app" do it "returns the path to the app" do
shutup do install_phase
install_phase
end
expect(contents).to eq(["#{target_path} (#{target_path.abv})"]) expect(contents).to eq(["#{target_path} (#{target_path.abv})"])
end end

View File

@ -1,9 +1,7 @@
describe Hbc::Artifact::Binary, :cask do describe Hbc::Artifact::Binary, :cask do
let(:cask) { let(:cask) {
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb").tap do |cask| Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb").tap do |cask|
shutup do InstallHelper.install_without_artifacts(cask)
InstallHelper.install_without_artifacts(cask)
end
end end
} }
let(:expected_path) { Hbc.binarydir.join("binary") } let(:expected_path) { Hbc.binarydir.join("binary") }
@ -22,18 +20,14 @@ describe Hbc::Artifact::Binary, :cask do
} }
it "doesn't link the binary when --no-binaries is specified" do it "doesn't link the binary when --no-binaries is specified" do
shutup do Hbc::Installer.new(cask, binaries: false).install
Hbc::Installer.new(cask, binaries: false).install
end
expect(expected_path).not_to exist expect(expected_path).not_to exist
end end
end end
it "links the binary to the proper directory" do it "links the binary to the proper directory" do
shutup do Hbc::Artifact::Binary.new(cask).install_phase
Hbc::Artifact::Binary.new(cask).install_phase
end
expect(expected_path).to be_a_symlink expect(expected_path).to be_a_symlink
expect(expected_path.readlink).to exist expect(expected_path.readlink).to exist
end end
@ -41,9 +35,7 @@ describe Hbc::Artifact::Binary, :cask do
context "when the binary is not executable" do context "when the binary is not executable" do
let(:cask) { let(:cask) {
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-non-executable-binary.rb").tap do |cask| Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-non-executable-binary.rb").tap do |cask|
shutup do InstallHelper.install_without_artifacts(cask)
InstallHelper.install_without_artifacts(cask)
end
end end
} }
@ -53,9 +45,7 @@ describe Hbc::Artifact::Binary, :cask do
expect(FileUtils).to receive(:chmod) expect(FileUtils).to receive(:chmod)
.with("+x", cask.staged_path.join("naked_non_executable")).and_call_original .with("+x", cask.staged_path.join("naked_non_executable")).and_call_original
shutup do Hbc::Artifact::Binary.new(cask).install_phase
Hbc::Artifact::Binary.new(cask).install_phase
end
expect(expected_path).to be_a_symlink expect(expected_path).to be_a_symlink
expect(expected_path.readlink).to be_executable expect(expected_path.readlink).to be_executable
@ -66,9 +56,7 @@ describe Hbc::Artifact::Binary, :cask do
FileUtils.touch expected_path FileUtils.touch expected_path
expect { expect {
shutup do Hbc::Artifact::Binary.new(cask).install_phase
Hbc::Artifact::Binary.new(cask).install_phase
end
}.to raise_error(Hbc::CaskError) }.to raise_error(Hbc::CaskError)
expect(expected_path).not_to be :symlink? expect(expected_path).not_to be :symlink?
@ -77,9 +65,7 @@ describe Hbc::Artifact::Binary, :cask do
it "clobbers an existing symlink" do it "clobbers an existing symlink" do
expected_path.make_symlink("/tmp") expected_path.make_symlink("/tmp")
shutup do Hbc::Artifact::Binary.new(cask).install_phase
Hbc::Artifact::Binary.new(cask).install_phase
end
expect(File.readlink(expected_path)).not_to eq("/tmp") expect(File.readlink(expected_path)).not_to eq("/tmp")
end end
@ -87,9 +73,7 @@ describe Hbc::Artifact::Binary, :cask do
it "creates parent directory if it doesn't exist" do it "creates parent directory if it doesn't exist" do
FileUtils.rmdir Hbc.binarydir FileUtils.rmdir Hbc.binarydir
shutup do Hbc::Artifact::Binary.new(cask).install_phase
Hbc::Artifact::Binary.new(cask).install_phase
end
expect(expected_path.exist?).to be true expect(expected_path.exist?).to be true
end end
@ -97,17 +81,13 @@ describe Hbc::Artifact::Binary, :cask do
context "binary is inside an app package" do context "binary is inside an app package" do
let(:cask) { let(:cask) {
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-embedded-binary.rb").tap do |cask| Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-embedded-binary.rb").tap do |cask|
shutup do InstallHelper.install_without_artifacts(cask)
InstallHelper.install_without_artifacts(cask)
end
end end
} }
it "links the binary to the proper directory" do it "links the binary to the proper directory" do
shutup do Hbc::Artifact::App.new(cask).install_phase
Hbc::Artifact::App.new(cask).install_phase Hbc::Artifact::Binary.new(cask).install_phase
Hbc::Artifact::Binary.new(cask).install_phase
end
expect(expected_path).to be_a_symlink expect(expected_path).to be_a_symlink
expect(expected_path.readlink).to exist expect(expected_path.readlink).to exist

View File

@ -21,9 +21,7 @@ describe Hbc::Artifact::Artifact, :cask do
end end
it "moves the artifact to the proper directory" do it "moves the artifact to the proper directory" do
shutup do install_phase.call
install_phase.call
end
expect(target_path).to be_a_directory expect(target_path).to be_a_directory
expect(source_path).not_to exist expect(source_path).not_to exist
@ -33,9 +31,7 @@ describe Hbc::Artifact::Artifact, :cask do
target_path.mkpath target_path.mkpath
expect { expect {
shutup do install_phase.call
install_phase.call
end
}.to raise_error(Hbc::CaskError) }.to raise_error(Hbc::CaskError)
expect(source_path).to be_a_directory expect(source_path).to be_a_directory

View File

@ -5,9 +5,7 @@ describe Hbc::Artifact::NestedContainer, :cask do
InstallHelper.install_without_artifacts(c) InstallHelper.install_without_artifacts(c)
end end
shutup do Hbc::Artifact::NestedContainer.new(cask).install_phase
Hbc::Artifact::NestedContainer.new(cask).install_phase
end
expect(cask.staged_path.join("MyNestedApp.app")).to be_a_directory expect(cask.staged_path.join("MyNestedApp.app")).to be_a_directory
end end

View File

@ -3,9 +3,7 @@ describe Hbc::Artifact::Pkg, :cask do
let(:fake_system_command) { class_double(Hbc::SystemCommand) } let(:fake_system_command) { class_double(Hbc::SystemCommand) }
before(:each) do before(:each) do
shutup do InstallHelper.install_without_artifacts(cask)
InstallHelper.install_without_artifacts(cask)
end
end end
describe "install_phase" do describe "install_phase" do
@ -19,9 +17,7 @@ describe Hbc::Artifact::Pkg, :cask do
print_stdout: true, print_stdout: true,
) )
shutup do pkg.install_phase
pkg.install_phase
end
end end
end end
@ -61,9 +57,7 @@ describe Hbc::Artifact::Pkg, :cask do
print_stdout: true, print_stdout: true,
) )
shutup do pkg.install_phase
pkg.install_phase
end
end end
end end
end end

View File

@ -11,9 +11,7 @@ describe Hbc::Artifact::Suite, :cask do
end end
it "creates a suite containing the expected app" do it "creates a suite containing the expected app" do
shutup do install_phase.call
install_phase.call
end
expect(target_path.join("Caffeine.app")).to exist expect(target_path.join("Caffeine.app")).to exist
end end
@ -22,9 +20,7 @@ describe Hbc::Artifact::Suite, :cask do
target_path.mkpath target_path.mkpath
expect { expect {
shutup do install_phase.call
install_phase.call
end
}.to raise_error(Hbc::CaskError) }.to raise_error(Hbc::CaskError)
expect(source_path).to be_a_directory expect(source_path).to be_a_directory

View File

@ -17,9 +17,7 @@ describe Hbc::Artifact::App, :cask do
end end
it "installs both apps using the proper target directory" do it "installs both apps using the proper target directory" do
shutup do install_phase.call
install_phase.call
end
expect(target_path_mini).to be_a_directory expect(target_path_mini).to be_a_directory
expect(source_path_mini).not_to exist expect(source_path_mini).not_to exist
@ -32,9 +30,7 @@ describe Hbc::Artifact::App, :cask do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-subdir.rb") } let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-subdir.rb") }
it "installs both apps using the proper target directory" do it "installs both apps using the proper target directory" do
shutup do install_phase.call
install_phase.call
end
expect(target_path_mini).to be_a_directory expect(target_path_mini).to be_a_directory
expect(source_path_mini).not_to exist expect(source_path_mini).not_to exist
@ -47,9 +43,7 @@ describe Hbc::Artifact::App, :cask do
it "only uses apps when they are specified" do it "only uses apps when they are specified" do
FileUtils.cp_r source_path_mini, source_path_mini.sub("Caffeine Mini.app", "Caffeine Deluxe.app") FileUtils.cp_r source_path_mini, source_path_mini.sub("Caffeine Mini.app", "Caffeine Deluxe.app")
shutup do install_phase.call
install_phase.call
end
expect(target_path_mini).to be_a_directory expect(target_path_mini).to be_a_directory
expect(source_path_mini).not_to exist expect(source_path_mini).not_to exist

View File

@ -5,10 +5,8 @@ describe Hbc::Artifact::Zap, :cask do
Hbc::Artifact::Zap.new(cask) Hbc::Artifact::Zap.new(cask)
} }
before do before(:each) do
shutup do InstallHelper.install_without_artifacts(cask)
InstallHelper.install_without_artifacts(cask)
end
end end
describe "#uninstall_phase" do describe "#uninstall_phase" do

View File

@ -3,11 +3,7 @@ shared_examples "#uninstall_phase or #zap_phase" do
let(:artifact) { described_class.new(cask, command: fake_system_command) } let(:artifact) { described_class.new(cask, command: fake_system_command) }
let(:fake_system_command) { Hbc::FakeSystemCommand } let(:fake_system_command) { Hbc::FakeSystemCommand }
subject do subject { artifact.public_send(:"#{artifact_name}_phase") }
shutup do
artifact.public_send(:"#{artifact_name}_phase")
end
end
context "using :launchctl" do context "using :launchctl" do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_name}-launchctl.rb") } let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_name}-launchctl.rb") }

View File

@ -39,9 +39,7 @@ describe Hbc::Cask, :cask do
end end
it "returns an instance of the Cask from a url" do it "returns an instance of the Cask from a url" do
c = shutup do c = Hbc::CaskLoader.load("file://#{tap_path}/Casks/local-caffeine.rb")
Hbc::CaskLoader.load("file://#{tap_path}/Casks/local-caffeine.rb")
end
expect(c).to be_kind_of(Hbc::Cask) expect(c).to be_kind_of(Hbc::Cask)
expect(c.token).to eq("local-caffeine") expect(c.token).to eq("local-caffeine")
end end
@ -49,9 +47,8 @@ describe Hbc::Cask, :cask do
it "raises an error when failing to download a Cask from a url" do it "raises an error when failing to download a Cask from a url" do
expect { expect {
url = "file://#{tap_path}/Casks/notacask.rb" url = "file://#{tap_path}/Casks/notacask.rb"
shutup do
Hbc::CaskLoader.load(url) Hbc::CaskLoader.load(url)
end
}.to raise_error(Hbc::CaskUnavailableError) }.to raise_error(Hbc::CaskUnavailableError)
end end

View File

@ -8,9 +8,7 @@ describe Hbc::CLI::Fetch, :cask do
} }
it "allows download the installer of a Cask" do it "allows download the installer of a Cask" do
shutup do Hbc::CLI::Fetch.run("local-transmission", "local-caffeine")
Hbc::CLI::Fetch.run("local-transmission", "local-caffeine")
end
expect(Hbc::CurlDownloadStrategy.new(local_transmission).cached_location).to exist expect(Hbc::CurlDownloadStrategy.new(local_transmission).cached_location).to exist
expect(Hbc::CurlDownloadStrategy.new(local_caffeine).cached_location).to exist expect(Hbc::CurlDownloadStrategy.new(local_caffeine).cached_location).to exist
end end
@ -18,31 +16,23 @@ describe Hbc::CLI::Fetch, :cask do
it "prevents double fetch (without nuking existing installation)" do it "prevents double fetch (without nuking existing installation)" do
download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission)
shutup do Hbc::Download.new(local_transmission).perform
Hbc::Download.new(local_transmission).perform
end
old_ctime = File.stat(download_stategy.cached_location).ctime old_ctime = File.stat(download_stategy.cached_location).ctime
shutup do Hbc::CLI::Fetch.run("local-transmission")
Hbc::CLI::Fetch.run("local-transmission")
end
new_ctime = File.stat(download_stategy.cached_location).ctime new_ctime = File.stat(download_stategy.cached_location).ctime
expect(old_ctime.to_i).to eq(new_ctime.to_i) expect(old_ctime.to_i).to eq(new_ctime.to_i)
end end
it "allows double fetch with --force" do it "allows double fetch with --force" do
shutup do Hbc::Download.new(local_transmission).perform
Hbc::Download.new(local_transmission).perform
end
download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission)
old_ctime = File.stat(download_stategy.cached_location).ctime old_ctime = File.stat(download_stategy.cached_location).ctime
sleep(1) sleep(1)
shutup do Hbc::CLI::Fetch.run("local-transmission", "--force")
Hbc::CLI::Fetch.run("local-transmission", "--force")
end
download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission)
new_ctime = File.stat(download_stategy.cached_location).ctime new_ctime = File.stat(download_stategy.cached_location).ctime
@ -51,9 +41,7 @@ describe Hbc::CLI::Fetch, :cask do
it "properly handles Casks that are not present" do it "properly handles Casks that are not present" do
expect { expect {
shutup do Hbc::CLI::Fetch.run("notacask")
Hbc::CLI::Fetch.run("notacask")
end
}.to raise_error(Hbc::CaskError, "Fetch incomplete.") }.to raise_error(Hbc::CaskError, "Fetch incomplete.")
end end

View File

@ -14,9 +14,7 @@ describe Hbc::CLI::Install, :cask do
end end
it "allows staging and activation of multiple Casks at once" do it "allows staging and activation of multiple Casks at once" do
shutup do Hbc::CLI::Install.run("local-transmission", "local-caffeine")
Hbc::CLI::Install.run("local-transmission", "local-caffeine")
end
expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed
expect(Hbc.appdir.join("Transmission.app")).to be_a_directory expect(Hbc.appdir.join("Transmission.app")).to be_a_directory
@ -25,19 +23,13 @@ describe Hbc::CLI::Install, :cask do
end end
it "skips double install (without nuking existing installation)" do it "skips double install (without nuking existing installation)" do
shutup do Hbc::CLI::Install.run("local-transmission")
Hbc::CLI::Install.run("local-transmission") Hbc::CLI::Install.run("local-transmission")
end
shutup do
Hbc::CLI::Install.run("local-transmission")
end
expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed
end end
it "prints a warning message on double install" do it "prints a warning message on double install" do
shutup do Hbc::CLI::Install.run("local-transmission")
Hbc::CLI::Install.run("local-transmission")
end
expect { expect {
Hbc::CLI::Install.run("local-transmission") Hbc::CLI::Install.run("local-transmission")
@ -45,9 +37,7 @@ describe Hbc::CLI::Install, :cask do
end end
it "allows double install with --force" do it "allows double install with --force" do
shutup do Hbc::CLI::Install.run("local-transmission")
Hbc::CLI::Install.run("local-transmission")
end
expect { expect {
expect { expect {
@ -57,9 +47,7 @@ describe Hbc::CLI::Install, :cask do
end end
it "skips dependencies with --skip-cask-deps" do it "skips dependencies with --skip-cask-deps" do
shutup do Hbc::CLI::Install.run("with-depends-on-cask-multiple", "--skip-cask-deps")
Hbc::CLI::Install.run("with-depends-on-cask-multiple", "--skip-cask-deps")
end
expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb")).to be_installed expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb")).to be_installed
expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")).not_to be_installed expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")).not_to be_installed
expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed
@ -67,9 +55,7 @@ describe Hbc::CLI::Install, :cask do
it "properly handles Casks that are not present" do it "properly handles Casks that are not present" do
expect { expect {
shutup do Hbc::CLI::Install.run("notacask")
Hbc::CLI::Install.run("notacask")
end
}.to raise_error(Hbc::CaskError, "Install incomplete.") }.to raise_error(Hbc::CaskError, "Install incomplete.")
end end

View File

@ -48,9 +48,7 @@ describe Hbc::CLI::List, :cask do
it "lists the installed files for those Casks" do it "lists the installed files for those Casks" do
casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile)) casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile))
shutup do Hbc::Artifact::App.new(transmission).install_phase
Hbc::Artifact::App.new(transmission).install_phase
end
expect { expect {
Hbc::CLI::List.run("local-transmission", "local-caffeine") Hbc::CLI::List.run("local-transmission", "local-caffeine")

View File

@ -10,9 +10,8 @@ describe Hbc::CLI::Outdated, :cask do
end end
before do before do
shutup do installed.each { |cask| InstallHelper.install_with_caskfile(cask) }
installed.each { |cask| InstallHelper.install_with_caskfile(cask) }
end
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true) allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
end end

View File

@ -2,9 +2,7 @@ describe Hbc::CLI::Reinstall, :cask do
it "displays the reinstallation progress" do it "displays the reinstallation progress" do
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
shutup do Hbc::Installer.new(caffeine).install
Hbc::Installer.new(caffeine).install
end
output = Regexp.new <<-EOS.undent output = Regexp.new <<-EOS.undent
==> Downloading file:.*caffeine.zip ==> Downloading file:.*caffeine.zip
@ -23,23 +21,18 @@ describe Hbc::CLI::Reinstall, :cask do
end end
it "allows reinstalling a Cask" do it "allows reinstalling a Cask" do
shutup do Hbc::CLI::Install.run("local-transmission")
Hbc::CLI::Install.run("local-transmission")
end
expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed
shutup do Hbc::CLI::Reinstall.run("local-transmission")
Hbc::CLI::Reinstall.run("local-transmission")
end
expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed
end end
it "allows reinstalling a non installed Cask" do it "allows reinstalling a non installed Cask" do
expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed
shutup do Hbc::CLI::Reinstall.run("local-transmission")
Hbc::CLI::Reinstall.run("local-transmission")
end
expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed
end end
end end

View File

@ -75,9 +75,7 @@ describe Hbc::CLI::Search, :cask do
end end
it "highlights installed packages" do it "highlights installed packages" do
shutup do Hbc::CLI::Install.run("local-caffeine")
Hbc::CLI::Install.run("local-caffeine")
end
expect(Hbc::CLI::Search.highlight_installed("local-caffeine")).to eq(pretty_installed("local-caffeine")) expect(Hbc::CLI::Search.highlight_installed("local-caffeine")).to eq(pretty_installed("local-caffeine"))
end end

View File

@ -5,9 +5,7 @@ describe Hbc::CLI::Style, :cask do
let(:args) { [] } let(:args) { [] }
let(:cli) { described_class.new(*args) } let(:cli) { described_class.new(*args) }
around do |example| around(&:run)
shutup { example.run }
end
describe "#run" do describe "#run" do
subject { cli.run } subject { cli.run }

View File

@ -2,9 +2,7 @@ describe Hbc::CLI::Uninstall, :cask do
it "displays the uninstallation progress" do it "displays the uninstallation progress" do
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
shutup do Hbc::Installer.new(caffeine).install
Hbc::Installer.new(caffeine).install
end
output = Regexp.new <<-EOS.undent output = Regexp.new <<-EOS.undent
==> Uninstalling Cask local-caffeine ==> Uninstalling Cask local-caffeine
@ -30,9 +28,7 @@ describe Hbc::CLI::Uninstall, :cask do
it "tries anyway on a non-present Cask when --force is given" do it "tries anyway on a non-present Cask when --force is given" do
expect { expect {
shutup do Hbc::CLI::Uninstall.run("local-caffeine", "--force")
Hbc::CLI::Uninstall.run("local-caffeine", "--force")
end
}.not_to raise_error }.not_to raise_error
end end
@ -40,17 +36,13 @@ describe Hbc::CLI::Uninstall, :cask do
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
shutup do Hbc::Installer.new(caffeine).install
Hbc::Installer.new(caffeine).install Hbc::Installer.new(transmission).install
Hbc::Installer.new(transmission).install
end
expect(caffeine).to be_installed expect(caffeine).to be_installed
expect(transmission).to be_installed expect(transmission).to be_installed
shutup do Hbc::CLI::Uninstall.run("local-caffeine", "local-transmission")
Hbc::CLI::Uninstall.run("local-caffeine", "local-transmission")
end
expect(caffeine).not_to be_installed expect(caffeine).not_to be_installed
expect(Hbc.appdir.join("Transmission.app")).not_to exist expect(Hbc.appdir.join("Transmission.app")).not_to exist
@ -61,17 +53,13 @@ describe Hbc::CLI::Uninstall, :cask do
it "calls `uninstall` before removing artifacts" do it "calls `uninstall` before removing artifacts" do
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script-app.rb") cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script-app.rb")
shutup do Hbc::Installer.new(cask).install
Hbc::Installer.new(cask).install
end
expect(cask).to be_installed expect(cask).to be_installed
expect(Hbc.appdir.join("MyFancyApp.app")).to exist expect(Hbc.appdir.join("MyFancyApp.app")).to exist
expect { expect {
shutup do Hbc::CLI::Uninstall.run("with-uninstall-script-app")
Hbc::CLI::Uninstall.run("with-uninstall-script-app")
end
}.not_to raise_error }.not_to raise_error
expect(cask).not_to be_installed expect(cask).not_to be_installed
@ -81,24 +69,20 @@ describe Hbc::CLI::Uninstall, :cask do
it "can uninstall Casks when the uninstall script is missing, but only when using `--force`" do it "can uninstall Casks when the uninstall script is missing, but only when using `--force`" do
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script-app.rb") cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script-app.rb")
shutup do Hbc::Installer.new(cask).install
Hbc::Installer.new(cask).install
end
expect(cask).to be_installed expect(cask).to be_installed
Hbc.appdir.join("MyFancyApp.app").rmtree Hbc.appdir.join("MyFancyApp.app").rmtree
expect { shutup { Hbc::CLI::Uninstall.run("with-uninstall-script-app") } } expect { Hbc::CLI::Uninstall.run("with-uninstall-script-app") }
.to output(/does not exist/).to_stderr .to output(/does not exist/).to_stderr
.and raise_error(Hbc::CaskError, "Uninstall incomplete.") .and raise_error(Hbc::CaskError, "Uninstall incomplete.")
expect(cask).to be_installed expect(cask).to be_installed
expect { expect {
shutup do Hbc::CLI::Uninstall.run("with-uninstall-script-app", "--force")
Hbc::CLI::Uninstall.run("with-uninstall-script-app", "--force")
end
}.not_to raise_error }.not_to raise_error
expect(cask).not_to be_installed expect(cask).not_to be_installed
@ -131,17 +115,13 @@ describe Hbc::CLI::Uninstall, :cask do
end end
it "uninstalls one version at a time" do it "uninstalls one version at a time" do
shutup do Hbc::CLI::Uninstall.run("versioned-cask")
Hbc::CLI::Uninstall.run("versioned-cask")
end
expect(caskroom_path.join(first_installed_version)).to exist expect(caskroom_path.join(first_installed_version)).to exist
expect(caskroom_path.join(last_installed_version)).not_to exist expect(caskroom_path.join(last_installed_version)).not_to exist
expect(caskroom_path).to exist expect(caskroom_path).to exist
shutup do Hbc::CLI::Uninstall.run("versioned-cask")
Hbc::CLI::Uninstall.run("versioned-cask")
end
expect(caskroom_path.join(first_installed_version)).not_to exist expect(caskroom_path.join(first_installed_version)).not_to exist
expect(caskroom_path).not_to exist expect(caskroom_path).not_to exist
@ -180,9 +160,7 @@ describe Hbc::CLI::Uninstall, :cask do
end end
it "can still uninstall those Casks" do it "can still uninstall those Casks" do
shutup do Hbc::CLI::Uninstall.run("ive-been-renamed")
Hbc::CLI::Uninstall.run("ive-been-renamed")
end
expect(app).not_to exist expect(app).not_to exist
expect(caskroom_path).not_to exist expect(caskroom_path).not_to exist

View File

@ -9,17 +9,13 @@ describe Hbc::CLI::Zap, :cask do
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
shutup do Hbc::Installer.new(caffeine).install
Hbc::Installer.new(caffeine).install Hbc::Installer.new(transmission).install
Hbc::Installer.new(transmission).install
end
expect(caffeine).to be_installed expect(caffeine).to be_installed
expect(transmission).to be_installed expect(transmission).to be_installed
shutup do Hbc::CLI::Zap.run("local-caffeine", "local-transmission")
Hbc::CLI::Zap.run("local-caffeine", "local-transmission")
end
expect(caffeine).not_to be_installed expect(caffeine).not_to be_installed
expect(Hbc.appdir.join("Caffeine.app")).not_to be_a_symlink expect(Hbc.appdir.join("Caffeine.app")).not_to be_a_symlink
@ -33,9 +29,7 @@ describe Hbc::CLI::Zap, :cask do
# it "dispatches both uninstall and zap stanzas" do # it "dispatches both uninstall and zap stanzas" do
# with_zap = Hbc::CaskLoader.load('with-zap') # with_zap = Hbc::CaskLoader.load('with-zap')
# #
# shutup do # Hbc::Installer.new(with_zap).install
# Hbc::Installer.new(with_zap).install
# end
# #
# with_zap.must_be :installed? # with_zap.must_be :installed?
# #
@ -48,9 +42,8 @@ describe Hbc::CLI::Zap, :cask do
# Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--', # Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--',
# Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path]) # Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path])
# #
# shutup do # Hbc::CLI::Zap.run('with-zap')
# Hbc::CLI::Zap.run('with-zap') #
# end
# with_zap.wont_be :installed? # with_zap.wont_be :installed?
# end # end

View File

@ -17,7 +17,7 @@ describe Hbc::CLI, :cask do
cli = described_class.new("--language=en") cli = described_class.new("--language=en")
expect(cli).to receive(:detect_command_and_arguments).with(no_args) expect(cli).to receive(:detect_command_and_arguments).with(no_args)
expect(cli).to receive(:exit).with(1) expect(cli).to receive(:exit).with(1)
shutup { cli.run } cli.run
end end
context "when no option is specified" do context "when no option is specified" do
@ -36,10 +36,6 @@ describe Hbc::CLI, :cask do
allow(noop_command).to receive(:run) allow(noop_command).to receive(:run)
end end
around do |example|
shutup { example.run }
end
it "passes `--version` along to the subcommand" do it "passes `--version` along to the subcommand" do
version_command = double("CLI::Version") version_command = double("CLI::Version")
allow(described_class).to receive(:lookup_command).with("--version").and_return(version_command) allow(described_class).to receive(:lookup_command).with("--version").and_return(version_command)

View File

@ -13,9 +13,7 @@ describe Hbc::Container::Naked, :cask do
container = Hbc::Container::Naked.new(cask, path, Hbc::FakeSystemCommand) container = Hbc::Container::Naked.new(cask, path, Hbc::FakeSystemCommand)
expect { expect {
shutup do container.extract
container.extract
end
}.not_to raise_error }.not_to raise_error
expect(Hbc::FakeSystemCommand.system_calls[expected_command]).to eq(1) expect(Hbc::FakeSystemCommand.system_calls[expected_command]).to eq(1)

View File

@ -3,9 +3,7 @@
describe "Satisfy Dependencies and Requirements", :cask do describe "Satisfy Dependencies and Requirements", :cask do
subject { subject {
lambda do lambda do
shutup do Hbc::Installer.new(cask).install
Hbc::Installer.new(cask).install
end
end end
} }

View File

@ -23,9 +23,7 @@ describe "download strategies", :cask do
it "calls curl with default arguments for a simple Cask" do it "calls curl with default arguments for a simple Cask" do
allow(downloader).to receive(:curl) allow(downloader).to receive(:curl)
shutup do downloader.fetch
downloader.fetch
end
expect(downloader).to have_received(:curl).with( expect(downloader).to have_received(:curl).with(
cask.url.to_s, cask.url.to_s,
@ -41,9 +39,7 @@ describe "download strategies", :cask do
curl_args = [] curl_args = []
allow(downloader).to receive(:curl) { |*args| curl_args = args } allow(downloader).to receive(:curl) { |*args| curl_args = args }
shutup do downloader.fetch
downloader.fetch
end
expect(curl_args.each_cons(2)).to include(["-A", "Mozilla/25.0.1"]) expect(curl_args.each_cons(2)).to include(["-A", "Mozilla/25.0.1"])
end end
@ -56,9 +52,7 @@ describe "download strategies", :cask do
curl_args = [] curl_args = []
allow(downloader).to receive(:curl) { |*args| curl_args = args } allow(downloader).to receive(:curl) { |*args| curl_args = args }
shutup do downloader.fetch
downloader.fetch
end
expect(curl_args.each_cons(2)).to include(["-A", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10) https://caskroom.github.io"]) expect(curl_args.each_cons(2)).to include(["-A", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10) https://caskroom.github.io"])
end end
@ -78,9 +72,7 @@ describe "download strategies", :cask do
curl_args = [] curl_args = []
allow(downloader).to receive(:curl) { |*args| curl_args = args } allow(downloader).to receive(:curl) { |*args| curl_args = args }
shutup do downloader.fetch
downloader.fetch
end
expect(curl_args.each_cons(2)).to include(["-b", "coo=kie;mon=ster"]) expect(curl_args.each_cons(2)).to include(["-b", "coo=kie;mon=ster"])
end end
@ -93,9 +85,7 @@ describe "download strategies", :cask do
curl_args = [] curl_args = []
allow(downloader).to receive(:curl) { |*args| curl_args = args } allow(downloader).to receive(:curl) { |*args| curl_args = args }
shutup do downloader.fetch
downloader.fetch
end
expect(curl_args.each_cons(2)).to include(["-e", "http://somehost/also"]) expect(curl_args.each_cons(2)).to include(["-e", "http://somehost/also"])
end end
@ -124,9 +114,7 @@ describe "download strategies", :cask do
curl_args = [] curl_args = []
allow(downloader).to receive(:curl) { |*args| curl_args = args } allow(downloader).to receive(:curl) { |*args| curl_args = args }
shutup do downloader.fetch
downloader.fetch
end
expect(curl_args.each_cons(2)).to include(["-d", "form=data"]) expect(curl_args.each_cons(2)).to include(["-d", "form=data"])
expect(curl_args.each_cons(2)).to include(["-d", "is=good"]) expect(curl_args.each_cons(2)).to include(["-d", "is=good"])
@ -140,9 +128,7 @@ describe "download strategies", :cask do
curl_args = [] curl_args = []
allow(downloader).to receive(:curl) { |*args| curl_args = args } allow(downloader).to receive(:curl) { |*args| curl_args = args }
shutup do downloader.fetch
downloader.fetch
end
expect(curl_args.each_cons(2)).to include(["-X", "POST"]) expect(curl_args.each_cons(2)).to include(["-X", "POST"])
end end
@ -161,18 +147,14 @@ describe "download strategies", :cask do
allow(downloader).to receive(:compress) allow(downloader).to receive(:compress)
allow(downloader).to receive(:fetch_repo) allow(downloader).to receive(:fetch_repo)
retval = shutup { downloader.fetch } expect(downloader.fetch).to equal(downloader.tarball_path)
expect(retval).to equal(downloader.tarball_path)
end end
it "calls fetch_repo with default arguments for a simple Cask" do it "calls fetch_repo with default arguments for a simple Cask" do
allow(downloader).to receive(:compress) allow(downloader).to receive(:compress)
allow(downloader).to receive(:fetch_repo) allow(downloader).to receive(:fetch_repo)
shutup do downloader.fetch
downloader.fetch
end
expect(downloader).to have_received(:fetch_repo).with( expect(downloader).to have_received(:fetch_repo).with(
downloader.cached_location, downloader.cached_location,
@ -183,9 +165,7 @@ describe "download strategies", :cask do
it "calls svn with default arguments for a simple Cask" do it "calls svn with default arguments for a simple Cask" do
allow(downloader).to receive(:compress) allow(downloader).to receive(:compress)
shutup do downloader.fetch
downloader.fetch
end
expect(fake_system_command).to have_received(:run!).with( expect(fake_system_command).to have_received(:run!).with(
"/usr/bin/svn", "/usr/bin/svn",
@ -211,9 +191,7 @@ describe "download strategies", :cask do
it "adds svn arguments for :trust_cert" do it "adds svn arguments for :trust_cert" do
allow(downloader).to receive(:compress) allow(downloader).to receive(:compress)
shutup do downloader.fetch
downloader.fetch
end
expect(fake_system_command).to have_received(:run!).with( expect(fake_system_command).to have_received(:run!).with(
"/usr/bin/svn", "/usr/bin/svn",
@ -242,9 +220,7 @@ describe "download strategies", :cask do
it "adds svn arguments for :revision" do it "adds svn arguments for :revision" do
allow(downloader).to receive(:compress) allow(downloader).to receive(:compress)
shutup do downloader.fetch
downloader.fetch
end
expect(fake_system_command).to have_received(:run!).with( expect(fake_system_command).to have_received(:run!).with(
"/usr/bin/svn", "/usr/bin/svn",
@ -269,9 +245,7 @@ describe "download strategies", :cask do
downloader.cached_location.mkdir downloader.cached_location.mkdir
} }
shutup do downloader.fetch
downloader.fetch
end
expect(fake_system_command).to have_received(:run!).with( expect(fake_system_command).to have_received(:run!).with(
"/usr/bin/tar", "/usr/bin/tar",
@ -299,7 +273,7 @@ describe "download strategies", :cask do
# FileUtils.touch(target.join('empty_file.txt')) # FileUtils.touch(target.join('empty_file.txt'))
# File.utime(1000,1000,target.join('empty_file.txt')) # File.utime(1000,1000,target.join('empty_file.txt'))
# end # end
# expect(shutup { downloader.fetch }).to equal(downloader.tarball_path) # expect(downloader.fetch).to equal(downloader.tarball_path)
# d = Hbc::Download.new(cask) # d = Hbc::Download.new(cask)
# d.send(:_check_sums, downloader.tarball_path, cask.sums) # d.send(:_check_sums, downloader.tarball_path, cask.sums)
# end # end

View File

@ -36,9 +36,7 @@ describe Hbc::DSL, :cask do
it "will simply warn, not throw an exception" do it "will simply warn, not throw an exception" do
expect { expect {
shutup do attempt_unknown_method.call
attempt_unknown_method.call
end
}.not_to raise_error }.not_to raise_error
end end
end end
@ -78,12 +76,10 @@ describe Hbc::DSL, :cask do
it "may use deprecated DSL version hash syntax" do it "may use deprecated DSL version hash syntax" do
allow(ENV).to receive(:[]).with("HOMEBREW_DEVELOPER").and_return(nil) allow(ENV).to receive(:[]).with("HOMEBREW_DEVELOPER").and_return(nil)
shutup do expect(cask.token).to eq("with-dsl-version")
expect(cask.token).to eq("with-dsl-version") expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg")
expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg") expect(cask.homepage).to eq("http://example.com/")
expect(cask.homepage).to eq("http://example.com/") expect(cask.version.to_s).to eq("1.2.3")
expect(cask.version.to_s).to eq("1.2.3")
end
end end
end end
end end

View File

@ -7,9 +7,7 @@ describe Hbc::Installer, :cask do
it "downloads and installs a nice fresh Cask" do it "downloads and installs a nice fresh Cask" do
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
shutup do Hbc::Installer.new(caffeine).install
Hbc::Installer.new(caffeine).install
end
expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory
expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory
@ -18,9 +16,7 @@ describe Hbc::Installer, :cask do
it "works with dmg-based Casks" do it "works with dmg-based Casks" do
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-dmg.rb") asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-dmg.rb")
shutup do Hbc::Installer.new(asset).install
Hbc::Installer.new(asset).install
end
expect(Hbc.caskroom.join("container-dmg", asset.version)).to be_a_directory expect(Hbc.caskroom.join("container-dmg", asset.version)).to be_a_directory
expect(Hbc.appdir.join("container")).to be_a_file expect(Hbc.appdir.join("container")).to be_a_file
@ -29,9 +25,7 @@ describe Hbc::Installer, :cask do
it "works with tar-gz-based Casks" do it "works with tar-gz-based Casks" do
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-tar-gz.rb") asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-tar-gz.rb")
shutup do Hbc::Installer.new(asset).install
Hbc::Installer.new(asset).install
end
expect(Hbc.caskroom.join("container-tar-gz", asset.version)).to be_a_directory expect(Hbc.caskroom.join("container-tar-gz", asset.version)).to be_a_directory
expect(Hbc.appdir.join("container")).to be_a_file expect(Hbc.appdir.join("container")).to be_a_file
@ -40,9 +34,7 @@ describe Hbc::Installer, :cask do
it "works with xar-based Casks" do it "works with xar-based Casks" do
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xar.rb") asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xar.rb")
shutup do Hbc::Installer.new(asset).install
Hbc::Installer.new(asset).install
end
expect(Hbc.caskroom.join("container-xar", asset.version)).to be_a_directory expect(Hbc.caskroom.join("container-xar", asset.version)).to be_a_directory
expect(Hbc.appdir.join("container")).to be_a_file expect(Hbc.appdir.join("container")).to be_a_file
@ -51,9 +43,7 @@ describe Hbc::Installer, :cask do
it "works with pure bzip2-based Casks" do it "works with pure bzip2-based Casks" do
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-bzip2.rb") asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-bzip2.rb")
shutup do Hbc::Installer.new(asset).install
Hbc::Installer.new(asset).install
end
expect(Hbc.caskroom.join("container-bzip2", asset.version)).to be_a_directory expect(Hbc.caskroom.join("container-bzip2", asset.version)).to be_a_directory
expect(Hbc.appdir.join("container-bzip2--#{asset.version}")).to be_a_file expect(Hbc.appdir.join("container-bzip2--#{asset.version}")).to be_a_file
@ -62,9 +52,7 @@ describe Hbc::Installer, :cask do
it "works with pure gzip-based Casks" do it "works with pure gzip-based Casks" do
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-gzip.rb") asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-gzip.rb")
shutup do Hbc::Installer.new(asset).install
Hbc::Installer.new(asset).install
end
expect(Hbc.caskroom.join("container-gzip", asset.version)).to be_a_directory expect(Hbc.caskroom.join("container-gzip", asset.version)).to be_a_directory
expect(Hbc.appdir.join("container")).to be_a_file expect(Hbc.appdir.join("container")).to be_a_file
@ -73,27 +61,21 @@ describe Hbc::Installer, :cask do
it "blows up on a bad checksum" do it "blows up on a bad checksum" do
bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb") bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb")
expect { expect {
shutup do Hbc::Installer.new(bad_checksum).install
Hbc::Installer.new(bad_checksum).install
end
}.to raise_error(Hbc::CaskSha256MismatchError) }.to raise_error(Hbc::CaskSha256MismatchError)
end end
it "blows up on a missing checksum" do it "blows up on a missing checksum" do
missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb") missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb")
expect { expect {
shutup do Hbc::Installer.new(missing_checksum).install
Hbc::Installer.new(missing_checksum).install
end
}.to raise_error(Hbc::CaskSha256MissingError) }.to raise_error(Hbc::CaskSha256MissingError)
end end
it "installs fine if sha256 :no_check is used" do it "installs fine if sha256 :no_check is used" do
no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb")
shutup do Hbc::Installer.new(no_checksum).install
Hbc::Installer.new(no_checksum).install
end
expect(no_checksum).to be_installed expect(no_checksum).to be_installed
end end
@ -101,18 +83,14 @@ describe Hbc::Installer, :cask do
it "fails to install if sha256 :no_check is used with --require-sha" do it "fails to install if sha256 :no_check is used with --require-sha" do
no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb")
expect { expect {
shutup do Hbc::Installer.new(no_checksum, require_sha: true).install
Hbc::Installer.new(no_checksum, require_sha: true).install
end
}.to raise_error(Hbc::CaskNoShasumError) }.to raise_error(Hbc::CaskNoShasumError)
end end
it "installs fine if sha256 :no_check is used with --require-sha and --force" do it "installs fine if sha256 :no_check is used with --require-sha and --force" do
no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb")
shutup do Hbc::Installer.new(no_checksum, require_sha: true, force: true).install
Hbc::Installer.new(no_checksum, require_sha: true, force: true).install
end
expect(no_checksum).to be_installed expect(no_checksum).to be_installed
end end
@ -140,9 +118,7 @@ describe Hbc::Installer, :cask do
it "does not extract __MACOSX directories from zips" do it "does not extract __MACOSX directories from zips" do
with_macosx_dir = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-macosx-dir.rb") with_macosx_dir = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-macosx-dir.rb")
shutup do Hbc::Installer.new(with_macosx_dir).install
Hbc::Installer.new(with_macosx_dir).install
end
expect(with_macosx_dir.staged_path.join("__MACOSX")).not_to be_a_directory expect(with_macosx_dir.staged_path.join("__MACOSX")).not_to be_a_directory
end end
@ -152,14 +128,10 @@ describe Hbc::Installer, :cask do
expect(with_auto_updates).not_to be_installed expect(with_auto_updates).not_to be_installed
shutup do Hbc::Installer.new(with_auto_updates).install
Hbc::Installer.new(with_auto_updates).install
end
expect { expect {
shutup do Hbc::Installer.new(with_auto_updates, force: true).install
Hbc::Installer.new(with_auto_updates, force: true).install
end
}.not_to raise_error }.not_to raise_error
end end
@ -171,9 +143,7 @@ describe Hbc::Installer, :cask do
installer = Hbc::Installer.new(transmission) installer = Hbc::Installer.new(transmission)
shutup do installer.install
installer.install
end
expect { expect {
installer.install installer.install
@ -185,21 +155,17 @@ describe Hbc::Installer, :cask do
expect(transmission).not_to be_installed expect(transmission).not_to be_installed
shutup do Hbc::Installer.new(transmission).install
Hbc::Installer.new(transmission).install
end
shutup do expect {
Hbc::Installer.new(transmission, force: true).install Hbc::Installer.new(transmission, force: true).install
end # wont_raise }.not_to raise_error
end end
it "works naked-pkg-based Casks" do it "works naked-pkg-based Casks" do
naked_pkg = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-pkg.rb") naked_pkg = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-pkg.rb")
shutup do Hbc::Installer.new(naked_pkg).install
Hbc::Installer.new(naked_pkg).install
end
expect(Hbc.caskroom.join("container-pkg", naked_pkg.version, "container.pkg")).to be_a_file expect(Hbc.caskroom.join("container-pkg", naked_pkg.version, "container.pkg")).to be_a_file
end end
@ -207,9 +173,7 @@ describe Hbc::Installer, :cask do
it "works properly with an overridden container :type" do it "works properly with an overridden container :type" do
naked_executable = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/naked-executable.rb") naked_executable = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/naked-executable.rb")
shutup do Hbc::Installer.new(naked_executable).install
Hbc::Installer.new(naked_executable).install
end
expect(Hbc.caskroom.join("naked-executable", naked_executable.version, "naked_executable")).to be_a_file expect(Hbc.caskroom.join("naked-executable", naked_executable.version, "naked_executable")).to be_a_file
end end
@ -217,9 +181,7 @@ describe Hbc::Installer, :cask do
it "works fine with a nested container" do it "works fine with a nested container" do
nested_app = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb") nested_app = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb")
shutup do Hbc::Installer.new(nested_app).install
Hbc::Installer.new(nested_app).install
end
expect(Hbc.appdir.join("MyNestedApp.app")).to be_a_directory expect(Hbc.appdir.join("MyNestedApp.app")).to be_a_directory
end end
@ -227,9 +189,7 @@ describe Hbc::Installer, :cask do
it "generates and finds a timestamped metadata directory for an installed Cask" do it "generates and finds a timestamped metadata directory for an installed Cask" do
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
shutup do Hbc::Installer.new(caffeine).install
Hbc::Installer.new(caffeine).install
end
m_path = caffeine.metadata_timestamped_path(timestamp: :now, create: true) m_path = caffeine.metadata_timestamped_path(timestamp: :now, create: true)
expect(caffeine.metadata_timestamped_path(timestamp: :latest)).to eq(m_path) expect(caffeine.metadata_timestamped_path(timestamp: :latest)).to eq(m_path)
@ -238,9 +198,7 @@ describe Hbc::Installer, :cask do
it "generates and finds a metadata subdirectory for an installed Cask" do it "generates and finds a metadata subdirectory for an installed Cask" do
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
shutup do Hbc::Installer.new(caffeine).install
Hbc::Installer.new(caffeine).install
end
subdir_name = "Casks" subdir_name = "Casks"
m_subdir = caffeine.metadata_subdir(subdir_name, timestamp: :now, create: true) m_subdir = caffeine.metadata_subdir(subdir_name, timestamp: :now, create: true)
@ -253,10 +211,8 @@ describe Hbc::Installer, :cask do
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
installer = Hbc::Installer.new(caffeine) installer = Hbc::Installer.new(caffeine)
shutup do installer.install
installer.install installer.uninstall
installer.uninstall
end
expect(Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app")).not_to be_a_directory expect(Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app")).not_to be_a_directory
expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory
@ -267,9 +223,7 @@ describe Hbc::Installer, :cask do
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
mutated_version = caffeine.version + ".1" mutated_version = caffeine.version + ".1"
shutup do Hbc::Installer.new(caffeine).install
Hbc::Installer.new(caffeine).install
end
expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory
expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory
@ -277,9 +231,7 @@ describe Hbc::Installer, :cask do
expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory
expect(Hbc.caskroom.join("local-caffeine", mutated_version)).to be_a_directory expect(Hbc.caskroom.join("local-caffeine", mutated_version)).to be_a_directory
shutup do Hbc::Installer.new(caffeine, force: true).uninstall
Hbc::Installer.new(caffeine, force: true).uninstall
end
expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory
expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory

View File

@ -88,9 +88,7 @@ describe Hbc::Pkg, :cask do
allow(pkg).to receive(:root).and_return(fake_root) allow(pkg).to receive(:root).and_return(fake_root)
allow(pkg).to receive(:forget) allow(pkg).to receive(:forget)
shutup do pkg.uninstall
pkg.uninstall
end
expect(fake_dir).to be_a_directory expect(fake_dir).to be_a_directory
expect(fake_file).not_to be_a_file expect(fake_file).not_to be_a_file

View File

@ -6,10 +6,7 @@ describe "Operations on staged Casks", :cask do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") } let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") }
let(:installer) { Hbc::Installer.new(cask) } let(:installer) { Hbc::Installer.new(cask) }
it "fetches the bundle ID from a staged cask" do it "fetches the bundle ID from a staged cask" do
shutup do installer.install
installer.install
end
expect(installer.bundle_identifier).to eq("org.m0k.transmission") expect(installer.bundle_identifier).to eq("org.m0k.transmission")
end end
end end

View File

@ -56,7 +56,7 @@ describe Hbc::SystemCommand, :cask do
shared_examples "it returns '1 2 3 4 5 6'" do shared_examples "it returns '1 2 3 4 5 6'" do
describe "its result" do describe "its result" do
subject { shutup { described_class.run(command, options) } } subject { described_class.run(command, options) }
it { is_expected.to be_a_success } it { is_expected.to be_a_success }
its(:stdout) { is_expected.to eq([1, 3, 5, nil].join("\n")) } its(:stdout) { is_expected.to eq([1, 3, 5, nil].join("\n")) }
@ -132,7 +132,7 @@ describe Hbc::SystemCommand, :cask do
it "returns without deadlocking" do it "returns without deadlocking" do
wait(15).for { wait(15).for {
shutup { described_class.run(command, options) } described_class.run(command, options)
}.to be_a_success }.to be_a_success
end end
end end

View File

@ -7,10 +7,6 @@ describe Hbc::Verify::Checksum, :cask do
allow(cask).to receive(:sha256).and_return(sha256) allow(cask).to receive(:sha256).and_return(sha256)
end end
around do |example|
shutup { example.run }
end
describe ".me?" do describe ".me?" do
subject { described_class.me?(cask) } subject { described_class.me?(cask) }

View File

@ -11,25 +11,21 @@ describe Formula do
describe "#brew" do describe "#brew" do
it "does not raise an error when the checksum matches" do it "does not raise an error when the checksum matches" do
expect { expect {
shutup do f = formula do
f = formula do sha256 TESTBALL_SHA256
sha256 TESTBALL_SHA256
end
f.brew {}
end end
f.brew {}
}.not_to raise_error }.not_to raise_error
end end
it "raises an error when the checksum doesn't match" do it "raises an error when the checksum doesn't match" do
expect { expect {
shutup do f = formula do
f = formula do sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8"
sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8"
end
f.brew {}
end end
f.brew {}
}.to raise_error(ChecksumMismatchError) }.to raise_error(ChecksumMismatchError)
end end
end end

View File

@ -18,9 +18,7 @@ describe Homebrew::Cleanup do
describe "::cleanup" do describe "::cleanup" do
it "removes .DS_Store files" do it "removes .DS_Store files" do
shutup do described_class.cleanup
described_class.cleanup
end
expect(ds_store).not_to exist expect(ds_store).not_to exist
end end
@ -28,9 +26,7 @@ describe Homebrew::Cleanup do
it "doesn't remove anything if `--dry-run` is specified" do it "doesn't remove anything if `--dry-run` is specified" do
ARGV << "--dry-run" ARGV << "--dry-run"
shutup do described_class.cleanup
described_class.cleanup
end
expect(ds_store).to exist expect(ds_store).to exist
end end
@ -42,14 +38,12 @@ describe Homebrew::Cleanup do
before(:each) do before(:each) do
described_class.instance_variable_set(:@unremovable_kegs, []) described_class.instance_variable_set(:@unremovable_kegs, [])
shutup do [f1, f2].each do |f|
[f1, f2].each do |f| f.brew do
f.brew do f.install
f.install
end
Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
end end
Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
end end
allow_any_instance_of(Keg) allow_any_instance_of(Keg)
@ -58,12 +52,12 @@ describe Homebrew::Cleanup do
end end
it "doesn't remove any kegs" do it "doesn't remove any kegs" do
shutup { described_class.cleanup_formula f2 } described_class.cleanup_formula f2
expect(f1.installed_kegs.size).to eq(2) expect(f1.installed_kegs.size).to eq(2)
end end
it "lists the unremovable kegs" do it "lists the unremovable kegs" do
shutup { described_class.cleanup_formula f2 } described_class.cleanup_formula f2
expect(described_class.unremovable_kegs).to contain_exactly(f1.installed_kegs[0]) expect(described_class.unremovable_kegs).to contain_exactly(f1.installed_kegs[0])
end end
end end
@ -89,14 +83,12 @@ describe Homebrew::Cleanup do
version_scheme 2 version_scheme 2
end.new end.new
shutup do [f1, f2, f3, f4].each do |f|
[f1, f2, f3, f4].each do |f| f.brew do
f.brew do f.install
f.install
end
Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
end end
Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
end end
expect(f1).to be_installed expect(f1).to be_installed
@ -104,9 +96,7 @@ describe Homebrew::Cleanup do
expect(f3).to be_installed expect(f3).to be_installed
expect(f4).to be_installed expect(f4).to be_installed
shutup do described_class.cleanup_formula f3
described_class.cleanup_formula f3
end
expect(f1).not_to be_installed expect(f1).not_to be_installed
expect(f2).not_to be_installed expect(f2).not_to be_installed
@ -119,9 +109,7 @@ describe Homebrew::Cleanup do
path.mkpath path.mkpath
ARGV << "--prune=all" ARGV << "--prune=all"
shutup do described_class.cleanup_logs
described_class.cleanup_logs
end
expect(path).not_to exist expect(path).not_to exist
end end
@ -131,9 +119,7 @@ describe Homebrew::Cleanup do
incomplete = (HOMEBREW_CACHE/"something.incomplete") incomplete = (HOMEBREW_CACHE/"something.incomplete")
incomplete.mkpath incomplete.mkpath
shutup do described_class.cleanup_cache
described_class.cleanup_cache
end
expect(incomplete).not_to exist expect(incomplete).not_to exist
end end
@ -142,9 +128,7 @@ describe Homebrew::Cleanup do
java_cache = (HOMEBREW_CACHE/"java_cache") java_cache = (HOMEBREW_CACHE/"java_cache")
java_cache.mkpath java_cache.mkpath
shutup do described_class.cleanup_cache
described_class.cleanup_cache
end
expect(java_cache).not_to exist expect(java_cache).not_to exist
end end
@ -153,9 +137,7 @@ describe Homebrew::Cleanup do
npm_cache = (HOMEBREW_CACHE/"npm_cache") npm_cache = (HOMEBREW_CACHE/"npm_cache")
npm_cache.mkpath npm_cache.mkpath
shutup do described_class.cleanup_cache
described_class.cleanup_cache
end
expect(npm_cache).not_to exist expect(npm_cache).not_to exist
end end

View File

@ -1,9 +1,7 @@
describe "brew analytics", :integration_test do describe "brew analytics", :integration_test do
before(:each) do before(:each) do
HOMEBREW_REPOSITORY.cd do HOMEBREW_REPOSITORY.cd do
shutup do system "git", "init"
system "git", "init"
end
end end
end end

View File

@ -4,10 +4,8 @@ describe "brew bundle", :integration_test, :needs_test_cmd_taps do
setup_remote_tap "homebrew/bundle" setup_remote_tap "homebrew/bundle"
HOMEBREW_REPOSITORY.cd do HOMEBREW_REPOSITORY.cd do
shutup do system "git", "init"
system "git", "init" system "git", "commit", "--allow-empty", "-m", "This is a test commit"
system "git", "commit", "--allow-empty", "-m", "This is a test commit"
end
end end
mktmpdir do |path| mktmpdir do |path|

View File

@ -2,9 +2,8 @@ describe "brew cask", :integration_test, :needs_macos, :needs_network do
describe "list" do describe "list" do
it "returns a list of installed Casks" do it "returns a list of installed Casks" do
setup_remote_tap("caskroom/cask") setup_remote_tap("caskroom/cask")
shutup do
expect { brew "cask", "list" }.to be_a_success expect { brew "cask", "list" }.to be_a_success
end
end end
end end
end end

View File

@ -30,9 +30,7 @@ describe "brew desc", :integration_test do
it "creates a description cache" do it "creates a description cache" do
expect(desc_cache).not_to exist expect(desc_cache).not_to exist
shutup do expect { brew "desc", "--description", "testball" }.to be_a_success
expect { brew "desc", "--description", "testball" }.to be_a_success
end
expect(desc_cache).to exist expect(desc_cache).to exist
end end

View File

@ -4,9 +4,7 @@ describe "brew fetch", :integration_test do
expect(HOMEBREW_CACHE/"testball-0.1.tbz").not_to exist expect(HOMEBREW_CACHE/"testball-0.1.tbz").not_to exist
shutup do expect { brew "fetch", "testball" }.to be_a_success
expect { brew "fetch", "testball" }.to be_a_success
end
expect(HOMEBREW_CACHE/"testball-0.1.tbz").to exist expect(HOMEBREW_CACHE/"testball-0.1.tbz").to exist
end end

View File

@ -101,9 +101,7 @@ describe "brew install", :integration_test do
.and not_to_output.to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
shutup do expect { brew "switch", "testball1", "3.0" }.to be_a_success
expect { brew "switch", "testball1", "3.0" }.to be_a_success
end
expect { brew "install", "testball1" } expect { brew "install", "testball1" }
.to output(/2.0 is already installed/).to_stderr .to output(/2.0 is already installed/).to_stderr
@ -156,14 +154,12 @@ describe "brew install", :integration_test do
repo_path.join("bin").mkpath repo_path.join("bin").mkpath
repo_path.cd do repo_path.cd do
shutup do system "git", "init"
system "git", "init" system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" FileUtils.touch "bin/something.bin"
FileUtils.touch "bin/something.bin" FileUtils.touch "README"
FileUtils.touch "README" system "git", "add", "--all"
system "git", "add", "--all" system "git", "commit", "-m", "Initial repo commit"
system "git", "commit", "-m", "Initial repo commit"
end
end end
setup_test_formula "testball1", <<-EOS.undent setup_test_formula "testball1", <<-EOS.undent

View File

@ -9,19 +9,15 @@ describe "brew link", :integration_test do
it "does not fail if the given Formula is already linked" do it "does not fail if the given Formula is already linked" do
setup_test_formula "testball1" setup_test_formula "testball1"
shutup do expect { brew "install", "testball1" }.to be_a_success
expect { brew "install", "testball1" }.to be_a_success expect { brew "link", "testball1" }.to be_a_success
expect { brew "link", "testball1" }.to be_a_success
end
end end
it "links a given Formula" do it "links a given Formula" do
setup_test_formula "testball1" setup_test_formula "testball1"
shutup do expect { brew "install", "testball1" }.to be_a_success
expect { brew "install", "testball1" }.to be_a_success expect { brew "unlink", "testball1" }.to be_a_success
expect { brew "unlink", "testball1" }.to be_a_success
end
expect { brew "link", "--dry-run", "testball1" } expect { brew "link", "--dry-run", "testball1" }
.to output(/Would link/).to_stdout .to output(/Would link/).to_stdout
@ -44,9 +40,7 @@ describe "brew link", :integration_test do
keg_only "just because" keg_only "just because"
EOS EOS
shutup do expect { brew "install", "testball1" }.to be_a_success
expect { brew "install", "testball1" }.to be_a_success
end
expect { brew "link", "testball1", "SHELL" => "/bin/zsh" } expect { brew "link", "testball1", "SHELL" => "/bin/zsh" }
.to output(/testball1 is keg-only/).to_stderr .to output(/testball1 is keg-only/).to_stderr

View File

@ -1,10 +1,8 @@
describe "brew log", :integration_test do describe "brew log", :integration_test do
it "shows the Git log for the Homebrew repository when no argument is given" do it "shows the Git log for the Homebrew repository when no argument is given" do
HOMEBREW_REPOSITORY.cd do HOMEBREW_REPOSITORY.cd do
shutup do system "git", "init"
system "git", "init" system "git", "commit", "--allow-empty", "-m", "This is a test commit"
system "git", "commit", "--allow-empty", "-m", "This is a test commit"
end
end end
expect { brew "log" } expect { brew "log" }
@ -18,18 +16,15 @@ describe "brew log", :integration_test do
core_tap = CoreTap.new core_tap = CoreTap.new
core_tap.path.cd do core_tap.path.cd do
shutup do system "git", "init"
system "git", "init" system "git", "add", "--all"
system "git", "add", "--all" system "git", "commit", "-m", "This is a test commit for Testball"
system "git", "commit", "-m", "This is a test commit for Testball"
end
end end
core_tap_url = "file://#{core_tap.path}" core_tap_url = "file://#{core_tap.path}"
shallow_tap = Tap.fetch("homebrew", "shallow") shallow_tap = Tap.fetch("homebrew", "shallow")
shutup do
system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path
end
expect { brew "log", "#{shallow_tap}/testball" } expect { brew "log", "#{shallow_tap}/testball" }
.to output(/This is a test commit for Testball/).to_stdout .to output(/This is a test commit for Testball/).to_stdout

View File

@ -28,9 +28,7 @@ describe "brew outdated", :integration_test do
setup_test_formula "testball" setup_test_formula "testball"
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
shutup do expect { brew "pin", "testball" }.to be_a_success
expect { brew "pin", "testball" }.to be_a_success
end
expect { brew "outdated", "--verbose" } expect { brew "outdated", "--verbose" }
.to output("testball (0.0.1) < 0.1 [pinned at 0.0.1]\n").to_stdout .to output("testball (0.0.1) < 0.1 [pinned at 0.0.1]\n").to_stdout
@ -44,9 +42,7 @@ describe "brew outdated", :integration_test do
setup_test_formula "testball" setup_test_formula "testball"
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
shutup do expect { brew "pin", "testball" }.to be_a_success
expect { brew "pin", "testball" }.to be_a_success
end
expected_json = [ expected_json = [
{ {

View File

@ -3,10 +3,8 @@ describe "brew pin", :integration_test do
setup_test_formula "testball" setup_test_formula "testball"
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
shutup do expect { brew "pin", "testball" }.to be_a_success
expect { brew "pin", "testball" }.to be_a_success expect { brew "upgrade" }.to be_a_success
expect { brew "upgrade" }.to be_a_success
end
expect(HOMEBREW_CELLAR/"testball/0.1").not_to be_a_directory expect(HOMEBREW_CELLAR/"testball/0.1").not_to be_a_directory
end end

View File

@ -4,9 +4,7 @@ describe "brew reinstall", :integration_test do
before(:each) do before(:each) do
setup_test_formula "testball" setup_test_formula "testball"
shutup do expect { brew "install", "testball", "--with-foo" }.to be_a_success
expect { brew "install", "testball", "--with-foo" }.to be_a_success
end
end end
it "reinstalls a Formula" do it "reinstalls a Formula" do

View File

@ -14,9 +14,7 @@ describe "brew switch", :integration_test do
keg_only "just because" keg_only "just because"
EOS EOS
shutup do expect { brew "install", "testball" }.to be_a_success
expect { brew "install", "testball" }.to be_a_success
end
testball_rack = HOMEBREW_CELLAR/"testball" testball_rack = HOMEBREW_CELLAR/"testball"
FileUtils.cp_r testball_rack/"0.1", testball_rack/"0.2" FileUtils.cp_r testball_rack/"0.1", testball_rack/"0.2"

View File

@ -2,9 +2,7 @@ require "cmd/uninstall"
describe "brew uninstall", :integration_test do describe "brew uninstall", :integration_test do
it "uninstalls a given Formula" do it "uninstalls a given Formula" do
shutup do expect { brew "install", testball }.to be_a_success
expect { brew "install", testball }.to be_a_success
end
expect { brew "uninstall", "--force", testball } expect { brew "uninstall", "--force", testball }
.to output(/Uninstalling testball/).to_stdout .to output(/Uninstalling testball/).to_stdout

View File

@ -2,9 +2,7 @@ describe "brew unlink", :integration_test do
it "unlinks a Formula" do it "unlinks a Formula" do
setup_test_formula "testball" setup_test_formula "testball"
shutup do expect { brew "install", "testball" }.to be_a_success
expect { brew "install", "testball" }.to be_a_success
end
expect { brew "unlink", "--dry-run", "testball" } expect { brew "unlink", "--dry-run", "testball" }
.to output(/Would remove/).to_stdout .to output(/Would remove/).to_stdout

View File

@ -3,10 +3,8 @@ describe "brew unpack", :integration_test do
setup_test_formula "testball" setup_test_formula "testball"
mktmpdir do |path| mktmpdir do |path|
shutup do expect { brew "unpack", "testball", "--destdir=#{path}" }
expect { brew "unpack", "testball", "--destdir=#{path}" } .to be_a_success
.to be_a_success
end
expect(path/"testball-0.1").to be_a_directory expect(path/"testball-0.1").to be_a_directory
end end

View File

@ -3,11 +3,9 @@ describe "brew unpin", :integration_test do
setup_test_formula "testball" setup_test_formula "testball"
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
shutup do expect { brew "pin", "testball" }.to be_a_success
expect { brew "pin", "testball" }.to be_a_success expect { brew "unpin", "testball" }.to be_a_success
expect { brew "unpin", "testball" }.to be_a_success expect { brew "upgrade" }.to be_a_success
expect { brew "upgrade" }.to be_a_success
end
expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory
end end

View File

@ -3,9 +3,7 @@ describe "brew upgrade", :integration_test do
setup_test_formula "testball" setup_test_formula "testball"
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
shutup do expect { brew "upgrade" }.to be_a_success
expect { brew "upgrade" }.to be_a_success
end
expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory
end end

View File

@ -174,13 +174,11 @@ describe FormulaAuditor do
specify "GithubGistFormula", :needs_compat do specify "GithubGistFormula", :needs_compat do
ENV.delete("HOMEBREW_DEVELOPER") ENV.delete("HOMEBREW_DEVELOPER")
fa = shutup do fa = formula_auditor "foo", <<-EOS.undent
formula_auditor "foo", <<-EOS.undent class Foo < GithubGistFormula
class Foo < GithubGistFormula url "http://example.com/foo-1.0.tgz"
url "http://example.com/foo-1.0.tgz" end
end EOS
EOS
end
fa.audit_class fa.audit_class
expect(fa.problems) expect(fa.problems)
@ -388,18 +386,14 @@ describe FormulaAuditor do
origin_tap_path.mkpath origin_tap_path.mkpath
origin_tap_path.cd do origin_tap_path.cd do
shutup do system "git", "init"
system "git", "init" system "git", "add", "--all"
system "git", "add", "--all" system "git", "commit", "-m", "init"
system "git", "commit", "-m", "init"
end
end end
tap_path.mkpath tap_path.mkpath
tap_path.cd do tap_path.cd do
shutup do system "git", "clone", origin_tap_path, "."
system "git", "clone", origin_tap_path, "."
end
end end
end end
@ -423,16 +417,12 @@ describe FormulaAuditor do
origin_formula_path.write text origin_formula_path.write text
origin_tap_path.cd do origin_tap_path.cd do
shutup do system "git", "commit", "-am", "commit"
system "git", "commit", "-am", "commit"
end
end end
tap_path.cd do tap_path.cd do
shutup do system "git", "fetch"
system "git", "fetch" system "git", "reset", "--hard", "origin/master"
system "git", "reset", "--hard", "origin/master"
end
end end
end end

View File

@ -1,10 +1,8 @@
describe "brew bottle", :integration_test do describe "brew bottle", :integration_test do
it "builds a bottle for the given Formula" do it "builds a bottle for the given Formula" do
begin begin
shutup do expect { brew "install", "--build-bottle", testball }
expect { brew "install", "--build-bottle", testball } .to be_a_success
.to be_a_success
end
expect { brew "bottle", "--no-rebuild", testball } expect { brew "bottle", "--no-rebuild", testball }
.to output(/Formula not from core or any taps/).to_stderr .to output(/Formula not from core or any taps/).to_stderr

View File

@ -3,9 +3,7 @@ describe "brew create", :integration_test do
let(:formula_file) { CoreTap.new.formula_dir/"testball.rb" } let(:formula_file) { CoreTap.new.formula_dir/"testball.rb" }
it "creates a new Formula file for a given URL" do it "creates a new Formula file for a given URL" do
shutup do brew "create", url, "HOMEBREW_EDITOR" => "/bin/cat"
brew "create", url, "HOMEBREW_EDITOR" => "/bin/cat"
end
expect(formula_file).to exist expect(formula_file).to exist
expect(formula_file.read).to match(%Q(sha256 "#{TESTBALL_SHA256}")) expect(formula_file.read).to match(%Q(sha256 "#{TESTBALL_SHA256}"))

View File

@ -1,9 +1,7 @@
describe "brew edit", :integration_test do describe "brew edit", :integration_test do
it "opens a given Formula in an editor" do it "opens a given Formula in an editor" do
HOMEBREW_REPOSITORY.cd do HOMEBREW_REPOSITORY.cd do
shutup do system "git", "init"
system "git", "init"
end
end end
setup_test_formula "testball" setup_test_formula "testball"

View File

@ -8,10 +8,8 @@ describe "brew pull", :integration_test do
it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network do it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network do
CoreTap.instance.path.cd do CoreTap.instance.path.cd do
shutup do system "git", "init"
system "git", "init" system "git", "checkout", "-b", "new-branch"
system "git", "checkout", "-b", "new-branch"
end
end end
expect { brew "pull", "https://jenkins.brew.sh/job/Homebrew\%20Testing/1028/" } expect { brew "pull", "https://jenkins.brew.sh/job/Homebrew\%20Testing/1028/" }

View File

@ -3,13 +3,11 @@ describe "brew tap", :integration_test do
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
path.mkpath path.mkpath
path.cd do path.cd do
shutup do system "git", "init"
system "git", "init" system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" FileUtils.touch "readme"
FileUtils.touch "readme" system "git", "add", "--all"
system "git", "add", "--all" system "git", "commit", "-m", "init"
system "git", "commit", "-m", "init"
end
end end
expect { brew "tap" } expect { brew "tap" }

View File

@ -14,9 +14,7 @@ describe "brew test", :integration_test do
end end
it "fails when a Formula has no test" do it "fails when a Formula has no test" do
shutup do expect { brew "install", testball }.to be_a_success
expect { brew "install", testball }.to be_a_success
end
expect { brew "test", testball } expect { brew "test", testball }
.to output(/testball defines no test/).to_stderr .to output(/testball defines no test/).to_stderr
@ -39,9 +37,7 @@ describe "brew test", :integration_test do
end end
EOS EOS
shutup do expect { brew "install", "testball" }.to be_a_success
expect { brew "install", "testball" }.to be_a_success
end
expect { brew "test", "--HEAD", "testball" } expect { brew "test", "--HEAD", "testball" }
.to output(/Testing testball/).to_stdout .to output(/Testing testball/).to_stdout

View File

@ -147,18 +147,14 @@ describe GitDownloadStrategy do
end end
def git_commit_all def git_commit_all
shutup do system "git", "add", "--all"
system "git", "add", "--all" system "git", "commit", "-m", "commit number #{@commit_id}"
system "git", "commit", "-m", "commit number #{@commit_id}" @commit_id += 1
@commit_id += 1
end
end end
def setup_git_repo def setup_git_repo
shutup do system "git", "init"
system "git", "init" system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
end
FileUtils.touch "README" FileUtils.touch "README"
git_commit_all git_commit_all
end end

View File

@ -17,9 +17,7 @@ describe FormulaInstaller do
expect(formula).to be_bottled expect(formula).to be_bottled
expect(formula).to pour_bottle expect(formula).to pour_bottle
shutup do described_class.new(formula).install
described_class.new(formula).install
end
keg = Keg.new(formula.prefix) keg = Keg.new(formula.prefix)

View File

@ -18,9 +18,7 @@ describe FormulaInstaller do
installer = described_class.new(formula) installer = described_class.new(formula)
shutup do installer.install
installer.install
end
keg = Keg.new(formula.prefix) keg = Keg.new(formula.prefix)

View File

@ -582,11 +582,9 @@ describe Formula do
cached_location.cd do cached_location.cd do
FileUtils.touch "LICENSE" FileUtils.touch "LICENSE"
shutup do system("git", "init")
system("git", "init") system("git", "add", "--all")
system("git", "add", "--all") system("git", "commit", "-m", "Initial commit")
system("git", "commit", "-m", "Initial commit")
end
end end
f.update_head_version f.update_head_version
@ -786,11 +784,9 @@ describe Formula do
version_scheme(2) version_scheme(2)
end.new end.new
shutup do [f1, f2, f3, f4].each do |f|
[f1, f2, f3, f4].each do |f| f.brew { f.install }
f.brew { f.install } Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
end
end end
expect(f1).to be_installed expect(f1).to be_installed
@ -806,18 +802,16 @@ describe Formula do
f2 = Class.new(Testball) { version("0.2") }.new f2 = Class.new(Testball) { version("0.2") }.new
f3 = Class.new(Testball) { version("0.3") }.new f3 = Class.new(Testball) { version("0.3") }.new
shutup do f1.brew { f1.install }
f1.brew { f1.install } f1.pin
f1.pin f2.brew { f2.install }
f2.brew { f2.install } f3.brew { f3.install }
f3.brew { f3.install }
end
expect(f1.prefix).to eq((HOMEBREW_PINNED_KEGS/f1.name).resolved_path) expect(f1.prefix).to eq((HOMEBREW_PINNED_KEGS/f1.name).resolved_path)
expect(f1).to be_installed expect(f1).to be_installed
expect(f2).to be_installed expect(f2).to be_installed
expect(f3).to be_installed expect(f3).to be_installed
expect(shutup { f3.eligible_kegs_for_cleanup }).to eq([Keg.new(f2.prefix)]) expect(f3.eligible_kegs_for_cleanup).to eq([Keg.new(f2.prefix)])
end end
specify "with HEAD installed" do specify "with HEAD installed" do
@ -1204,11 +1198,9 @@ describe Formula do
testball_repo.cd do testball_repo.cd do
FileUtils.touch "LICENSE" FileUtils.touch "LICENSE"
shutup do system("git", "init")
system("git", "init") system("git", "add", "--all")
system("git", "add", "--all") system("git", "commit", "-m", "Initial commit")
system("git", "commit", "-m", "Initial commit")
end
end end
expect(f.outdated_kegs(fetch_head: true)).not_to be_empty expect(f.outdated_kegs(fetch_head: true)).not_to be_empty

View File

@ -84,10 +84,7 @@ describe Formulary do
end end
it "returns a Formula when given a URL" do it "returns a Formula when given a URL" do
formula = shutup do formula = subject.factory("file://#{formula_path}")
subject.factory("file://#{formula_path}")
end
expect(formula).to be_kind_of(Formula) expect(formula).to be_kind_of(Formula)
end end
@ -112,9 +109,7 @@ describe Formulary do
let(:installer) { FormulaInstaller.new(formula) } let(:installer) { FormulaInstaller.new(formula) }
it "returns a Formula when given a rack" do it "returns a Formula when given a rack" do
shutup do installer.install
installer.install
end
f = subject.from_rack(formula.rack) f = subject.from_rack(formula.rack)
expect(f).to be_kind_of(Formula) expect(f).to be_kind_of(Formula)
@ -122,9 +117,7 @@ describe Formulary do
end end
it "returns a Formula when given a Keg" do it "returns a Formula when given a Keg" do
shutup do installer.install
installer.install
end
keg = Keg.new(formula.prefix) keg = Keg.new(formula.prefix)
f = subject.from_keg(keg) f = subject.from_keg(keg)
@ -206,9 +199,7 @@ describe Formulary do
it "prioritizes Formulae from pinned Taps" do it "prioritizes Formulae from pinned Taps" do
begin begin
tap.pin tap.pin
formula = shutup do formula = subject.find_with_priority(formula_name)
subject.find_with_priority(formula_name)
end
expect(formula).to be_kind_of(Formula) expect(formula).to be_kind_of(Formula)
expect(formula.path).to eq(tap_path.realpath) expect(formula.path).to eq(tap_path.realpath)
ensure ensure

View File

@ -7,9 +7,7 @@ describe Language::Go do
expect(described_class).to receive(:opoo).once expect(described_class).to receive(:opoo).once
mktmpdir do |path| mktmpdir do |path|
shutup do described_class.stage_deps [], path
described_class.stage_deps [], path
end
end end
end end
end end

View File

@ -81,9 +81,7 @@ describe Migrator do
specify "#move_to_new_directory" do specify "#move_to_new_directory" do
keg.unlink keg.unlink
shutup do subject.move_to_new_directory
subject.move_to_new_directory
end
expect(new_keg_record).to be_a_directory expect(new_keg_record).to be_a_directory
expect(new_keg_record/"bin").to be_a_directory expect(new_keg_record/"bin").to be_a_directory
@ -117,9 +115,7 @@ describe Migrator do
expect(HOMEBREW_LINKED_KEGS.children.count).to eq(1) expect(HOMEBREW_LINKED_KEGS.children.count).to eq(1)
expect((HOMEBREW_PREFIX/"opt").children.count).to eq(1) expect((HOMEBREW_PREFIX/"opt").children.count).to eq(1)
shutup do subject.unlink_oldname
subject.unlink_oldname
end
expect(HOMEBREW_LINKED_KEGS).not_to exist expect(HOMEBREW_LINKED_KEGS).not_to exist
expect(HOMEBREW_LIBRARY/"bin").not_to exist expect(HOMEBREW_LIBRARY/"bin").not_to exist
@ -134,9 +130,7 @@ describe Migrator do
FileUtils.touch new_keg_record/"bin"/file FileUtils.touch new_keg_record/"bin"/file
end end
shutup do subject.link_newname
subject.link_newname
end
expect(HOMEBREW_LINKED_KEGS.children.count).to eq(1) expect(HOMEBREW_LINKED_KEGS.children.count).to eq(1)
expect((HOMEBREW_PREFIX/"opt").children.count).to eq(1) expect((HOMEBREW_PREFIX/"opt").children.count).to eq(1)
@ -172,9 +166,7 @@ describe Migrator do
tab.source["path"] = old_formula.path.to_s tab.source["path"] = old_formula.path.to_s
tab.write tab.write
shutup do subject.migrate
subject.migrate
end
expect(new_keg_record).to exist expect(new_keg_record).to exist
expect(old_keg_record.parent).to be_a_symlink expect(old_keg_record.parent).to be_a_symlink

View File

@ -148,13 +148,11 @@ describe Homebrew::MissingFormula do
(tap_path/"deleted-formula.rb").write "placeholder" (tap_path/"deleted-formula.rb").write "placeholder"
tap_path.cd do tap_path.cd do
shutup do system "git", "init"
system "git", "init" system "git", "add", "--all"
system "git", "add", "--all" system "git", "commit", "-m", "initial state"
system "git", "commit", "-m", "initial state" system "git", "rm", "deleted-formula.rb"
system "git", "rm", "deleted-formula.rb" system "git", "commit", "-m", "delete formula 'deleted-formula'"
system "git", "commit", "-m", "delete formula 'deleted-formula'"
end
end end
end end

View File

@ -21,27 +21,23 @@ describe "patching" do
matcher :be_patched do matcher :be_patched do
match do |formula| match do |formula|
shutup do formula.brew do
formula.brew do formula.patch
formula.patch s = File.read("libexec/NOOP")
s = File.read("libexec/NOOP") expect(s).not_to include("NOOP"), "libexec/NOOP was not patched as expected"
expect(s).not_to include("NOOP"), "libexec/NOOP was not patched as expected" expect(s).to include("ABCD"), "libexec/NOOP was not patched as expected"
expect(s).to include("ABCD"), "libexec/NOOP was not patched as expected"
end
end end
end end
end end
matcher :be_sequentially_patched do matcher :be_sequentially_patched do
match do |formula| match do |formula|
shutup do formula.brew do
formula.brew do formula.patch
formula.patch s = File.read("libexec/NOOP")
s = File.read("libexec/NOOP") expect(s).not_to include("NOOP"), "libexec/NOOP was not patched as expected"
expect(s).not_to include("NOOP"), "libexec/NOOP was not patched as expected" expect(s).not_to include("ABCD"), "libexec/NOOP was not patched as expected"
expect(s).not_to include("ABCD"), "libexec/NOOP was not patched as expected" expect(s).to include("1234"), "libexec/NOOP was not patched as expected"
expect(s).to include("1234"), "libexec/NOOP was not patched as expected"
end
end end
end end
end end
@ -49,10 +45,8 @@ describe "patching" do
matcher :miss_apply do matcher :miss_apply do
match do |formula| match do |formula|
expect { expect {
shutup do formula.brew do
formula.brew do formula.patch
formula.patch
end
end end
}.to raise_error(MissingApplyError) }.to raise_error(MissingApplyError)
end end
@ -128,32 +122,28 @@ describe "patching" do
specify "single_patch_dsl_with_incorrect_strip" do specify "single_patch_dsl_with_incorrect_strip" do
expect { expect {
shutup do f = formula do
f = formula do patch :p0 do
patch :p0 do url PATCH_URL_A
url PATCH_URL_A sha256 PATCH_A_SHA256
sha256 PATCH_A_SHA256
end
end end
f.brew { |formula, _staging| formula.patch }
end end
f.brew { |formula, _staging| formula.patch }
}.to raise_error(ErrorDuringExecution) }.to raise_error(ErrorDuringExecution)
end end
specify "single_patch_dsl_with_incorrect_strip_with_apply" do specify "single_patch_dsl_with_incorrect_strip_with_apply" do
expect { expect {
shutup do f = formula do
f = formula do patch :p0 do
patch :p0 do url TESTBALL_PATCHES_URL
url TESTBALL_PATCHES_URL sha256 TESTBALL_PATCHES_SHA256
sha256 TESTBALL_PATCHES_SHA256 apply APPLY_A
apply APPLY_A
end
end end
f.brew { |formula, _staging| formula.patch }
end end
f.brew { |formula, _staging| formula.patch }
}.to raise_error(ErrorDuringExecution) }.to raise_error(ErrorDuringExecution)
end end
@ -261,17 +251,15 @@ describe "patching" do
specify "single_patch_dsl_with_apply_enoent_fail" do specify "single_patch_dsl_with_apply_enoent_fail" do
expect { expect {
shutup do f = formula do
f = formula do patch do
patch do url TESTBALL_PATCHES_URL
url TESTBALL_PATCHES_URL sha256 TESTBALL_PATCHES_SHA256
sha256 TESTBALL_PATCHES_SHA256 apply "patches/#{APPLY_A}"
apply "patches/#{APPLY_A}"
end
end end
f.brew { |formula, _staging| formula.patch }
end end
f.brew { |formula, _staging| formula.patch }
}.to raise_error(ErrorDuringExecution) }.to raise_error(ErrorDuringExecution)
end end
end end

View File

@ -126,9 +126,7 @@ describe Resource do
expect(fn).to receive(:verify_checksum).and_raise(ChecksumMissingError) expect(fn).to receive(:verify_checksum).and_raise(ChecksumMissingError)
expect(fn).to receive(:sha256) expect(fn).to receive(:sha256)
shutup do subject.verify_download_integrity(fn)
subject.verify_download_integrity(fn)
end
end end
specify "#verify_download_integrity_mismatch" do specify "#verify_download_integrity_mismatch" do
@ -138,10 +136,8 @@ describe Resource do
expect(fn).to receive(:verify_checksum).with(checksum) expect(fn).to receive(:verify_checksum).with(checksum)
.and_raise(ChecksumMismatchError.new(fn, checksum, Object.new)) .and_raise(ChecksumMismatchError.new(fn, checksum, Object.new))
shutup do expect {
expect { subject.verify_download_integrity(fn)
subject.verify_download_integrity(fn) }.to raise_error(ChecksumMismatchError)
}.to raise_error(ChecksumMismatchError)
end
end end
end end

View File

@ -37,11 +37,9 @@ describe Sandbox do
describe "#exec" do describe "#exec" do
it "fails when writing to file not specified with ##allow_write" do it "fails when writing to file not specified with ##allow_write" do
shutup do expect {
expect { subject.exec "touch", file
subject.exec "touch", file }.to raise_error(ErrorDuringExecution)
}.to raise_error(ErrorDuringExecution)
end
expect(file).not_to exist expect(file).not_to exist
end end

View File

@ -19,7 +19,6 @@ $LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/su
require "global" require "global"
require "tap" require "tap"
require "test/support/helper/shutup"
require "test/support/helper/fixtures" require "test/support/helper/fixtures"
require "test/support/helper/formula" require "test/support/helper/formula"
require "test/support/helper/mktmpdir" require "test/support/helper/mktmpdir"
@ -44,7 +43,6 @@ RSpec.configure do |config|
config.filter_run_when_matching :focus config.filter_run_when_matching :focus
config.include(Test::Helper::Shutup)
config.include(Test::Helper::Fixtures) config.include(Test::Helper::Fixtures)
config.include(Test::Helper::Formula) config.include(Test::Helper::Formula)
config.include(Test::Helper::MkTmpDir) config.include(Test::Helper::MkTmpDir)
@ -88,11 +86,25 @@ RSpec.configure do |config|
@__argv = ARGV.dup @__argv = ARGV.dup
@__env = ENV.to_hash # dup doesn't work on ENV @__env = ENV.to_hash # dup doesn't work on ENV
unless example.metadata.key?(:focus) || ENV.key?("VERBOSE_TESTS")
@__stdout = $stdout.clone
@__stderr = $stderr.clone
$stdout.reopen(File::NULL)
$stderr.reopen(File::NULL)
end
example.run example.run
ensure ensure
ARGV.replace(@__argv) ARGV.replace(@__argv)
ENV.replace(@__env) ENV.replace(@__env)
unless example.metadata.key?(:focus) || ENV.key?("VERBOSE_TESTS")
$stdout.reopen(@__stdout)
$stderr.reopen(@__stderr)
@__stdout.close
@__stderr.close
end
Tab.clear_cache Tab.clear_cache
FileUtils.rm_rf [ FileUtils.rm_rf [

View File

@ -1,42 +1,29 @@
module InstallHelper module InstallHelper
module_function module_function
require "test/support/helper/shutup"
extend Test::Helper::Shutup
def self.install_without_artifacts(cask) def self.install_without_artifacts(cask)
Hbc::Installer.new(cask).tap do |i| Hbc::Installer.new(cask).tap do |i|
shutup do i.download
i.download i.extract_primary_container
i.extract_primary_container
end
end end
end end
def self.install_without_artifacts_with_caskfile(cask) def self.install_without_artifacts_with_caskfile(cask)
Hbc::Installer.new(cask).tap do |i| Hbc::Installer.new(cask).tap do |i|
shutup do i.download
i.download i.extract_primary_container
i.extract_primary_container i.save_caskfile
i.save_caskfile
end
end end
end end
def install_without_artifacts(cask) def install_without_artifacts(cask)
Hbc::Installer.new(cask).tap do |i| Hbc::Installer.new(cask).tap do |i|
shutup do i.download
i.download i.extract_primary_container
i.extract_primary_container
end
end end
end end
def install_with_caskfile(cask) def install_with_caskfile(cask)
Hbc::Installer.new(cask).tap do |i| Hbc::Installer.new(cask).tap(&:save_caskfile)
shutup do
i.save_caskfile
end
end
end end
end end

View File

@ -1,24 +0,0 @@
module Test
module Helper
module Shutup
def shutup
if ENV.key?("VERBOSE_TESTS")
yield
else
begin
tmperr = $stderr.clone
tmpout = $stdout.clone
$stderr.reopen("/dev/null")
$stdout.reopen("/dev/null")
yield
ensure
$stderr.reopen(tmperr)
$stdout.reopen(tmpout)
tmperr.close
tmpout.close
end
end
end
end
end
end

View File

@ -171,22 +171,20 @@ RSpec.shared_context "integration test" do
end end
def install_and_rename_coretap_formula(old_name, new_name) def install_and_rename_coretap_formula(old_name, new_name)
shutup do CoreTap.instance.path.cd do |tap_path|
CoreTap.instance.path.cd do |tap_path| system "git", "init"
system "git", "init" system "git", "add", "--all"
system "git", "add", "--all" system "git", "commit", "-m",
system "git", "commit", "-m", "#{old_name.capitalize} has not yet been renamed"
"#{old_name.capitalize} has not yet been renamed"
brew "install", old_name brew "install", old_name
(tap_path/"Formula/#{old_name}.rb").unlink (tap_path/"Formula/#{old_name}.rb").unlink
(tap_path/"formula_renames.json").write JSON.generate(old_name => new_name) (tap_path/"formula_renames.json").write JSON.generate(old_name => new_name)
system "git", "add", "--all" system "git", "add", "--all"
system "git", "commit", "-m", system "git", "commit", "-m",
"#{old_name.capitalize} has been renamed to #{new_name.capitalize}" "#{old_name.capitalize} has been renamed to #{new_name.capitalize}"
end
end end
end end

View File

@ -18,9 +18,7 @@ shared_examples Hbc::Staged do
["echo", "homebrew-cask", "rocks!"], ["echo", "homebrew-cask", "rocks!"],
) )
shutup do staged.system_command("echo", args: ["homebrew-cask", "rocks!"])
staged.system_command("echo", args: ["homebrew-cask", "rocks!"])
end
end end
it "can get the Info.plist file for the primary app" do it "can get the Info.plist file for the primary app" do
@ -34,9 +32,7 @@ shared_examples Hbc::Staged do
["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file], ["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file],
) )
shutup do staged.plist_exec("Print CFBundleIdentifier")
staged.plist_exec("Print CFBundleIdentifier")
end
end end
it "can set a key in the Info.plist file" do it "can set a key in the Info.plist file" do
@ -46,9 +42,7 @@ shared_examples Hbc::Staged do
["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file], ["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file],
) )
shutup do staged.plist_set(":JVMOptions:JVMVersion", "1.6+")
staged.plist_set(":JVMOptions:JVMVersion", "1.6+")
end
end end
it "can set the permissions of a file" do it "can set the permissions of a file" do
@ -59,9 +53,7 @@ shared_examples Hbc::Staged do
["/bin/chmod", "-R", "--", "777", fake_pathname], ["/bin/chmod", "-R", "--", "777", fake_pathname],
) )
shutup do staged.set_permissions(fake_pathname.to_s, "777")
staged.set_permissions(fake_pathname.to_s, "777")
end
end end
it "can set the permissions of multiple files" do it "can set the permissions of multiple files" do
@ -72,9 +64,7 @@ shared_examples Hbc::Staged do
["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname], ["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname],
) )
shutup do staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777")
staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777")
end
end end
it "cannot set the permissions of a file that does not exist" do it "cannot set the permissions of a file that does not exist" do
@ -93,9 +83,7 @@ shared_examples Hbc::Staged do
["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname], ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname],
) )
shutup do staged.set_ownership(fake_pathname.to_s)
staged.set_ownership(fake_pathname.to_s)
end
end end
it "can set the ownership of multiple files" do it "can set the ownership of multiple files" do
@ -108,9 +96,7 @@ shared_examples Hbc::Staged do
["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname], ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname],
) )
shutup do staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s])
staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s])
end
end end
it "can set the ownership of a file with a different user and group" do it "can set the ownership of a file with a different user and group" do
@ -122,9 +108,7 @@ shared_examples Hbc::Staged do
["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname], ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname],
) )
shutup do staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group")
staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group")
end
end end
it "cannot set the ownership of a file that does not exist" do it "cannot set the ownership of a file that does not exist" do
@ -132,8 +116,6 @@ shared_examples Hbc::Staged do
fake_pathname = non_existent_path fake_pathname = non_existent_path
allow(staged).to receive(:Pathname).and_return(fake_pathname) allow(staged).to receive(:Pathname).and_return(fake_pathname)
shutup do staged.set_ownership(fake_pathname.to_s)
staged.set_ownership(fake_pathname.to_s)
end
end end
end end

View File

@ -52,12 +52,10 @@ describe Tap do
def setup_git_repo def setup_git_repo
path.cd do path.cd do
shutup do system "git", "init"
system "git", "init" system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" system "git", "add", "--all"
system "git", "add", "--all" system "git", "commit", "-m", "init"
system "git", "commit", "-m", "init"
end
end end
end end
@ -104,7 +102,7 @@ describe Tap do
path = Tap::TAP_DIRECTORY/"someone/homebrew-foo" path = Tap::TAP_DIRECTORY/"someone/homebrew-foo"
path.mkpath path.mkpath
cd path do cd path do
shutup { system "git", "init" } system "git", "init"
system "git", "remote", "add", "origin", system "git", "remote", "add", "origin",
"https://github.com/someone/homebrew-foo" "https://github.com/someone/homebrew-foo"
end end
@ -148,10 +146,8 @@ describe Tap do
services_tap = described_class.new("Homebrew", "services") services_tap = described_class.new("Homebrew", "services")
services_tap.path.mkpath services_tap.path.mkpath
services_tap.path.cd do services_tap.path.cd do
shutup do system "git", "init"
system "git", "init" system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-services"
system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-services"
end
end end
expect(services_tap).not_to be_private expect(services_tap).not_to be_private
end end
@ -217,7 +213,7 @@ describe Tap do
tap = described_class.new("user", "repo") tap = described_class.new("user", "repo")
expect { expect {
shutup { tap.install clone_target: "file:///not/existed/remote/url" } tap.install clone_target: "file:///not/existed/remote/url"
}.to raise_error(ErrorDuringExecution) }.to raise_error(ErrorDuringExecution)
expect(tap).not_to be_installed expect(tap).not_to be_installed
@ -238,17 +234,16 @@ describe Tap do
setup_git_repo setup_git_repo
tap = Tap.new("Homebrew", "bar") tap = Tap.new("Homebrew", "bar")
shutup do
tap.install clone_target: subject.path/".git" tap.install clone_target: subject.path/".git"
end
expect(tap).to be_installed expect(tap).to be_installed
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file
expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file
expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file
expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file
shutup do tap.uninstall
tap.uninstall
end
expect(tap).not_to be_installed expect(tap).not_to be_installed
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").not_to exist expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").not_to exist
expect(HOMEBREW_PREFIX/"share/man/man1").not_to exist expect(HOMEBREW_PREFIX/"share/man/man1").not_to exist
@ -266,17 +261,17 @@ describe Tap do
setup_tap_files setup_tap_files
setup_git_repo setup_git_repo
tap = Tap.new("Homebrew", "baz") tap = Tap.new("Homebrew", "baz")
shutup { tap.install clone_target: subject.path/".git" } tap.install clone_target: subject.path/".git"
(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete (HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete
(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete (HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete
(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").delete (HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").delete
shutup { tap.link_completions_and_manpages } tap.link_completions_and_manpages
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file
expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file
expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file
expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file
shutup { tap.uninstall } tap.uninstall
ensure ensure
(HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist? (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
(HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?