Convert Uninstall test to spec.
This commit is contained in:
parent
82e6070ca0
commit
3d03142040
@ -1,22 +1,22 @@
|
|||||||
require "test_helper"
|
require "spec_helper"
|
||||||
|
|
||||||
describe Hbc::CLI::Uninstall do
|
describe Hbc::CLI::Uninstall do
|
||||||
it "shows an error when a bad Cask is provided" do
|
it "shows an error when a bad Cask is provided" do
|
||||||
lambda {
|
expect {
|
||||||
Hbc::CLI::Uninstall.run("notacask")
|
Hbc::CLI::Uninstall.run("notacask")
|
||||||
}.must_raise Hbc::CaskUnavailableError
|
}.to raise_error(Hbc::CaskUnavailableError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shows an error when a Cask is provided that's not installed" do
|
it "shows an error when a Cask is provided that's not installed" do
|
||||||
lambda {
|
expect {
|
||||||
Hbc::CLI::Uninstall.run("anvil")
|
Hbc::CLI::Uninstall.run("anvil")
|
||||||
}.must_raise Hbc::CaskNotInstalledError
|
}.to raise_error(Hbc::CaskNotInstalledError)
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
lambda do
|
expect {
|
||||||
Hbc::CLI::Uninstall.run("anvil", "--force")
|
Hbc::CLI::Uninstall.run("anvil", "--force")
|
||||||
end # wont_raise
|
}.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can uninstall and unlink multiple Casks at once" do
|
it "can uninstall and unlink multiple Casks at once" do
|
||||||
@ -28,17 +28,17 @@ describe Hbc::CLI::Uninstall do
|
|||||||
Hbc::Installer.new(transmission).install
|
Hbc::Installer.new(transmission).install
|
||||||
end
|
end
|
||||||
|
|
||||||
caffeine.must_be :installed?
|
expect(caffeine).to be_installed
|
||||||
transmission.must_be :installed?
|
expect(transmission).to be_installed
|
||||||
|
|
||||||
shutup do
|
shutup do
|
||||||
Hbc::CLI::Uninstall.run("local-caffeine", "local-transmission")
|
Hbc::CLI::Uninstall.run("local-caffeine", "local-transmission")
|
||||||
end
|
end
|
||||||
|
|
||||||
caffeine.wont_be :installed?
|
expect(caffeine).not_to be_installed
|
||||||
Hbc.appdir.join("Transmission.app").wont_be :exist?
|
expect(Hbc.appdir.join("Transmission.app")).not_to exist
|
||||||
transmission.wont_be :installed?
|
expect(transmission).not_to be_installed
|
||||||
Hbc.appdir.join("Caffeine.app").wont_be :exist?
|
expect(Hbc.appdir.join("Caffeine.app")).not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when multiple versions of a cask are installed" do
|
describe "when multiple versions of a cask are installed" do
|
||||||
@ -67,34 +67,29 @@ describe Hbc::CLI::Uninstall do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:each) do
|
|
||||||
caskroom_path.rmtree if caskroom_path.exist?
|
|
||||||
end
|
|
||||||
|
|
||||||
it "uninstalls one version at a time" do
|
it "uninstalls one version at a time" do
|
||||||
shutup do
|
shutup do
|
||||||
Hbc::CLI::Uninstall.run("versioned-cask")
|
Hbc::CLI::Uninstall.run("versioned-cask")
|
||||||
end
|
end
|
||||||
|
|
||||||
caskroom_path.join(first_installed_version).must_be :exist?
|
expect(caskroom_path.join(first_installed_version)).to exist
|
||||||
caskroom_path.join(last_installed_version).wont_be :exist?
|
expect(caskroom_path.join(last_installed_version)).not_to exist
|
||||||
caskroom_path.must_be :exist?
|
expect(caskroom_path).to exist
|
||||||
|
|
||||||
shutup do
|
shutup do
|
||||||
Hbc::CLI::Uninstall.run("versioned-cask")
|
Hbc::CLI::Uninstall.run("versioned-cask")
|
||||||
end
|
end
|
||||||
|
|
||||||
caskroom_path.join(first_installed_version).wont_be :exist?
|
expect(caskroom_path.join(first_installed_version)).not_to exist
|
||||||
caskroom_path.wont_be :exist?
|
expect(caskroom_path).not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
it "displays a message when versions remain installed" do
|
it "displays a message when versions remain installed" do
|
||||||
out, err = capture_io do
|
expect {
|
||||||
Hbc::CLI::Uninstall.run("versioned-cask")
|
expect {
|
||||||
end
|
Hbc::CLI::Uninstall.run("versioned-cask")
|
||||||
|
}.not_to output.to_stderr
|
||||||
out.must_match(/#{token} #{first_installed_version} is still installed./)
|
}.to output(/#{token} #{first_installed_version} is still installed./).to_stdout
|
||||||
err.must_be :empty?
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -121,34 +116,29 @@ describe Hbc::CLI::Uninstall do
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
|
||||||
app.rmtree if app.exist?
|
|
||||||
caskroom_path.rmtree if caskroom_path.exist?
|
|
||||||
end
|
|
||||||
|
|
||||||
it "can still uninstall those Casks" do
|
it "can still uninstall those Casks" do
|
||||||
shutup do
|
shutup do
|
||||||
Hbc::CLI::Uninstall.run("ive-been-renamed")
|
Hbc::CLI::Uninstall.run("ive-been-renamed")
|
||||||
end
|
end
|
||||||
|
|
||||||
app.wont_be :exist?
|
expect(app).not_to exist
|
||||||
caskroom_path.wont_be :exist?
|
expect(caskroom_path).not_to exist
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when no Cask is specified" do
|
describe "when no Cask is specified" do
|
||||||
it "raises an exception" do
|
it "raises an exception" do
|
||||||
lambda {
|
expect {
|
||||||
Hbc::CLI::Uninstall.run
|
Hbc::CLI::Uninstall.run
|
||||||
}.must_raise Hbc::CaskUnspecifiedError
|
}.to raise_error(Hbc::CaskUnspecifiedError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when no Cask is specified, but an invalid option" do
|
describe "when no Cask is specified, but an invalid option" do
|
||||||
it "raises an exception" do
|
it "raises an exception" do
|
||||||
lambda {
|
expect {
|
||||||
Hbc::CLI::Uninstall.run("--notavalidoption")
|
Hbc::CLI::Uninstall.run("--notavalidoption")
|
||||||
}.must_raise Hbc::CaskUnspecifiedError
|
}.to raise_error(Hbc::CaskUnspecifiedError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user