Improve standardization of strategy tests

This commit is contained in:
Sam Ford 2021-08-10 17:39:11 -04:00
parent 56dd89114d
commit 7e07010f06
No known key found for this signature in database
GPG Key ID: 95209E46C7FFDEFE
17 changed files with 63 additions and 47 deletions

View File

@ -10,11 +10,11 @@ describe Homebrew::Livecheck::Strategy::Apache do
let(:non_apache_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is an Apache URL" do
it "returns true for an Apache URL" do
expect(apache.match?(apache_url)).to be true
end
it "returns false if the argument provided is not an Apache URL" do
it "returns false for a non-Apache URL" do
expect(apache.match?(non_apache_url)).to be false
end
end

View File

@ -10,11 +10,11 @@ describe Homebrew::Livecheck::Strategy::Bitbucket do
let(:non_bitbucket_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is a Bitbucket URL" do
it "returns true for a Bitbucket URL" do
expect(bitbucket.match?(bitbucket_url)).to be true
end
it "returns false if the argument provided is not a Bitbucket URL" do
it "returns false for a non-Bitbucket URL" do
expect(bitbucket.match?(non_bitbucket_url)).to be false
end
end

View File

@ -11,12 +11,12 @@ describe Homebrew::Livecheck::Strategy::Cpan do
let(:non_cpan_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is a CPAN URL" do
it "returns true for a CPAN URL" do
expect(cpan.match?(cpan_url_no_subdirectory)).to be true
expect(cpan.match?(cpan_url_with_subdirectory)).to be true
end
it "returns false if the argument provided is not a CPAN URL" do
it "returns false for a non-CPAN URL" do
expect(cpan.match?(non_cpan_url)).to be false
end
end

View File

@ -6,8 +6,8 @@ require "livecheck/strategy"
describe Homebrew::Livecheck::Strategy::ElectronBuilder do
subject(:electron_builder) { described_class }
let(:valid_url) { "https://www.example.com/example/latest-mac.yml" }
let(:invalid_url) { "https://brew.sh/test" }
let(:yaml_url) { "https://www.example.com/example/latest-mac.yml" }
let(:non_yaml_url) { "https://brew.sh/test" }
let(:electron_builder_yaml) {
<<~EOS
@ -29,12 +29,12 @@ describe Homebrew::Livecheck::Strategy::ElectronBuilder do
let(:versions) { ["1.2.3"] }
describe "::match?" do
it "returns true for any URL pointing to a YAML file" do
expect(electron_builder.match?(valid_url)).to be true
it "returns true for a YAML file URL" do
expect(electron_builder.match?(yaml_url)).to be true
end
it "returns false for a URL not pointing to a YAML file" do
expect(electron_builder.match?(invalid_url)).to be false
it "returns false for non-YAML URL" do
expect(electron_builder.match?(non_yaml_url)).to be false
end
end

View File

@ -39,11 +39,11 @@ describe Homebrew::Livecheck::Strategy::Git do
end
describe "::match?" do
it "returns true if the argument provided is a Git repository" do
it "returns true for a Git repository URL" do
expect(git.match?(git_url)).to be true
end
it "returns false if the argument provided is not a Git repository" do
it "returns false for a non-Git URL" do
expect(git.match?(non_git_url)).to be false
end
end

View File

@ -14,19 +14,19 @@ describe Homebrew::Livecheck::Strategy::GithubLatest do
let(:non_github_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is a GitHub release artifact URL" do
it "returns true for a GitHub release artifact URL" do
expect(github_latest.match?(github_release_artifact_url)).to be true
end
it "returns true if the argument provided is a GitHub tag archive URL" do
it "returns true for a GitHub tag archive URL" do
expect(github_latest.match?(github_tag_archive_url)).to be true
end
it "returns true if the argument provided is a GitHub repository upload URL" do
it "returns true for a GitHub repository upload URL" do
expect(github_latest.match?(github_repository_upload_url)).to be true
end
it "returns false if the argument provided is not a GitHub URL" do
it "returns false for a non-GitHub URL" do
expect(github_latest.match?(non_github_url)).to be false
end
end

View File

@ -10,11 +10,11 @@ describe Homebrew::Livecheck::Strategy::Gnome do
let(:non_gnome_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is a GNOME URL" do
it "returns true for a GNOME URL" do
expect(gnome.match?(gnome_url)).to be true
end
it "returns false if the argument provided is not a GNOME URL" do
it "returns false for a non-GNOME URL" do
expect(gnome.match?(non_gnome_url)).to be false
end
end

View File

@ -11,15 +11,15 @@ describe Homebrew::Livecheck::Strategy::Gnu do
let(:non_gnu_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is a non-Savannah GNU URL" do
it "returns true for a [non-Savannah] GNU URL" do
expect(gnu.match?(gnu_url)).to be true
end
it "returns false if the argument provided is a Savannah GNU URL" do
it "returns false for a Savannah GNU URL" do
expect(gnu.match?(savannah_gnu_url)).to be false
end
it "returns false if the argument provided is not a GNU URL" do
it "returns false for a non-GNU URL (not nongnu.org)" do
expect(gnu.match?(non_gnu_url)).to be false
end
end

View File

@ -11,12 +11,12 @@ describe Homebrew::Livecheck::Strategy::Hackage do
let(:non_hackage_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is a Hackage URL" do
it "returns true for a Hackage URL" do
expect(hackage.match?(hackage_url)).to be true
expect(hackage.match?(hackage_downloads_url)).to be true
end
it "returns false if the argument provided is not a Hackage URL" do
it "returns false for a non-Hackage URL" do
expect(hackage.match?(non_hackage_url)).to be false
end
end

View File

@ -6,7 +6,8 @@ require "livecheck/strategy"
describe Homebrew::Livecheck::Strategy::HeaderMatch do
subject(:header_match) { described_class }
let(:url) { "https://www.example.com/" }
let(:http_url) { "https://brew.sh/blog/" }
let(:non_http_url) { "ftp://brew.sh/" }
let(:versions) {
versions = {
@ -47,8 +48,12 @@ describe Homebrew::Livecheck::Strategy::HeaderMatch do
}
describe "::match?" do
it "returns true for any URL" do
expect(header_match.match?(url)).to be true
it "returns true for an HTTP URL" do
expect(header_match.match?(http_url)).to be true
end
it "returns false for a non-HTTP URL" do
expect(header_match.match?(non_http_url)).to be false
end
end

View File

@ -10,11 +10,11 @@ describe Homebrew::Livecheck::Strategy::Launchpad do
let(:non_launchpad_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is a Launchpad URL" do
it "returns true for a Launchpad URL" do
expect(launchpad.match?(launchpad_url)).to be true
end
it "returns false if the argument provided is not a Launchpad URL" do
it "returns false for a non-Launchpad URL" do
expect(launchpad.match?(non_launchpad_url)).to be false
end
end

View File

@ -11,12 +11,12 @@ describe Homebrew::Livecheck::Strategy::Npm do
let(:non_npm_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is an npm URL" do
it "returns true for an npm URL" do
expect(npm.match?(npm_url)).to be true
expect(npm.match?(npm_scoped_url)).to be true
end
it "returns false if the argument provided is not an npm URL" do
it "returns false for a non-npm URL" do
expect(npm.match?(non_npm_url)).to be false
end
end

View File

@ -6,7 +6,9 @@ require "livecheck/strategy"
describe Homebrew::Livecheck::Strategy::PageMatch do
subject(:page_match) { described_class }
let(:url) { "https://brew.sh/blog/" }
let(:http_url) { "https://brew.sh/blog/" }
let(:non_http_url) { "ftp://brew.sh/" }
let(:regex) { %r{href=.*?/homebrew[._-]v?(\d+(?:\.\d+)+)/?["' >]}i }
let(:content) {
@ -50,7 +52,7 @@ describe Homebrew::Livecheck::Strategy::PageMatch do
"1.9.0" => Version.new("1.9.0"),
},
regex: regex,
url: url,
url: http_url,
}
}
@ -61,8 +63,12 @@ describe Homebrew::Livecheck::Strategy::PageMatch do
}
describe "::match?" do
it "returns true for any URL" do
expect(page_match.match?(url)).to be true
it "returns true for an HTTP URL" do
expect(page_match.match?(http_url)).to be true
end
it "returns false for a non-HTTP URL" do
expect(page_match.match?(non_http_url)).to be false
end
end
@ -100,7 +106,7 @@ describe Homebrew::Livecheck::Strategy::PageMatch do
describe "::find_versions?" do
it "finds versions in provided_content" do
expect(page_match.find_versions(url, regex, provided_content: content))
expect(page_match.find_versions(http_url, regex, provided_content: content))
.to eq(find_versions_cached_return_hash)
end
end

View File

@ -10,11 +10,11 @@ describe Homebrew::Livecheck::Strategy::Pypi do
let(:non_pypi_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is a PyPI URL" do
it "returns true for a PyPI URL" do
expect(pypi.match?(pypi_url)).to be true
end
it "returns false if the argument provided is not a PyPI URL" do
it "returns false for a non-PyPI URL" do
expect(pypi.match?(non_pypi_url)).to be false
end
end

View File

@ -10,11 +10,11 @@ describe Homebrew::Livecheck::Strategy::Sourceforge do
let(:non_sourceforge_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is a SourceForge URL" do
it "returns true for a SourceForge URL" do
expect(sourceforge.match?(sourceforge_url)).to be true
end
it "returns false if the argument provided is not a SourceForge URL" do
it "returns false for a non-SourceForge URL" do
expect(sourceforge.match?(non_sourceforge_url)).to be false
end
end

View File

@ -7,7 +7,8 @@ require "bundle_version"
describe Homebrew::Livecheck::Strategy::Sparkle do
subject(:sparkle) { described_class }
let(:url) { "https://www.example.com/example/appcast.xml" }
let(:appcast_url) { "https://www.example.com/example/appcast.xml" }
let(:non_http_url) { "ftp://brew.sh/" }
let(:appcast_data) {
{
@ -25,7 +26,7 @@ describe Homebrew::Livecheck::Strategy::Sparkle do
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
<channel>
<title>Example Changelog</title>
<link>#{url}</link>
<link>#{appcast_url}</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
@ -52,8 +53,12 @@ describe Homebrew::Livecheck::Strategy::Sparkle do
let(:versions) { [item.bundle_version.nice_version] }
describe "::match?" do
it "returns true for any URL" do
expect(sparkle.match?(url)).to be true
it "returns true for an HTTP URL" do
expect(sparkle.match?(appcast_url)).to be true
end
it "returns false for a non-HTTP URL" do
expect(sparkle.match?(non_http_url)).to be false
end
end

View File

@ -10,11 +10,11 @@ describe Homebrew::Livecheck::Strategy::Xorg do
let(:non_xorg_url) { "https://brew.sh/test" }
describe "::match?" do
it "returns true if the argument provided is an X.Org URL" do
it "returns true for an X.Org URL" do
expect(xorg.match?(xorg_url)).to be true
end
it "returns false if the argument provided is not an X.Org URL" do
it "returns false for a non-X.Org URL" do
expect(xorg.match?(non_xorg_url)).to be false
end
end