diff --git a/lib/fake_pipe/mutator.rb b/lib/fake_pipe/mutator.rb index 5ee7f19..c61b47f 100644 --- a/lib/fake_pipe/mutator.rb +++ b/lib/fake_pipe/mutator.rb @@ -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 diff --git a/spec/anonymizer/mutator_spec.rb b/spec/anonymizer/mutator_spec.rb index d0a4369..bffe7bc 100644 --- a/spec/anonymizer/mutator_spec.rb +++ b/spec/anonymizer/mutator_spec.rb @@ -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 @@ -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