Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/fake_pipe/mutator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ def mutate_zip_code(_)
Faker::Address.zip_code
end

# Large number with eight digits
def mutate_large_number(_)
Faker::Number.number(8)
end

# Small number with two digits
def mutate_small_number(_)
Faker::Number.number(2)
end

# Reopen class to define aliases on module_function
class << self
alias mutate_guid mutate_uuid
Expand Down
15 changes: 14 additions & 1 deletion spec/anonymizer/mutator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module FakePipe
context 'happy path' do
it 'lists mutators' do
expect(described_class.list)
.to contain_exactly('address_city','zip_code','latitude', 'longitude','address_country', 'address_line_1', 'address_line_2', 'address_postcode', 'address_state', 'bcrypt_password', 'bcrypt_salt', 'clean_phone_number', 'company_catch_phrase', 'company_name', 'email', 'empty_curly', 'empty_bracket', 'empty_string', 'first_name', 'full_name', 'last_name', 'lorem_paragraph', 'lorem_sentence', 'lorem_word', 'md5', 'phone_ext', 'phone_number', 'url', 'user_name', 'uuid', 'guid', 'ugcid', 'bank_name')
.to contain_exactly('address_city','zip_code','latitude', 'longitude','address_country', 'address_line_1', 'address_line_2', 'address_postcode', 'address_state', 'bcrypt_password', 'bcrypt_salt', 'clean_phone_number', 'company_catch_phrase', 'company_name', 'email', 'empty_curly', 'empty_bracket', 'empty_string', 'first_name', 'full_name', 'last_name', 'lorem_paragraph', 'lorem_sentence', 'lorem_word', 'md5', 'phone_ext', 'phone_number', 'url', 'user_name', 'uuid', 'guid', 'ugcid', 'bank_name', 'large_number', 'small_number')
end

context '#mutate_clean_phone_number' do
Expand Down Expand Up @@ -209,6 +209,19 @@ module FakePipe
expect(described_class.mutate('empty_bracket', 'dont_care')).to eq '[]'
end
end

context '#mutate_large_number' do
it 'matches proper format' do
expect(described_class.mutate('large_number', 'dont_care')).to match(/\d{8}/)
end
end

context '#mutate_small_number' do
it 'matches proper format' do
expect(described_class.mutate('small_number', 'dont_care')).to match(/\d{2}/)
end
end

end

context 'sad path' do
Expand Down