From a7503ec713ec24258870ffddf79568ccc118ebc4 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 26 Jan 2023 09:47:20 +0000 Subject: [PATCH] Revert "Enable RSpec/LeakyConstantDeclaration" --- Library/.rubocop_rspec.yml | 2 ++ Library/Homebrew/test/exceptions_spec.rb | 3 --- .../Homebrew/test/formula_free_port_spec.rb | 13 ++++++------ Library/Homebrew/test/patching_spec.rb | 20 +++++++++---------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Library/.rubocop_rspec.yml b/Library/.rubocop_rspec.yml index 34fb6943b97db..6b27ca21a24c8 100644 --- a/Library/.rubocop_rspec.yml +++ b/Library/.rubocop_rspec.yml @@ -11,6 +11,8 @@ RSpec/SubjectStub: # TODO: try to enable these RSpec/DescribeClass: Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false RSpec/MessageSpies: Enabled: false RSpec/StubbedMock: diff --git a/Library/Homebrew/test/exceptions_spec.rb b/Library/Homebrew/test/exceptions_spec.rb index 6c6a39ddc37f8..ad95309fcd1f1 100644 --- a/Library/Homebrew/test/exceptions_spec.rb +++ b/Library/Homebrew/test/exceptions_spec.rb @@ -89,12 +89,9 @@ let(:mod) do Module.new do - # These are defined within an anonymous module to avoid polluting the global namespace. - # rubocop:disable RSpec/LeakyConstantDeclaration class Bar < Requirement; end class Baz < Formula; end - # rubocop:enable RSpec/LeakyConstantDeclaration end end diff --git a/Library/Homebrew/test/formula_free_port_spec.rb b/Library/Homebrew/test/formula_free_port_spec.rb index 8aecab4f8dd6d..84412d61d51cf 100644 --- a/Library/Homebrew/test/formula_free_port_spec.rb +++ b/Library/Homebrew/test/formula_free_port_spec.rb @@ -9,15 +9,16 @@ module Homebrew include described_class describe "#free_port" do + # IANA suggests user port from 1024 to 49151 + # and dynamic port for 49152 to 65535 + # http://www.iana.org/assignments/port-numbers + MIN_PORT = 1024 + MAX_PORT = 65535 + it "returns a free TCP/IP port" do - # IANA suggests user port from 1024 to 49151 - # and dynamic port for 49152 to 65535 - # http://www.iana.org/assignments/port-numbers - min_port = 1024 - max_port = 65535 port = free_port - expect(port).to be_between(min_port, max_port) + expect(port).to be_between(MIN_PORT, MAX_PORT) expect { TCPServer.new(port).close }.not_to raise_error end end diff --git a/Library/Homebrew/test/patching_spec.rb b/Library/Homebrew/test/patching_spec.rb index ed5c4a41306e1..1259ac7c4a2b3 100644 --- a/Library/Homebrew/test/patching_spec.rb +++ b/Library/Homebrew/test/patching_spec.rb @@ -4,17 +4,15 @@ require "formula" describe "patching" do - before do - stub_const("TESTBALL_URL", "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz") - stub_const("TESTBALL_PATCHES_URL", "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1-patches.tgz") - stub_const("PATCH_URL_A", "file://#{TEST_FIXTURE_DIR}/patches/noop-a.diff") - stub_const("PATCH_URL_B", "file://#{TEST_FIXTURE_DIR}/patches/noop-b.diff") - stub_const("PATCH_A_CONTENTS", File.read("#{TEST_FIXTURE_DIR}/patches/noop-a.diff").freeze) - stub_const("PATCH_B_CONTENTS", File.read("#{TEST_FIXTURE_DIR}/patches/noop-b.diff").freeze) - stub_const("APPLY_A", "noop-a.diff") - stub_const("APPLY_B", "noop-b.diff") - stub_const("APPLY_C", "noop-c.diff") - end + TESTBALL_URL = "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" + TESTBALL_PATCHES_URL = "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1-patches.tgz" + PATCH_URL_A = "file://#{TEST_FIXTURE_DIR}/patches/noop-a.diff" + PATCH_URL_B = "file://#{TEST_FIXTURE_DIR}/patches/noop-b.diff" + PATCH_A_CONTENTS = File.read("#{TEST_FIXTURE_DIR}/patches/noop-a.diff").freeze + PATCH_B_CONTENTS = File.read("#{TEST_FIXTURE_DIR}/patches/noop-b.diff").freeze + APPLY_A = "noop-a.diff" + APPLY_B = "noop-b.diff" + APPLY_C = "noop-c.diff" def formula(name = "formula_name", path: Formulary.core_path(name), spec: :stable, alias_path: nil, &block) Class.new(Formula) {