condensation 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +35 -0
- data/Rakefile +6 -6
- data/condensation.gemspec +18 -16
- data/lib/condensation.rb +9 -7
- data/lib/condensation/extensions.rb +7 -5
- data/lib/condensation/filters.rb +15 -13
- data/lib/condensation/filters/advance_date_to_next.rb +13 -9
- data/lib/condensation/filters/at_midnight.rb +12 -8
- data/lib/condensation/filters/days_since.rb +10 -6
- data/lib/condensation/filters/days_until.rb +10 -6
- data/lib/condensation/filters/default.rb +2 -2
- data/lib/condensation/filters/hmac_sha256.rb +12 -0
- data/lib/condensation/filters/hyperlink.rb +1 -1
- data/lib/condensation/filters/in_time_zone.rb +6 -6
- data/lib/condensation/filters/md5.rb +12 -0
- data/lib/condensation/filters/replace_inner_html.rb +4 -4
- data/lib/condensation/filters/strip_commas.rb +2 -2
- data/lib/condensation/filters/url_encode.rb +4 -2
- data/lib/condensation/filters/weeks_since.rb +10 -6
- data/lib/condensation/filters/weeks_until.rb +10 -6
- data/lib/condensation/sanitizer.rb +4 -2
- data/lib/condensation/version.rb +1 -1
- data/spec/condensation/filters/advance_date_to_next_spec.rb +39 -39
- data/spec/condensation/filters/at_midnight_spec.rb +29 -29
- data/spec/condensation/filters/days_since_spec.rb +34 -34
- data/spec/condensation/filters/days_until_spec.rb +39 -39
- data/spec/condensation/filters/default_spec.rb +19 -19
- data/spec/condensation/filters/hmac_sha256_spec.rb +21 -0
- data/spec/condensation/filters/hyperlink_spec.rb +23 -23
- data/spec/condensation/filters/in_time_zone_spec.rb +10 -10
- data/spec/condensation/filters/md5_spec.rb +21 -0
- data/spec/condensation/filters/replace_inner_html_spec.rb +10 -10
- data/spec/condensation/filters/strip_commas_spec.rb +10 -10
- data/spec/condensation/filters/timestamp_spec.rb +34 -34
- data/spec/condensation/filters/url_encode_spec.rb +10 -10
- data/spec/condensation/filters/weeks_since_spec.rb +34 -34
- data/spec/condensation/filters/weeks_until_spec.rb +39 -39
- data/spec/condensation/sanitizer_spec.rb +4 -4
- data/spec/condensation_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -2
- metadata +25 -3
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
describe Condensation::Filters::HmacSha256 do
|
4
|
+
def render_with_filter(template, context)
|
5
|
+
template.render(context, filters: [Condensation::Filters::HmacSha256])
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should convert a string into a SHA-256 hash using a hash message authentication code' do
|
9
|
+
template = Liquid::Template.parse("{{ text | hmac_sha256: 'abcd' }}")
|
10
|
+
|
11
|
+
result = render_with_filter(template, 'text' => 'The foo to the bar')
|
12
|
+
result.must_equal 'ea8ffbac691e798b71e9604fd8cbd58a55618f5b29bb1dbd781aac769edb2901'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should handle nil values' do
|
16
|
+
template = Liquid::Template.parse("{{ text | hmac_sha256: '' }}")
|
17
|
+
|
18
|
+
result = render_with_filter(template, 'text' => nil)
|
19
|
+
result.must_equal ''
|
20
|
+
end
|
21
|
+
end
|
@@ -2,49 +2,49 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe Condensation::Filters::Hyperlink do
|
4
4
|
def render_with_filter(template, context)
|
5
|
-
template.render(context, :
|
5
|
+
template.render(context, filters: [Condensation::Filters::Hyperlink])
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
url =
|
10
|
-
template = Liquid::Template.parse(
|
11
|
-
result = render_with_filter(template,
|
8
|
+
it 'should use the URL as the anchor text if none provided' do
|
9
|
+
url = 'http://www.example.com'
|
10
|
+
template = Liquid::Template.parse('{{ url | hyperlink }}')
|
11
|
+
result = render_with_filter(template, 'url' => url)
|
12
12
|
result.must_equal "<a href='#{url}'>#{url}</a>"
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
url =
|
15
|
+
it 'should use the provided anchor text' do
|
16
|
+
url = 'http://www.example.com'
|
17
17
|
template = Liquid::Template.parse("{{ url | hyperlink: 'Click here!' }}")
|
18
|
-
result = render_with_filter(template,
|
18
|
+
result = render_with_filter(template, 'url' => url)
|
19
19
|
result.must_equal "<a href='#{url}'>Click here!</a>"
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
url =
|
24
|
-
escaped =
|
25
|
-
template = Liquid::Template.parse(
|
26
|
-
result = render_with_filter(template,
|
22
|
+
it 'should escape HTML in the URL' do
|
23
|
+
url = '<script>attack.me()</script>'
|
24
|
+
escaped = '<script>attack.me()</script>'
|
25
|
+
template = Liquid::Template.parse('{{ url | hyperlink }}')
|
26
|
+
result = render_with_filter(template, 'url' => url)
|
27
27
|
result.must_equal "<a href='#{escaped}'>#{escaped}</a>"
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
31
|
-
url =
|
32
|
-
text =
|
33
|
-
escaped =
|
30
|
+
it 'should escape HTML in the anchor text' do
|
31
|
+
url = 'http://www.example.com'
|
32
|
+
text = '<script>attack.me()</script>'
|
33
|
+
escaped = '<script>attack.me()</script>'
|
34
34
|
template = Liquid::Template.parse("{{ url | hyperlink: '#{text}' }}")
|
35
|
-
result = render_with_filter(template,
|
35
|
+
result = render_with_filter(template, 'url' => url)
|
36
36
|
result.must_equal "<a href='#{url}'>#{escaped}</a>"
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
40
|
-
template = Liquid::Template.parse(
|
39
|
+
it 'should return empty string if input is nil' do
|
40
|
+
template = Liquid::Template.parse('{{ url | hyperlink }}')
|
41
41
|
result = render_with_filter(template, {})
|
42
|
-
result.must_equal
|
42
|
+
result.must_equal ''
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'should handle numeric input' do
|
46
46
|
template = Liquid::Template.parse("{{ url | hyperlink: 'Bar' }}")
|
47
|
-
result = render_with_filter(template,
|
47
|
+
result = render_with_filter(template, 'url' => 1)
|
48
48
|
result.must_equal "<a href='1'>Bar</a>"
|
49
49
|
end
|
50
50
|
end
|
@@ -2,24 +2,24 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe Condensation::Filters::InTimeZone do
|
4
4
|
def render_with_filter(template, context)
|
5
|
-
template.render(context, :
|
5
|
+
template.render(context, filters: [Condensation::Filters::InTimeZone])
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
created_at =
|
8
|
+
it 'should handle UTC ISO 8601 dates' do
|
9
|
+
created_at = '2015-01-01T10:00:00Z'
|
10
10
|
template = Liquid::Template.parse("{{ created_at | in_time_zone: 'America/Los_Angeles' }}")
|
11
|
-
result = render_with_filter(template,
|
12
|
-
result.must_equal
|
11
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
12
|
+
result.must_equal '2015-01-01 02:00:00 -0800'
|
13
13
|
|
14
14
|
template = Liquid::Template.parse("{{ created_at | in_time_zone: 'Indian/Maldives' }}")
|
15
|
-
result = render_with_filter(template,
|
16
|
-
result.must_equal
|
15
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
16
|
+
result.must_equal '2015-01-01 15:00:00 +0500'
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'should handle Time input' do
|
20
20
|
created_at = Time.utc(2015, 1, 1, 10, 0, 0)
|
21
21
|
template = Liquid::Template.parse("{{ created_at | in_time_zone: 'America/Los_Angeles' }}")
|
22
|
-
result = render_with_filter(template,
|
23
|
-
result.must_equal
|
22
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
23
|
+
result.must_equal '2015-01-01 02:00:00 -0800'
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
describe Condensation::Filters::MD5 do
|
4
|
+
def render_with_filter(template, context)
|
5
|
+
template.render(context, filters: [Condensation::Filters::MD5])
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should return a MD5 hash of the input' do
|
9
|
+
template = Liquid::Template.parse('{{ text | md5 }}')
|
10
|
+
|
11
|
+
result = render_with_filter(template, 'text' => 'The foo to the bar')
|
12
|
+
result.must_equal '9dd755a53b119d3e8d7106aafe7d9d44'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should handle nil values' do
|
16
|
+
template = Liquid::Template.parse('{{ text | md5 }}')
|
17
|
+
|
18
|
+
result = render_with_filter(template, 'text' => nil)
|
19
|
+
result.must_equal ''
|
20
|
+
end
|
21
|
+
end
|
@@ -2,17 +2,17 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe Condensation::Filters::ReplaceInnerHTML do
|
4
4
|
def render_with_filter(template, context)
|
5
|
-
template.render(context, :
|
5
|
+
template.render(context, filters: [Condensation::Filters::ReplaceInnerHTML])
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should replace the inner content of a given HTML tag' do
|
9
9
|
tag = "<a href='http://www.example.com'>Foo</a>"
|
10
10
|
template = Liquid::Template.parse("{{ example_link | replace_inner_html: 'Bar' }}")
|
11
|
-
result = render_with_filter(template,
|
11
|
+
result = render_with_filter(template, 'example_link' => tag)
|
12
12
|
result.must_equal "<a href='http://www.example.com'>Bar</a>"
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'should not alter malformed input' do
|
16
16
|
tags = [
|
17
17
|
"< a href='http://www.example.com'>Foo</a>",
|
18
18
|
"<a href='http://www.example.com'>Foo< /a>",
|
@@ -22,20 +22,20 @@ describe Condensation::Filters::ReplaceInnerHTML do
|
|
22
22
|
|
23
23
|
tags.each do |tag|
|
24
24
|
template = Liquid::Template.parse("{{ example_link | replace_inner_html: 'Bar' }}")
|
25
|
-
result = render_with_filter(template,
|
25
|
+
result = render_with_filter(template, 'example_link' => tag)
|
26
26
|
result.must_equal tag
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
30
|
+
it 'should return empty string if input is nil' do
|
31
31
|
template = Liquid::Template.parse("{{ example_link | replace_inner_html: 'Bar' }}")
|
32
32
|
result = render_with_filter(template, {})
|
33
|
-
result.must_equal
|
33
|
+
result.must_equal ''
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should handle numeric input' do
|
37
37
|
template = Liquid::Template.parse("{{ example_link | replace_inner_html: 'Bar' }}")
|
38
|
-
result = render_with_filter(template,
|
39
|
-
result.must_equal
|
38
|
+
result = render_with_filter(template, 'example_link' => 1)
|
39
|
+
result.must_equal '1'
|
40
40
|
end
|
41
41
|
end
|
@@ -2,20 +2,20 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe Condensation::Filters::StripCommas do
|
4
4
|
def render_with_filter(template, context)
|
5
|
-
template.render(context, :
|
5
|
+
template.render(context, filters: [Condensation::Filters::StripCommas])
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
tag =
|
10
|
-
template = Liquid::Template.parse(
|
11
|
-
result = render_with_filter(template,
|
12
|
-
result.must_equal
|
8
|
+
it 'remove commas' do
|
9
|
+
tag = 'foo, bar, bop'
|
10
|
+
template = Liquid::Template.parse('{{ tag | strip_commas }}')
|
11
|
+
result = render_with_filter(template, 'tag' => tag)
|
12
|
+
result.must_equal 'foo bar bop'
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'should handle nil values' do
|
16
16
|
tag = nil
|
17
|
-
template = Liquid::Template.parse(
|
18
|
-
result = render_with_filter(template,
|
19
|
-
result.must_equal
|
17
|
+
template = Liquid::Template.parse('{{ tags | strip_commas }}')
|
18
|
+
result = render_with_filter(template, 'tag' => tag)
|
19
|
+
result.must_equal ''
|
20
20
|
end
|
21
21
|
end
|
@@ -2,63 +2,63 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe Condensation::Filters::Timestamp do
|
4
4
|
def render_with_filter(template, context)
|
5
|
-
template.render(context, :
|
5
|
+
template.render(context, filters: [Condensation::Filters::Timestamp])
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
created_at =
|
10
|
-
template = Liquid::Template.parse(
|
11
|
-
result = render_with_filter(template,
|
8
|
+
it 'should handle UTC ISO 8601 dates' do
|
9
|
+
created_at = '2015-06-11T10:00:00Z' # a Thursday
|
10
|
+
template = Liquid::Template.parse('{{ created_at | timestamp }}')
|
11
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
12
12
|
result.must_equal Time.parse(created_at).to_i.to_s
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
created_at =
|
17
|
-
template = Liquid::Template.parse(
|
18
|
-
result = render_with_filter(template,
|
15
|
+
it 'should handle non-UTC ISO 8601 dates' do
|
16
|
+
created_at = '2015-06-11T20:00:00-07:00' # a Thursday
|
17
|
+
template = Liquid::Template.parse('{{ created_at | timestamp }}')
|
18
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
19
19
|
result.must_equal Time.parse(created_at).to_i.to_s
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
created_at =
|
24
|
-
template = Liquid::Template.parse(
|
25
|
-
result = render_with_filter(template,
|
22
|
+
it 'should handle YMD formatted dates' do
|
23
|
+
created_at = '2015-06-11' # a Thursday
|
24
|
+
template = Liquid::Template.parse('{{ created_at | timestamp }}')
|
25
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
26
26
|
result.must_equal Time.parse(created_at).to_i.to_s
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'should handle UTC Time input' do
|
30
30
|
created_at = Time.utc(2015, 6, 11, 10, 0, 0) # a Thursday
|
31
|
-
template = Liquid::Template.parse(
|
32
|
-
result = render_with_filter(template,
|
31
|
+
template = Liquid::Template.parse('{{ created_at | timestamp }}')
|
32
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
33
33
|
result.must_equal created_at.to_i.to_s
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
37
|
-
zone = ActiveSupport::TimeZone[
|
36
|
+
it 'should handle non-UTC ActiveSupport::TimeWithZone input' do
|
37
|
+
zone = ActiveSupport::TimeZone['Indian/Maldives'] # UTC+05:00
|
38
38
|
created_at = Time.utc(2015, 6, 11, 10, 0, 0).in_time_zone(zone) # Thu, 11 Jun 2015 15:00:00 MVT +05:00
|
39
|
-
template = Liquid::Template.parse(
|
40
|
-
result = render_with_filter(template,
|
39
|
+
template = Liquid::Template.parse('{{ created_at | timestamp }}')
|
40
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
41
41
|
result.must_equal created_at.to_i.to_s
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
45
|
-
created_at =
|
46
|
-
template = Liquid::Template.parse(
|
47
|
-
result = render_with_filter(template,
|
48
|
-
result.must_equal
|
44
|
+
it 'should render an error given an invalid date' do
|
45
|
+
created_at = 'foo'
|
46
|
+
template = Liquid::Template.parse('{{ created_at | timestamp }}')
|
47
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
48
|
+
result.must_equal 'Liquid error: cannot convert foo to timestamp'
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
52
|
-
created_at =
|
53
|
-
template = Liquid::Template.parse(
|
54
|
-
result = render_with_filter(template,
|
55
|
-
result.must_equal
|
51
|
+
it 'should handle empty string input' do
|
52
|
+
created_at = ''
|
53
|
+
template = Liquid::Template.parse('{{ created_at | timestamp }}')
|
54
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
55
|
+
result.must_equal ''
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
58
|
+
it 'should handle nil input' do
|
59
59
|
created_at = nil
|
60
|
-
template = Liquid::Template.parse(
|
61
|
-
result = render_with_filter(template,
|
62
|
-
result.must_equal
|
60
|
+
template = Liquid::Template.parse('{{ created_at | timestamp }}')
|
61
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
62
|
+
result.must_equal ''
|
63
63
|
end
|
64
64
|
end
|
@@ -2,20 +2,20 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe Condensation::Filters::UrlEncode do
|
4
4
|
def render_with_filter(template, context)
|
5
|
-
template.render(context, :
|
5
|
+
template.render(context, filters: [Condensation::Filters::UrlEncode])
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
email =
|
10
|
-
template = Liquid::Template.parse(
|
11
|
-
result = render_with_filter(template,
|
12
|
-
result.must_equal
|
8
|
+
it 'encode the input' do
|
9
|
+
email = 'derrick+1@example.com'
|
10
|
+
template = Liquid::Template.parse('{{ email | url_encode }}')
|
11
|
+
result = render_with_filter(template, 'email' => email)
|
12
|
+
result.must_equal 'derrick%2B1%40example.com'
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'should handle nil values' do
|
16
16
|
email = nil
|
17
|
-
template = Liquid::Template.parse(
|
18
|
-
result = render_with_filter(template,
|
19
|
-
result.must_equal
|
17
|
+
template = Liquid::Template.parse('{{ email | url_encode }}')
|
18
|
+
result = render_with_filter(template, 'email' => email)
|
19
|
+
result.must_equal ''
|
20
20
|
end
|
21
21
|
end
|
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe Condensation::Filters::WeeksSince do
|
4
4
|
def render_with_filter(template, context)
|
5
|
-
template.render(context, :
|
5
|
+
template.render(context, filters: [Condensation::Filters::WeeksSince])
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:now) do
|
@@ -17,52 +17,52 @@ describe Condensation::Filters::WeeksSince do
|
|
17
17
|
Timecop.return
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
created_at =
|
22
|
-
template = Liquid::Template.parse(
|
23
|
-
result = render_with_filter(template,
|
24
|
-
result.must_equal
|
20
|
+
it 'should handle UTC ISO 8601 dates' do
|
21
|
+
created_at = '2014-05-15T10:00:00Z'
|
22
|
+
template = Liquid::Template.parse('{{ created_at | weeks_since }}')
|
23
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
24
|
+
result.must_equal '2'
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
created_at =
|
29
|
-
template = Liquid::Template.parse(
|
30
|
-
result = render_with_filter(template,
|
31
|
-
result.must_equal
|
27
|
+
it 'should handle non-UTC ISO 8601 dates' do
|
28
|
+
created_at = '2014-05-15T20:00:00-07:00'
|
29
|
+
template = Liquid::Template.parse('{{ created_at | weeks_since }}')
|
30
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
31
|
+
result.must_equal '1'
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it 'should handle Time input' do
|
35
35
|
created_at = Time.utc(2014, 5, 1, 0, 0, 0)
|
36
|
-
template = Liquid::Template.parse(
|
37
|
-
result = render_with_filter(template,
|
38
|
-
result.must_equal
|
36
|
+
template = Liquid::Template.parse('{{ created_at | weeks_since }}')
|
37
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
38
|
+
result.must_equal '4'
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
42
|
-
created_at =
|
43
|
-
template = Liquid::Template.parse(
|
44
|
-
result = render_with_filter(template,
|
45
|
-
result.must_equal
|
41
|
+
it 'should handle malformed dates' do
|
42
|
+
created_at = 'foo'
|
43
|
+
template = Liquid::Template.parse('{{ created_at | weeks_since }}')
|
44
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
45
|
+
result.must_equal ''
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
49
|
-
created_at =
|
50
|
-
template = Liquid::Template.parse(
|
51
|
-
result = render_with_filter(template,
|
52
|
-
result.must_equal
|
48
|
+
it 'should be zero for times in the future' do
|
49
|
+
created_at = '2014-06-01T20:00:00Z'
|
50
|
+
template = Liquid::Template.parse('{{ created_at | weeks_since }}')
|
51
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
52
|
+
result.must_equal '0'
|
53
53
|
end
|
54
54
|
|
55
|
-
it
|
56
|
-
created_at =
|
57
|
-
template = Liquid::Template.parse(
|
58
|
-
result = render_with_filter(template,
|
59
|
-
result.must_equal
|
55
|
+
it 'should handle empty string input' do
|
56
|
+
created_at = ''
|
57
|
+
template = Liquid::Template.parse('{{ created_at | weeks_since }}')
|
58
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
59
|
+
result.must_equal ''
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
62
|
+
it 'should handle nil input' do
|
63
63
|
created_at = nil
|
64
|
-
template = Liquid::Template.parse(
|
65
|
-
result = render_with_filter(template,
|
66
|
-
result.must_equal
|
64
|
+
template = Liquid::Template.parse('{{ created_at | weeks_since }}')
|
65
|
+
result = render_with_filter(template, 'created_at' => created_at)
|
66
|
+
result.must_equal ''
|
67
67
|
end
|
68
68
|
end
|