Sha256: 28013b69d21d6d937f6f99fbbb1615548a40c676173ff8b9da2ab04c48cbc33f
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
require 'factories/profiles.rb' describe PhoneNumberFormatValidator do let(:subject) { PhoneNumberFormatValidator } let( :attribute ) { :phone_number } let (:object) { Profile.new } context 'Wrong phone number format' do context 'No message is sent on the options' do it 'it returns error message expecified on the validator' do n = subject.new( { attributes: attribute } ) expect(n.validate_each(object, attribute, '777 777')).to include('enter a valid 10-digit number (e.g. 587-555-5555)') end end context 'Message is sent on the options' do it 'it returns error message expecified on the options' do n = subject.new( { message: 'Test error message', attributes: attribute } ) expect(n.validate_each(object, attribute, '777 777')).to include('Test error message') end end end context 'Correct phone number format' do context 'No message is sent on the options' do it 'it do not return error message' do n = subject.new( { attributes: attribute } ) expect(n.validate_each(object, attribute, '777 123 4567')).to equal(nil) end end context 'Message is sent on the options' do it 'it do not return error message' do n = subject.new( { message: 'Test error message', attributes: attribute } ) expect(n.validate_each(object, attribute, '777 123 4567')).to equal(nil) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ama_validators-0.0.3 | spec/phone_number_format_validator_spec.rb |
ama_validators-0.0.2 | spec/phone_number_format_validator_spec.rb |