require 'simplecov' require 'simplecov-rcov' SimpleCov.start SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter require 'test_helper' class GovspeakTest < Test::Unit::TestCase test "simple smoke-test" do rendered = Govspeak::Document.new("*this is markdown*").to_html assert_equal "
this is markdown
\n", rendered end test "simple smoke-test for simplified API" do rendered = Govspeak::Document.to_html("*this is markdown*") assert_equal "this is markdown
\n", rendered end test "simple block extension" do rendered = Govspeak::Document.new("this \n{::reverse}\n*is*\n{:/reverse}\n markdown").to_html assert_equal "this
\n\nsi
\n\nmarkdown
\n", rendered end test "extracts headers with text, level and generated id" do document = Govspeak::Document.new %{ # Big title ### Small subtitle ## Medium title } assert_equal [ Govspeak::Header.new('Big title', 1, 'big-title'), Govspeak::Header.new('Small subtitle', 3, 'small-subtitle'), Govspeak::Header.new('Medium title', 2, 'medium-title') ], document.headers end test "extracts different ids for duplicate headers" do document = Govspeak::Document.new("## Duplicate header\n\n## Duplicate header") assert_equal [ Govspeak::Header.new('Duplicate header', 2, 'duplicate-header'), Govspeak::Header.new('Duplicate header', 2, 'duplicate-header-1') ], document.headers end test "govspark extensions" do markdown_regression_tests = [ { input: "^ I am very informational ^", output: %{I am very informational
The following is very informational
I am very informational
I am very informational
I am very important
} }, { input: "The following is very important @ I am very important @", output: %{The following is very important
I am very important
} }, { input: "% I am very helpful %", output: %{I am very helpful
The following is very helpful
I am very helpful
I am very helpful
I am very helpful
This is a link isn’t it?
' }, { input: "This is a [link with an at sign in it](http://www.google.com/@dg/@this) isn't it?", output: 'This is a link with an at sign in it isn’t it?
' }, { input: "HTML *[HTML]: Hyper Text Markup Language", output: %{HTML
} }, { input: "x[a link](http://rubyforge.org)x", output: '' }, { input: "$! rainbow $!", output: %{rainbow
help, send cake
street
road
help
\ncan you tell me how to get to…
zippy
\nbungle
\ngeorge
\nThis section applies to Scotland
I am very devolved and very scottish
Message with a link
} assert_equal output, Govspeak::Document.new(input).to_html end end