diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2011-08-19 03:09:35 +0200 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2011-08-19 03:09:35 +0200 |
commit | 75bc5455af8c3c3381066aac3d5fff42264cac6f (patch) | |
tree | 589d2c912ddd94c517eb794bcdf3257f8348f3c0 /test/functional | |
parent | fdd17b6a09efb275238a3baef275465d31452f2a (diff) | |
download | coderay-75bc5455af8c3c3381066aac3d5fff42264cac6f.tar.gz |
Major rewrite of encoders to support IO output; fixed some minor scanner bugs; cleanups; dropped NitroXHTML scanner; improved tests
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/basic.rb | 41 | ||||
-rwxr-xr-x | test/functional/examples.rb | 2 | ||||
-rw-r--r-- | test/functional/for_redcloth.rb | 18 | ||||
-rwxr-xr-x | test/functional/suite.rb | 3 |
4 files changed, 42 insertions, 22 deletions
diff --git a/test/functional/basic.rb b/test/functional/basic.rb index 94e1dd7..8200ae4 100755 --- a/test/functional/basic.rb +++ b/test/functional/basic.rb @@ -1,21 +1,12 @@ # encoding: utf-8 require 'test/unit' +require File.expand_path('../../lib/assert_warning', __FILE__) + +$:.unshift File.expand_path('../../../lib', __FILE__) require 'coderay' class BasicTest < Test::Unit::TestCase - def assert_warning expected_warning - require 'stringio' - oldstderr = $stderr - $stderr = StringIO.new - yield - $stderr.rewind - given_warning = $stderr.read.chomp - assert_equal expected_warning, given_warning - ensure - $stderr = oldstderr - end - def test_version assert_nothing_raised do assert_match(/\A\d\.\d\.\d?\z/, CodeRay::VERSION) @@ -135,7 +126,7 @@ more code # and another comment, in-line. assert_equal 0, CodeRay.scan(rHTML, :html).lines_of_code assert_equal 0, CodeRay.scan(rHTML, :php).lines_of_code assert_equal 0, CodeRay.scan(rHTML, :yaml).lines_of_code - assert_equal 4, CodeRay.scan(rHTML, :rhtml).lines_of_code + assert_equal 4, CodeRay.scan(rHTML, :erb).lines_of_code end def test_rubygems_not_loaded @@ -243,8 +234,28 @@ more code # and another comment, in-line. scanner = CodeRay::Scanners::Plain.new "foo\nbär+quux" assert_equal 0, scanner.pos assert_equal 1, scanner.line - assert_equal 0, scanner.column - scanner.scan(/foo\nbär/) + assert_equal 1, scanner.column + scanner.scan(/foo/) + assert_equal 3, scanner.pos + assert_equal 1, scanner.line + assert_equal 4, scanner.column + scanner.scan(/\n/) + assert_equal 4, scanner.pos + assert_equal 2, scanner.line + assert_equal 1, scanner.column + scanner.scan(/b/) + assert_equal 5, scanner.pos + assert_equal 2, scanner.line + assert_equal 2, scanner.column + scanner.scan(/a/) + assert_equal 5, scanner.pos + assert_equal 2, scanner.line + assert_equal 2, scanner.column + scanner.scan(/ä/) + assert_equal 7, scanner.pos + assert_equal 2, scanner.line + assert_equal 4, scanner.column + scanner.scan(/r/) assert_equal 8, scanner.pos assert_equal 2, scanner.line assert_equal 5, scanner.column diff --git a/test/functional/examples.rb b/test/functional/examples.rb index f80c90c..3de8be5 100755 --- a/test/functional/examples.rb +++ b/test/functional/examples.rb @@ -1,4 +1,6 @@ require 'test/unit' + +$:.unshift File.expand_path('../../../lib', __FILE__) require 'coderay' class ExamplesTest < Test::Unit::TestCase diff --git a/test/functional/for_redcloth.rb b/test/functional/for_redcloth.rb index 8c6491d..3c45eec 100644 --- a/test/functional/for_redcloth.rb +++ b/test/functional/for_redcloth.rb @@ -1,5 +1,7 @@ require 'test/unit' -$:.unshift 'lib' +require File.expand_path('../../lib/assert_warning', __FILE__) + +$:.unshift File.expand_path('../../../lib', __FILE__) require 'coderay' begin @@ -64,15 +66,19 @@ class BasicTest < Test::Unit::TestCase # 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_equal '<p><code>[project]_dff.skjd</code></p>', - RedCloth.new('@[project]_dff.skjd@').to_html + assert_warning 'CodeRay::Scanners could not load plugin :project; falling back to :text' do + assert_equal '<p><code>[project]_dff.skjd</code></p>', + RedCloth.new('@[project]_dff.skjd@').to_html + end # false positive, but expected behavior / known issue assert_equal "<p><span lang=\"ruby\" class=\"CodeRay\">_dff.skjd</span></p>", RedCloth.new('@[ruby]_dff.skjd@').to_html - assert_equal <<-BLOCKCODE.chomp, + assert_warning 'CodeRay::Scanners could not load plugin :project; falling back to :text' do + assert_equal <<-BLOCKCODE.chomp, <pre><code>[project]_dff.skjd</code></pre> - BLOCKCODE - RedCloth.new('bc. [project]_dff.skjd').to_html + BLOCKCODE + RedCloth.new('bc. [project]_dff.skjd').to_html + end end end if defined? RedCloth
\ No newline at end of file diff --git a/test/functional/suite.rb b/test/functional/suite.rb index 6d795c0..5490f98 100755 --- a/test/functional/suite.rb +++ b/test/functional/suite.rb @@ -1,5 +1,6 @@ require 'test/unit' -$:.unshift 'lib' + +$:.unshift File.expand_path('../../../lib', __FILE__) require 'coderay' mydir = File.dirname(__FILE__) |