Permalink
Browse files

Add Rubinius specific spec for string building

This ensures that we cover the behavior of string interpolation where
the string doesn't have an encoding yet. This is possible on Rubinius,
we only setup the encoding then in the method retrieving the encoding
from the string.

This is an extraction from issue #2222 and is added to prevent
regressions in this behavior.
  • Loading branch information...
dbussink committed Mar 25, 2013
1 parent cbe57a7 commit 7a0ce819f00b02e44e04ee89cbb1bce5fc14b42d
Showing with 15 additions and 0 deletions.
  1. +15 −0 spec/language/string_spec.rb
@@ -0,0 +1,15 @@
+# -*- encoding: us-ascii -*-
+#
+with_feature :encoding do
+ describe "Ruby String interpolation" do
+ it "creates a String when a string doesn't have an encoding yet" do
+ a = "ascii"
+ b = "\x00+/\xa8"
+ b.instance_variable_set("@encoding", nil)
+
+ str = "#{a}:#{b}"
+ str.should == "ascii:\x00+/\xa8"
+ str.encoding.should == Encoding::ASCII_8BIT
+ end
+ end
+end

0 comments on commit 7a0ce81

Please sign in to comment.