Skip to content

Commit

Permalink
Test for issue #74
Browse files Browse the repository at this point in the history
  • Loading branch information
bhollis committed Feb 13, 2013
1 parent b53adfa commit 246e75f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 20 deletions.
37 changes: 37 additions & 0 deletions spec/block_docs/issue74.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
https://github.com/bhollis/maruku/issues/74
*** Parameters: ***
{}
*** Markdown input: ***
## Cool Title

<ul>
<li>Cool Text yada yada</li>
<li>ICool Tex 2 yada yada</li>
</ul>



<p id="icons">
<a href="" class="stumbleupon" target="_blank"></a>
<a href="" class="stumbleupon" target="_blank"></a>
<a href="" class="stumbleupon" target="_blank"></a>
</p>

## Recents Post
*** Output of inspect ***
md_el(:document, [
md_el(:header, "Cool Title", {:level=>2}),
md_html("<ul>\n <li>Cool Text yada yada</li>\n <li>ICool Tex 2 yada yada</li>\n</ul>"),
md_html("<p id=\"icons\">\n <a href=\"\" class=\"stumbleupon\" target=\"_blank\"></a>\n <a href=\"\" class=\"stumbleupon\" target=\"_blank\"></a>\n <a href=\"\" class=\"stumbleupon\" target=\"_blank\"></a>\n</p>"),
md_el(:header, "Recents Post", {:level=>2})
])
*** Output of to_html ***
<h2 id="cool_title_1">Cool Title</h2>
<ul><li>Cool Text yada yada</li>
<li>ICool Tex 2 yada yada</li>
</ul><p id="icons">
<a href="" class="stumbleupon" target="_blank"></a>
<a href="" class="stumbleupon" target="_blank"></a>
<a href="" class="stumbleupon" target="_blank"></a>
</p>
<h2 id="recents_post_2">Recents Post</h2>
46 changes: 26 additions & 20 deletions spec/block_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,45 +49,51 @@ def tdiff_equal(node)
params = input.shift
markdown = input.shift
ast = input.shift
expected = METHODS.zip(input).inject({}) {|h, (k, v)| h[k] = v ? v.strip : '' ; h}

before(:each) do
pending "#{comment} - #{md}" if comment.start_with?("PENDING")
pending "#{comment} - #{md}" if comment.start_with?("JRUBY PENDING") && RUBY_PLATFORM == 'java'
$already_warned_itex2mml = false
@doc = Maruku.new(markdown, eval(params))
@expected = METHODS.zip(input).inject({}) {|h, (k, v)| h[k] = v ? v.strip : '' ; h}
end

it "should read in the output of #inspect as the same document" do
Maruku.new.instance_eval("#coding: utf-8\n#{@doc.inspect}").should == @doc
end

it "should produce the given AST" do
@doc.should == Maruku.new.instance_eval(ast)
unless ast.strip.empty?
it "should produce the given AST" do
@doc.should == Maruku.new.instance_eval(ast)
end
end

it "should have the expected to_html output" do
res = @doc.to_html.strip
pending "install itex2mml to run these tests" if $already_warned_itex2mml
unless expected[:to_html].strip.empty?
it "should have the expected to_html output" do
res = @doc.to_html.strip
pending "install itex2mml to run these tests" if $already_warned_itex2mml

resdoc = Nokogiri::XML("<dummy>#{res}</dummy>")
expdoc = Nokogiri::XML("<dummy>#{@expected[:to_html]}</dummy>")
resdoc = Nokogiri::XML("<dummy>#{res}</dummy>")
expdoc = Nokogiri::XML("<dummy>#{expected[:to_html]}</dummy>")

diff = ""
changed = false
expdoc.diff(resdoc) do |change, node|
diff << "#{change} #{node.inspect}\n"
changed = true unless change == ' '
end
diff = ""
changed = false
expdoc.diff(resdoc) do |change, node|
diff << "#{change} #{node.inspect}\n"
changed = true unless change == ' '
end

if changed
res.should == @expected[:to_html]
if changed
res.should == expected[:to_html]
end
end
end

it "should have the expected to_latex output" do
res = @doc.to_latex.strip
res.should == @expected[:to_latex]

unless expected[:to_latex].strip.empty?
it "should have the expected to_latex output" do
res = @doc.to_latex.strip
res.should == expected[:to_latex]
end
end
end
end
Expand Down

0 comments on commit 246e75f

Please sign in to comment.