From 549fbcf148a81236cd4d4564923e715552c4997e Mon Sep 17 00:00:00 2001 From: Yasuo Honda Date: Wed, 30 Oct 2024 18:13:02 +0900 Subject: [PATCH] Address `warning: literal string will be frozen in the future` This commit addresses the following warnings. - Steps to reproduce: ```ruby $ ruby -v ruby 3.4.0dev (2024-10-26T13:20:34Z master 484ea00d2e) +PRISM [x86_64-linux] $ RUBYOPT="--debug-frozen-string-literal" bundle exec thor spec ``` - Warnings addressed by this commit: ``` /path/to/thor/spec/base_spec.rb:322: warning: literal string will be frozen in the future /path/to/thor/spec/base_spec.rb:321: info: the string was created here ``` ``` /path/to/thor/spec/parser/options_spec.rb:121: warning: literal string will be frozen in the future /path/to/thor/spec/parser/options_spec.rb:120: info: the string was created here ``` Refer to: https://bugs.ruby-lang.org/issues/20205 https://github.com/ruby/ruby/pull/11893 --- spec/base_spec.rb | 2 +- spec/parser/options_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/base_spec.rb b/spec/base_spec.rb index 7ffef5fd..2208bce9 100644 --- a/spec/base_spec.rb +++ b/spec/base_spec.rb @@ -318,7 +318,7 @@ def hello end it "suggests commands that are similar if there is a typo" do - expected = "Could not find command \"paintz\" in \"barn\" namespace.\n" + expected = "Could not find command \"paintz\" in \"barn\" namespace.\n".dup expected << "Did you mean? \"paint\"\n" if Thor::Correctable expect(capture(:stderr) { Barn.start(%w(paintz)) }).to eq(expected) diff --git a/spec/parser/options_spec.rb b/spec/parser/options_spec.rb index 200a5d5f..d5c22ffb 100644 --- a/spec/parser/options_spec.rb +++ b/spec/parser/options_spec.rb @@ -117,7 +117,7 @@ def remaining create foo: "baz", bar: :required parse("--bar", "baz", "--baz", "unknown") - expected = "Unknown switches \"--baz\"" + expected = "Unknown switches \"--baz\"".dup expected << "\nDid you mean? \"--bar\"" if Thor::Correctable expect { check_unknown! }.to raise_error(Thor::UnknownArgumentError) do |error|