diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-06-11 17:11:26 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-06-22 17:43:21 +0100 |
commit | 3d8f0cc6b70b55aad20ab4d86642f0e6d605c921 (patch) | |
tree | 9ea992e219fb9d2909c9e15e4349f304e2d43ab1 /spec/lib/basic_encoding_spec.rb | |
parent | d359f76233787533c973a1f30c3f6439d5919783 (diff) |
convert_string_to_utf8 returns struct of string and scrubbing status.
Diffstat (limited to 'spec/lib/basic_encoding_spec.rb')
-rw-r--r-- | spec/lib/basic_encoding_spec.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/spec/lib/basic_encoding_spec.rb b/spec/lib/basic_encoding_spec.rb index d802da892..6758d60a3 100644 --- a/spec/lib/basic_encoding_spec.rb +++ b/spec/lib/basic_encoding_spec.rb @@ -160,20 +160,24 @@ describe "convert_string_to_utf8" do describe "when passed uninterpretable character data" do - it "should return it as a valid utf8 string with non-utf8 characters removed" do + it "should return it as a valid utf8 string with non-utf8 characters removed + and mark it as scrubbed" do converted = convert_string_to_utf8 random_string if String.method_defined?(:encode) - converted.encoding.to_s.should == 'UTF-8' - converted.valid_encoding?.should == true + converted.string.encoding.to_s.should == 'UTF-8' + converted.string.valid_encoding?.should == true end + converted.scrubbed?.should == true converted = convert_string_to_utf8 random_string,'UTF-8' if String.method_defined?(:encode) - converted.encoding.to_s.should == 'UTF-8' + converted.string.encoding.to_s.should == 'UTF-8' + converted.string.valid_encoding?.should == true end + converted.scrubbed?.should == true end end @@ -184,11 +188,13 @@ describe "convert_string_to_utf8" do converted = convert_string_to_utf8 windows_1252_string - converted.should == "DASH – DASH" + converted.string.should == "DASH – DASH" if String.method_defined?(:encode) - converted.encoding.to_s.should == 'UTF-8' + converted.string.encoding.to_s.should == 'UTF-8' end + converted.scrubbed?.should == false + end end @@ -199,11 +205,12 @@ describe "convert_string_to_utf8" do converted = convert_string_to_utf8 gb_18030_spam_string - converted.should start_with("贵公司负责人") + converted.string.should start_with("贵公司负责人") if String.method_defined?(:encode) - converted.encoding.to_s.should == 'UTF-8' + converted.string.encoding.to_s.should == 'UTF-8' end + converted.scrubbed?.should == false end end |