Merge pull request #5944 from MikeMcQuaid/rubocop-specs-cleanup
Cleanup some RSpec tests
This commit is contained in:
commit
f1f792e101
@ -1,21 +1,29 @@
|
|||||||
inherit_from: ./.rubocop.yml
|
inherit_from: ./.rubocop.yml
|
||||||
|
|
||||||
|
AllCops:
|
||||||
|
Include:
|
||||||
|
- '**/*_spec.rb'
|
||||||
|
Exclude:
|
||||||
|
- '**/vendor/**/*'
|
||||||
|
|
||||||
NewFormulaAudit:
|
NewFormulaAudit:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
# TODO: try to enable these
|
# Intentionally disabled as it doesn't fit with our code style.
|
||||||
RSpec/AnyInstance:
|
RSpec/AnyInstance:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# TODO: try to enable these (also requires fixing Homebrew/bundle)
|
||||||
RSpec/ContextWording:
|
RSpec/ContextWording:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
RSpec/DescribeClass:
|
RSpec/DescribeClass:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
RSpec/ExampleLength:
|
|
||||||
Enabled: false
|
|
||||||
RSpec/MessageSpies:
|
RSpec/MessageSpies:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# TODO: try to reduce these
|
# TODO: try to reduce these (also requires fixing Homebrew/bundle)
|
||||||
|
RSpec/ExampleLength:
|
||||||
|
Max: 75
|
||||||
RSpec/MultipleExpectations:
|
RSpec/MultipleExpectations:
|
||||||
Max: 26
|
Max: 26
|
||||||
RSpec/NestedGroups:
|
RSpec/NestedGroups:
|
||||||
|
|||||||
@ -1,37 +1,58 @@
|
|||||||
# This configuration was generated by
|
# This configuration was generated by
|
||||||
# `rubocop --auto-gen-config`
|
# `rubocop --auto-gen-config --exclude-limit 100`
|
||||||
# on 2019-01-21 13:27:20 +0000 using RuboCop version 0.63.0.
|
# 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
|
# The point is for the user to remove these configuration records
|
||||||
# one by one as the offenses are removed from the code base.
|
# one by one as the offenses are removed from the code base.
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
# versions of RuboCop, may require this file to be generated again.
|
# versions of RuboCop, may require this file to be generated again.
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
# Cop supports --auto-correct.
|
# Configuration parameters: Max.
|
||||||
Lint/UnneededCopEnableDirective:
|
RSpec/ExampleLength:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'cask/artifact/shared_examples/uninstall_zap.rb'
|
- 'rubocops/patches_spec.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'
|
|
||||||
|
|
||||||
# Offense count: 37
|
# Offense count: 37
|
||||||
# Configuration parameters: CustomTransform, IgnoreMethods.
|
# Configuration parameters: CustomTransform, IgnoreMethods.
|
||||||
RSpec/FilePath:
|
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
|
# Offense count: 6
|
||||||
# Configuration parameters: AssignmentOnly.
|
# Configuration parameters: AssignmentOnly.
|
||||||
@ -42,39 +63,185 @@ RSpec/InstanceVariable:
|
|||||||
- 'utils/git_spec.rb'
|
- 'utils/git_spec.rb'
|
||||||
- 'version_spec.rb'
|
- 'version_spec.rb'
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 74
|
||||||
RSpec/MissingExampleGroupArgument:
|
|
||||||
Exclude:
|
|
||||||
- 'cask/depends_on_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 24
|
|
||||||
RSpec/MultipleDescribes:
|
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.
|
# Configuration parameters: IgnoreSharedExamples.
|
||||||
RSpec/NamedSubject:
|
RSpec/NamedSubject:
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 7
|
|
||||||
RSpec/RepeatedDescription:
|
|
||||||
Exclude:
|
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'
|
- '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'
|
- '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'
|
- '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:
|
RSpec/SubjectStub:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'cache_store_spec.rb'
|
- 'cache_store_spec.rb'
|
||||||
- 'cmd/update-report/reporter_spec.rb'
|
|
||||||
- 'download_strategies_spec.rb'
|
- 'download_strategies_spec.rb'
|
||||||
- 'formula_installer_spec.rb'
|
- 'formula_installer_spec.rb'
|
||||||
- 'java_requirement_spec.rb'
|
- 'java_requirement_spec.rb'
|
||||||
- 'language/python_spec.rb'
|
- 'language/python_spec.rb'
|
||||||
- 'os/mac/java_requirement_spec.rb'
|
- 'os/mac/java_requirement_spec.rb'
|
||||||
|
|
||||||
# Offense count: 67
|
# Offense count: 66
|
||||||
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
||||||
RSpec/VerifiedDoubles:
|
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'
|
||||||
|
|||||||
@ -17,14 +17,12 @@ describe CacheStoreDatabase do
|
|||||||
describe "#set" do
|
describe "#set" do
|
||||||
let(:db) { double("db", :[]= => nil) }
|
let(:db) { double("db", :[]= => nil) }
|
||||||
|
|
||||||
before do
|
it "sets the value in the `CacheStoreDatabase`" do
|
||||||
allow(File).to receive(:write)
|
allow(File).to receive(:write)
|
||||||
allow(subject).to receive(:created?).and_return(true)
|
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)
|
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)
|
expect(db).not_to have_key(:foo)
|
||||||
subject.set(:foo, "bar")
|
subject.set(:foo, "bar")
|
||||||
end
|
end
|
||||||
@ -34,13 +32,10 @@ describe CacheStoreDatabase do
|
|||||||
context "database created" do
|
context "database created" do
|
||||||
let(:db) { double("db", :[] => "bar") }
|
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)
|
allow(subject).to receive(:created?).and_return(true)
|
||||||
expect(db).to receive(:has_key?).with(:foo).and_return(true)
|
expect(db).to receive(:has_key?).with(:foo).and_return(true)
|
||||||
allow(subject).to receive(:db).and_return(db)
|
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(db).to have_key(:foo)
|
||||||
expect(subject.get(:foo)).to eq("bar")
|
expect(subject.get(:foo)).to eq("bar")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -203,7 +203,6 @@ shared_examples "#uninstall_phase or #zap_phase" do
|
|||||||
FileUtils.rm_rf result.stdout.split("\0")
|
FileUtils.rm_rf result.stdout.split("\0")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop:enable RSpec/AnyInstance
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is supported" do
|
it "is supported" do
|
||||||
|
|||||||
@ -495,14 +495,13 @@ describe Cask::Audit, :cask do
|
|||||||
let(:cask_token) { "with-binary" }
|
let(:cask_token) { "with-binary" }
|
||||||
let(:check_token_conflicts) { true }
|
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
|
context "when cask token conflicts with a core formula" do
|
||||||
let(:formula_names) { %w[with-binary other-formula] }
|
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
|
end
|
||||||
|
|
||||||
context "when cask token does not conflict with a core formula" do
|
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(:verify) { class_double(Cask::Verify).as_stubbed_const }
|
||||||
let(:error_msg) { "Download Failed" }
|
let(:error_msg) { "Download Failed" }
|
||||||
|
|
||||||
context "when download and verification succeed" do
|
it "when download and verification succeed it does not fail" do
|
||||||
before do
|
|
||||||
expect(download).to receive(:perform)
|
expect(download).to receive(:perform)
|
||||||
expect(verify).to receive(:all)
|
expect(verify).to receive(:all)
|
||||||
|
expect(subject).not_to fail_with(/#{error_msg}/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.not_to fail_with(/#{error_msg}/) }
|
it "when download fails it does not fail" do
|
||||||
end
|
|
||||||
|
|
||||||
context "when download fails" do
|
|
||||||
before do
|
|
||||||
expect(download).to receive(:perform).and_raise(StandardError.new(error_msg))
|
expect(download).to receive(:perform).and_raise(StandardError.new(error_msg))
|
||||||
|
expect(subject).to fail_with(/#{error_msg}/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to fail_with(/#{error_msg}/) }
|
it "when verification fails it does not fail" do
|
||||||
end
|
|
||||||
|
|
||||||
context "when verification fails" do
|
|
||||||
before do
|
|
||||||
expect(download).to receive(:perform)
|
expect(download).to receive(:perform)
|
||||||
expect(verify).to receive(:all).and_raise(StandardError.new(error_msg))
|
expect(verify).to receive(:all).and_raise(StandardError.new(error_msg))
|
||||||
end
|
expect(subject).to fail_with(/#{error_msg}/)
|
||||||
|
|
||||||
it { is_expected.to fail_with(/#{error_msg}/) }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when an exception is raised" do
|
context "when an exception is raised" do
|
||||||
let(:cask) { instance_double(Cask::Cask) }
|
let(:cask) { instance_double(Cask::Cask) }
|
||||||
|
|
||||||
before do
|
it "does not fail" do
|
||||||
expect(cask).to receive(:version).and_raise(StandardError.new)
|
expect(cask).to receive(:version).and_raise(StandardError.new)
|
||||||
|
expect(subject).to fail_with(/exception while auditing/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to fail_with(/exception while auditing/) }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -8,6 +8,15 @@ describe "Satisfy Dependencies and Requirements", :cask do
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe "depends_on 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
|
context "when depends_on cask is cyclic" do
|
||||||
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-cask-cyclic")) }
|
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-cask-cyclic")) }
|
||||||
|
|
||||||
@ -19,17 +28,6 @@ describe "Satisfy Dependencies and Requirements", :cask do
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "depends_on macos" do
|
describe "depends_on macos" do
|
||||||
|
|||||||
@ -232,7 +232,7 @@ describe Utils::Inreplace do
|
|||||||
}.to raise_error(Utils::InreplaceError)
|
}.to raise_error(Utils::InreplaceError)
|
||||||
end
|
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 {
|
expect {
|
||||||
described_class.inreplace(file.path) do |s|
|
described_class.inreplace(file.path) do |s|
|
||||||
s.gsub!("d", "f") # rubocop:disable Performance/StringReplacement
|
s.gsub!("d", "f") # rubocop:disable Performance/StringReplacement
|
||||||
@ -240,7 +240,7 @@ describe Utils::Inreplace do
|
|||||||
}.to raise_error(Utils::InreplaceError)
|
}.to raise_error(Utils::InreplaceError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises error if there is nothing to replace" do
|
it "raises error if there is no make variables to replace" do
|
||||||
expect {
|
expect {
|
||||||
described_class.inreplace(file.path) do |s|
|
described_class.inreplace(file.path) do |s|
|
||||||
s.change_make_var! "VAR", "value"
|
s.change_make_var! "VAR", "value"
|
||||||
|
|||||||
@ -8,21 +8,15 @@ describe LinkageCacheStore do
|
|||||||
|
|
||||||
describe "#keg_exists?" do
|
describe "#keg_exists?" do
|
||||||
context "`keg_name` exists in cache" 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
|
it "returns `true`" do
|
||||||
|
expect(database).to receive(:get).with(keg_name).and_return("")
|
||||||
expect(subject.keg_exists?).to be(true)
|
expect(subject.keg_exists?).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "`keg_name` does not exist in cache" do
|
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
|
it "returns `false`" do
|
||||||
|
expect(database).to receive(:get).with(keg_name).and_return(nil)
|
||||||
expect(subject.keg_exists?).to be(false)
|
expect(subject.keg_exists?).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -52,11 +46,8 @@ describe LinkageCacheStore do
|
|||||||
|
|
||||||
describe "#fetch" do
|
describe "#fetch" do
|
||||||
context "`HASH_LINKAGE_TYPES.include?(type)`" 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
|
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)
|
expect(subject.fetch(:keg_files_dylibs)).to be_an_instance_of(Hash)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -197,7 +197,7 @@ describe Migrator do
|
|||||||
expect(old_keg_record.parent).not_to be_a_symlink
|
expect(old_keg_record.parent).not_to be_a_symlink
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#backup_oldname_cellar" do
|
specify "#backup_oldname_cellar after uninstall" do
|
||||||
(new_keg_record/"bin").mkpath
|
(new_keg_record/"bin").mkpath
|
||||||
keg.unlink
|
keg.unlink
|
||||||
keg.uninstall
|
keg.uninstall
|
||||||
@ -217,7 +217,9 @@ describe Migrator do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#backup_oldname" do
|
describe "#backup_oldname" do
|
||||||
after do
|
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).to be_a_directory
|
||||||
expect(old_keg_record.parent.subdirs).not_to be_empty
|
expect(old_keg_record.parent.subdirs).not_to be_empty
|
||||||
expect(HOMEBREW_LINKED_KEGS/"oldname").to exist
|
expect(HOMEBREW_LINKED_KEGS/"oldname").to exist
|
||||||
@ -225,11 +227,6 @@ describe Migrator do
|
|||||||
expect(HOMEBREW_PINNED_KEGS/"oldname").to be_a_symlink
|
expect(HOMEBREW_PINNED_KEGS/"oldname").to be_a_symlink
|
||||||
expect(keg).to be_linked
|
expect(keg).to be_linked
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when cellar exists" do
|
|
||||||
it "backs up the old name" do
|
|
||||||
subject.backup_oldname
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when cellar is removed" do
|
context "when cellar is removed" do
|
||||||
@ -238,6 +235,12 @@ describe Migrator do
|
|||||||
keg.unlink
|
keg.unlink
|
||||||
keg.uninstall
|
keg.uninstall
|
||||||
subject.backup_oldname
|
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
|
end
|
||||||
|
|
||||||
@ -248,6 +251,12 @@ describe Migrator do
|
|||||||
keg.uninstall
|
keg.uninstall
|
||||||
old_keg_record.parent.make_relative_symlink(new_keg_record.parent)
|
old_keg_record.parent.make_relative_symlink(new_keg_record.parent)
|
||||||
subject.backup_oldname
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -8,75 +8,28 @@ describe Homebrew::MissingFormula do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "::blacklisted_reason" do
|
describe "::blacklisted_reason" do
|
||||||
matcher :be_blacklisted do
|
matcher :blacklist do |name|
|
||||||
match do |expected|
|
match do |expected|
|
||||||
described_class.blacklisted_reason(expected)
|
expected.blacklisted_reason(name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "RubyGems is blacklisted" do
|
it { is_expected.to blacklist("gem") }
|
||||||
expect(%w[gem rubygem rubygems]).to all be_blacklisted
|
it { is_expected.to blacklist("latex") }
|
||||||
end
|
it { is_expected.to blacklist("pip") }
|
||||||
|
it { is_expected.to blacklist("pil") }
|
||||||
specify "LaTeX is blacklisted" do
|
it { is_expected.to blacklist("macruby") }
|
||||||
expect(%w[latex tex tex-live texlive TexLive]).to all be_blacklisted
|
it { is_expected.to blacklist("lzma") }
|
||||||
end
|
it { is_expected.to blacklist("gtest") }
|
||||||
|
it { is_expected.to blacklist("gmock") }
|
||||||
specify "pip is blacklisted" do
|
it { is_expected.to blacklist("sshpass") }
|
||||||
expect("pip").to be_blacklisted
|
it { is_expected.to blacklist("gsutil") }
|
||||||
end
|
it { is_expected.to blacklist("gfortran") }
|
||||||
|
it { is_expected.to blacklist("play") }
|
||||||
specify "PIL is blacklisted" do
|
it { is_expected.to blacklist("haskell-platform") }
|
||||||
expect("pil").to be_blacklisted
|
it { is_expected.to blacklist("mysqldump-secure") }
|
||||||
end
|
it { is_expected.to blacklist("ngrok") }
|
||||||
|
it("blacklists Xcode", :needs_macos) { is_expected.to blacklist("xcode") }
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "::tap_migration_reason" do
|
describe "::tap_migration_reason" do
|
||||||
|
|||||||
@ -10,10 +10,11 @@ describe JavaRequirement do
|
|||||||
FileUtils.mkdir java_home/"bin"
|
FileUtils.mkdir java_home/"bin"
|
||||||
FileUtils.touch java_home/"bin/java"
|
FileUtils.touch java_home/"bin/java"
|
||||||
allow(subject).to receive(:preferred_java).and_return(java_home/"bin/java")
|
allow(subject).to receive(:preferred_java).and_return(java_home/"bin/java")
|
||||||
expect(subject).to be_satisfied
|
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "Apple Java environment" do
|
specify "Apple Java environment" do
|
||||||
|
expect(subject).to be_satisfied
|
||||||
|
|
||||||
expect(ENV).to receive(:prepend_path)
|
expect(ENV).to receive(:prepend_path)
|
||||||
expect(ENV).to receive(:append_to_cflags)
|
expect(ENV).to receive(:append_to_cflags)
|
||||||
|
|
||||||
@ -22,6 +23,8 @@ describe JavaRequirement do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "Oracle Java environment" do
|
specify "Oracle Java environment" do
|
||||||
|
expect(subject).to be_satisfied
|
||||||
|
|
||||||
FileUtils.mkdir java_home/"include"
|
FileUtils.mkdir java_home/"include"
|
||||||
expect(ENV).to receive(:prepend_path)
|
expect(ENV).to receive(:prepend_path)
|
||||||
expect(ENV).to receive(:append_to_cflags).twice
|
expect(ENV).to receive(:append_to_cflags).twice
|
||||||
|
|||||||
@ -3,9 +3,8 @@ require "rubocops/urls"
|
|||||||
describe RuboCop::Cop::FormulaAudit::Urls do
|
describe RuboCop::Cop::FormulaAudit::Urls do
|
||||||
subject(:cop) { described_class.new }
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
context "When auditing urls" do
|
let(:formulae) {
|
||||||
it "with offenses" do
|
[{
|
||||||
formulas = [{
|
|
||||||
"url" => "https://ftpmirror.gnu.org/lightning/lightning-2.1.0.tar.gz",
|
"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.',
|
"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,
|
"col" => 2,
|
||||||
@ -142,7 +141,11 @@ describe RuboCop::Cop::FormulaAudit::Urls do
|
|||||||
"`https://search.maven.org/remotecontent?filepath=com/bar/foo/1.1/foo-1.1.jar`",
|
"`https://search.maven.org/remotecontent?filepath=com/bar/foo/1.1/foo-1.1.jar`",
|
||||||
"col" => 2,
|
"col" => 2,
|
||||||
}]
|
}]
|
||||||
formulas.each do |formula|
|
}
|
||||||
|
|
||||||
|
context "When auditing urls" do
|
||||||
|
it "with offenses" do
|
||||||
|
formulae.each do |formula|
|
||||||
source = <<~RUBY
|
source = <<~RUBY
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
desc "foo"
|
desc "foo"
|
||||||
|
|||||||
@ -326,7 +326,7 @@ describe Tab do
|
|||||||
expect(tab.source["path"]).to eq(alias_path.to_s)
|
expect(tab.source["path"]).to eq(alias_path.to_s)
|
||||||
end
|
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.prefix.mkpath
|
||||||
f_tab_path.write f_tab_content
|
f_tab_path.write f_tab_content
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user