Sha256: 14cd7ea1ff8b0a5ec29e41a8b68b9a8b80efae1641b090d4af91bf3b46456345

Contents?: true

Size: 1.69 KB

Versions: 50

Compression:

Stored size: 1.69 KB

Contents

require File.dirname(__FILE__) + '/helper'

class TestFilters < Test::Unit::TestCase
  class JekyllFilter
    include Jekyll::Filters
  end

  context "filters" do
    setup do
      @filter = JekyllFilter.new
    end

    should "textilize with simple string" do
      assert_equal "<p>something <strong>really</strong> simple</p>", @filter.textilize("something *really* simple")
    end

    should "convert array to sentence string with no args" do
      assert_equal "", @filter.array_to_sentence_string([])
    end

    should "convert array to sentence string with one arg" do
      assert_equal "1", @filter.array_to_sentence_string([1])
      assert_equal "chunky", @filter.array_to_sentence_string(["chunky"])
    end

    should "convert array to sentence string with two args" do
      assert_equal "1 and 2", @filter.array_to_sentence_string([1, 2])
      assert_equal "chunky and bacon", @filter.array_to_sentence_string(["chunky", "bacon"])
    end

    should "convert array to sentence string with multiple args" do
      assert_equal "1, 2, 3, and 4", @filter.array_to_sentence_string([1, 2, 3, 4])
      assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"])
    end

    should "escape xml with ampersands" do
      assert_equal "AT&amp;T", @filter.xml_escape("AT&T")
      assert_equal "&lt;code&gt;command &amp;lt;filename&amp;gt;&lt;/code&gt;", @filter.xml_escape("<code>command &lt;filename&gt;</code>")
    end

    should "escape space as plus" do
      assert_equal "my+things", @filter.cgi_escape("my things")
    end

    should "escape special characters" do
      assert_equal "hey%21", @filter.cgi_escape("hey!")
    end
  end
end

Version data entries

50 entries across 50 versions & 20 rubygems

Version Path
Chrononaut-hyde-0.1.0 test/test_filters.rb
Chrononaut-hyde-0.1.1 test/test_filters.rb
PerfectlyNormal-jekyll-0.5.1 test/test_filters.rb
PerfectlyNormal-jekyll-0.5.3 test/test_filters.rb
codeslinger-jekyll-0.5.1 test/test_filters.rb
codeslinger-jekyll-0.5.2 test/test_filters.rb
codeslinger-jekyll-0.5.3 test/test_filters.rb
codeslinger-jekyll-0.5.4 test/test_filters.rb
cypher-jekyll-0.5.2 test/test_filters.rb
jroes-jekyll-0.5.1 test/test_filters.rb
jroes-jekyll-0.5.2 test/test_filters.rb
jroes-jekyll-0.5.3 test/test_filters.rb
jroes-jekyll-0.5.4 test/test_filters.rb
mojombo-jekyll-0.5.1 test/test_filters.rb
mojombo-jekyll-0.5.2 test/test_filters.rb
mojombo-jekyll-0.5.3 test/test_filters.rb
nirvdrum-jekyll-0.6.0 test/test_filters.rb
pol-hyde-0.1.2 test/test_filters.rb
pol-hyde-0.1.3 test/test_filters.rb
sixones-jekyll-0.5.2.2 test/test_filters.rb