Sha256: b1e5d854727b251ea9f4e9154839e1d99759b0daf663b8aff372eed505446b19

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

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 "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 "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

1 entries across 1 versions & 1 rubygems

Version Path
slugger-0.3.0 spec/lib/post_spec.rb