2013-02-05 14:16:51 -05:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
require 'slug'
|
|
|
|
|
|
|
|
describe Slug do
|
|
|
|
|
|
|
|
it 'replaces spaces with hyphens' do
|
|
|
|
Slug.for("hello world").should == 'hello-world'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'changes accented characters' do
|
|
|
|
Slug.for('àllo').should == 'allo'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes symbols' do
|
|
|
|
Slug.for('evil#trout').should == 'eviltrout'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'handles a.b.c properly' do
|
|
|
|
Slug.for("a.b.c").should == "a-b-c"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'handles double dots right' do
|
|
|
|
Slug.for("a....b.....c").should == "a-b-c"
|
|
|
|
end
|
|
|
|
|
2013-02-06 20:52:14 -05:00
|
|
|
it 'strips trailing punctuation' do
|
|
|
|
Slug.for("hello...").should == "hello"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'strips leading punctuation' do
|
|
|
|
Slug.for("...hello").should == "hello"
|
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
|
2013-02-11 21:34:38 -05:00
|
|
|
it 'handles our initial transliteration' do
|
|
|
|
from = "àáäâčďèéëěêìíïîľĺňòóöôŕřšťůùúüûýžñç"
|
|
|
|
to = "aaaacdeeeeeiiiillnoooorrstuuuuuyznc"
|
|
|
|
Slug.for(from).should == to
|
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|