Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use squeeze instead of gsub in SquishNormalizer #53

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/attribute_normalizer/normalizers/squish_normalizer.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/author_spec.rb
Expand Up @@ -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) }
Expand Down