forked from jekyll/jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_filters.rb
53 lines (42 loc) · 1.79 KB
/
test_filters.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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&T", @filter.xml_escape("AT&T")
assert_equal "<code>command &lt;filename&gt;</code>", @filter.xml_escape("<code>command <filename></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
should "escape space as %20" do
assert_equal "my%20things", @filter.uri_escape("my things")
end
end
end