Sha256: ad3188b2427a88acd19f458f304ac4efd22008c4d8b20faab18ea3025ed485b6
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require 'spec_helper' describe SsnValidator do context "SSN has a valid value" do let(:klass) do Class.new do include ActiveModel::Validations attr_accessor :ssn, :name validates :ssn, ssn: true end end subject { klass.new } it { should allow_value("333-22-4444").for(:ssn) } it { should allow_value("333224444").for(:ssn) } it { should_not allow_value('').for(:ssn) } it { should_not allow_value(' ').for(:ssn) } it { should_not allow_value(nil).for(:ssn) } it { should_not allow_value(" 333-22-4444").for(:ssn) } it { should_not allow_value(" 333-22-4444 ").for(:ssn) } it { should_not allow_value("333-22-4444 ").for(:ssn) } it { should_not allow_value("333 22 4444").for(:ssn) } it { should_not allow_value("333-22-444n").for(:ssn) } it { should_not allow_value("333 22 4444").for(:ssn) } it { should_not allow_value("3-2-4").for(:ssn) } it { should_not allow_value("! \#$%\`|").for(:ssn) } it { should_not allow_value("<>@[]\`|").for(:ssn) } it { should ensure_valid_ssn_format_of(:ssn) } it { should_not ensure_valid_ssn_format_of(:name) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flash_validators-1.0.0 | spec/lib/ssn_validator_spec.rb |
flash_validators-0.0.1 | spec/lib/ssn_validator_spec.rb |