Expand #checkable_urls test coverage
This expands tests for `#checkable_urls` to cover everything except branches that shouldn't ever be reached.
This commit is contained in:
parent
d7b515bf73
commit
bfdb84f676
@ -36,6 +36,15 @@ RSpec.describe Homebrew::Livecheck do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:f_stable_url_only) do
|
||||||
|
stable_url_s = stable_url
|
||||||
|
|
||||||
|
formula("test_stable_url_only") do
|
||||||
|
desc "Test formula with only a stable URL"
|
||||||
|
url stable_url_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
let(:r) { f.resources.first }
|
let(:r) { f.resources.first }
|
||||||
|
|
||||||
let(:c) do
|
let(:c) do
|
||||||
@ -56,6 +65,17 @@ RSpec.describe Homebrew::Livecheck do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:c_no_checkable_urls) do
|
||||||
|
Cask::CaskLoader.load(+<<-RUBY)
|
||||||
|
cask "test_no_checkable_urls" do
|
||||||
|
version "1.2.3"
|
||||||
|
|
||||||
|
name "Test"
|
||||||
|
desc "Test cask with no checkable URLs"
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
describe "::resolve_livecheck_reference" do
|
describe "::resolve_livecheck_reference" do
|
||||||
context "when a formula/cask has a livecheck block without formula/cask methods" do
|
context "when a formula/cask has a livecheck block without formula/cask methods" do
|
||||||
it "returns [nil, []]" do
|
it "returns [nil, []]" do
|
||||||
@ -134,15 +154,6 @@ RSpec.describe Homebrew::Livecheck do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:f_stable_url_only) do
|
|
||||||
stable_url_s = stable_url
|
|
||||||
|
|
||||||
formula("test_stable_url_only") do
|
|
||||||
desc "Test formula with only a stable URL"
|
|
||||||
url stable_url_s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:r_livecheck_url) { f_livecheck_url.resources.first }
|
let(:r_livecheck_url) { f_livecheck_url.resources.first }
|
||||||
|
|
||||||
let(:c_livecheck_url) do
|
let(:c_livecheck_url) do
|
||||||
@ -158,17 +169,6 @@ RSpec.describe Homebrew::Livecheck do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:c_no_checkable_urls) do
|
|
||||||
Cask::CaskLoader.load(+<<-RUBY)
|
|
||||||
cask "test_no_checkable_urls" do
|
|
||||||
version "1.2.3"
|
|
||||||
|
|
||||||
name "Test"
|
|
||||||
desc "Test cask with no checkable URLs"
|
|
||||||
end
|
|
||||||
RUBY
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns a URL string when given a livecheck_url string for a formula" do
|
it "returns a URL string when given a livecheck_url string for a formula" do
|
||||||
expect(livecheck.livecheck_url_to_string(livecheck_url, f_livecheck_url)).to eq(livecheck_url)
|
expect(livecheck.livecheck_url_to_string(livecheck_url, f_livecheck_url)).to eq(livecheck_url)
|
||||||
end
|
end
|
||||||
@ -235,6 +235,8 @@ RSpec.describe Homebrew::Livecheck do
|
|||||||
expect(livecheck.checkable_urls(c)).to eq([cask_url, homepage_url])
|
expect(livecheck.checkable_urls(c)).to eq([cask_url, homepage_url])
|
||||||
expect(livecheck.checkable_urls(r)).to eq([resource_url])
|
expect(livecheck.checkable_urls(r)).to eq([resource_url])
|
||||||
expect(livecheck.checkable_urls(f_duplicate_urls)).to eq([stable_url, head_url])
|
expect(livecheck.checkable_urls(f_duplicate_urls)).to eq([stable_url, head_url])
|
||||||
|
expect(livecheck.checkable_urls(f_stable_url_only)).to eq([stable_url])
|
||||||
|
expect(livecheck.checkable_urls(c_no_checkable_urls)).to eq([])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user