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

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