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

Опубликовано: 08 Февраль 2023
на канале: Stateless Code
66
1

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    • Codecast: Create a RubyGem 88: Add Ru...  

Resources that we relied upon for this solution:
RubyGems https://rubygems.org
Ruby 3.2 release notes https://www.ruby-lang.org/en/news/202...
RSpec Mocks expect.to receive issue https://github.com/rspec/rspec-mocks/...


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 version онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Stateless Code 08 Февраль 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 66 раз и оно понравилось 1 людям.