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

puts "Hello, World!"

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

puts \"Hello, World!\"

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

>

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

#include <test.h>

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

[project]_dff.skjd

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

_dff.skjd

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