More refactorings and specs
This commit is contained in:
4
spec/fixtures/wordpress_dump.xml
vendored
4
spec/fixtures/wordpress_dump.xml
vendored
@@ -62,7 +62,7 @@
|
||||
<wp:comment_status>open</wp:comment_status>
|
||||
<wp:ping_status>open</wp:ping_status>
|
||||
<wp:post_name>hello-world</wp:post_name>
|
||||
<wp:status>publish</wp:status>
|
||||
<wp:status>draft</wp:status>
|
||||
<wp:post_parent>0</wp:post_parent>
|
||||
<wp:menu_order>0</wp:menu_order>
|
||||
<wp:post_type>post</wp:post_type>
|
||||
@@ -107,7 +107,7 @@ As a new WordPress user, you should go to <a href="http://localhost/wordpress/wp
|
||||
<wp:comment_status>open</wp:comment_status>
|
||||
<wp:ping_status>open</wp:ping_status>
|
||||
<wp:post_name>sample-page</wp:post_name>
|
||||
<wp:status>publish</wp:status>
|
||||
<wp:status>draft</wp:status>
|
||||
<wp:post_parent>0</wp:post_parent>
|
||||
<wp:menu_order>0</wp:menu_order>
|
||||
<wp:post_type>page</wp:post_type>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Refinery::WordPress::Dump, :type => :model do
|
||||
let(:file_name) { File.realpath(File.join(File.dirname(__FILE__), '../../fixtures/wordpress_dump.xml')) }
|
||||
let(:dump) { Refinery::WordPress::Dump.new(file_name) }
|
||||
let(:dump) { test_dump }
|
||||
|
||||
it "should create a Dump object given a xml file" do
|
||||
dump.should be_a Refinery::WordPress::Dump
|
||||
@@ -46,6 +45,10 @@ describe Refinery::WordPress::Dump, :type => :model do
|
||||
it "should return all included pages" do
|
||||
dump.pages.should have(3).pages
|
||||
end
|
||||
|
||||
it "should return only published pages with only_published=true" do
|
||||
dump.pages(true).should have(2).pages
|
||||
end
|
||||
end
|
||||
|
||||
describe "#authors" do
|
||||
@@ -58,5 +61,9 @@ describe Refinery::WordPress::Dump, :type => :model do
|
||||
it "should return all posts" do
|
||||
dump.posts.should have(3).posts
|
||||
end
|
||||
|
||||
it "should return only published posts with only_published=true" do
|
||||
dump.posts(true).should have(2).posts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,5 +39,67 @@ describe Refinery::WordPress::Page, :type => :model do
|
||||
@page.parts.first.body.should == "#{simple_format(page.content)}"
|
||||
end
|
||||
end
|
||||
|
||||
describe "#format_paragraphs" do
|
||||
let(:sample_text) do
|
||||
text = <<-EOT
|
||||
This is sample text.
|
||||
|
||||
Even more text.
|
||||
But this time no paragraph.
|
||||
EOT
|
||||
end
|
||||
|
||||
before do
|
||||
@result = page.send(:format_paragraphs, sample_text)
|
||||
end
|
||||
|
||||
it "should add paragraphs to the sample text" do
|
||||
@result.should include('<p>')
|
||||
@result.should include('</p>')
|
||||
end
|
||||
end
|
||||
|
||||
describe "#format_syntax_highlighter" do
|
||||
let(:sample_text) do
|
||||
text = <<-EOT
|
||||
This is sample text.
|
||||
|
||||
[ruby]
|
||||
p "this is ruby code"
|
||||
[/ruby]
|
||||
|
||||
This is more sample text.
|
||||
EOT
|
||||
end
|
||||
|
||||
before do
|
||||
@result = page.send(:format_syntax_highlighter, sample_text)
|
||||
end
|
||||
|
||||
it "should reformat the [ruby] tag to a pre with correct class" do
|
||||
@result.should match(/<pre class="brush: ruby">/)
|
||||
@result.should include('</pre>')
|
||||
end
|
||||
|
||||
context "without correct code tags" do
|
||||
let(:sample_text) do
|
||||
text = <<-EOT
|
||||
This is sample text.
|
||||
|
||||
[ruby]
|
||||
p "this is ruby code"
|
||||
[/php]
|
||||
|
||||
This is more sample text.
|
||||
EOT
|
||||
end
|
||||
|
||||
it "should not reformat the [ruby] tag" do
|
||||
@result.should == sample_text
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Refinery::WordPress::Post, :type => :model do
|
||||
let(:post) { test_dump.posts.last }
|
||||
let(:post) { test_dump.posts.last }
|
||||
|
||||
it { post.title.should == 'Third blog post' }
|
||||
it { post.content.should include('Lorem ipsum dolor sit') }
|
||||
|
||||
Reference in New Issue
Block a user