Skip to content

Commit

Permalink
Upgrade all the things, 2023 edition
Browse files Browse the repository at this point in the history
This gem is severely out of date. Not only is the version of
`shoulda-matchers` very old, but I can't even get this project up and
running on my computer anymore because it relies on an old version of
Ruby.

So, the primary motivation behind this commit is to bump the dependency
on `shoulda-matchers` to 5.x.

Besides this, in `shoulda-matchers` there are changes that either have
been merged or are in flight which aim to upgrade dependencies, drop
support for old Rubies and Rails, etc., and I've integrated them into
this commit as well. These include:

* Update development Ruby to 3.2.1
* Replace Travis config with GitHub Actions workflows
* Upgrade Rubocop configuration, and correct lint violations
* Add support for Ruby 3.0, 3.1, and 3.2 as well as Rails 6.1 and 7.0
* Drop support for Ruby < 3 and Rails < 6.1

In addition, I've had to update some of the tests which failed after
performing these upgrades:

* Patch Snowglobe (which is used in tests to generate a Rails
  application) due to some incompatibilities with recent Rails versions
  and bugs
* Make sure to install `rails-controller-testing` and `bcrypt` in
  generated Rails application
* Update tests involving `filter_param` as Rails changed which
  parameters are filtered in recent versions
  • Loading branch information
mcmire committed Mar 24, 2023
1 parent af4d0e1 commit 5fa5f1b
Show file tree
Hide file tree
Showing 33 changed files with 1,059 additions and 1,660 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
types:
- opened
- synchronize
paths-ignore:
- '**.md'

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby:
- 3.2.1
- 3.1.3
- 3.0.5
appraisal:
- rails_7_0
- rails_6_1
adapter:
- sqlite3
- postgresql
exclude:
- { ruby: 3.2.1, appraisal: rails_6_1 }
- { ruby: 3.0.5, appraisal: rails_7_0 }
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.appraisal }}.gemfile
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
id: set-up-ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- uses: actions/cache@v3
with:
path: vendor/bundle
key: v1-rubygems-local-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles(format('gemfiles/{0}.gemfile.lock', matrix.appraisal)) }}
- name: Install dependencies
run: bundle install --jobs=3 --retry=3
- name: Run Tests
run: bundle exec rake
30 changes: 30 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: RuboCop

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Ruby
uses: ruby/setup-ruby@v1

