diff --git a/lib/attribute_normalizer/normalizers/squish_normalizer.rb b/lib/attribute_normalizer/normalizers/squish_normalizer.rb index 8cafbc0..e247d4a 100644 --- a/lib/attribute_normalizer/normalizers/squish_normalizer.rb +++ b/lib/attribute_normalizer/normalizers/squish_normalizer.rb @@ -2,7 +2,7 @@ module AttributeNormalizer module Normalizers module SquishNormalizer def self.normalize(value, options = {}) - value.is_a?(String) ? value.strip.gsub(/\s+/, ' ') : value + value.is_a?(String) ? value.strip.squeeze(' ') : value end end end diff --git a/spec/author_spec.rb b/spec/author_spec.rb index d06b6f7..41eb496 100644 --- a/spec/author_spec.rb +++ b/spec/author_spec.rb @@ -13,7 +13,7 @@ it { should normalize_attribute(:first_name).from(' ').to('') } # :squish normalizer - it { should normalize_attribute(:nickname).from(' this nickname ').to('this nickname') } + it { should normalize_attribute(:nickname).from(' hello world ').to('hello world') } # :blank normalizer it { should normalize_attribute(:last_name).from('').to(nil) }