@StatelessCode
  @StatelessCode
Stateless Code | Create a RubyGem 89: Add Ruby 3.2 to GitHub Actions and Update RSpec to a compatible version @StatelessCode | Uploaded February 2023 | Updated October 2024, 4 hours ago.
This is the 89th video in the NerdDice create a RubyGem series. In this video we ensure compatibility with Ruby 3.2 by adding it to the GitHub Actions for the gem.

This does not run as smoothly as our transition from 3.0 to 3.1, though. Many of our specs are failing, and it's hard to figure out why. All of our keyword arguments are using the double-splat and seem to meet the Ruby 3.0+ specifications.

We go into the console and the method is working fine. What gives?

Maybe the issue isn't in our application code, but in RSpec. The tests that are failing all have one thing in common: the expect().to receive() pattern. Our gem itself is using the Ruby 3 keyword arguments properly, but the current version of RSpec we have installed is not delegating them properly when evaluating the expect().to receive() syntax.

We didn't want to modify our Gemfile, gemspec, or Gemfile.lock as part of this video, but it looks like we have no alternative in order to make our test suite pass with Ruby 3.2. We upgrade RSpec from 3.10 to 3.12 and use `bundle update rspec` to update the related gems.

After doing this our test suite is back to passing with Ruby 3.2. We push again. This time the build fails on 2.7. For right now, we remove Ruby 2.7 from our GitHub actions build. We'll evaluate the gem's future as it relates to supporting Ruby 2.7 in a future video.

This video covers:
00:00:12 Introduction
00:02:57 Take a look at the issue and the previous commit when we updated to Ruby 3.1
00:06:03 Run RSpec. Fails. Troubleshoot
00:07:25 Switch to Ruby 3.1 in RVM. All tests passing.
00:08:43 Back to 3.2. Still failing. More troubleshooting.
00:16:25 Check to see if the problem is RSpec and not the gem itself by trying the convenience method in the console
00:19:06 Update RSpec in the Gemfile and run bundle update rspec. Tests now passing
00:21:53 Run RuboCop. Try to change target Ruby version. Not supported by currently installed version of RuboCop. Decide to defer that.
00:22:44 Update the GitHub action to add Ruby 3.2
00:23:49 Run the benchmark script a few times. Decide not to modify it and see if the GitHub Action build succeeds.
00:26:03 Review diff, commit and push to the branch
00:28:09 Build fails because 2.7 won't work with the new version of RSpec. Drop 2.7 from the build.
00:31:56 Build successful. Open and merge pull request. Close issue and update project.

#ruby #rubygems #codecast #screencast #NerdDice #DnD #roleplaying #softwaredevelopment #github #opensource #rspec #rubocop #dice #TDD #upgrade #maintain #ruby32 #keywordarguments #kwargs #githubactions

See other related StatelessCode videos:
- Codecast: Create a RubyGem 88: Add Ruby 3.1 to GitHub Actions and Update Bundle youtu.be/xaTAZQuDGpI

Resources that we relied upon for this solution:
- RubyGems rubygems.org
- Ruby 3.2 release notes ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released
- RSpec Mocks expect.to receive issue github.com/rspec/rspec-mocks/pull/1514


This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE. Stateless Code denies the concept of "intellectual property". Copying is not stealing.
Create a RubyGem 89: Add Ruby 3.2 to GitHub Actions and Update RSpec to a compatible versionAdd UUID Support and Generate the Devise User ModelMigrate from SFDX CLI version 7.x to Salesforce CLI version 2.xAdd Code Climate to Project and Allow for Browser Test Driver OptionsInstall Windows Subsystem for Linux 2 (WSL2) and Set Up Remote Development for Visual Studio CodeCodecast: Getting Started with Rails 7 10: Destroy an Article and Get it Working with TurboCreate a RubyGem 94: Fix a Cognitive Complexity Code Smell from Code ClimateConfigure Devise Settings and Add Environment-Specific Rails CredentialsCodecast: Install Rails 6, PostgreSQL 13, MariaDB 10.5Install balenaEtcher on Ubuntu 22.04Inkscape 07: Create a logo for the statelesscode.com WordPress SeriesUpgrade to Devise 4.9 on Rails 7 and Decommission the 4.8 Hacks

Create a RubyGem 89: Add Ruby 3.2 to GitHub Actions and Update RSpec to a compatible version @StatelessCode

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER