From c999deb1e932b3290561a58923603eb87809c8df Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Mon, 13 Jun 2016 01:03:13 +0200 Subject: fix tests --- test/functional/basic.rb | 9 +++++++-- test/functional/examples.rb | 14 +++++++++----- test/functional/for_redcloth.rb | 8 ++++++-- test/unit/html.rb | 10 +++++++--- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/test/functional/basic.rb b/test/functional/basic.rb index 917b5ff..8554a78 100755 --- a/test/functional/basic.rb +++ b/test/functional/basic.rb @@ -7,6 +7,10 @@ require 'coderay' class BasicTest < Test::Unit::TestCase + def normalize_html html + html.gsub(''', "'").gsub('"', '"') + end + def test_version assert_nothing_raised do assert_match(/\A\d\.\d\.\d?\z/, CodeRay::VERSION) @@ -50,7 +54,7 @@ class BasicTest < Test::Unit::TestCase 'Hello, World!"' def test_simple_highlight assert_nothing_raised do - assert_equal RUBY_TEST_HTML, CodeRay.scan(RUBY_TEST_CODE, :ruby).html + assert_equal RUBY_TEST_HTML, normalize_html(CodeRay.scan(RUBY_TEST_CODE, :ruby).html) end end @@ -75,7 +79,8 @@ class BasicTest < Test::Unit::TestCase end def test_highlight_file - assert_match "require 'test/unit'\n", CodeRay.highlight_file(__FILE__) + assert_match "require 'test/unit'\n", + normalize_html(CodeRay.highlight_file(__FILE__)) end def test_duo diff --git a/test/functional/examples.rb b/test/functional/examples.rb index 8da4fc7..49337cb 100755 --- a/test/functional/examples.rb +++ b/test/functional/examples.rb @@ -5,10 +5,14 @@ require 'coderay' class ExamplesTest < Test::Unit::TestCase + def normalize_html html + html.gsub(''', "'").gsub('"', '"') + end + def test_examples # output as HTML div (using inline CSS styles) div = CodeRay.scan('puts "Hello, world!"', :ruby).div - assert_equal <<-DIV, div + assert_equal <<-DIV, normalize_html(div)
puts "Hello, world!"
@@ -20,7 +24,7 @@ class ExamplesTest < Test::Unit::TestCase puts 'Hello, world!' end CODE - assert_equal <<-DIV, div + assert_equal <<-DIV, normalize_html(div)
1
 2
@@ -34,7 +38,7 @@ end
     
     # output as standalone HTML page (using CSS classes)
     page = CodeRay.scan('puts "Hello, world!"', :ruby).page
-    assert_match <<-PAGE, page
+    assert_match <<-PAGE, normalize_html(page)
 
 
 
@@ -90,7 +94,7 @@ Token Types (7):
     
     # produce a HTML div, but with CSS classes
     div = tokens.div(:css => :class)
-    assert_equal <<-DIV, div
+    assert_equal <<-DIV, normalize_html(div)
 
{ "just": "an", "example": 42 }
@@ -119,7 +123,7 @@ Token Types (7): # re-using scanner and encoder ruby_highlighter = CodeRay::Duo[:ruby, :div] div = ruby_highlighter.encode('puts "Hello, world!"') - assert_equal <<-DIV, div + assert_equal <<-DIV, normalize_html(div)
puts "Hello, world!"
diff --git a/test/functional/for_redcloth.rb b/test/functional/for_redcloth.rb index eebf19c..50fc50c 100644 --- a/test/functional/for_redcloth.rb +++ b/test/functional/for_redcloth.rb @@ -14,16 +14,20 @@ end class BasicTest < Test::Unit::TestCase + def normalize_html html + html.gsub(''', "'").gsub('"', '"') + end + def test_for_redcloth require 'coderay/for_redcloth' assert_equal "

puts \"Hello, World!\"

", - RedCloth.new('@[ruby]puts "Hello, World!"@').to_html + normalize_html(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 + normalize_html(RedCloth.new('bc[ruby]. puts "Hello, World!"').to_html) end def test_for_redcloth_no_lang diff --git a/test/unit/html.rb b/test/unit/html.rb index 750b6c9..9175a4f 100644 --- a/test/unit/html.rb +++ b/test/unit/html.rb @@ -3,6 +3,10 @@ require 'coderay' class HtmlTest < Test::Unit::TestCase + def normalize_html html + html.gsub(''', "'").gsub('"', '"') + end + def test_break_lines_option snippets = {} @@ -95,9 +99,9 @@ public class Test { for lang, code in snippets tokens = CodeRay.scan code[:in], lang - assert_equal code[:expected_with_option_off], tokens.html - assert_equal code[:expected_with_option_off], tokens.html(:break_lines => false) - assert_equal code[:expected_with_option_on], tokens.html(:break_lines => true) + assert_equal code[:expected_with_option_off], normalize_html(tokens.html) + assert_equal code[:expected_with_option_off], normalize_html(tokens.html(:break_lines => false)) + assert_equal code[:expected_with_option_on], normalize_html(tokens.html(:break_lines => true)) end end end -- cgit v1.2.1