aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib/basic_encoding_spec.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2015-05-28 10:57:19 +0100
committerLouise Crow <louise.crow@gmail.com>2015-05-28 10:57:19 +0100
commite936b687a7df62dc69d1cc0493492346bd8e300a (patch)
tree61206adc9f66b7bfc691174c9f93c92ccea1ffe9 /spec/lib/basic_encoding_spec.rb
parentc6e8e298fd0861cd822f23f370a01ccbc21cb9d3 (diff)
parent495f82365ccd374d5b33339abce356f3a3662295 (diff)
Merge branch 'force-filenames-to-utf8' into rails-3-develop
Diffstat (limited to 'spec/lib/basic_encoding_spec.rb')
-rw-r--r--spec/lib/basic_encoding_spec.rb57
1 files changed, 56 insertions, 1 deletions
diff --git a/spec/lib/basic_encoding_spec.rb b/spec/lib/basic_encoding_spec.rb
index 1b3d9cd1c..d77465ad8 100644
--- a/spec/lib/basic_encoding_spec.rb
+++ b/spec/lib/basic_encoding_spec.rb
@@ -103,7 +103,7 @@ end
describe "convert_string_to_utf8_or_binary" do
- describe "when passed uniterpretable character data" do
+ describe "when passed uninterpretable character data" do
it "should return it as a binary string" do
@@ -155,3 +155,58 @@ describe "convert_string_to_utf8_or_binary" do
end
end
+
+describe "convert_string_to_utf8" do
+
+ describe "when passed uninterpretable character data" do
+
+ it "should return it as a utf8 string" do
+
+ converted = convert_string_to_utf8 random_string
+ converted.should == random_string
+
+ if String.method_defined?(:encode)
+ converted.encoding.to_s.should == 'UTF-8'
+ end
+
+ converted = convert_string_to_utf8 random_string,'UTF-8'
+ converted.should == random_string
+
+ if String.method_defined?(:encode)
+ converted.encoding.to_s.should == 'UTF-8'
+ end
+
+ end
+ end
+
+ describe "when passed unlabelled Windows 1252 data" do
+
+ it "should correctly convert it to UTF-8" do
+
+ converted = convert_string_to_utf8 windows_1252_string
+
+ converted.should == "DASH – DASH"
+
+ if String.method_defined?(:encode)
+ converted.encoding.to_s.should == 'UTF-8'
+ end
+ end
+
+ end
+
+ describe "when passed GB 18030 data" do
+
+ it "should correctly convert it to UTF-8 if unlabelled" do
+
+ converted = convert_string_to_utf8 gb_18030_spam_string
+
+ converted.should start_with("贵公司负责人")
+
+ if String.method_defined?(:encode)
+ converted.encoding.to_s.should == 'UTF-8'
+ end
+ end
+
+ end
+
+end \ No newline at end of file