test/unit/string_extensions_test.rb in stringex-2.5.2 vs test/unit/string_extensions_test.rb in stringex-2.6.0

- old
+ new

@@ -1,6 +1,6 @@ -# encoding: UTF-8 +# encoding: utf-8 require "test_helper" require "stringex" if RUBY_VERSION.to_f < 1.9 @@ -116,10 +116,14 @@ def test_to_url_with_alternate_whitespace_replacement assert_equal "under_scores", "Under Scores".to_url(:replace_whitespace_with => "_") end + def test_to_url_with_alternate_whitespace_replacement_and_with_limit_and_with_truncate_words_disabled + assert_equal "i_am_much", "I am much too long".to_url(:replace_whitespace_with => "_", :limit => 12, :truncate_words => false) + end + def test_remove_formatting { "<p>This has 100% too much <em>formatting</em></p>" => "This has 100 percent too much formatting", "Tea &amp; crumpets &amp; <strong>cr&ecirc;pes</strong> for me!" => @@ -275,9 +279,17 @@ remove_method :to_ascii def to_ascii old_to_ascii end + end + end + + def test_remove_nonreadable_characters + cases = { "Jörg Immendor\u0014. Les théâtres" => "jorg-immendor-les-theatres", + } + cases.each do |plain, converted| + assert_equal converted, plain.to_url end end if defined?(RedCloth) def test_to_html