-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathpost_spec.rb
47 lines (39 loc) · 1.54 KB
/
post_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require File.dirname(__FILE__) + '/base'
describe Post do
before do
@post = Post.new
end
it "has a url in simplelog format: /past/2008/10/17/my_post/" do
@post.created_at = '2008-10-22'
@post.slug = "my_post"
@post.url.should == '/past/2008/10/22/my_post/'
end
it "has a full url including the Blog.url_base" do
@post.created_at = '2008-10-22'
@post.slug = "my_post"
Blog.stub!(:url_base).and_return('http://blog.example.com/')
@post.full_url.should == 'http://blog.example.com/past/2008/10/22/my_post/'
end
it "produces html from the markdown body" do
@post.body = "* Bullet"
@post.body_html.should == "<ul>\n<li>Bullet</li>\n</ul>"
end
it "syntax highlights code blocks" do
@post.to_html("<code>\none\ntwo</code>").should == "<code><pre>\n<span class=\"ident\">one</span>\n<span class=\"ident\">two</span></pre></code>"
end
it "makes the tags into links to the tag search" do
@post.tags = "one two"
@post.linked_tags.should == '<a href="/past/tags/one">one</a> <a href="/past/tags/two">two</a>'
end
it "can save itself (primary key is set up)" do
@post.title = 'hello'
@post.body = 'world'
@post.save
Post.filter(:title => 'hello').first.body.should == 'world'
end
it "generates a slug from the title (but saved to db on first pass so that url never changes)" do
Post.make_slug("RestClient 0.8").should == 'restclient_08'
Post.make_slug("Rushmate, rush + TextMate").should == 'rushmate_rush_textmate'
Post.make_slug("Object-Oriented File Manipulation").should == 'objectoriented_file_manipulation'
end
end