diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39706c2..64b407c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,32 +8,25 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, macos-13] - ruby: [2.2, 2.3, 2.4, 2.5, 2.6, head, jruby, jruby-head] + os: [ubuntu-latest, macos-latest] + 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: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - # HACK: Continue to use bundler <2 because of Ruby v2.2 support. Once the - # lowest dependency is Ruby v2.3 we can consider upgrading to Bundler 2.x. - bundler: 1.14 bundler-cache: true - run: bundle exec rake spec coverage: needs: [ test ] name: coverage - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '2.2' - # HACK: Continue to use bundler <2 because of Ruby v2.2 support. Once the - # lowest dependency is Ruby v2.3 we can consider upgrading to Bundler 2.x. - bundler: 1.14 bundler-cache: true - run: bundle exec rake env: diff --git a/.rubocop.yml b/.rubocop.yml index 3c33d34..1f4c59e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,13 @@ -require: rubocop-rspec +require: + - rubocop-performance + - rubocop-rake + - rubocop-rspec + +AllCops: + NewCops: enable + +Gemspec/DevelopmentDependencies: + EnforcedStyle: gemspec Metrics/MethodLength: Max: 20 diff --git a/.ruby-version b/.ruby-version index 0d3ad67..ef538c2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.2.10 +3.1.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index b4a7b4a..e4eabdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Changed -- upgrade Rake to v12 to resolve [CVE-2020-8130](https://github.com/advisories/GHSA-jppv-gw3r-w3q8) +- upgrade Rake to v13 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/Gemfile b/Gemfile index 1064384..0075398 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' # Specify your gem's dependencies in rspec-side_effects.gemspec diff --git a/README.md b/README.md index bd734be..98036b7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ [![Test Coverage](https://codeclimate.com/github/sugarcrm/rspec-side_effects/badges/coverage.svg)](https://codeclimate.com/github/sugarcrm/rspec-side_effects/coverage) [![License](http://img.shields.io/badge/license-Apache2-green.svg?style=flat)](LICENSE) -[![Inline docs](http://inch-ci.org/github/sugarcrm/rspec-side_effects.svg)](http://inch-ci.org/github/sugarcrm/rspec-side_effects) [![RubyDoc](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://rubydoc.org/gems/rspec-side_effects) RSpec extension for checking the side effects of your specifications. @@ -99,14 +98,12 @@ To install this gem onto your local machine, run `bundle exec rake install`. To Links to other places on the web where this projects exists: * [Code Climate](https://codeclimate.com/github/sugarcrm/rspec-side_effects) -* [InchCI](http://inch-ci.org/github/sugarcrm/rspec-side_effects) * [Github](https://github.com/sugarcrm/rspec-side_effects) * [OpenHub](https://www.openhub.net/p/rspec-side_effects) -* [RubyDoc](http://rubydoc.org/gems/rspec-side_effects) +* [RubyDoc](https://rubydoc.info/gems/rspec-side_effects) * [RubyGems](https://rubygems.org/gems/rspec-side_effects) * [Ruby LibHunt](https://ruby.libhunt.com/rspec-side_effects-alternatives) * [Ruby Toolbox](https://www.ruby-toolbox.com/projects/rspec-side_effects) -* [TravisCI](https://travis-ci.org/sugarcrm/rspec-side_effects) ## Contributing @@ -114,4 +111,4 @@ See [CONTRIBUTING](CONTRIBUTING.md) for how you can contribute changes back into ## Acknowledgments -Copyright 2019 [SugarCRM Inc.](http://sugarcrm.com), released under the Apache2 License. +Copyright 2025 [SugarCRM Inc.](http://sugarcrm.com), released under the [Apache2 License](https://www.apache.org/licenses/LICENSE-2.0.html). diff --git a/Rakefile b/Rakefile index d1ef82f..e15e102 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'rubocop/rake_task' @@ -30,6 +32,16 @@ end Bundler::Audit::Task.new +desc 'Show which specified gems are outdated' +task 'bundle:outdated' do + bundle_outdated_report_pathname = + Pathname(Rake.application.original_dir).join('tmp', 'bundle_outdated.txt') + bundle_outdated_report_pathname.dirname.mkpath + + # TODO: Should consider re-writing this without using `tee`. + sh("bundle outdated --only-explicit | tee #{bundle_outdated_report_pathname}") +end + desc 'Check dependency licenses' task :license_finder do puts `license_finder --quiet --format text` diff --git a/bin/console b/bin/console index f5e863e..9d68398 100755 --- a/bin/console +++ b/bin/console @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require 'bundler/setup' require 'rspec/side_effects' diff --git a/doc/dependency_decisions.yml b/doc/dependency_decisions.yml index 53659bd..8d7b4fb 100644 --- a/doc/dependency_decisions.yml +++ b/doc/dependency_decisions.yml @@ -5,19 +5,19 @@ :why: :versions: [] :when: 2018-06-13 15:20:17.351348000 Z -- - :whitelist +- - :permit - Apache 2.0 - :who: Andrew Sullivan Cant :why: SugarCRM's primary approved open source license :versions: [] :when: 2018-06-18 19:28:33.314061000 Z -- - :whitelist +- - :permit - MIT - :who: Andrew Sullivan Cant :why: SugarCRM's secondary approved open source license :versions: [] :when: 2018-06-13 15:18:36.240771000 Z -- - :whitelist +- - :permit - BSD - :who: Andrew Sullivan Cant :why: SugarCRM's secondary approved open source license diff --git a/lib/rspec/side_effects.rb b/lib/rspec/side_effects.rb index f33e93c..adaa3b0 100644 --- a/lib/rspec/side_effects.rb +++ b/lib/rspec/side_effects.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rspec/side_effects/version' module Rspec @@ -7,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 @@ -16,11 +18,12 @@ def its_side_effects_are(*options, &block) describe('side effects', *options) do if block + # rubocop:disable Lint/RescueException, Lint/SuppressedException before do - # rubocop:disable Lint/HandleExceptions, Lint/RescueException - begin; subject; rescue Exception; end - # rubocop:enable Lint/HandleExceptions, Lint/RescueException + subject + rescue Exception end + # rubocop:enable Lint/RescueException, Lint/SuppressedException example(nil, :aggregate_failures, *options, &block) else example(nil, {}) { subject } diff --git a/lib/rspec/side_effects/version.rb b/lib/rspec/side_effects/version.rb index b399c5e..3fdfb81 100644 --- a/lib/rspec/side_effects/version.rb +++ b/lib/rspec/side_effects/version.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + module Rspec module SideEffects - VERSION = '0.2.0'.freeze + VERSION = '0.2.0' end end diff --git a/rspec-side_effects.gemspec b/rspec-side_effects.gemspec index fba6e1d..3e776e2 100644 --- a/rspec-side_effects.gemspec +++ b/rspec-side_effects.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rspec/side_effects/version' @@ -16,28 +18,29 @@ 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.2.0' + spec.required_ruby_version = '>= 3.1.2' + + spec.metadata['rubygems_mfa_required'] = 'true' - spec.add_runtime_dependency 'rspec-core', '>= 2.99.0' + spec.add_dependency 'rspec-core', '>= 2.99.0' - spec.add_development_dependency 'bundler', '~> 1.14' - spec.add_development_dependency 'rake', '~> 12.3' - spec.add_development_dependency 'rspec', '~> 3.0' + spec.add_development_dependency 'rake', '~> 13.2' + 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-performance' + spec.add_development_dependency 'rubocop-rake' spec.add_development_dependency 'rubocop-rspec' spec.add_development_dependency 'simplecov' + spec.add_development_dependency 'simplecov-lcov' spec.add_development_dependency 'yard' spec.add_development_dependency 'yardstick' end diff --git a/spec/rspec/side_effects_spec.rb b/spec/rspec/side_effects_spec.rb index 903250b..5d3cde5 100644 --- a/spec/rspec/side_effects_spec.rb +++ b/spec/rspec/side_effects_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' class TestClass @@ -32,7 +34,7 @@ def test_standard_error # @raise [Exception] def test_exception @exception = :exception - raise(Exception) + raise(Exception) # rubocop:disable Lint/RaiseException end end @@ -41,7 +43,7 @@ def test_exception # @param [#to_s] variable_name def expect_instance_variable(variable_name) - expect(test_class.instance_variable_get("@#{variable_name}")) + expect(test_class.instance_variable_get(:"@#{variable_name}")) end describe '#its_side_effects_are' do @@ -49,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 @@ -76,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 @@ -88,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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 31c88a8..538fb60 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,8 +1,24 @@ +# frozen_string_literal: true + require 'bundler/setup' # Setup code coverage require 'simplecov' -SimpleCov.start +require 'simplecov-lcov' +require 'simplecov_json_formatter' +SimpleCov.start do + # NOTE: Include the lcov formatter for CodeClimate reporting. + # Even though the simplecov JSON format will be output and used by default, + # the test reporter does not handle it reliable. + # Using the lcov formatter is more reliable. + SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new( + [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::JSONFormatter, + SimpleCov::Formatter::LcovFormatter + ] + ) +end require 'rspec/side_effects'