2011-06-01 19:11:57 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-03-04 22:47:53 +00:00
|
|
|
describe WordPressImport::Dump, :type => :model do
|
2011-06-05 11:38:39 +00:00
|
|
|
let(:dump) { test_dump }
|
2011-06-01 19:11:57 +00:00
|
|
|
|
|
|
|
it "should create a Dump object given a xml file" do
|
2014-03-04 22:47:53 +00:00
|
|
|
dump.should be_a WordPressImport::Dump
|
2011-06-01 19:11:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should include a Nokogiri::XML object" do
|
|
|
|
dump.doc.should be_a Nokogiri::XML::Document
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#tags" do
|
|
|
|
let(:tags) do
|
2014-03-04 22:47:53 +00:00
|
|
|
[ WordPressImport::Tag.new('css'), WordPressImport::Tag.new('html'),
|
|
|
|
WordPressImport::Tag.new('php'), WordPressImport::Tag.new('ruby')]
|
2011-06-01 19:11:57 +00:00
|
|
|
end
|
|
|
|
|
2011-06-05 11:09:06 +00:00
|
|
|
specify { dump.tags.count == 4 }
|
2014-03-04 22:47:53 +00:00
|
|
|
specify { dump.tags.first.should be_a(WordPressImport::Tag) }
|
2011-06-05 11:09:06 +00:00
|
|
|
|
2011-06-01 19:11:57 +00:00
|
|
|
it "should return all included tags" do
|
|
|
|
tags.each do |tag|
|
|
|
|
dump.tags.should include(tag)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#categories" do
|
|
|
|
let(:categories) do
|
2014-03-04 22:47:53 +00:00
|
|
|
[ WordPressImport::Category.new('Rant'), WordPressImport::Category.new('Tutorials'),
|
|
|
|
WordPressImport::Category.new('Uncategorized') ]
|
2011-06-01 19:11:57 +00:00
|
|
|
end
|
|
|
|
|
2011-06-05 11:09:06 +00:00
|
|
|
specify { dump.categories.count == 4 }
|
2014-03-04 22:47:53 +00:00
|
|
|
specify { dump.categories.first.should be_a(WordPressImport::Category) }
|
2011-06-05 11:09:06 +00:00
|
|
|
|
2011-06-01 19:11:57 +00:00
|
|
|
it "should return all included categories" do
|
|
|
|
categories.each do |cat|
|
|
|
|
dump.categories.should include(cat)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#pages" do
|
|
|
|
it "should return all included pages" do
|
|
|
|
dump.pages.should have(3).pages
|
|
|
|
end
|
2011-06-05 11:38:39 +00:00
|
|
|
|
2014-03-04 22:47:53 +00:00
|
|
|
specify { dump.pages.first.should be_a(WordPressImport::Page) }
|
2011-06-05 15:55:00 +00:00
|
|
|
|
2011-06-05 11:38:39 +00:00
|
|
|
it "should return only published pages with only_published=true" do
|
|
|
|
dump.pages(true).should have(2).pages
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "#authors" do
|
|
|
|
it "should return all authors" do
|
|
|
|
dump.authors.should have(1).author
|
|
|
|
end
|
2011-06-05 15:55:00 +00:00
|
|
|
|
2014-03-04 22:47:53 +00:00
|
|
|
specify { dump.authors.first.should be_a(WordPressImport::Author) }
|
2011-06-01 19:11:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "#posts" do
|
|
|
|
it "should return all posts" do
|
|
|
|
dump.posts.should have(3).posts
|
|
|
|
end
|
2011-06-05 11:38:39 +00:00
|
|
|
|
2014-03-04 22:47:53 +00:00
|
|
|
specify { dump.posts.first.should be_a(WordPressImport::Post) }
|
2011-06-05 15:55:00 +00:00
|
|
|
|
2011-06-05 11:38:39 +00:00
|
|
|
it "should return only published posts with only_published=true" do
|
|
|
|
dump.posts(true).should have(2).posts
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
end
|
2011-06-05 15:43:30 +00:00
|
|
|
|
|
|
|
describe "#attachments" do
|
|
|
|
it "should return all attachments" do
|
2011-06-06 17:39:27 +00:00
|
|
|
dump.attachments.should have(2).attachments
|
2011-06-05 15:43:30 +00:00
|
|
|
end
|
2011-06-05 15:55:00 +00:00
|
|
|
|
2014-03-04 22:47:53 +00:00
|
|
|
specify { dump.attachments.first.should be_a(WordPressImport::Attachment) }
|
2011-06-05 15:43:30 +00:00
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
end
|