
Untitled
By: a guest on
Apr 30th, 2012 | syntax:
None | size: 0.60 KB | hits: 11 | expires: Never
# in specs/models/post_spec.rb
require 'spec_helper'
describe Post do
it {
should belong_to :user
should validate_presence_of :title
}
# class method spec
describe '.find_by_url_param' do
it 'should find a Post by converting a URL param to a post title' do
post = Post.create(:title => 'My New Post')
Post.find_by_url_param('my-new-post').should == post
end
end
# instance method spec
describe '#url_param' do
it 'should convert the post title to a param for URLs' do
Post.create(:title => 'Another Post').url_param.should == 'another-post'
end
end
end