From 7442de395e55f637b71db96c984a8b6b8e3c27ea Mon Sep 17 00:00:00 2001 From: Andrew Sullivan Cant Date: Mon, 6 Jan 2025 16:23:22 -0500 Subject: [PATCH] Change minimum required Ruby to v3.1.2 This is consider the correct minimum Ruby, because it is the Ruby version which is available in the current Debian release, Debian 12 (bookworm). * https://www.debian.org/releases/ * https://packages.debian.org/bookworm/ruby/ Drop support for Ruby 2.6, 2.7, and 3.0. * clean up Rubocop reports * remove the bundler dependency, becuase it is built in now * add required Rubygems MFA to the gemspec --- .github/workflows/ci.yml | 2 +- .rubocop.yml | 6 ++++++ .ruby-version | 2 +- CHANGELOG.md | 1 + lib/rspec/side_effects.rb | 6 +++--- rspec-side_effects.gemspec | 16 +++++++--------- spec/rspec/side_effects_spec.rb | 18 +++++++++--------- 7 files changed, 28 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac0655d..64b407c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - ruby: [2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, head, jruby, jruby-head] + ruby: [3.1, 3.2, 3.3, 3.4, head, jruby, jruby-head] continue-on-error: ${{ endsWith(matrix.ruby, 'head') || endsWith(matrix.ruby, 'jruby') }} runs-on: ${{ matrix.os }} steps: diff --git a/.rubocop.yml b/.rubocop.yml index 3c33d34..47ed75c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,11 @@ require: rubocop-rspec +AllCops: + NewCops: enable + +Gemspec/DevelopmentDependencies: + EnforcedStyle: gemspec + Metrics/MethodLength: Max: 20 diff --git a/.ruby-version b/.ruby-version index a04abec..ef538c2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.10 +3.1.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index b4a7b4a..c4eab26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - upgrade Rake to v12 to resolve [CVE-2020-8130](https://github.com/advisories/GHSA-jppv-gw3r-w3q8) +- minimum required Ruby version to 3.1.2, dropping support for 2.x and 3.0 ## 0.2.0 - 2018-07-12 ### Changed diff --git a/lib/rspec/side_effects.rb b/lib/rspec/side_effects.rb index 338c3d7..adaa3b0 100644 --- a/lib/rspec/side_effects.rb +++ b/lib/rspec/side_effects.rb @@ -9,7 +9,7 @@ module Rspec # @example module SideEffects def its_side_effects_are(*options, &block) - its_caller = caller.reject { |file_line| file_line =~ /its_side_effects/ } + its_caller = caller.grep_v(/its_side_effects/) if options.last.is_a?(Hash) options.last.merge(called: its_caller) else @@ -18,12 +18,12 @@ def its_side_effects_are(*options, &block) describe('side effects', *options) do if block - # rubocop:disable Lint/HandleExceptions, Lint/RescueException + # rubocop:disable Lint/RescueException, Lint/SuppressedException before do subject rescue Exception end - # rubocop:enable Lint/HandleExceptions, Lint/RescueException + # rubocop:enable Lint/RescueException, Lint/SuppressedException example(nil, :aggregate_failures, *options, &block) else example(nil, {}) { subject } diff --git a/rspec-side_effects.gemspec b/rspec-side_effects.gemspec index 277f37d..c7f89a1 100644 --- a/rspec-side_effects.gemspec +++ b/rspec-side_effects.gemspec @@ -18,26 +18,24 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0").reject do |f| f.match(%r{^(test|spec|features)/}) end - spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.bindir = 'exe' spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' + spec.required_ruby_version = '>= 3.1.2' - spec.add_runtime_dependency 'rspec-core', '>= 2.99.0' + spec.metadata['rubygems_mfa_required'] = 'true' - spec.add_development_dependency 'bundler', '~> 2.1' - spec.add_development_dependency 'rake', '~> 12.3' - spec.add_development_dependency 'rspec', '~> 3.0' + spec.add_dependency 'rspec-core', '>= 2.99.0' + + spec.add_development_dependency 'rake', '~> 12.3' + spec.add_development_dependency 'rspec', '~> 3.0' # Dependencies whose APIs we do not really depend upon, and can be upgraded # without limiting. spec.add_development_dependency 'bundler-audit' spec.add_development_dependency 'license_finder' - # HACK: Limit ourselves to Rubocop versions which still support Ruby2.2. This - # can be removed once we drop support for Ruby2.2. - spec.add_development_dependency 'rubocop', '~> 0.68.0' + spec.add_development_dependency 'rubocop' spec.add_development_dependency 'rubocop-rspec' spec.add_development_dependency 'simplecov' spec.add_development_dependency 'simplecov-lcov' diff --git a/spec/rspec/side_effects_spec.rb b/spec/rspec/side_effects_spec.rb index dee1b69..3a29d5e 100644 --- a/spec/rspec/side_effects_spec.rb +++ b/spec/rspec/side_effects_spec.rb @@ -34,7 +34,7 @@ def test_standard_error # @raise [Exception] def test_exception @exception = :exception - raise(Exception) + raise(Exception) # rubocop:disable Lint/RaiseException end end @@ -51,9 +51,9 @@ def expect_instance_variable(variable_name) subject { test_class.test1 } its_side_effects_are do - expect_instance_variable(:var1).to eq(:var1) - expect_instance_variable(:var2).to eq(nil) - expect_instance_variable(:var3).to eq(nil) + expect_instance_variable(:var1).to be(:var1) + expect_instance_variable(:var2).to be_nil + expect_instance_variable(:var3).to be_nil end end @@ -78,9 +78,9 @@ def expect_instance_variable(variable_name) subject { test_class.test2 } before do - # rubocop:disable RSpec/ExpectInHook, RSpec/MessageSpies + # rubocop:disable RSpec/ExpectInHook, RSpec/MessageSpies, RSpec/SubjectStub expect(test_class).to receive(:inner_test) - # rubocop:enable RSpec/ExpectInHook, RSpec/MessageSpies + # rubocop:enable RSpec/ExpectInHook, RSpec/MessageSpies, RSpec/SubjectStub end it_has_side_effects @@ -90,9 +90,9 @@ def expect_instance_variable(variable_name) subject { test_class.test1 } specify_side_effects do - expect_instance_variable(:var1).to eq(:var1) - expect_instance_variable(:var2).to eq(nil) - expect_instance_variable(:var3).to eq(nil) + expect_instance_variable(:var1).to be(:var1) + expect_instance_variable(:var2).to be_nil + expect_instance_variable(:var3).to be_nil end end end