Cleanup some RSpec tests

Fix some Rubocop RSpec checks, update some values and improve
documentation.
This commit is contained in:
Mike McQuaid 2019-03-28 19:16:56 +00:00
parent 192603bbdf
commit 75257886f2
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
13 changed files with 434 additions and 319 deletions

View File

@ -1,21 +1,29 @@
inherit_from: ./.rubocop.yml
AllCops:
Include:
- '**/*_spec.rb'
Exclude:
- '**/vendor/**/*'
NewFormulaAudit:
Enabled: true
# TODO: try to enable these
# Intentionally disabled as it doesn't fit with our code style.
RSpec/AnyInstance:
Enabled: false
# TODO: try to enable these (also requires fixing Homebrew/bundle)
RSpec/ContextWording:
Enabled: false
RSpec/DescribeClass:
Enabled: false
RSpec/ExampleLength:
Enabled: false
RSpec/MessageSpies:
Enabled: false
# TODO: try to reduce these
# TODO: try to reduce these (also requires fixing Homebrew/bundle)
RSpec/ExampleLength:
Max: 75
RSpec/MultipleExpectations:
Max: 26
RSpec/NestedGroups:

View File

@ -1,37 +1,58 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-01-21 13:27:20 +0000 using RuboCop version 0.63.0.
# `rubocop --auto-gen-config --exclude-limit 100`
# on 2019-03-28 10:03:26 +0000 using RuboCop version 0.66.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# Cop supports --auto-correct.
Lint/UnneededCopEnableDirective:
# Configuration parameters: Max.
RSpec/ExampleLength:
Exclude:
- 'cask/artifact/shared_examples/uninstall_zap.rb'
# Offense count: 16
RSpec/ExpectActual:
Exclude:
- 'spec/routing/**/*'
- 'missing_formula_spec.rb'
# Offense count: 20
RSpec/ExpectInHook:
Exclude:
- 'cache_store_spec.rb'
- 'cask/audit_spec.rb'
- 'cmd/reinstall_spec.rb'
- 'linkage_cache_store_spec.rb'
- 'migrator_spec.rb'
- 'os/mac/java_requirement_spec.rb'
- 'rubocops/patches_spec.rb'
# Offense count: 37
# Configuration parameters: CustomTransform, IgnoreMethods.
RSpec/FilePath:
Enabled: false
Exclude:
- 'ARGV_spec.rb'
- 'PATH_spec.rb'
- 'bottle_filename_spec.rb'
- 'cache_store_spec.rb'
- 'cask/artifact/alt_target_spec.rb'
- 'cask/artifact/generic_artifact_spec.rb'
- 'cask/artifact/two_apps_correct_spec.rb'
- 'cask/artifact/uninstall_no_zap_spec.rb'
- 'cask/cask_loader/from__path_loader_spec.rb'
- 'cask/macos_spec.rb'
- 'checksum_verification_spec.rb'
- 'cli_parser_spec.rb'
- 'cxxstdlib_spec.rb'
- 'diagnostic_checks_spec.rb'
- 'missing_formula_spec.rb'
- 'os/linux/diagnostic_spec.rb'
- 'os/mac/diagnostic_spec.rb'
- 'requirements/macos_requirement_spec.rb'
- 'rubocops/cask/homepage_matches_url_spec.rb'
- 'rubocops/cask/homepage_url_trailing_slash_spec.rb'
- 'rubocops/cask/no_dsl_version_spec.rb'
- 'rubocops/cask/stanza_grouping_spec.rb'
- 'rubocops/cask/stanza_order_spec.rb'
- 'rubocops/caveats_spec.rb'
- 'rubocops/components_order_spec.rb'
- 'rubocops/components_redundancy_spec.rb'
- 'rubocops/conflicts_spec.rb'
- 'rubocops/dependency_order_spec.rb'
- 'rubocops/homepage_spec.rb'
- 'rubocops/options_spec.rb'
- 'rubocops/patches_spec.rb'
- 'rubocops/text_spec.rb'
- 'search_spec.rb'
- 'string_spec.rb'
- 'system_command_result_spec.rb'
- 'unpack_strategy/p7zip_spec.rb'
- 'utils/github_spec.rb'
# Offense count: 6
# Configuration parameters: AssignmentOnly.
@ -42,39 +63,185 @@ RSpec/InstanceVariable:
- 'utils/git_spec.rb'
- 'version_spec.rb'
# Offense count: 1
RSpec/MissingExampleGroupArgument:
Exclude:
- 'cask/depends_on_spec.rb'
# Offense count: 24
# Offense count: 74
RSpec/MultipleDescribes:
Enabled: false
Exclude:
- 'ENV_spec.rb'
- 'cleanup_spec.rb'
- 'cmd/--cache_spec.rb'
- 'cmd/--cellar_spec.rb'
- 'cmd/--env_spec.rb'
- 'cmd/--prefix_spec.rb'
- 'cmd/--repository_spec.rb'
- 'cmd/--version_spec.rb'
- 'cmd/analytics_spec.rb'
- 'cmd/cat_spec.rb'
- 'cmd/cleanup_spec.rb'
- 'cmd/command_spec.rb'
- 'cmd/commands_spec.rb'
- 'cmd/config_spec.rb'
- 'cmd/desc_spec.rb'
- 'cmd/doctor_spec.rb'
- 'cmd/fetch_spec.rb'
- 'cmd/home_spec.rb'
- 'cmd/info_spec.rb'
- 'cmd/install_spec.rb'
- 'cmd/leaves_spec.rb'
- 'cmd/link_spec.rb'
- 'cmd/list_spec.rb'
- 'cmd/log_spec.rb'
- 'cmd/migrate_spec.rb'
- 'cmd/missing_spec.rb'
- 'cmd/options_spec.rb'
- 'cmd/outdated_spec.rb'
- 'cmd/pin_spec.rb'
- 'cmd/readall_spec.rb'
- 'cmd/reinstall_spec.rb'
- 'cmd/search_spec.rb'
- 'cmd/sh_spec.rb'
- 'cmd/style_spec.rb'
- 'cmd/switch_spec.rb'
- 'cmd/tap-info_spec.rb'
- 'cmd/tap_spec.rb'
- 'cmd/uninstall_spec.rb'
- 'cmd/unlink_spec.rb'
- 'cmd/unpack_spec.rb'
- 'cmd/unpin_spec.rb'
- 'cmd/untap_spec.rb'
- 'cmd/update-report_spec.rb'
- 'cmd/upgrade_spec.rb'
- 'cmd/uses_spec.rb'
- 'dependency_spec.rb'
- 'dev-cmd/bottle_spec.rb'
- 'dev-cmd/create_spec.rb'
- 'dev-cmd/edit_spec.rb'
- 'dev-cmd/extract_spec.rb'
- 'dev-cmd/formula_spec.rb'
- 'dev-cmd/irb_spec.rb'
- 'dev-cmd/linkage_spec.rb'
- 'dev-cmd/pull_spec.rb'
- 'dev-cmd/ruby_spec.rb'
- 'dev-cmd/tap-new_spec.rb'
- 'dev-cmd/test_spec.rb'
- 'download_strategies_spec.rb'
- 'exceptions_spec.rb'
- 'formula_support_spec.rb'
- 'inreplace_spec.rb'
- 'language/python_spec.rb'
- 'options_spec.rb'
- 'os/mac/mach_spec.rb'
- 'patch_spec.rb'
- 'rubocops/checksum_spec.rb'
- 'rubocops/class_spec.rb'
- 'rubocops/formula_desc_spec.rb'
- 'rubocops/lines_spec.rb'
- 'rubocops/urls_spec.rb'
- 'software_spec_spec.rb'
- 'tap_spec.rb'
- 'utils/git_spec.rb'
- 'version_spec.rb'
# Offense count: 825
# Offense count: 816
# Configuration parameters: IgnoreSharedExamples.
RSpec/NamedSubject:
Enabled: false
# Offense count: 7
RSpec/RepeatedDescription:
Exclude:
- 'ARGV_spec.rb'
- 'ENV_spec.rb'
- 'build_environment_spec.rb'
- 'build_options_spec.rb'
- 'cache_store_spec.rb'
- 'cask/audit_spec.rb'
- 'cask/cmd/style_spec.rb'
- 'cask/cmd_spec.rb'
- 'cask/depends_on_spec.rb'
- 'cask/dsl/appcast_spec.rb'
- 'caveats_spec.rb'
- 'cleaner_spec.rb'
- 'cleanup_spec.rb'
- 'cmd/info_spec.rb'
- 'compiler_selector_spec.rb'
- 'dependable_spec.rb'
- 'dependencies_spec.rb'
- 'dependency_collector_spec.rb'
- 'dependency_spec.rb'
- 'descriptions_spec.rb'
- 'diagnostic_checks_spec.rb'
- 'download_strategies_spec.rb'
- 'emoji_spec.rb'
- 'error_during_execution_spec.rb'
- 'exceptions_spec.rb'
- 'formatter_spec.rb'
- 'formula_pin_spec.rb'
- 'inreplace_spec.rb'
- 'java_requirement_spec.rb'
- 'language/node_spec.rb'
- 'language/python_spec.rb'
- 'linkage_cache_store_spec.rb'
- 'locale_spec.rb'
- 'lock_file_spec.rb'
- 'migrator_spec.rb'
- 'options_spec.rb'
- 'os/linux/dependency_collector_spec.rb'
- 'os/linux/diagnostic_spec.rb'
- 'os/mac/dependency_collector_spec.rb'
- 'os/mac/diagnostic_spec.rb'
- 'os/mac/java_requirement_spec.rb'
- 'os/mac/keg_spec.rb'
- 'os/mac/version_spec.rb'
- 'os/mac_spec.rb'
- 'patch_spec.rb'
- 'requirement_spec.rb'
- 'requirements_spec.rb'
- 'resource_spec.rb'
- 'sandbox_spec.rb'
- 'searchable_spec.rb'
- 'software_spec_spec.rb'
- 'string_spec.rb'
- 'system_command_result_spec.rb'
- 'tab_spec.rb'
- 'tap_spec.rb'
- 'utils/bottles/collector_spec.rb'
- 'utils/github_spec.rb'
- 'utils/popen_spec.rb'
- 'utils/shell_spec.rb'
- 'utils/tty_spec.rb'
- 'utils_spec.rb'
- 'version_spec.rb'
- 'x11_requirement_spec.rb'
# Offense count: 25
# Offense count: 24
RSpec/SubjectStub:
Exclude:
- 'cache_store_spec.rb'
- 'cmd/update-report/reporter_spec.rb'
- 'download_strategies_spec.rb'
- 'formula_installer_spec.rb'
- 'java_requirement_spec.rb'
- 'language/python_spec.rb'
- 'os/mac/java_requirement_spec.rb'
# Offense count: 67
# Offense count: 66
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Enabled: false
Exclude:
- 'cache_store_spec.rb'
- 'cask/artifact/pkg_spec.rb'
- 'cask/cmd/style_spec.rb'
- 'cask/cmd_spec.rb'
- 'cask/installer_spec.rb'
- 'cask/pkg_spec.rb'
- 'cmd/update-report_spec.rb'
- 'compiler_failure_spec.rb'
- 'compiler_selector_spec.rb'
- 'dependable_spec.rb'
- 'dependency_expansion_spec.rb'
- 'description_cache_store_spec.rb'
- 'exceptions_spec.rb'
- 'formula_pin_spec.rb'
- 'formula_spec.rb'
- 'language/python_spec.rb'
- 'linkage_cache_store_spec.rb'
- 'resource_spec.rb'
- 'software_spec_spec.rb'
- 'support/helper/formula.rb'
- 'utils/analytics_spec.rb'
- 'version_spec.rb'

