Skip to content

Instantly share code, notes, and snippets.

@darashi
Created January 23, 2011 07:53
Show Gist options
  • Save darashi/791906 to your computer and use it in GitHub Desktop.
Save darashi/791906 to your computer and use it in GitHub Desktop.
require File.join(File.dirname(__FILE__), 'spec_helper')
describe HikiDoc, '(character)' do
(1..6).each do |i|
it "に#{'!'*i}helloを渡すとH#{i}になる" do
HikiDoc.to_xhtml("#{'!'*i}hello").should == "<h#{i}>hello</h#{i}>\n"
end
end
it 'に!!!!!!!helloを渡すと<h6>!hello</h6>になる' do
HikiDoc.to_xhtml('!!!!!!!hello').should == "<h6>!hello</h6>\n"
end
it '' do
HikiDoc.to_xhtml("<<<\n!hoge\n>>>").should == "<pre>!hoge</pre>\n"
end
it do
HikiDoc.to_xhtml("{{myplugin}}").should == "<div class=\"plugin\">{{myplugin}}</div>\n"
end
it do
HikiDoc.to_xhtml("Hello, {{myplugin}}").should == "<p>Hello, <span class=\"plugin\">{{myplugin}}</span></p>\n"
end
it do
lambda { HikiDoc.to_xhtml("\00\0") }.should raise_exception HikiDoc::UnexpectedError
end
it do
HikiDoc.to_xhtml("//{{plugin}} comment").should == ""
end
it do
HikiDoc.to_xhtml("*hoge").should == "<ul>\n<li>hoge</li>\n</ul>\n"
end
it do
HikiDoc.to_xhtml("**hoge").should == "<ul>\n<li><ul>\n<li>hoge</li>\n</ul></li>\n</ul>\n"
end
it do
HikiDoc.to_xhtml("#hoge").should == "<ol>\n<li>hoge</li>\n</ol>\n"
end
it do
HikiDoc.to_xhtml("#*hoge").should == "<ol>\n<li><ol>\n<li>hoge</li>\n</ol></li>\n</ol>\n"
end
it do
HikiDoc.to_xhtml("*").should == "<ul>\n<li></li>\n</ul>\n"
end
it do
HikiDoc.to_xhtml(%Q("")).should == "<blockquote></blockquote>\n"
end
it do
HikiDoc.to_xhtml(%Q(""hoge)).should == "<blockquote><p>hoge</p>\n</blockquote>\n"
end
it do
HikiDoc.to_xhtml(%Q(<<<ruby\ni = 1\nj = 2\n>>>)).should == "<pre class=\"prettyprint\">i = 1\nj = 2</pre>\n"
end
it "with syntax gem" do
HikiDoc.to_xhtml(%Q(<<<\ni = 1\nj = 2\n>>>)).should == "<blockquote><p>hoge</p>\n</blockquote>\n"
end
it "blockquoteとpreを組み合わせる" do
HikiDoc.to_xhtml(%Q(""<<<\nhello\n>>>)).should == "<blockquote><p>hoge</p>\n</blockquote>\n"
end
it do
pending
f = HikiDoc::LineInput.new(StringIO.new('hogehoge'))
output = HikiDoc::HTMLOutput.new(">")
output.reset
hikidoc = HikiDoc.new(output)
hikidoc.send(:compile_paragraph, f)
output.finish.should == "<p>hogehoge</p>\n"
end
it do
pending
f = HikiDoc::LineInput.new(StringIO.new("\00\0"))
output = HikiDoc::HTMLOutput.new(">")
output.reset
hikidoc = HikiDoc.new(output)
hikidoc.instance_eval do
@plugin_blocks = ['testplugin']
end
hikidoc.send(:compile_paragraph, f)
output.finish.should == 'hoge'
end
it 'strip'
end
require File.join(File.dirname(__FILE__), 'spec_helper')
describe HikiDoc do
it '|| を使うとテーブルがボーダーなしで描画できる' do
HikiDoc.to_xhtml('||1||2||').should == "<table>\n<tr><td>1</td><td>2</td></tr>\n</table>\n"
end
it '|| を使うとテーブルが描画できる' do
HikiDoc.to_xhtml('||1||2||').should == "<table>\n<tr><td>1</td><td>2</td></tr>\n</table>\n"
end
it '|| > を使うと行を結合したテーブルが描画できる' do
HikiDoc.to_xhtml('||>1||3||').should == "<table>\n<tr><td colspan=\"2\">1</td><td>3</td></tr>\n</table>\n"
end
end
require 'hikidoc'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment