Skip to content

Conversation

r7kamura
Copy link

@r7kamura r7kamura commented Oct 9, 2025

This addresses two issues::

  1. Some errors occuring on Ruby 3.5 (Deprecation warnings emitted on Ruby 3.4)
  2. Test failures occurring on Ruby 3.5

In Ruby 3.5 and later, string literals are frozen by default. As a result, even if there’s no actual runtime issue, deprecation warnings may appear on Ruby 3.4. For example, running tests on Ruby 3.4 with RUBYOPT=-W:deprecated will display these warnings.

To address this warning, it’s recommended to consistently add # frozen_string_literal: true at the top of files. In this case, I applied it to all affected files. The process was automated using the command:

rubocop --only Style/FrozenStringLiteralComment -A

The Rack::Tracker::GoogleTagManager#inject method provided by this library is implemented on the assumption that it receives a mutable string as an argument; specifically, it internally calls String#sub! on that string. While this is generally fine as long as users pass in a mutable string, the library’s test code originally passed string literals to test this behavior. Therefore, some care was needed when making changes in this context.

Additionally, String#force_encoding was used to create strings with a specific encoding, so special care was also needed for this part during the current changes.

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