Sha256: e620f66f698da2a99214f31a2b346a6c2fe5a7bcd50c1b97789aba0a837dbfbb
Contents?: true
Size: 1.14 KB
Versions: 17
Compression:
Stored size: 1.14 KB
Contents
require 'spec_helper' describe SsnValidator do context "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
17 entries across 17 versions & 3 rubygems