aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cask/cli
diff options
context:
space:
mode:
authorL. E. Segovia2017-10-29 17:31:07 -0300
committerL. E. Segovia2017-10-29 17:34:53 -0300
commit55727b789532fbfa7997929aa0506d7843eda3ce (patch)
tree7b69cc7b0b5ee506bb5c2b9eddf898c8858b5cf2 /Library/Homebrew/test/cask/cli
parent4c44266aa5cfab215b92ef0aa5bb12112d8a4cb8 (diff)
downloadbrew-55727b789532fbfa7997929aa0506d7843eda3ce.tar.bz2
Hack a first working version of upgrade
Diffstat (limited to 'Library/Homebrew/test/cask/cli')
-rw-r--r--Library/Homebrew/test/cask/cli/upgrade_spec.rb78
1 files changed, 78 insertions, 0 deletions
diff --git a/Library/Homebrew/test/cask/cli/upgrade_spec.rb b/Library/Homebrew/test/cask/cli/upgrade_spec.rb
new file mode 100644
index 000000000..532541ba7
--- /dev/null
+++ b/Library/Homebrew/test/cask/cli/upgrade_spec.rb
@@ -0,0 +1,78 @@
+require_relative "shared_examples/invalid_option"
+
+describe Hbc::CLI::Upgrade, :cask do
+ let(:installed) do
+ [
+ Hbc::CaskLoader.load(cask_path("outdated/local-caffeine")),
+ Hbc::CaskLoader.load(cask_path("outdated/local-transmission")),
+ Hbc::CaskLoader.load(cask_path("outdated/auto-updates")),
+ ]
+ end
+
+ it_behaves_like "a command that handles invalid options"
+
+ before(:example) do
+ installed.each { |cask| InstallHelper.install_with_caskfile(cask) }
+
+ allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
+ end
+
+ describe 'without --greedy it ignores the Casks with "version latest" or "auto_updates true"' do
+ it "updates all the installed Casks when no token is provided" do
+ described_class.run
+
+ expect(Hbc::CaskLoader.load("local-caffeine")).to be_installed
+ expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory
+ expect(Hbc::CaskLoader.load("local-caffeine").versions).to include("1.2.3")
+
+ expect(Hbc::CaskLoader.load("local-transmission")).to be_installed
+ expect(Hbc.appdir.join("Transmission.app")).to be_a_directory
+ expect(Hbc::CaskLoader.load("local-transmission").versions).to include("2.61")
+ end
+
+ it "updates only the Casks specified in the command line" do
+ expect(Hbc::CaskLoader.load("local-caffeine").versions).to include("1.2.2")
+ expect(Hbc::CaskLoader.load("local-transmission").versions).to include("2.60")
+
+ described_class.run("local-caffeine")
+
+ expect(Hbc::CaskLoader.load("local-caffeine").versions).to include("1.2.3")
+ expect(Hbc::CaskLoader.load("local-caffeine").versions).to_not include("1.2.2")
+ expect(Hbc::CaskLoader.load("local-transmission").versions).to include("2.60")
+ end
+
+ it 'ignores "auto_updates" and "latest" Casks even when their tokens are provided in the command line' do
+ expect(Hbc::CaskLoader.load("local-caffeine").versions).to include("1.2.2")
+ expect(Hbc::CaskLoader.load("auto-updates").versions).to include("2.57")
+
+ described_class.run("local-caffeine", "auto-updates", "version-latest-string")
+
+ expect(Hbc::CaskLoader.load("local-caffeine").versions).to include("1.2.3")
+ expect(Hbc::CaskLoader.load("auto-updates").versions).to include("2.57")
+ end
+ end
+
+ describe "with --greedy it checks additional Casks" do
+ it 'includes the Casks with "auto_updates true" or "version latest" with --greedy' do
+ expect(Hbc::CaskLoader.load("auto-updates").versions).to include("2.57")
+ expect(Hbc::CaskLoader.load("local-caffeine").versions).to include("1.2.2")
+ expect(Hbc::CaskLoader.load("local-transmission").versions).to include("2.60")
+
+ described_class.run("--greedy")
+
+ expect(Hbc::CaskLoader.load("auto-updates").versions).to include("2.61")
+ expect(Hbc::CaskLoader.load("local-caffeine").versions).to include("1.2.3")
+ expect(Hbc::CaskLoader.load("local-transmission").versions).to include("2.61")
+ end
+
+ it 'does not include the Casks with "auto_updates true" when the version did not change' do
+ cask = Hbc::CaskLoader.load(cask_path("auto-updates"))
+ InstallHelper.install_with_caskfile(cask)
+ expect(Hbc::CaskLoader.load("auto-updates").versions).to include("2.61")
+
+ described_class.run("auto-updates", "--greedy")
+
+ expect(Hbc::CaskLoader.load("auto-updates").versions).to include("2.61")
+ end
+ end
+end