Chris@210: require 'test/unit' Chris@210: $:.unshift 'lib' Chris@210: require 'coderay' Chris@210: Chris@210: begin Chris@210: require 'rubygems' unless defined? Gem Chris@210: gem 'RedCloth', '>= 4.0.3' rescue nil Chris@210: require 'redcloth' Chris@210: rescue LoadError Chris@210: warn 'RedCloth not found - skipping for_redcloth tests.' Chris@210: end Chris@210: Chris@210: class BasicTest < Test::Unit::TestCase Chris@210: Chris@210: def test_for_redcloth Chris@210: require 'coderay/for_redcloth' Chris@210: assert_equal "

puts "Hello, World!"

", Chris@210: RedCloth.new('@[ruby]puts "Hello, World!"@').to_html Chris@210: assert_equal <<-BLOCKCODE.chomp, Chris@210:
Chris@210:
puts "Hello, World!"
Chris@210:
Chris@210: BLOCKCODE Chris@210: RedCloth.new('bc[ruby]. puts "Hello, World!"').to_html Chris@210: end Chris@210: Chris@210: def test_for_redcloth_no_lang Chris@210: require 'coderay/for_redcloth' Chris@210: assert_equal "

puts \"Hello, World!\"

", Chris@210: RedCloth.new('@puts "Hello, World!"@').to_html Chris@210: assert_equal <<-BLOCKCODE.chomp, Chris@210:
puts \"Hello, World!\"
Chris@210: BLOCKCODE Chris@210: RedCloth.new('bc. puts "Hello, World!"').to_html Chris@210: end Chris@210: Chris@210: def test_for_redcloth_style Chris@210: require 'coderay/for_redcloth' Chris@210: assert_equal <<-BLOCKCODE.chomp, Chris@210:
puts \"Hello, World!\"
Chris@210: BLOCKCODE Chris@210: RedCloth.new('bc{color: red}. puts "Hello, World!"').to_html Chris@210: end Chris@210: Chris@210: def test_for_redcloth_escapes Chris@210: require 'coderay/for_redcloth' Chris@210: assert_equal '

>

', Chris@210: RedCloth.new('@[ruby]>@').to_html Chris@210: assert_equal <<-BLOCKCODE.chomp, Chris@210:
Chris@210:
&
Chris@210:
Chris@210: BLOCKCODE Chris@210: RedCloth.new('bc[ruby]. &').to_html Chris@210: end Chris@210: Chris@210: def test_for_redcloth_escapes2 Chris@210: require 'coderay/for_redcloth' Chris@210: assert_equal "

#include <test.h>

", Chris@210: RedCloth.new('@[c]#include @').to_html Chris@210: end Chris@210: Chris@210: # See http://jgarber.lighthouseapp.com/projects/13054/tickets/124-code-markup-does-not-allow-brackets. Chris@210: def test_for_redcloth_false_positive Chris@210: require 'coderay/for_redcloth' Chris@210: assert_equal '

[project]_dff.skjd

', Chris@210: RedCloth.new('@[project]_dff.skjd@').to_html Chris@210: # false positive, but expected behavior / known issue Chris@210: assert_equal "

_dff.skjd

", Chris@210: RedCloth.new('@[ruby]_dff.skjd@').to_html Chris@210: assert_equal <<-BLOCKCODE.chomp, Chris@210:
[project]_dff.skjd
Chris@210: BLOCKCODE Chris@210: RedCloth.new('bc. [project]_dff.skjd').to_html Chris@210: end Chris@210: Chris@210: end if defined? RedCloth