Skip to content

Fix for rails 8.1#291

Closed
cub8 wants to merge 2 commits into
thoughtbot:mainfrom
cub8:main
Closed

Fix for rails 8.1#291
cub8 wants to merge 2 commits into
thoughtbot:mainfrom
cub8:main

Conversation

@cub8

@cub8 cub8 commented Jun 9, 2026

Copy link
Copy Markdown

Motivation

Rails 8.1 updated class executable attribute definition in Rails::TestUnitReporter:

# previously
class_attribute :executable, default: ENV.fetch("RAILS_TEST_EXECUTABLE", "bin/rails test")

# currently
singleton_class.attr_accessor :executable

As a consequence, when tests failed there would be a nasty error because Shoulda used executable accessor instead of self.class.executable.

Fix

  • Changed executable call to self.class.executable. This works because class_attribute :executable allows both self.class.executable call on singleton class and executable on class instance
  • Added rails 8.1 Appraisal and tests
  • adjusted tests code to work with older Rails versions (6.1, 7.0) and Rails 8.1

@cub8 cub8 requested a review from matsales28 as a code owner June 9, 2026 11:12
@cub8

cub8 commented Jun 10, 2026

Copy link
Copy Markdown
Author

Just realized that first, it's the case with shoulda-matchers and not shoulda and there's already way around this problem: thoughtbot/shoulda-context#109

Sorry for causing chaos 😅

@cub8 cub8 closed this Jun 10, 2026
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