View File

@ -17,14 +17,12 @@ describe CacheStoreDatabase do
describe "#set" do
let(:db) { double("db", :[]= => nil) }
before do
it "sets the value in the `CacheStoreDatabase`" do
allow(File).to receive(:write)
allow(subject).to receive(:created?).and_return(true)
expect(db).to receive(:has_key?).with(:foo).and_return(false)
allow(subject).to receive(:db).and_return(db)
end
it "sets the value in the `CacheStoreDatabase`" do
expect(db).to receive(:has_key?).with(:foo).and_return(false)
expect(db).not_to have_key(:foo)
subject.set(:foo, "bar")
end
@ -34,13 +32,10 @@ describe CacheStoreDatabase do
context "database created" do
let(:db) { double("db", :[] => "bar") }
before do
it "gets value in the `CacheStoreDatabase` corresponding to the key" do
allow(subject).to receive(:created?).and_return(true)
expect(db).to receive(:has_key?).with(:foo).and_return(true)
allow(subject).to receive(:db).and_return(db)
end
it "gets value in the `CacheStoreDatabase` corresponding to the key" do
expect(db).to have_key(:foo)
expect(subject.get(:foo)).to eq("bar")
end

View File

@ -203,7 +203,6 @@ shared_examples "#uninstall_phase or #zap_phase" do
FileUtils.rm_rf result.stdout.split("\0")
end
end
# rubocop:enable RSpec/AnyInstance
end
it "is supported" do

