Expand livecheck/livecheck tests

This commit is contained in:
Sam Ford 2020-12-19 23:45:26 -05:00
parent 3261bbc0bd
commit 732e67d5db
No known key found for this signature in database
GPG Key ID: 95209E46C7FFDEFE

View File

@ -47,6 +47,24 @@ describe Homebrew::Livecheck do
end
end
let(:c_discontinued) do
Cask::CaskLoader.load(+<<-RUBY)
cask "test_discontinued" do
version "0.0.1"
sha256 :no_check
url "https://brew.sh/test-0.0.1.tgz"
name "Test Discontinued"
desc "Discontinued test cask"
homepage "https://brew.sh"
caveats do
discontinued
end
end
RUBY
end
let(:f_disabled) do
formula("test_disabled") do
desc "Disabled test formula"
@ -64,6 +82,34 @@ describe Homebrew::Livecheck do
end
end
let(:c_latest) do
Cask::CaskLoader.load(+<<-RUBY)
cask "test_latest" do
version :latest
sha256 :no_check
url "https://brew.sh/test-0.0.1.tgz"
name "Test Latest"
desc "Latest test cask"
homepage "https://brew.sh"
end
RUBY
end
# `URL#unversioned?` doesn't work properly when using the
# `Cask::CaskLoader.load` setup above, so we use `Cask::Cask.new` instead.
let(:c_unversioned) do
Cask::Cask.new "test_unversioned" do
version "1.2.3"
sha256 :no_check
url "https://brew.sh/test.tgz"
name "Test Unversioned"
desc "Unversioned test cask"
homepage "https://brew.sh"
end
end
let(:f_head_only) do
formula("test_head_only") do
desc "HEAD-only test formula"
@ -133,6 +179,12 @@ describe Homebrew::Livecheck do
.and not_to_output.to_stderr
end
it "skips a discontinued cask without a livecheckable" do
expect { livecheck.skip_conditions(c_discontinued) }
.to output("test_discontinued : discontinued\n").to_stdout
.and not_to_output.to_stderr
end
it "skips a disabled formula without a livecheckable" do
expect { livecheck.skip_conditions(f_disabled) }
.to output("test_disabled : disabled\n").to_stdout
@ -145,6 +197,18 @@ describe Homebrew::Livecheck do
.and not_to_output.to_stderr
end
it "skips a cask containing `version :latest` without a livecheckable" do
expect { livecheck.skip_conditions(c_latest) }
.to output("test_latest : latest\n").to_stdout
.and not_to_output.to_stderr
end
it "skips a cask containing an unversioned URL without a livecheckable" do
expect { livecheck.skip_conditions(c_unversioned) }
.to output("test_unversioned : unversioned\n").to_stdout
.and not_to_output.to_stderr
end
it "skips a HEAD-only formula if not installed" do
expect { livecheck.skip_conditions(f_head_only) }
.to output("test_head_only : HEAD only formula must be installed to be livecheckable\n").to_stdout