Spec improvements

* replaced it with specify on {...} blocks
This commit is contained in:
Marc Remolt 2011-06-05 17:55:00 +02:00
parent 772cfdc25b
commit 9a2b5acef6
3 changed files with 44 additions and 34 deletions

View File

@ -18,6 +18,7 @@ describe Refinery::WordPress::Dump, :type => :model do
end
specify { dump.tags.count == 4 }
specify { dump.tags.first.should be_a(Refinery::WordPress::Tag) }
it "should return all included tags" do
tags.each do |tag|
@ -33,6 +34,7 @@ describe Refinery::WordPress::Dump, :type => :model do
end
specify { dump.categories.count == 4 }
specify { dump.categories.first.should be_a(Refinery::WordPress::Category) }
it "should return all included categories" do
categories.each do |cat|
@ -46,6 +48,8 @@ describe Refinery::WordPress::Dump, :type => :model do
dump.pages.should have(3).pages
end
specify { dump.pages.first.should be_a(Refinery::WordPress::Page) }
it "should return only published pages with only_published=true" do
dump.pages(true).should have(2).pages
end
@ -55,6 +59,8 @@ describe Refinery::WordPress::Dump, :type => :model do
it "should return all authors" do
dump.authors.should have(1).author
end
specify { dump.authors.first.should be_a(Refinery::WordPress::Author) }
end
describe "#posts" do
@ -62,6 +68,8 @@ describe Refinery::WordPress::Dump, :type => :model do
dump.posts.should have(3).posts
end
specify { dump.posts.first.should be_a(Refinery::WordPress::Post) }
it "should return only published posts with only_published=true" do
dump.posts(true).should have(2).posts
end
@ -71,5 +79,7 @@ describe Refinery::WordPress::Dump, :type => :model do
it "should return all attachments" do
dump.attachments.should have(1).attachment
end
specify { dump.attachments.first.should be_a(Refinery::WordPress::Attachment) }
end
end

View File

@ -5,15 +5,15 @@ describe Refinery::WordPress::Page, :type => :model do
let(:page) { test_dump.pages.last }
it { page.title.should == 'About me' }
it { page.content.should include('Lorem ipsum dolor sit') }
it { page.creator.should == 'admin' }
it { page.post_date.should == DateTime.new(2011, 5, 21, 12, 25, 42) }
it { page.post_id.should == 10 }
it { page.parent_id.should == 8 }
specify { page.title.should == 'About me' }
specify { page.content.should include('Lorem ipsum dolor sit') }
specify { page.creator.should == 'admin' }
specify { page.post_date.should == DateTime.new(2011, 5, 21, 12, 25, 42) }
specify { page.post_id.should == 10 }
specify { page.parent_id.should == 8 }
it { page.should == dump.pages.last }
it { page.should_not == dump.pages.first }
specify { page.should == dump.pages.last }
specify { page.should_not == dump.pages.first }
describe "#to_refinery" do
include ::ActionView::Helpers::TagHelper

View File

@ -3,32 +3,32 @@ require 'spec_helper'
describe Refinery::WordPress::Post, :type => :model do
let(:post) { test_dump.posts.last }
it { post.title.should == 'Third blog post' }
it { post.content.should include('Lorem ipsum dolor sit') }
it { post.content_formatted.should include('Lorem ipsum dolor sit') }
it { post.creator.should == 'admin' }
it { post.post_date.should == DateTime.new(2011, 5, 21, 12, 24, 45) }
it { post.post_id.should == 6 }
it { post.parent_id.should == nil }
it { post.status.should == 'publish' }
specify { post.title.should == 'Third blog post' }
specify { post.content.should include('Lorem ipsum dolor sit') }
specify { post.content_formatted.should include('Lorem ipsum dolor sit') }
specify { post.creator.should == 'admin' }
specify { post.post_date.should == DateTime.new(2011, 5, 21, 12, 24, 45) }
specify { post.post_id.should == 6 }
specify { post.parent_id.should == nil }
specify { post.status.should == 'publish' }
it { post.should == test_dump.posts.last }
it { post.should_not == test_dump.posts.first }
specify { post.should == test_dump.posts.last }
specify { post.should_not == test_dump.posts.first }
describe "#categories" do
it { post.categories.should have(1).category }
it { post.categories.first.should == Refinery::WordPress::Category.new('Rant') }
specify { post.categories.should have(1).category }
specify { post.categories.first.should == Refinery::WordPress::Category.new('Rant') }
end
describe "#tags" do
it { post.tags.should have(3).tags }
specify { post.tags.should have(3).tags }
it { post.tags.should include(Refinery::WordPress::Tag.new('css')) }
it { post.tags.should include(Refinery::WordPress::Tag.new('html')) }
it { post.tags.should include(Refinery::WordPress::Tag.new('php')) }
specify { post.tags.should include(Refinery::WordPress::Tag.new('css')) }
specify { post.tags.should include(Refinery::WordPress::Tag.new('html')) }
specify { post.tags.should include(Refinery::WordPress::Tag.new('php')) }
end
it { post.tag_list.should == 'css,html,php' }
specify { post.tag_list.should == 'css,html,php' }
describe "#comments" do
it "should return all attached comments" do
@ -38,14 +38,14 @@ describe Refinery::WordPress::Post, :type => :model do
context "the last comment" do
let(:comment) { post.comments.last }
it { comment.author.should == 'admin' }
it { comment.email.should == 'admin@example.com' }
it { comment.url.should == 'http://www.example.com/' }
it { comment.date.should == DateTime.new(2011, 5, 21, 12, 26, 30) }
it { comment.content.should include('Another one!') }
it { comment.should be_approved }
specify { comment.author.should == 'admin' }
specify { comment.email.should == 'admin@example.com' }
specify { comment.url.should == 'http://www.example.com/' }
specify { comment.date.should == DateTime.new(2011, 5, 21, 12, 26, 30) }
specify { comment.content.should include('Another one!') }
specify { comment.should be_approved }
it { comment.should == post.comments.last }
specify { comment.should == post.comments.last }
describe "#to_refinery" do
before do
@ -79,7 +79,7 @@ describe Refinery::WordPress::Post, :type => :model do
@post = post.to_refinery
end
it { BlogPost.should have(1).record }
specify { BlogPost.should have(1).record }
it "should copy the attributes from Refinery::WordPress::Post" do
@post.title.should == post.title
@ -106,7 +106,7 @@ describe Refinery::WordPress::Post, :type => :model do
end
it { BlogPost.should have(2).records }
specify { BlogPost.should have(2).records }
it "should create the BlogPost with #post_id attached" do
@post.title.should == "#{post.title}-#{post.post_id}"