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

puts "Hello, World!"

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

puts \"Hello, World!\"

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

>

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

#include <test.h>

", RedCloth.new('@[c]#include @').to_html end # See http://jgarber.lighthouseapp.com/projects/13054/tickets/124-code-markup-does-not-allow-brackets. def test_for_redcloth_false_positive require 'coderay/for_redcloth' assert_warning 'CodeRay::Scanners could not load plugin :project; falling back to :text' do assert_equal '

[project]_dff.skjd

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

_dff.skjd

", RedCloth.new('@[ruby]_dff.skjd@').to_html assert_warning 'CodeRay::Scanners could not load plugin :project; falling back to :text' do assert_equal <<-BLOCKCODE.chomp,
[project]_dff.skjd
BLOCKCODE RedCloth.new('bc. [project]_dff.skjd').to_html end end end if defined? RedCloth