summaryrefslogtreecommitdiff
path: root/spec/ruby/core/kernel/shared/sprintf_encoding.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/kernel/shared/sprintf_encoding.rb')
-rw-r--r--spec/ruby/core/kernel/shared/sprintf_encoding.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/spec/ruby/core/kernel/shared/sprintf_encoding.rb b/spec/ruby/core/kernel/shared/sprintf_encoding.rb
index 9cedb8b662..7ec0fe4c48 100644
--- a/spec/ruby/core/kernel/shared/sprintf_encoding.rb
+++ b/spec/ruby/core/kernel/shared/sprintf_encoding.rb
@@ -14,14 +14,14 @@ describe :kernel_sprintf_encoding, shared: true do
end
it "returns a String in the same encoding as the format String if compatible" do
- string = "%s".force_encoding(Encoding::KOI8_U)
+ string = "%s".dup.force_encoding(Encoding::KOI8_U)
result = @method.call(string, "dogs")
result.encoding.should equal(Encoding::KOI8_U)
end
it "returns a String in the argument's encoding if format encoding is more restrictive" do
- string = "foo %s".force_encoding(Encoding::US_ASCII)
- argument = "b\303\274r".force_encoding(Encoding::UTF_8)
+ string = "foo %s".dup.force_encoding(Encoding::US_ASCII)
+ argument = "b\303\274r".dup.force_encoding(Encoding::UTF_8)
result = @method.call(string, argument)
result.encoding.should equal(Encoding::UTF_8)
@@ -56,7 +56,7 @@ describe :kernel_sprintf_encoding, shared: true do
end
it "uses the encoding of the format string to interpret codepoints" do
- format = "%c".force_encoding("euc-jp")
+ format = "%c".dup.force_encoding("euc-jp")
result = @method.call(format, 9415601)
result.encoding.should == Encoding::EUC_JP