diff --git a/Library/Homebrew/test/cask/audit_spec.rb b/Library/Homebrew/test/cask/audit_spec.rb index 4819f81ade..9d332e8f3c 100644 --- a/Library/Homebrew/test/cask/audit_spec.rb +++ b/Library/Homebrew/test/cask/audit_spec.rb @@ -472,7 +472,6 @@ describe Cask::Audit, :cask do before do allow(audit).to receive_messages(download: download_double, signing?: true) - allow(audit).to receive(:check_https_availability) end context "when cask is not using a signed artifact" do @@ -1024,7 +1023,6 @@ describe Cask::Audit, :cask do before do allow(audit).to receive(:download).and_return(download_double) - allow(audit).to receive(:check_https_availability) allow(UnpackStrategy).to receive(:detect).and_return(nil) end diff --git a/Library/Homebrew/test/cask/upgrade_spec.rb b/Library/Homebrew/test/cask/upgrade_spec.rb index a4daa8a175..ad4d6f1644 100644 --- a/Library/Homebrew/test/cask/upgrade_spec.rb +++ b/Library/Homebrew/test/cask/upgrade_spec.rb @@ -25,8 +25,6 @@ describe Cask::Upgrade, :cask do installed.each do |cask| Cask::Installer.new(Cask::CaskLoader.load(cask_path(cask))).install end - - allow_any_instance_of(described_class).to receive(:verbose?).and_return(true) end context "when the upgrade is a dry run" do diff --git a/Library/Homebrew/test/cli/parser_spec.rb b/Library/Homebrew/test/cli/parser_spec.rb index 42fd1757ab..68ab766fcb 100644 --- a/Library/Homebrew/test/cli/parser_spec.rb +++ b/Library/Homebrew/test/cli/parser_spec.rb @@ -235,14 +235,18 @@ describe Homebrew::CLI::Parser do end it "prioritizes cli arguments over env vars when they conflict" do - allow(Homebrew::EnvConfig).to receive_messages(switch_a?: true, switch_b?: false) + without_partial_double_verification do + allow(Homebrew::EnvConfig).to receive_messages(switch_a?: true, switch_b?: false) + end args = parser.parse(["--switch-b"]) expect(args.switch_a?).to be false expect(args).to be_switch_b end it "raises an exception on constraint violation when both are env vars" do - allow(Homebrew::EnvConfig).to receive_messages(switch_a?: true, switch_b?: true) + without_partial_double_verification do + allow(Homebrew::EnvConfig).to receive_messages(switch_a?: true, switch_b?: true) + end expect { parser.parse([]) }.to raise_error(Homebrew::CLI::OptionConflictError) end end diff --git a/Library/Homebrew/test/formula_installer_spec.rb b/Library/Homebrew/test/formula_installer_spec.rb index b9c8ae33a1..5a3ebb72d3 100644 --- a/Library/Homebrew/test/formula_installer_spec.rb +++ b/Library/Homebrew/test/formula_installer_spec.rb @@ -282,7 +282,6 @@ describe FormulaInstaller do expect(formula).to receive(:plist).and_return(nil) expect(formula).to receive(:service?).exactly(3).and_return(nil) expect(formula).not_to receive(:launchd_service_path) - expect(formula).not_to receive(:to_systemd_unit) installer = described_class.new(formula) expect do diff --git a/Library/Homebrew/test/language/node_spec.rb b/Library/Homebrew/test/language/node_spec.rb index 0dddf376f8..f024e223e7 100644 --- a/Library/Homebrew/test/language/node_spec.rb +++ b/Library/Homebrew/test/language/node_spec.rb @@ -11,12 +11,16 @@ describe Language::Node do url "node-test-v1.0" end stub_formula_loader(node) - expect(ENV).to receive(:prepend_path) + without_partial_double_verification do + expect(ENV).to receive(:prepend_path) + end described_class.instance_variable_set(:@env_set, false) expect(described_class.setup_npm_environment).to be_nil expect(described_class.instance_variable_get(:@env_set)).to be(true) - expect(ENV).not_to receive(:prepend_path) + without_partial_double_verification do + expect(ENV).not_to receive(:prepend_path) + end expect(described_class.setup_npm_environment).to be_nil end diff --git a/Library/Homebrew/test/requirement_spec.rb b/Library/Homebrew/test/requirement_spec.rb index 193d895247..eb676810f2 100644 --- a/Library/Homebrew/test/requirement_spec.rb +++ b/Library/Homebrew/test/requirement_spec.rb @@ -139,7 +139,9 @@ describe Requirement do end it "infers path from #satisfy result" do - expect(ENV).to receive(:prepend_path).with("PATH", Pathname.new("/foo/bar")) + without_partial_double_verification do + expect(ENV).to receive(:prepend_path).with("PATH", Pathname.new("/foo/bar")) + end requirement.satisfied? requirement.modify_build_environment end diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 938ff52fde..d5e0f035ec 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -87,6 +87,24 @@ RSpec.configure do |config| # identify flaky tests. config.default_retry_count = 2 unless ENV["BUILDPULSE"] + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + config.shared_context_metadata_behavior = :apply_to_host_groups + # Increase timeouts for integration tests (as we expect them to take longer). config.around(:each, :integration_test) do |example| example.metadata[:timeout] ||= 120