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

Version Path
active_validation-1.0.0 spec/lib/ssn_validator_spec.rb
yukonisuru-1.0.0 spec/lib/ssn_validator_spec.rb
yukonisuru-0.0.1 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.12 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.11 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.10 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.9 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.8 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.7 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.6 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.5 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.4 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.3 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.2 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.1 spec/lib/ssn_validator_spec.rb
flash_validators-3.0.0 spec/lib/ssn_validator_spec.rb
flash_validators-1.1.0 spec/lib/ssn_validator_spec.rb