mirror of
https://github.com/danbee/slugtastic
synced 2025-03-04 08:49:05 +00:00
Switch to newer expect spec format
This commit is contained in:
parent
c1529f0867
commit
a6637f463a
@ -23,23 +23,23 @@ end
|
||||
|
||||
describe Slugtastic::ModelAdditions do
|
||||
it "generates a slug from the name" do
|
||||
Model.create!(:name => "A Simple Name").slug.should eq "a-simple-name"
|
||||
expect(Model.create!(:name => "A Simple Name").slug).to eq "a-simple-name"
|
||||
end
|
||||
|
||||
it "defaults to generating the slug from title" do
|
||||
ModelDefault.create!(:title => "A Simple Title").slug.should eq "a-simple-title"
|
||||
expect(ModelDefault.create!(:title => "A Simple Title").slug).to eq "a-simple-title"
|
||||
end
|
||||
|
||||
it "generates a slug from the title with delimiter substitutions" do
|
||||
ModelDelimiter.create!(:title => "A Simple Title").slug.should eq "a_simple_title"
|
||||
expect(ModelDelimiter.create!(:title => "A Simple Title").slug).to eq "a_simple_title"
|
||||
end
|
||||
|
||||
it "doesn't regenerate the slug if it already exists" do
|
||||
model = Model.create!(:name => "A Simple Name")
|
||||
model.slug.should eq "a-simple-name"
|
||||
expect(model.slug).to eq "a-simple-name"
|
||||
|
||||
model.title = "A new title"
|
||||
model.save
|
||||
model.slug.should eq "a-simple-name"
|
||||
expect(model.slug).to eq "a-simple-name"
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,32 +4,32 @@ require 'spec_helper'
|
||||
describe Slugtastic do
|
||||
describe ".generate_slug" do
|
||||
it "returns empty if the input string is empty" do
|
||||
Slugtastic.generate_slug("").should eq ""
|
||||
expect(Slugtastic.generate_slug("")).to eq ""
|
||||
end
|
||||
|
||||
it "generates a slug from a simple string" do
|
||||
Slugtastic.generate_slug("A simple string.").should eq "a-simple-string"
|
||||
expect(Slugtastic.generate_slug("A simple string.")).to eq "a-simple-string"
|
||||
end
|
||||
|
||||
it "substitutes hyphens for delimiter if specified" do
|
||||
Slugtastic.generate_slug("A simple string.", "_").should eq "a_simple_string"
|
||||
expect(Slugtastic.generate_slug("A simple string.", "_")).to eq "a_simple_string"
|
||||
end
|
||||
|
||||
it "generates a slug from a string with numbers" do
|
||||
Slugtastic.generate_slug("Slugtastic was built in 2012.").should eq "slugtastic-was-built-in-2012"
|
||||
expect(Slugtastic.generate_slug("Slugtastic was built in 2012.")).to eq "slugtastic-was-built-in-2012"
|
||||
end
|
||||
|
||||
it "handles strings with hypens in them" do
|
||||
Slugtastic.generate_slug("A string - with Hyphens").should eq "a-string-with-hyphens"
|
||||
expect(Slugtastic.generate_slug("A string - with Hyphens")).to eq "a-string-with-hyphens"
|
||||
end
|
||||
|
||||
it "handles strings with other characters in them" do
|
||||
Slugtastic.generate_slug("A string, with /All sorts!").should eq "a-string-with-all-sorts"
|
||||
expect(Slugtastic.generate_slug("A string, with /All sorts!")).to eq "a-string-with-all-sorts"
|
||||
end
|
||||
|
||||
it "handles basic transliteration" do
|
||||
Slugtastic.generate_slug("Un été À la maison.").should eq "un-ete-a-la-maison"
|
||||
Slugtastic.generate_slug("Ātri brūna lapsa").should eq "atri-bruna-lapsa"
|
||||
expect(Slugtastic.generate_slug("Un été À la maison.")).to eq "un-ete-a-la-maison"
|
||||
expect(Slugtastic.generate_slug("Ātri brūna lapsa")).to eq "atri-bruna-lapsa"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user