Skip to content

Add Ruby 3.4 / 4.0 to CI and fix JRuby spec failures - #87

Open
willnet wants to merge 2 commits into
jalkoby:masterfrom
willnet:update-ci-ruby-4.0
Open

willnet wants to merge 2 commits into
jalkoby:masterfrom
willnet:update-ci-ruby-4.0

Conversation

@willnet

@willnet willnet commented Nov 30, 2026

Copy link
Copy Markdown

Summary

  • Add Ruby 3.4 and 4.0 to the CI matrix.
  • Bump actions/checkout from v3 to v7. v3 runs on Node.js 16, which GitHub Actions no longer supports.
  • Fix the Squasher.rake specs that fail on JRuby.

Why the JRuby specs failed

Three Squasher.rake specs failed on JRuby with:

The message 'system' was received by #<Module:...> but has already been received by Squasher

The specs stubbed system with expect_any_instance_of(Object). Since rspec-mocks 3.13.3, any_instance preserves the original visibility of the method, so on reset rspec-mocks calls private :system on Squasher's singleton class. CRuby and JRuby treat that call differently when the method is inherited:

class Parent; def greet = :old; end
class Child < Parent; private :greet; end
class Parent; def greet = :new; end
Child.new.send(:greet) # CRuby => :new / JRuby => :old

On JRuby, private copies the method body that is current at that moment. Here that body is the Object#system that any_instance installed in the previous example, which raises on a second call. That body stays on Squasher, so the next example fails. This behavior is the same on JRuby 9.4, 10.0 and 10.1. JRuby presumably passed on earlier CI runs because rspec-mocks was 3.13.2 or older.

Squasher itself calls system, so the specs now stub it directly on Squasher instead of on every Object instance.

🤖 Generated with Claude Code

willnet and others added 2 commits November 30, 2026 11:43
Ruby 3.4 and 4.0 have been released, but the CI matrix stopped at 3.3,
so we had no continuous check that squasher works on the latest Rubies.

actions/checkout@v3 is built on Node.js 16, a runtime GitHub Actions no
longer supports, so bump it to v7, the current major version.

Ruby 2.7 through 3.2 have reached EOL but are kept in the matrix. The
gemspec does not declare required_ruby_version, and whether to narrow
the supported versions is a separate decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On JRuby, three of the Squasher.rake specs failed with
"The message 'system' was received by ... but has already been received
by Squasher".

These specs stubbed system with expect_any_instance_of(Object). Since
rspec-mocks 3.13.3, any_instance preserves the original method
visibility, so on reset it calls `private :system` on Squasher's
singleton class. On CRuby that only adds a visibility entry, and the
method is looked up in the ancestors again on each call. JRuby instead
copies the method body that is current at that moment. As a result, the
Object#system that any_instance had installed in the previous example
(the one that raises on a second call) stayed on Squasher, and the
following examples failed.

  class Parent; def greet = :old; end
  class Child < Parent; private :greet; end
  class Parent; def greet = :new; end
  Child.new.send(:greet) # CRuby => :new / JRuby => :old

This behavior is the same on JRuby 9.4 / 10.0 / 10.1. JRuby presumably
passed on earlier CI runs because rspec-mocks was 3.13.2 or older.

Squasher itself is the one calling system, so stubbing it directly on
Squasher instead of on every Object instance is enough and avoids the
problem above.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant