Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rubies in CI and make the minimum Ruby version v3.1 #6

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 10 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.10
3.1.2
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in rspec-side_effects.gemspec
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -99,19 +98,17 @@ 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

See [CONTRIBUTING](CONTRIBUTING.md) for how you can contribute changes back into this project.

## 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).
12 changes: 12 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
Expand Down Expand Up @@ -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`
Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'rspec/side_effects'
Expand Down
6 changes: 3 additions & 3 deletions doc/dependency_decisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
:why:
:versions: []
:when: 2018-06-13 15:20:17.351348000 Z
- - :whitelist
- - :permit
- Apache 2.0
- :who: Andrew Sullivan Cant <[email protected]>
: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 <[email protected]>
: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 <[email protected]>
:why: SugarCRM's secondary approved open source license
Expand Down
11 changes: 7 additions & 4 deletions lib/rspec/side_effects.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rspec/side_effects/version'

module Rspec
Expand All @@ -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
Expand All @@ -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 }
Expand Down
4 changes: 3 additions & 1 deletion lib/rspec/side_effects/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

module Rspec
module SideEffects
VERSION = '0.2.0'.freeze
VERSION = '0.2.0'
end
end
21 changes: 12 additions & 9 deletions rspec-side_effects.gemspec
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
22 changes: 12 additions & 10 deletions spec/rspec/side_effects_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

class TestClass
Expand Down Expand Up @@ -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

Expand All @@ -41,17 +43,17 @@ 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
context 'when no exception' do
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

Expand All @@ -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
Expand All @@ -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
18 changes: 17 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
Loading