Skip to content

Commit

Permalink
Always return a String vs ActiveSupport::Multibyte::Chars.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Apr 11, 2013
1 parent 0a95d1e commit 15dac79
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/gigo.rb
Expand Up @@ -29,7 +29,8 @@ def self.safe_detect_and_encoder(data)
string = string.encode forced_encoding, :undef => :replace, :invalid => :replace
end
end
EnsureValidEncoding.ensure_valid_encoding string, invalid: :replace, replace: "?"
string = EnsureValidEncoding.ensure_valid_encoding string, invalid: :replace, replace: "?"
string.to_s
end

def self.forced_encoding
Expand Down
2 changes: 1 addition & 1 deletion lib/gigo/version.rb
@@ -1,3 +1,3 @@
module GIGO
VERSION = "1.1.0"
VERSION = "1.2.0"
end
4 changes: 4 additions & 0 deletions test/cases/gigo_test.rb
Expand Up @@ -23,6 +23,10 @@ class BaseTest < TestCase
GIGO.load(o).must_equal o
end

it 'always returns a String object' do
GIGO.load(data_bin_apos).must_be_instance_of String
end

it 'fixes windows apostrophe' do
GIGO.load(data_bin_apos).must_equal "won’t"
end
Expand Down

0 comments on commit 15dac79

Please sign in to comment.