Sha256: 83fb7d43797ef45b6c6a862f835cac31bb32be490204cd0a2f0bc2191fa573f8
Contents?: true
Size: 1.4 KB
Versions: 17
Compression:
Stored size: 1.4 KB
Contents
require 'spec_helper' describe SlugValidator do context "has a valid value" do let(:klass) do Class.new do include ActiveModel::Validations attr_accessor :slug, :name validates :slug, slug: true end end subject { klass.new } it { should allow_value("slug").for(:slug) } it { should allow_value("slug1234").for(:slug) } it { should allow_value("slug-word").for(:slug) } it { should allow_value("slug-1234").for(:slug) } it { should_not allow_value('').for(:slug) } it { should_not allow_value(' ').for(:slug) } it { should_not allow_value(nil).for(:slug) } it { should_not allow_value(" slug").for(:slug) } it { should_not allow_value(" slug ").for(:slug) } it { should_not allow_value("slug ").for(:slug) } it { should_not allow_value(" 1234").for(:slug) } it { should_not allow_value(" 1234 ").for(:slug) } it { should_not allow_value("1234 ").for(:slug) } it { should_not allow_value("slug word").for(:slug) } it { should_not allow_value("slug 1234").for(:slug) } it { should_not allow_value("slug_word").for(:slug) } it { should_not allow_value("slug_1234").for(:slug) } it { should_not allow_value("! \#$%\`|").for(:slug) } it { should_not allow_value("<>@[]\`|").for(:slug) } it { should ensure_valid_slug_format_of(:slug) } it { should_not ensure_valid_slug_format_of(:name) } end end
Version data entries
17 entries across 17 versions & 3 rubygems