From 246e75f875be9fa85196501ed05cba4fd0aa9dae Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 12 Feb 2013 23:27:25 -0800 Subject: [PATCH] Test for issue #74 --- spec/block_docs/issue74.md | 37 ++++++++++++++++++++++++++++++ spec/block_spec.rb | 46 +++++++++++++++++++++----------------- 2 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 spec/block_docs/issue74.md diff --git a/spec/block_docs/issue74.md b/spec/block_docs/issue74.md new file mode 100644 index 0000000..2cb5e73 --- /dev/null +++ b/spec/block_docs/issue74.md @@ -0,0 +1,37 @@ +https://github.com/bhollis/maruku/issues/74 +*** Parameters: *** +{} +*** Markdown input: *** +## Cool Title + + + + + +

+ + + +

+ +## Recents Post +*** Output of inspect *** +md_el(:document, [ + md_el(:header, "Cool Title", {:level=>2}), + md_html(""), + md_html("

\n \n \n \n

"), + md_el(:header, "Recents Post", {:level=>2}) + ]) +*** Output of to_html *** +

Cool Title

+

+ + + +

+

Recents Post

diff --git a/spec/block_spec.rb b/spec/block_spec.rb index 14360a7..e76d2d6 100644 --- a/spec/block_spec.rb +++ b/spec/block_spec.rb @@ -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("#{res}") - expdoc = Nokogiri::XML("#{@expected[:to_html]}") + resdoc = Nokogiri::XML("#{res}") + expdoc = Nokogiri::XML("#{expected[:to_html]}") - 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