Sha256: 97eeccc54dee6ef334b4ae319e7c42bd185a789c138166c0904ae848dcd713f1

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe Post do
  it "should set slug on create" do
    p = Post.create(:title => "hello world")
    p.slug.should == "hello-world"
  end
  it "should not override given slug" do
    p = Post.create(:title => "hello world", :slug => "custom-slug")
    p.slug.should == "custom-slug"
  end
  it "should remove apostrophes" do
    p = Post.create(:title => "apostrop'hes", :slug => "apostrophes")
    p.slug.should == "apostrophes"
  end
  it "slug should be limited to 20 characters" do
    p = Post.create(
      :title => "when you write really long titles slugs should be shortened")
    p.slug.should == "when-you-write-reall"
  end
  it "slug should not end with a substitution character" do
    p = Post.create(
      :title => "when you write very long titles slugs should be shortened")
    p.slug.should == "when-you-write-very"
  end
  it "should not be valid on duplicate" do
    p = Post.create(:title => "hello")
    p.slug.should == "hello"
    q = Post.create(:title => "hello")
    q.should_not be_valid
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slugger-0.5.0 spec/lib/post_spec.rb
slugger-0.4.1 spec/lib/post_spec.rb
slugger-0.4.0 spec/lib/post_spec.rb
slugger-0.3.2 spec/lib/post_spec.rb
slugger-0.3.1 spec/lib/post_spec.rb