require 'helper'
class TestRedcarpet < Test::Unit::TestCase
context "redcarpet" do
setup do
@config = {
'redcarpet' => { 'extensions' => ['smart', 'strikethrough', 'filter_html'] },
'markdown' => 'redcarpet'
}
@markdown = Converters::Markdown.new @config
end
should "pass redcarpet options" do
assert_equal "
Some Header
", @markdown.convert('# Some Header #').strip
end
should "pass redcarpet SmartyPants options" do
assert_equal "“smart”
", @markdown.convert('"smart"').strip
end
should "pass redcarpet extensions" do
assert_equal "deleted
", @markdown.convert('~~deleted~~').strip
end
should "pass redcarpet render options" do
assert_equal "bad code not here: i am bad
", @markdown.convert('**bad code not here**: ').strip
end
context "with pygments enabled" do
setup do
@markdown = Converters::Markdown.new @config.merge({ 'highlighter' => 'pygments' })
end
should "render fenced code blocks with syntax highlighting" do
assert_equal "", @markdown.convert(
<<-EOS
```ruby
puts "Hello world"
```
EOS
).strip
end
end
context "with rouge enabled" do
setup do
@markdown = Converters::Markdown.new @config.merge({ 'highlighter' => 'rouge' })
end
should "render fenced code blocks with syntax highlighting" do
assert_equal "", @markdown.convert(
<<-EOS
```ruby
puts "Hello world"
```
EOS
).strip
end
end
context "without any highlighter" do
setup do
@markdown = Converters::Markdown.new @config.merge({ 'highlighter' => nil })
end
should "render fenced code blocks without syntax highlighting" do
assert_equal "", @markdown.convert(
<<-EOS
```ruby
puts "Hello world"
```
EOS
).strip
end
end
end
end