Skip to content

Instantly share code, notes, and snippets.

@pdlug
Created December 1, 2008 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdlug/30901 to your computer and use it in GitHub Desktop.
Save pdlug/30901 to your computer and use it in GitHub Desktop.
describe DataMapper::Types::Slug do
before(:all) do
class SlugTest
include DataMapper::Resource
property :id, Serial
property :name, Slug
property :title, String
property :title_slug, Slug
end
SlugTest.auto_migrate!
end
it "should create the permalink" do
repository(:default) do
SlugTest.create(:name => 'New DataMapper Type')
end
SlugTest.first.name.should == "new-datamapper-type"
end
it "should create the slug from the title" do
repository(:default) do
st = SlugTest.new(:title => 'New Title')
st.title_slug = st.title
st.save
end
SlugTest.first.title_slug.should == "new-title"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment