Sha256: de00b72488c1cbe70ebe597ac93b06af88b721ea0f2dab33042afa2acd490114
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
require 'spec_helper' describe UsernameValidator do context "Username has a valid value" do let(:klass) do Class.new do include ActiveModel::Validations attr_accessor :username, :name validates :username, username: true end end subject { klass.new } it { should allow_value("username").for(:username) } it { should allow_value("username123").for(:username) } it { should allow_value("username_123").for(:username) } it { should allow_value("username-123").for(:username) } it { should_not allow_value('').for(:username) } it { should_not allow_value(' ').for(:username) } it { should_not allow_value(nil).for(:username) } it { should_not allow_value("u").for(:username) } it { should_not allow_value(" username").for(:username) } it { should_not allow_value(" username ").for(:username) } it { should_not allow_value("username ").for(:username) } it { should_not allow_value("user name").for(:username) } it { should_not allow_value("username-123456789").for(:username) } it { should_not allow_value("! \#$%\`|").for(:username) } it { should_not allow_value("<>@[]\`|").for(:username) } it { should ensure_valid_username_format_of(:username) } it { should_not ensure_valid_username_format_of(:name) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flash_validators-1.0.0 | spec/lib/username_validator_spec.rb |
flash_validators-0.0.1 | spec/lib/username_validator_spec.rb |