Sha256: f51fb80b86b64678b92bdd034ac00fc04e15b39a191bb5492be06c42c035f4b0

Contents?: true

Size: 1.42 KB

Versions: 17

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

describe NameValidator do

  context "has a valid value" do
    let(:klass) do
      Class.new do
        include ActiveModel::Validations
        attr_accessor :name, :email
        validates :name, name: true
      end
    end

    subject { klass.new }

    it { should allow_value("First Last").for(:name) }
    it { should allow_value("First Last-Name").for(:name) }
    it { should allow_value("First Middle Last").for(:name) }
    it { should allow_value("Sur First Middle Last").for(:name) }
    it { should allow_value("Sur First Middle Last Family").for(:name) }
    it { should allow_value("Sur First Middle Last-Family").for(:name) }

    it { should_not allow_value('').for(:name) }
    it { should_not allow_value(' ').for(:name) }
    it { should_not allow_value(nil).for(:name) }
    it { should_not allow_value("First").for(:name) }
    it { should_not allow_value("First Last_Name").for(:name) }
    it { should_not allow_value("First1 Last").for(:name) }
    it { should_not allow_value("First 1 Last").for(:name) }
    it { should_not allow_value("Sur. First Middle Last Jr.").for(:name) }
    it { should_not allow_value("Sur First Middle Last Family III").for(:name) }
    it { should_not allow_value("! \#$%\`|").for(:name) }
    it { should_not allow_value("<>@[]\`|").for(:name) }

    it { should ensure_valid_name_format_of(:name) }
    it { should_not ensure_valid_name_format_of(:email) }
  end

end

Version data entries

17 entries across 17 versions & 3 rubygems

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