View File

@ -495,14 +495,13 @@ describe Cask::Audit, :cask do
let(:cask_token) { "with-binary" }
let(:check_token_conflicts) { true }
before do
expect(audit).to receive(:core_formula_names).and_return(formula_names)
end
context "when cask token conflicts with a core formula" do
let(:formula_names) { %w[with-binary other-formula] }
it { is_expected.to warn_with(/possible duplicate/) }
it "warns about duplicates" do
expect(audit).to receive(:core_formula_names).and_return(formula_names)
expect(subject).to warn_with(/possible duplicate/)
end
end
context "when cask token does not conflict with a core formula" do
@ -519,41 +518,31 @@ describe Cask::Audit, :cask do
let(:verify) { class_double(Cask::Verify).as_stubbed_const }
let(:error_msg) { "Download Failed" }
context "when download and verification succeed" do
before do
expect(download).to receive(:perform)
expect(verify).to receive(:all)
end
it { is_expected.not_to fail_with(/#{error_msg}/) }
it "when download and verification succeed it does not fail" do
expect(download).to receive(:perform)
expect(verify).to receive(:all)
expect(subject).not_to fail_with(/#{error_msg}/)
end
context "when download fails" do
before do
expect(download).to receive(:perform).and_raise(StandardError.new(error_msg))
end
it { is_expected.to fail_with(/#{error_msg}/) }
it "when download fails it does not fail" do
expect(download).to receive(:perform).and_raise(StandardError.new(error_msg))
expect(subject).to fail_with(/#{error_msg}/)
end
context "when verification fails" do
before do
expect(download).to receive(:perform)
expect(verify).to receive(:all).and_raise(StandardError.new(error_msg))
end
it { is_expected.to fail_with(/#{error_msg}/) }
it "when verification fails it does not fail" do
expect(download).to receive(:perform)
expect(verify).to receive(:all).and_raise(StandardError.new(error_msg))
expect(subject).to fail_with(/#{error_msg}/)
end
end
context "when an exception is raised" do
let(:cask) { instance_double(Cask::Cask) }
before do
it "does not fail" do
expect(cask).to receive(:version).and_raise(StandardError.new)
expect(subject).to fail_with(/exception while auditing/)
end
it { is_expected.to fail_with(/exception while auditing/) }
end
end
end

View File

@ -8,6 +8,15 @@ describe "Satisfy Dependencies and Requirements", :cask do
}
describe "depends_on cask" do
let(:dependency) { Cask::CaskLoader.load(cask.depends_on.cask.first) }
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-cask")) }
it "installs the dependency of a Cask and the Cask itself" do
expect(subject).not_to raise_error
expect(cask).to be_installed
expect(dependency).to be_installed
end
context "when depends_on cask is cyclic" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-cask-cyclic")) }
@ -19,17 +28,6 @@ describe "Satisfy Dependencies and Requirements", :cask do
)
}
end
context do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-cask")) }
let(:dependency) { Cask::CaskLoader.load(cask.depends_on.cask.first) }
it "installs the dependency of a Cask and the Cask itself" do
expect(subject).not_to raise_error
expect(cask).to be_installed
expect(dependency).to be_installed
end
end
end
describe "depends_on macos" do

View File

@ -232,7 +232,7 @@ describe Utils::Inreplace do
}.to raise_error(Utils::InreplaceError)
end
it "raises error if there is nothing to replace" do
it "raises error if there is nothing to replace in block form" do
expect {
described_class.inreplace(file.path) do |s|
s.gsub!("d", "f") # rubocop:disable Performance/StringReplacement
@ -240,7 +240,7 @@ describe Utils::Inreplace do
}.to raise_error(Utils::InreplaceError)
end
it "raises error if there is nothing to replace" do
it "raises error if there is no make variables to replace" do
expect {
described_class.inreplace(file.path) do |s|
s.change_make_var! "VAR", "value"

View File

@ -8,21 +8,15 @@ describe LinkageCacheStore do
describe "#keg_exists?" do
context "`keg_name` exists in cache" do
before do
expect(database).to receive(:get).with(keg_name).and_return("")
end
it "returns `true`" do
expect(database).to receive(:get).with(keg_name).and_return("")
expect(subject.keg_exists?).to be(true)
end
end
context "`keg_name` does not exist in cache" do
before do
expect(database).to receive(:get).with(keg_name).and_return(nil)
end
it "returns `false`" do
expect(database).to receive(:get).with(keg_name).and_return(nil)
expect(subject.keg_exists?).to be(false)
end
end
@ -52,11 +46,8 @@ describe LinkageCacheStore do
describe "#fetch" do
context "`HASH_LINKAGE_TYPES.include?(type)`" do
before do
expect(database).to receive(:get).with(keg_name).and_return(nil)
end
it "returns a `Hash` of values" do
expect(database).to receive(:get).with(keg_name).and_return(nil)
expect(subject.fetch(:keg_files_dylibs)).to be_an_instance_of(Hash)
end
end

View File

@ -197,7 +197,7 @@ describe Migrator do
expect(old_keg_record.parent).not_to be_a_symlink
end
specify "#backup_oldname_cellar" do
specify "#backup_oldname_cellar after uninstall" do
(new_keg_record/"bin").mkpath
keg.unlink
keg.uninstall
@ -217,18 +217,15 @@ describe Migrator do
end
describe "#backup_oldname" do
after do
expect(old_keg_record.parent).to be_a_directory
expect(old_keg_record.parent.subdirs).not_to be_empty
expect(HOMEBREW_LINKED_KEGS/"oldname").to exist
expect(HOMEBREW_PREFIX/"opt/oldname").to exist
expect(HOMEBREW_PINNED_KEGS/"oldname").to be_a_symlink
expect(keg).to be_linked
end
context "when cellar exists" do
it "backs up the old name" do
subject.backup_oldname
expect(old_keg_record.parent).to be_a_directory
expect(old_keg_record.parent.subdirs).not_to be_empty
expect(HOMEBREW_LINKED_KEGS/"oldname").to exist
expect(HOMEBREW_PREFIX/"opt/oldname").to exist
expect(HOMEBREW_PINNED_KEGS/"oldname").to be_a_symlink
expect(keg).to be_linked
end
end
@ -238,6 +235,12 @@ describe Migrator do
keg.unlink
keg.uninstall
subject.backup_oldname
expect(old_keg_record.parent).to be_a_directory
expect(old_keg_record.parent.subdirs).not_to be_empty
expect(HOMEBREW_LINKED_KEGS/"oldname").to exist
expect(HOMEBREW_PREFIX/"opt/oldname").to exist
expect(HOMEBREW_PINNED_KEGS/"oldname").to be_a_symlink
expect(keg).to be_linked
end
end
@ -248,6 +251,12 @@ describe Migrator do
keg.uninstall
old_keg_record.parent.make_relative_symlink(new_keg_record.parent)
subject.backup_oldname
expect(old_keg_record.parent).to be_a_directory
expect(old_keg_record.parent.subdirs).not_to be_empty
expect(HOMEBREW_LINKED_KEGS/"oldname").to exist
expect(HOMEBREW_PREFIX/"opt/oldname").to exist
expect(HOMEBREW_PINNED_KEGS/"oldname").to be_a_symlink
expect(keg).to be_linked
end
end
end

View File

@ -8,75 +8,28 @@ describe Homebrew::MissingFormula do
end
describe "::blacklisted_reason" do
matcher :be_blacklisted do
matcher :blacklist do |name|
match do |expected|
described_class.blacklisted_reason(expected)
expected.blacklisted_reason(name)
end
end
specify "RubyGems is blacklisted" do
expect(%w[gem rubygem rubygems]).to all be_blacklisted
end
specify "LaTeX is blacklisted" do
expect(%w[latex tex tex-live texlive TexLive]).to all be_blacklisted
end
specify "pip is blacklisted" do
expect("pip").to be_blacklisted
end
specify "PIL is blacklisted" do
expect("pil").to be_blacklisted
end
specify "MacRuby is blacklisted" do
expect("MacRuby").to be_blacklisted
end
specify "lzma is blacklisted" do
expect(%w[lzma liblzma]).to all be_blacklisted
end
specify "gtest is blacklisted" do
expect(%w[gtest googletest google-test]).to all be_blacklisted
end
specify "gmock is blacklisted" do
expect(%w[gmock googlemock google-mock]).to all be_blacklisted
end
specify "sshpass is blacklisted" do
expect("sshpass").to be_blacklisted
end
specify "gsutil is blacklisted" do
expect("gsutil").to be_blacklisted
end
specify "gfortran is blacklisted" do
expect("gfortran").to be_blacklisted
end
specify "play is blacklisted" do
expect("play").to be_blacklisted
end
specify "haskell-platform is blacklisted" do
expect("haskell-platform").to be_blacklisted
end
specify "mysqldump-secure is blacklisted" do
expect("mysqldump-secure").to be_blacklisted
end
specify "ngrok is blacklisted" do
expect("ngrok").to be_blacklisted
end
specify "Xcode is blacklisted", :needs_macos do
expect(%w[xcode Xcode]).to all be_blacklisted
end
it { is_expected.to blacklist("gem") }
it { is_expected.to blacklist("latex") }
it { is_expected.to blacklist("pip") }
it { is_expected.to blacklist("pil") }
it { is_expected.to blacklist("macruby") }
it { is_expected.to blacklist("lzma") }
it { is_expected.to blacklist("gtest") }
it { is_expected.to blacklist("gmock") }
it { is_expected.to blacklist("sshpass") }
it { is_expected.to blacklist("gsutil") }
it { is_expected.to blacklist("gfortran") }
it { is_expected.to blacklist("play") }
it { is_expected.to blacklist("haskell-platform") }
it { is_expected.to blacklist("mysqldump-secure") }
it { is_expected.to blacklist("ngrok") }
it("blacklists Xcode", :needs_macos) { is_expected.to blacklist("xcode") }
end
describe "::tap_migration_reason" do

View File

@ -10,10 +10,11 @@ describe JavaRequirement do
FileUtils.mkdir java_home/"bin"
FileUtils.touch java_home/"bin/java"
allow(subject).to receive(:preferred_java).and_return(java_home/"bin/java")
expect(subject).to be_satisfied
end
specify "Apple Java environment" do
expect(subject).to be_satisfied
expect(ENV).to receive(:prepend_path)
expect(ENV).to receive(:append_to_cflags)
@ -22,6 +23,8 @@ describe JavaRequirement do
end
specify "Oracle Java environment" do
expect(subject).to be_satisfied
FileUtils.mkdir java_home/"include"
expect(ENV).to receive(:prepend_path)
expect(ENV).to receive(:append_to_cflags).twice

View File

@ -3,146 +3,149 @@ require "rubocops/urls"
describe RuboCop::Cop::FormulaAudit::Urls do
subject(:cop) { described_class.new }
let(:formulae) {
[{
"url" => "https://ftpmirror.gnu.org/lightning/lightning-2.1.0.tar.gz",
"msg" => 'Please use "https://ftp.gnu.org/gnu/lightning/lightning-2.1.0.tar.gz" instead of https://ftpmirror.gnu.org/lightning/lightning-2.1.0.tar.gz.',
"col" => 2,
}, {
"url" => "https://fossies.org/linux/privat/monit-5.23.0.tar.gz",
"msg" => "Please don't use fossies.org in the url (using as a mirror is fine)",
"col" => 2,
}, {
"url" => "http://tools.ietf.org/tools/rfcmarkup/rfcmarkup-1.119.tgz",
"msg" => "Please use https:// for http://tools.ietf.org/tools/rfcmarkup/rfcmarkup-1.119.tgz",
"col" => 2,
}, {
"url" => "http://search.mcpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz",
"msg" => "http://search.mcpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz should be " \
"`https://cpan.metacpan.org/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz`",
"col" => 2,
}, {
"url" => "http://ftp.gnome.org/pub/GNOME/binaries/mac/banshee/banshee-2.macosx.intel.dmg",
"msg" => "http://ftp.gnome.org/pub/GNOME/binaries/mac/banshee/banshee-2.macosx.intel.dmg should be " \
"`https://download.gnome.org/binaries/mac/banshee/banshee-2.macosx.intel.dmg`",
"col" => 2,
}, {
"url" => "git://anonscm.debian.org/users/foo/foostrap.git",
"msg" => "git://anonscm.debian.org/users/foo/foostrap.git should be " \
"`https://anonscm.debian.org/git/users/foo/foostrap.git`",
"col" => 2,
}, {
"url" => "ftp://ftp.mirrorservice.org/foo-1.tar.gz",
"msg" => "Please use https:// for ftp://ftp.mirrorservice.org/foo-1.tar.gz",
"col" => 2,
}, {
"url" => "ftp://ftp.cpan.org/pub/CPAN/foo-1.tar.gz",
"msg" => "ftp://ftp.cpan.org/pub/CPAN/foo-1.tar.gz should be `http://search.cpan.org/CPAN/foo-1.tar.gz`",
"col" => 2,
}, {
"url" => "http://sourceforge.net/projects/something/files/Something-1.2.3.dmg",
"msg" => "Use https://downloads.sourceforge.net to get geolocation (url is " \
"http://sourceforge.net/projects/something/files/Something-1.2.3.dmg).",
"col" => 2,
}, {
"url" => "https://downloads.sourceforge.net/project/foo/download",
"msg" => "Don't use /download in SourceForge urls (url is " \
"https://downloads.sourceforge.net/project/foo/download).",
"col" => 2,
}, {
"url" => "https://sourceforge.net/project/foo",
"msg" => "Use https://downloads.sourceforge.net to get geolocation " \
"(url is https://sourceforge.net/project/foo).",
"col" => 2,
}, {
"url" => "http://prdownloads.sourceforge.net/foo/foo-1.tar.gz",
"msg" => <<~EOS.chomp,
Don't use prdownloads in SourceForge urls (url is http://prdownloads.sourceforge.net/foo/foo-1.tar.gz).
See: http://librelist.com/browser/homebrew/2011/1/12/prdownloads-is-bad/
EOS
"col" => 2,
}, {
"url" => "http://foo.dl.sourceforge.net/sourceforge/foozip/foozip_1.0.tar.bz2",
"msg" => "Don't use specific dl mirrors in SourceForge urls (url is " \
"http://foo.dl.sourceforge.net/sourceforge/foozip/foozip_1.0.tar.bz2).",
"col" => 2,
}, {
"url" => "http://downloads.sourceforge.net/project/foo/foo/2/foo-2.zip",
"msg" => "Please use https:// for http://downloads.sourceforge.net/project/foo/foo/2/foo-2.zip",
"col" => 2,
}, {
"url" => "http://http.debian.net/debian/dists/foo/",
"msg" => <<~EOS,
Please use a secure mirror for Debian URLs.
We recommend:
https://deb.debian.org/debian/dists/foo/
EOS
"col" => 2,
}, {
"url" => "https://mirrors.kernel.org/debian/pool/main/n/nc6/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://mirrors.kernel.org/debian/pool/main/n/nc6/foo.tar.gz",
"col" => 2,
}, {
"url" => "https://mirrors.ocf.berkeley.edu/debian/pool/main/m/mkcue/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://mirrors.ocf.berkeley.edu/debian/pool/main/m/mkcue/foo.tar.gz",
"col" => 2,
}, {
"url" => "https://mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"col" => 2,
}, {
"url" => "https://www.mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://www.mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"col" => 2,
}, {
"url" => "http://foo.googlecode.com/files/foo-1.0.zip",
"msg" => "Please use https:// for http://foo.googlecode.com/files/foo-1.0.zip",
"col" => 2,
}, {
"url" => "git://github.com/foo.git",
"msg" => "Please use https:// for git://github.com/foo.git",
"col" => 2,
}, {
"url" => "git://gitorious.org/foo/foo5",
"msg" => "Please use https:// for git://gitorious.org/foo/foo5",
"col" => 2,
}, {
"url" => "http://github.com/foo/foo5.git",
"msg" => "Please use https:// for http://github.com/foo/foo5.git",
"col" => 2,
}, {
"url" => "https://github.com/foo/foobar/archive/master.zip",
"msg" => "Use versioned rather than branch tarballs for stable checksums.",
"col" => 2,
}, {
"url" => "https://github.com/foo/bar/tarball/v1.2.3",
"msg" => "Use /archive/ URLs for GitHub tarballs (url is https://github.com/foo/bar/tarball/v1.2.3).",
"col" => 2,
}, {
"url" => "https://codeload.github.com/foo/bar/tar.gz/v0.1.1",
"msg" => <<~EOS,
Use GitHub archive URLs:
https://github.com/foo/bar/archive/v0.1.1.tar.gz
Rather than codeload:
https://codeload.github.com/foo/bar/tar.gz/v0.1.1
EOS
"col" => 2,
}, {
"url" => "https://central.maven.org/maven2/com/bar/foo/1.1/foo-1.1.jar",
"msg" => "https://central.maven.org/maven2/com/bar/foo/1.1/foo-1.1.jar should be " \
"`https://search.maven.org/remotecontent?filepath=com/bar/foo/1.1/foo-1.1.jar`",
"col" => 2,
}]
}
context "When auditing urls" do
it "with offenses" do
formulas = [{
"url" => "https://ftpmirror.gnu.org/lightning/lightning-2.1.0.tar.gz",
"msg" => 'Please use "https://ftp.gnu.org/gnu/lightning/lightning-2.1.0.tar.gz" instead of https://ftpmirror.gnu.org/lightning/lightning-2.1.0.tar.gz.',
"col" => 2,
}, {
"url" => "https://fossies.org/linux/privat/monit-5.23.0.tar.gz",
"msg" => "Please don't use fossies.org in the url (using as a mirror is fine)",
"col" => 2,
}, {
"url" => "http://tools.ietf.org/tools/rfcmarkup/rfcmarkup-1.119.tgz",
"msg" => "Please use https:// for http://tools.ietf.org/tools/rfcmarkup/rfcmarkup-1.119.tgz",
"col" => 2,
}, {
"url" => "http://search.mcpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz",
"msg" => "http://search.mcpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz should be " \
"`https://cpan.metacpan.org/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz`",
"col" => 2,
}, {
"url" => "http://ftp.gnome.org/pub/GNOME/binaries/mac/banshee/banshee-2.macosx.intel.dmg",
"msg" => "http://ftp.gnome.org/pub/GNOME/binaries/mac/banshee/banshee-2.macosx.intel.dmg should be " \
"`https://download.gnome.org/binaries/mac/banshee/banshee-2.macosx.intel.dmg`",
"col" => 2,
}, {
"url" => "git://anonscm.debian.org/users/foo/foostrap.git",
"msg" => "git://anonscm.debian.org/users/foo/foostrap.git should be " \
"`https://anonscm.debian.org/git/users/foo/foostrap.git`",
"col" => 2,
}, {
"url" => "ftp://ftp.mirrorservice.org/foo-1.tar.gz",
"msg" => "Please use https:// for ftp://ftp.mirrorservice.org/foo-1.tar.gz",
"col" => 2,
}, {
"url" => "ftp://ftp.cpan.org/pub/CPAN/foo-1.tar.gz",
"msg" => "ftp://ftp.cpan.org/pub/CPAN/foo-1.tar.gz should be `http://search.cpan.org/CPAN/foo-1.tar.gz`",
"col" => 2,
}, {
"url" => "http://sourceforge.net/projects/something/files/Something-1.2.3.dmg",
"msg" => "Use https://downloads.sourceforge.net to get geolocation (url is " \
"http://sourceforge.net/projects/something/files/Something-1.2.3.dmg).",
"col" => 2,
}, {
"url" => "https://downloads.sourceforge.net/project/foo/download",
"msg" => "Don't use /download in SourceForge urls (url is " \
"https://downloads.sourceforge.net/project/foo/download).",
"col" => 2,
}, {
"url" => "https://sourceforge.net/project/foo",
"msg" => "Use https://downloads.sourceforge.net to get geolocation " \
"(url is https://sourceforge.net/project/foo).",
"col" => 2,
}, {
"url" => "http://prdownloads.sourceforge.net/foo/foo-1.tar.gz",
"msg" => <<~EOS.chomp,
Don't use prdownloads in SourceForge urls (url is http://prdownloads.sourceforge.net/foo/foo-1.tar.gz).
See: http://librelist.com/browser/homebrew/2011/1/12/prdownloads-is-bad/
EOS
"col" => 2,
}, {
"url" => "http://foo.dl.sourceforge.net/sourceforge/foozip/foozip_1.0.tar.bz2",
"msg" => "Don't use specific dl mirrors in SourceForge urls (url is " \
"http://foo.dl.sourceforge.net/sourceforge/foozip/foozip_1.0.tar.bz2).",
"col" => 2,
}, {
"url" => "http://downloads.sourceforge.net/project/foo/foo/2/foo-2.zip",
"msg" => "Please use https:// for http://downloads.sourceforge.net/project/foo/foo/2/foo-2.zip",
"col" => 2,
}, {
"url" => "http://http.debian.net/debian/dists/foo/",
"msg" => <<~EOS,
Please use a secure mirror for Debian URLs.
We recommend:
https://deb.debian.org/debian/dists/foo/
EOS
"col" => 2,
}, {
"url" => "https://mirrors.kernel.org/debian/pool/main/n/nc6/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://mirrors.kernel.org/debian/pool/main/n/nc6/foo.tar.gz",
"col" => 2,
}, {
"url" => "https://mirrors.ocf.berkeley.edu/debian/pool/main/m/mkcue/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://mirrors.ocf.berkeley.edu/debian/pool/main/m/mkcue/foo.tar.gz",
"col" => 2,
}, {
"url" => "https://mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"col" => 2,
}, {
"url" => "https://www.mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://www.mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"col" => 2,
}, {
"url" => "http://foo.googlecode.com/files/foo-1.0.zip",
"msg" => "Please use https:// for http://foo.googlecode.com/files/foo-1.0.zip",
"col" => 2,
}, {
"url" => "git://github.com/foo.git",
"msg" => "Please use https:// for git://github.com/foo.git",
"col" => 2,
}, {
"url" => "git://gitorious.org/foo/foo5",
"msg" => "Please use https:// for git://gitorious.org/foo/foo5",
"col" => 2,
}, {
"url" => "http://github.com/foo/foo5.git",
"msg" => "Please use https:// for http://github.com/foo/foo5.git",
"col" => 2,
}, {
"url" => "https://github.com/foo/foobar/archive/master.zip",
"msg" => "Use versioned rather than branch tarballs for stable checksums.",
"col" => 2,
}, {
"url" => "https://github.com/foo/bar/tarball/v1.2.3",
"msg" => "Use /archive/ URLs for GitHub tarballs (url is https://github.com/foo/bar/tarball/v1.2.3).",
"col" => 2,
}, {
"url" => "https://codeload.github.com/foo/bar/tar.gz/v0.1.1",
"msg" => <<~EOS,
Use GitHub archive URLs:
https://github.com/foo/bar/archive/v0.1.1.tar.gz
Rather than codeload:
https://codeload.github.com/foo/bar/tar.gz/v0.1.1
EOS
"col" => 2,
}, {
"url" => "https://central.maven.org/maven2/com/bar/foo/1.1/foo-1.1.jar",
"msg" => "https://central.maven.org/maven2/com/bar/foo/1.1/foo-1.1.jar should be " \
"`https://search.maven.org/remotecontent?filepath=com/bar/foo/1.1/foo-1.1.jar`",
"col" => 2,
}]
formulas.each do |formula|
formulae.each do |formula|
source = <<~RUBY
class Foo < Formula
desc "foo"

View File

@ -326,7 +326,7 @@ describe Tab do
expect(tab.source["path"]).to eq(alias_path.to_s)
end
it "creates a Tab for a given Formula" do
it "creates a Tab for a given Formula with existing Tab" do
f.prefix.mkpath
f_tab_path.write f_tab_content