From be4c8c3836e2d61edd516cac9ba1f4f0cb1ddf3b Mon Sep 17 00:00:00 2001 From: Joe Sak Date: Mon, 9 Aug 2010 14:05:16 -0500 Subject: Converted to factory_girl use, a little refactored --- spec/models/blog_categories_spec.rb | 18 +++++++++++++++--- spec/models/blog_comments_spec.rb | 18 +++++++++++++++--- spec/models/blog_posts_spec.rb | 15 +++++++++++---- 3 files changed, 41 insertions(+), 10 deletions(-) (limited to 'spec/models') diff --git a/spec/models/blog_categories_spec.rb b/spec/models/blog_categories_spec.rb index 14d0dcc..d97172c 100644 --- a/spec/models/blog_categories_spec.rb +++ b/spec/models/blog_categories_spec.rb @@ -1,8 +1,20 @@ require 'spec_helper' describe BlogCategory do - it "initializes" do - blog = BlogCategory.new - blog.should_not be_nil + context "wiring up" do + + before(:each) do + @category = Factory(:blog_category) + end + + it "saves" do + @category.should_not be_nil + end + + it "has a blog post" do + BlogPost.last.categories.should include(@category) + end + end + end \ No newline at end of file diff --git a/spec/models/blog_comments_spec.rb b/spec/models/blog_comments_spec.rb index 43daf7d..145626d 100644 --- a/spec/models/blog_comments_spec.rb +++ b/spec/models/blog_comments_spec.rb @@ -1,8 +1,20 @@ require 'spec_helper' describe BlogComment do - it "initializes" do - blog = BlogComment.new - blog.should_not be_nil + + context "wiring up" do + + before(:each) do + @comment = Factory(:blog_comment) + end + + it "saves" do + @comment.should_not be_nil + end + + it "has a blog post" do + @comment.post.should_not be_nil + end + end end \ No newline at end of file diff --git a/spec/models/blog_posts_spec.rb b/spec/models/blog_posts_spec.rb index f9629b0..a334c73 100644 --- a/spec/models/blog_posts_spec.rb +++ b/spec/models/blog_posts_spec.rb @@ -1,8 +1,15 @@ require 'spec_helper' describe BlogPost do - it "initializes" do - blog = BlogPost.new - blog.should_not be_nil - end + context "wiring up" do + + before(:each) do + @post = Factory(:post) + end + + it "saves to the database" do + @post.should_not be_nil + end + + end end \ No newline at end of file -- cgit v1.2.3