- name: Cache gems
uses: actions/cache@v3
with:
path: ../vendor/bundle
key: ${{ runner.os }}-rubocop-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-rubocop-
- name: Install gems
run: |
bundle config path ../vendor/bundle
bundle install --jobs 4 --retry 3
- name: Run RuboCop
run: bundle exec rubocop --parallel
110 changes: 82 additions & 28 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
require:
- rubocop-packaging
AllCops:
TargetRubyVersion: 2.4
Layout/ParameterAlignment:
NewCops: disable
TargetRubyVersion: 3.0
Exclude:
- 'gemfiles/*'
- 'tmp/**/*'
SuggestExtensions: false
Bundler/OrderedGems:
Include:
- '**/Gemfile'
Layout/ArgumentAlignment:
EnforcedStyle: with_fixed_indentation
Layout/CommentIndentation:
Enabled: false
Layout/ConditionPosition:
Enabled: false
Layout/DotPosition:
EnforcedStyle: trailing
Layout/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true
Layout/HeredocIndentation:
Enabled: false
Layout/LineLength:
Exclude:
- spec/**/*
AllowedPatterns:
- !ruby/regexp /\A +(it|describe|context|shared_examples|include_examples|it_behaves_like) ["']/
- !ruby/regexp /\A(require|require_relative) ["']/
- '^[ ]*#.+$'
- '^[ ]*''.+?'' => ''.+?'',?$'
- '^[ ]*".+?" => ".+?",?$'
Max: 100
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
Layout/ParameterAlignment:
EnforcedStyle: with_fixed_indentation
Layout/SpaceInLambdaLiteral:
EnforcedStyle: require_space
Layout/SpaceInsideBlockBraces:
Enabled: false
Lint/AmbiguousBlockAssociation:
Exclude:
- spec/**/*
Lint/AmbiguousOperator:
Enabled: false
Lint/AmbiguousRegexpLiteral:
Expand All @@ -20,53 +53,61 @@ Lint/DeprecatedClassMethods:
Enabled: false
Lint/ElseLayout:
Enabled: false
Lint/SuppressedException:
Lint/FlipFlop:
Enabled: false
Lint/LiteralInInterpolation:
Enabled: false
Lint/Loop:
Enabled: false
Lint/MissingSuper:
Enabled: false
Lint/ParenthesesAsGroupedExpression:
Enabled: false
Lint/RequireParentheses:
Enabled: false
Lint/SafeNavigationChain:
Enabled: false
Lint/SuppressedException:
Enabled: false
Lint/UnderscorePrefixedVariableName:
Enabled: false
Lint/Void:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/LineLength:
IgnoredPatterns:
- "^[ ]*describe.+$"
- "^[ ]*context.+$"
- "^[ ]*shared_context.+$"
- "^[ ]*shared_examples_for.+$"
- "^[ ]*it.+$"
- "^[ ]*'.+?' => '.+?',?$"
- "^[ ]*\".+?\" => \".+?\",?$"
- "^[ ]*.+?: .+?$"
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/MethodLength:
Max: 30
Metrics/ModuleLength:
Enabled: true
Exclude:
- spec/**/*
Metrics/ParameterLists:
CountKeywordArgs: false
Metrics/PerceivedComplexity:
Enabled: false
Naming/AccessorMethodName:
Enabled: false
Naming/AsciiIdentifiers:
Enabled: false
Naming/BinaryOperatorParameterName:
Enabled: false
Style/ClassVars:
Naming/FileName:
Enabled: false
Style/ColonMethodCall:
Naming/HeredocDelimiterNaming:
Enabled: false
Naming/FileName:
Naming/MemoizedInstanceVariableName:
EnforcedStyleForLeadingUnderscores: required
Naming/PredicateName:
Enabled: false
Rails:
Enabled: true
Rails/Delegate:
Naming/VariableNumber:
Enabled: false
Rails/HttpPositionalArguments:
Naming/RescuedExceptionsVariableName:
Enabled: false
Style/Alias:
Enabled: false
Expand All @@ -76,18 +117,25 @@ Style/AsciiComments:
Enabled: false
Style/Attr:
Enabled: false
Style/BlockDelimiters:
Enabled: false
Style/CaseEquality:
Enabled: false
Style/CharacterLiteral:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Style/ClassVars:
Enabled: false
Style/CollectionMethods:
Enabled: true
PreferredMethods:
find: detect
reduce: inject
collect: map
find: detect
find_all: select
reduce: inject
Style/ColonMethodCall:
Enabled: false
Style/CommentAnnotation:
Enabled: false
Style/Documentation:
Expand All @@ -96,16 +144,20 @@ Style/DoubleNegation:
Enabled: false
Style/EachWithObject:
Enabled: false
Style/EmptyElse:
Enabled: false
Style/EmptyLiteral:
Enabled: false
Style/EmptyMethod:
EnforcedStyle: expanded
Style/Encoding:
Enabled: false
Style/EvenOdd:
Enabled: false
Lint/FlipFlop:
Enabled: false
Style/FormatString:
Enabled: false
Style/FormatStringToken:
EnforcedStyle: template
Style/FrozenStringLiteralComment:
Enabled: false
Style/GlobalVars:
Expand All @@ -118,6 +170,8 @@ Style/IfWithSemicolon:
Enabled: false
Style/InlineComment:
Enabled: false
Style/InverseMethods:
Enabled: false
Style/Lambda:
Enabled: false
Style/LambdaCall:
Expand All @@ -144,6 +198,8 @@ Style/NumericPredicate:
Enabled: false
Style/OneLineConditional:
Enabled: false
Style/OptionalBooleanParameter:
Enabled: false
Style/ParenthesesAroundCondition:
Enabled: false
Style/PercentLiteralDelimiters:
Expand All @@ -156,8 +212,6 @@ Style/Proc:
Enabled: false
Style/RaiseArgs:
Enabled: false
Style/RedundantParentheses:
Enabled: false
Style/RegexpLiteral:
Enabled: false
Style/SelfAssignment:
Expand All @@ -182,11 +236,11 @@ Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma
Style/TrivialAccessors:
Enabled: false
Style/VariableInterpolation:
Enabled: false
Style/WhenThen:
Enabled: false
Style/WhileUntilModifier:
Enabled: false
Style/WordArray:
Enabled: false
Style/VariableInterpolation:
Enabled: false
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.1
3.2.1
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.2.1
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

Loading

0 comments on commit 5fa5f1b

Please sign in to comment.