diff options
author | Gareth Rees <gareth@mysociety.org> | 2015-06-24 11:19:43 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2015-06-24 11:19:43 +0100 |
commit | 2cce1794a4d9d2c42b83bab8a693900e8ca23ebc (patch) | |
tree | 7408a04d5ac0963ec2defbbf7d4955cff7cd62b5 /spec/lib/basic_encoding_spec.rb | |
parent | ed6b256539e0dcaa3764951d90e2dc599a8acddd (diff) | |
parent | 54ba7a4fa232ad3b57310551b9a5e19d72060abe (diff) |
Merge branch 'develop' into release-22-develop
Diffstat (limited to 'spec/lib/basic_encoding_spec.rb')
-rw-r--r-- | spec/lib/basic_encoding_spec.rb | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/spec/lib/basic_encoding_spec.rb b/spec/lib/basic_encoding_spec.rb index d77465ad8..6758d60a3 100644 --- a/spec/lib/basic_encoding_spec.rb +++ b/spec/lib/basic_encoding_spec.rb @@ -160,21 +160,24 @@ describe "convert_string_to_utf8" do describe "when passed uninterpretable character data" do - it "should return it as a utf8 string" 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 - converted.should == random_string 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 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' + converted.string.encoding.to_s.should == 'UTF-8' + converted.string.valid_encoding?.should == true end + converted.scrubbed?.should == true end end @@ -185,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 @@ -200,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 |