Skip to content

Conversation

@ydah
Copy link
Contributor

@ydah ydah commented Jan 11, 2026

Summary

This PR adds compatibility for Ruby 4.0.0 by addressing breaking changes in the Ruby runtime.

Changes

Thread variable access for Bullet notification collector

Ruby 4.0 / Bullet now uses thread_variable_get/set instead of hash-style accessor for thread-local variables.

# Before
Thread.current[:bullet_notification_collector]

# After
Thread.current.thread_variable_get(:bullet_notification_collector)

Backtrace format changes

Ruby 4.0 changed the backtrace format:

  • Uses single quotes on both sides instead of backtick + single quote: 'method' instead of `method'
  • Includes class name in method: 'ClassName#method_name' instead of 'method_name'

Updated all regex patterns in markers.rb to support both formats.

Hash#to_s output format

Ruby 4.0 changed Hash#to_s to use new-style syntax {key: val} instead of {:key=>val}.

Added to_hash_rocket_syntax helper method in corrector_builder.rb to ensure consistent output format.

RSpec version update

Updated RSpec gems to versions compatible with Ruby 4.0:

  • rspec ~> 3.12
  • rspec-rails ~> 6.0

Deprecated API fix

Fixed deprecated config.fixture_path to config.fixture_paths in spec/rails_helper.rb.

Testing

All 28 examples pass on Ruby 4.0.0.

## Summary

This PR adds compatibility for Ruby 4.0.0 by addressing breaking changes in the Ruby runtime.

## Changes

### Thread variable access for Bullet notification collector

Ruby 4.0 / Bullet now uses `thread_variable_get/set` instead of hash-style accessor for thread-local variables.

```ruby
# Before
Thread.current[:bullet_notification_collector]

# After
Thread.current.thread_variable_get(:bullet_notification_collector)
```

### Backtrace format changes

Ruby 4.0 changed the backtrace format:
- Uses single quotes on both sides instead of backtick + single quote: `'method'` instead of `` `method' ``
- Includes class name in method: `'ClassName#method_name'` instead of `'method_name'`

Updated all regex patterns in `markers.rb` to support both formats.

### Hash#to_s output format

Ruby 4.0 changed `Hash#to_s` to use new-style syntax `{key: val}` instead of `{:key=>val}`.

Added `to_hash_rocket_syntax` helper method in `corrector_builder.rb` to ensure consistent output format.

### RSpec version update

Updated RSpec gems to versions compatible with Ruby 4.0:
- `rspec` ~> 3.12
- `rspec-rails` ~> 6.0

### Deprecated API fix

Fixed deprecated `config.fixture_path` to `config.fixture_paths` in `spec/rails_helper.rb`.

## Testing

All 28 examples pass on Ruby 4.0.0.
matrix:
os: [ubuntu-latest, macos-latest]
ruby: [2.7, 3.0, 3.1, 3.2, head]
ruby: ["3.0", "3.1", "3.2", "3.3", "3.4", "4.0", "head"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to discuss this, but the 2.7 test fails during SQLite installation. I dropped it, but I'd like to know if there's a better workaround.
My current motivation is that this gem can't be used with Ruby versions close to the latest, so I'd like to incorporate this fix if possible.

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