/
comment_spec.rb
47 lines (41 loc) · 1.15 KB
/
comment_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 'spec_helper'
describe Comment do
before (:each) do
@post = Factory(:post)
@attr = {:author=>"Ananth",
:email=>"ananth@gmail.com",
:url=>"www.ananth.com",
:content=>"Lorem Ipsum Tatum Batum"}
@comment = @post.comments.new(@attr)
end
describe "Comment" do
it "should be valid with valid attributes" do
@comment.should be_valid
end
it "should be invalid without author" do
@comment.author = nil
@comment.should_not be_valid
end
it "should be invalid without email" do
@comment.email = nil
@comment.should_not be_valid
end
it "should be invalid without content" do
@comment.content = nil
@comment.should_not be_valid
end
it "should be valid without url" do
@comment.url = nil
@comment.should be_valid
end
it "should be embedded in Post" do
@comment.should be_embedded_in(:post).as_inverse_of(:comments)
end
end
describe "Comment Validations" do
it "should have published date" do
@comment.save!
@comment.published_on.strftime('%Y%m%d').should == Date.today.strftime('%Y%m%d')
end
end
end