condensation 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.rubocop_todo.yml +35 -0
  4. data/Rakefile +6 -6
  5. data/condensation.gemspec +18 -16
  6. data/lib/condensation.rb +9 -7
  7. data/lib/condensation/extensions.rb +7 -5
  8. data/lib/condensation/filters.rb +15 -13
  9. data/lib/condensation/filters/advance_date_to_next.rb +13 -9
  10. data/lib/condensation/filters/at_midnight.rb +12 -8
  11. data/lib/condensation/filters/days_since.rb +10 -6
  12. data/lib/condensation/filters/days_until.rb +10 -6
  13. data/lib/condensation/filters/default.rb +2 -2
  14. data/lib/condensation/filters/hmac_sha256.rb +12 -0
  15. data/lib/condensation/filters/hyperlink.rb +1 -1
  16. data/lib/condensation/filters/in_time_zone.rb +6 -6
  17. data/lib/condensation/filters/md5.rb +12 -0
  18. data/lib/condensation/filters/replace_inner_html.rb +4 -4
  19. data/lib/condensation/filters/strip_commas.rb +2 -2
  20. data/lib/condensation/filters/url_encode.rb +4 -2
  21. data/lib/condensation/filters/weeks_since.rb +10 -6
  22. data/lib/condensation/filters/weeks_until.rb +10 -6
  23. data/lib/condensation/sanitizer.rb +4 -2
  24. data/lib/condensation/version.rb +1 -1
  25. data/spec/condensation/filters/advance_date_to_next_spec.rb +39 -39
  26. data/spec/condensation/filters/at_midnight_spec.rb +29 -29
  27. data/spec/condensation/filters/days_since_spec.rb +34 -34
  28. data/spec/condensation/filters/days_until_spec.rb +39 -39
  29. data/spec/condensation/filters/default_spec.rb +19 -19
  30. data/spec/condensation/filters/hmac_sha256_spec.rb +21 -0
  31. data/spec/condensation/filters/hyperlink_spec.rb +23 -23
  32. data/spec/condensation/filters/in_time_zone_spec.rb +10 -10
  33. data/spec/condensation/filters/md5_spec.rb +21 -0
  34. data/spec/condensation/filters/replace_inner_html_spec.rb +10 -10
  35. data/spec/condensation/filters/strip_commas_spec.rb +10 -10
  36. data/spec/condensation/filters/timestamp_spec.rb +34 -34
  37. data/spec/condensation/filters/url_encode_spec.rb +10 -10
  38. data/spec/condensation/filters/weeks_since_spec.rb +34 -34
  39. data/spec/condensation/filters/weeks_until_spec.rb +39 -39
  40. data/spec/condensation/sanitizer_spec.rb +4 -4
  41. data/spec/condensation_spec.rb +1 -1
  42. data/spec/spec_helper.rb +1 -2
  43. metadata +25 -3
@@ -3,16 +3,20 @@ require 'time'
3
3
  module Condensation
4
4
  module Filters
5
5
  module WeeksUntil
6
- SECONDS_PER_WEEK = 86400 * 7
6
+ SECONDS_PER_WEEK = 86_400 * 7
7
7
 
8
8
  def weeks_until(input)
9
9
  return if input.nil?
10
10
 
11
- if input.is_a?(Time)
12
- value = input
13
- else
14
- value = Time.parse(input) rescue nil
15
- end
11
+ value = if input.is_a?(Time)
12
+ input
13
+ else
14
+ begin
15
+ Time.parse(input)
16
+ rescue
17
+ nil
18
+ end
19
+ end
16
20
 
17
21
  return unless value.is_a?(Time)
18
22
 
@@ -7,7 +7,9 @@ module Condensation
7
7
  end
8
8
 
9
9
  def escape_html
10
- CGI.escapeHTML(input) rescue input
10
+ CGI.escapeHTML(input)
11
+ rescue
12
+ input
11
13
  end
12
14
  end
13
- end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Condensation
2
- VERSION = "1.5.0"
2
+ VERSION = '1.6.0'.freeze
3
3
  end
@@ -2,14 +2,14 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  describe Condensation::Filters::AdvanceDateToNext do
4
4
  def render_with_filter(template, context)
5
- template.render(context, :filters => [Condensation::Filters::AdvanceDateToNext])
5
+ template.render(context, filters: [Condensation::Filters::AdvanceDateToNext])
6
6
  end
7
7
 
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 | advance_date_to_next: \"Saturday\" }}")
11
- result = render_with_filter(template, { "created_at" => created_at })
12
- result.must_equal "2015-06-13 10:00:00 UTC"
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 | advance_date_to_next: "Saturday" }}')
11
+ result = render_with_filter(template, 'created_at' => created_at)
12
+ result.must_equal '2015-06-13 10:00:00 UTC'
13
13
  end
14
14
 
15
15
  # it "should handle non-UTC ISO 8601 dates" do
@@ -26,53 +26,53 @@ describe Condensation::Filters::AdvanceDateToNext do
26
26
  # result.must_equal "2015-06-13 00:00:00 UTC"
27
27
  # end
28
28
 
29
- it "should handle UTC Time input" do
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("{{ created_at | advance_date_to_next: \"Saturday\" }}")
32
- result = render_with_filter(template, { "created_at" => created_at })
33
- result.must_equal "2015-06-13 10:00:00 UTC"
31
+ template = Liquid::Template.parse('{{ created_at | advance_date_to_next: "Saturday" }}')
32
+ result = render_with_filter(template, 'created_at' => created_at)
33
+ result.must_equal '2015-06-13 10:00:00 UTC'
34
34
  end
35
35
 
36
- it "should handle non-UTC ActiveSupport::TimeWithZone input" do
37
- zone = ActiveSupport::TimeZone["Indian/Maldives"] # UTC+05:00
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("{{ created_at | advance_date_to_next: \"Saturday\" }}")
40
- result = render_with_filter(template, { "created_at" => created_at })
41
- result.must_equal "2015-06-13 15:00:00 +0500"
39
+ template = Liquid::Template.parse('{{ created_at | advance_date_to_next: "Saturday" }}')
40
+ result = render_with_filter(template, 'created_at' => created_at)
41
+ result.must_equal '2015-06-13 15:00:00 +0500'
42
42
  end
43
43
 
44
- it "never return the same day" do
45
- created_at = "2015-06-11T10:00:00Z" # a Thursday
46
- template = Liquid::Template.parse("{{ created_at | advance_date_to_next: \"Thursday\" }}")
47
- result = render_with_filter(template, { "created_at" => created_at })
48
- result.must_equal "2015-06-18 10:00:00 UTC"
44
+ it 'never return the same day' do
45
+ created_at = '2015-06-11T10:00:00Z' # a Thursday
46
+ template = Liquid::Template.parse('{{ created_at | advance_date_to_next: "Thursday" }}')
47
+ result = render_with_filter(template, 'created_at' => created_at)
48
+ result.must_equal '2015-06-18 10:00:00 UTC'
49
49
  end
50
50
 
51
- it "should handle malformed dates" do
52
- created_at = "foo"
53
- template = Liquid::Template.parse("{{ created_at | advance_date_to_next: \"Saturday\" }}")
54
- result = render_with_filter(template, { "created_at" => created_at })
55
- result.must_equal "foo"
51
+ it 'should handle malformed dates' do
52
+ created_at = 'foo'
53
+ template = Liquid::Template.parse('{{ created_at | advance_date_to_next: "Saturday" }}')
54
+ result = render_with_filter(template, 'created_at' => created_at)
55
+ result.must_equal 'foo'
56
56
  end
57
57
 
58
- it "should handle empty string input" do
59
- created_at = ""
60
- template = Liquid::Template.parse("{{ created_at | advance_date_to_next: \"Saturday\" }}")
61
- result = render_with_filter(template, { "created_at" => created_at })
62
- result.must_equal ""
58
+ it 'should handle empty string input' do
59
+ created_at = ''
60
+ template = Liquid::Template.parse('{{ created_at | advance_date_to_next: "Saturday" }}')
61
+ result = render_with_filter(template, 'created_at' => created_at)
62
+ result.must_equal ''
63
63
  end
64
64
 
65
- it "should handle nil input" do
65
+ it 'should handle nil input' do
66
66
  created_at = nil
67
- template = Liquid::Template.parse("{{ created_at | advance_date_to_next: \"Saturday\" }}")
68
- result = render_with_filter(template, { "created_at" => created_at })
69
- result.must_equal ""
67
+ template = Liquid::Template.parse('{{ created_at | advance_date_to_next: "Saturday" }}')
68
+ result = render_with_filter(template, 'created_at' => created_at)
69
+ result.must_equal ''
70
70
  end
71
71
 
72
- it "should render an error given an invalid day" do
73
- created_at = "2015-06-11T10:00:00Z" # a Thursday
74
- template = Liquid::Template.parse("{{ created_at | advance_date_to_next: \"fooday\" }}")
75
- result = render_with_filter(template, { "created_at" => created_at })
76
- result.must_equal "Liquid error: fooday is not a valid day"
72
+ it 'should render an error given an invalid day' do
73
+ created_at = '2015-06-11T10:00:00Z' # a Thursday
74
+ template = Liquid::Template.parse('{{ created_at | advance_date_to_next: "fooday" }}')
75
+ result = render_with_filter(template, 'created_at' => created_at)
76
+ result.must_equal 'Liquid error: fooday is not a valid day'
77
77
  end
78
78
  end
@@ -2,21 +2,21 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  describe Condensation::Filters::AtMidnight do
4
4
  def render_with_filter(template, context)
5
- template.render(context, :filters => [Condensation::Filters::AtMidnight])
5
+ template.render(context, filters: [Condensation::Filters::AtMidnight])
6
6
  end
7
7
 
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 | at_midnight }}")
11
- result = render_with_filter(template, { "created_at" => created_at })
12
- result.must_equal "2015-06-11 00:00:00 UTC"
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 | at_midnight }}')
11
+ result = render_with_filter(template, 'created_at' => created_at)
12
+ result.must_equal '2015-06-11 00:00:00 UTC'
13
13
  end
14
14
 
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 | at_midnight }}")
18
- result = render_with_filter(template, { "created_at" => created_at })
19
- result.must_equal "2015-06-11 00:00:00 -0700"
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 | at_midnight }}')
18
+ result = render_with_filter(template, 'created_at' => created_at)
19
+ result.must_equal '2015-06-11 00:00:00 -0700'
20
20
  end
21
21
 
22
22
  # it "should handle YMD formatted dates" do
@@ -26,31 +26,31 @@ describe Condensation::Filters::AtMidnight do
26
26
  # result.must_equal "2015-06-11 00:00:00 UTC"
27
27
  # end
28
28
 
29
- it "should handle Time input" do
29
+ it 'should handle Time input' do
30
30
  created_at = Time.utc(2015, 6, 11, 10, 0, 0) # a Thursday
31
- template = Liquid::Template.parse("{{ created_at | at_midnight }}")
32
- result = render_with_filter(template, { "created_at" => created_at })
33
- result.must_equal "2015-06-11 00:00:00 UTC"
31
+ template = Liquid::Template.parse('{{ created_at | at_midnight }}')
32
+ result = render_with_filter(template, 'created_at' => created_at)
33
+ result.must_equal '2015-06-11 00:00:00 UTC'
34
34
  end
35
35
 
36
- it "should handle malformed dates" do
37
- created_at = "foo"
38
- template = Liquid::Template.parse("{{ created_at | at_midnight }}")
39
- result = render_with_filter(template, { "created_at" => created_at })
40
- result.must_equal "foo"
36
+ it 'should handle malformed dates' do
37
+ created_at = 'foo'
38
+ template = Liquid::Template.parse('{{ created_at | at_midnight }}')
39
+ result = render_with_filter(template, 'created_at' => created_at)
40
+ result.must_equal 'foo'
41
41
  end
42
42
 
43
- it "should handle empty string input" do
44
- created_at = ""
45
- template = Liquid::Template.parse("{{ created_at | at_midnight }}")
46
- result = render_with_filter(template, { "created_at" => created_at })
47
- result.must_equal ""
43
+ it 'should handle empty string input' do
44
+ created_at = ''
45
+ template = Liquid::Template.parse('{{ created_at | at_midnight }}')
46
+ result = render_with_filter(template, 'created_at' => created_at)
47
+ result.must_equal ''
48
48
  end
49
49
 
50
- it "should handle nil input" do
50
+ it 'should handle nil input' do
51
51
  created_at = nil
52
- template = Liquid::Template.parse("{{ created_at | at_midnight }}")
53
- result = render_with_filter(template, { "created_at" => created_at })
54
- result.must_equal ""
52
+ template = Liquid::Template.parse('{{ created_at | at_midnight }}')
53
+ result = render_with_filter(template, 'created_at' => created_at)
54
+ result.must_equal ''
55
55
  end
56
56
  end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  describe Condensation::Filters::DaysSince do
4
4
  def render_with_filter(template, context)
5
- template.render(context, :filters => [Condensation::Filters::DaysSince])
5
+ template.render(context, filters: [Condensation::Filters::DaysSince])
6
6
  end
7
7
 
8
8
  let(:now) do
@@ -17,52 +17,52 @@ describe Condensation::Filters::DaysSince do
17
17
  Timecop.return
18
18
  end
19
19
 
20
- it "should handle UTC ISO 8601 dates" do
21
- created_at = "2014-05-15T10:00:00Z"
22
- template = Liquid::Template.parse("{{ created_at | days_since }}")
23
- result = render_with_filter(template, { "created_at" => created_at })
24
- result.must_equal "14"
20
+ it 'should handle UTC ISO 8601 dates' do
21
+ created_at = '2014-05-15T10:00:00Z'
22
+ template = Liquid::Template.parse('{{ created_at | days_since }}')
23
+ result = render_with_filter(template, 'created_at' => created_at)
24
+ result.must_equal '14'
25
25
  end
26
26
 
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 | days_since }}")
30
- result = render_with_filter(template, { "created_at" => created_at })
31
- result.must_equal "13"
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 | days_since }}')
30
+ result = render_with_filter(template, 'created_at' => created_at)
31
+ result.must_equal '13'
32
32
  end
33
33
 
34
- it "should handle Time input" do
34
+ it 'should handle Time input' do
35
35
  created_at = Time.utc(2014, 5, 20, 0, 0, 0)
36
- template = Liquid::Template.parse("{{ created_at | days_since }}")
37
- result = render_with_filter(template, { "created_at" => created_at })
38
- result.must_equal "10"
36
+ template = Liquid::Template.parse('{{ created_at | days_since }}')
37
+ result = render_with_filter(template, 'created_at' => created_at)
38
+ result.must_equal '10'
39
39
  end
40
40
 
41
- it "should handle malformed dates" do
42
- created_at = "foo"
43
- template = Liquid::Template.parse("{{ created_at | days_since }}")
44
- result = render_with_filter(template, { "created_at" => created_at })
45
- result.must_equal ""
41
+ it 'should handle malformed dates' do
42
+ created_at = 'foo'
43
+ template = Liquid::Template.parse('{{ created_at | days_since }}')
44
+ result = render_with_filter(template, 'created_at' => created_at)
45
+ result.must_equal ''
46
46
  end
47
47
 
48
- it "should be zero for days in the future" do
49
- created_at = "2014-06-01T20:00:00Z"
50
- template = Liquid::Template.parse("{{ created_at | days_since }}")
51
- result = render_with_filter(template, { "created_at" => created_at })
52
- result.must_equal "0"
48
+ it 'should be zero for days in the future' do
49
+ created_at = '2014-06-01T20:00:00Z'
50
+ template = Liquid::Template.parse('{{ created_at | days_since }}')
51
+ result = render_with_filter(template, 'created_at' => created_at)
52
+ result.must_equal '0'
53
53
  end
54
54
 
55
- it "should handle empty string input" do
56
- created_at = ""
57
- template = Liquid::Template.parse("{{ created_at | days_since }}")
58
- result = render_with_filter(template, { "created_at" => created_at })
59
- result.must_equal ""
55
+ it 'should handle empty string input' do
56
+ created_at = ''
57
+ template = Liquid::Template.parse('{{ created_at | days_since }}')
58
+ result = render_with_filter(template, 'created_at' => created_at)
59
+ result.must_equal ''
60
60
  end
61
61
 
62
- it "should handle nil input" do
62
+ it 'should handle nil input' do
63
63
  created_at = nil
64
- template = Liquid::Template.parse("{{ created_at | days_since }}")
65
- result = render_with_filter(template, { "created_at" => created_at })
66
- result.must_equal ""
64
+ template = Liquid::Template.parse('{{ created_at | days_since }}')
65
+ result = render_with_filter(template, 'created_at' => created_at)
66
+ result.must_equal ''
67
67
  end
68
68
  end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  describe Condensation::Filters::DaysUntil do
4
4
  def render_with_filter(template, context)
5
- template.render(context, :filters => [Condensation::Filters::DaysUntil])
5
+ template.render(context, filters: [Condensation::Filters::DaysUntil])
6
6
  end
7
7
 
8
8
  let(:now) do
@@ -17,59 +17,59 @@ describe Condensation::Filters::DaysUntil do
17
17
  Timecop.return
18
18
  end
19
19
 
20
- it "should handle UTC ISO 8601 dates" do
21
- created_at = "2014-05-30T10:00:00Z"
22
- template = Liquid::Template.parse("{{ created_at | days_until }}")
23
- result = render_with_filter(template, { "created_at" => created_at })
24
- result.must_equal "15"
20
+ it 'should handle UTC ISO 8601 dates' do
21
+ created_at = '2014-05-30T10:00:00Z'
22
+ template = Liquid::Template.parse('{{ created_at | days_until }}')
23
+ result = render_with_filter(template, 'created_at' => created_at)
24
+ result.must_equal '15'
25
25
  end
26
26
 
27
- it "should handle non-UTC ISO 8601 dates" do
28
- created_at = "2014-05-30T20:00:00-07:00"
29
- template = Liquid::Template.parse("{{ created_at | days_until }}")
30
- result = render_with_filter(template, { "created_at" => created_at })
31
- result.must_equal "16"
27
+ it 'should handle non-UTC ISO 8601 dates' do
28
+ created_at = '2014-05-30T20:00:00-07:00'
29
+ template = Liquid::Template.parse('{{ created_at | days_until }}')
30
+ result = render_with_filter(template, 'created_at' => created_at)
31
+ result.must_equal '16'
32
32
  end
33
33
 
34
- it "should handle YMD formatted dates" do
35
- created_at = "2014-05-30"
36
- template = Liquid::Template.parse("{{ created_at | days_until }}")
37
- result = render_with_filter(template, { "created_at" => created_at })
38
- result.must_equal "15"
34
+ it 'should handle YMD formatted dates' do
35
+ created_at = '2014-05-30'
36
+ template = Liquid::Template.parse('{{ created_at | days_until }}')
37
+ result = render_with_filter(template, 'created_at' => created_at)
38
+ result.must_equal '15'
39
39
  end
40
40
 
41
- it "should handle Time input" do
41
+ it 'should handle Time input' do
42
42
  created_at = Time.utc(2014, 5, 20, 0, 0, 0)
43
- template = Liquid::Template.parse("{{ created_at | days_until }}")
44
- result = render_with_filter(template, { "created_at" => created_at })
45
- result.must_equal "5"
43
+ template = Liquid::Template.parse('{{ created_at | days_until }}')
44
+ result = render_with_filter(template, 'created_at' => created_at)
45
+ result.must_equal '5'
46
46
  end
47
47
 
48
- it "should handle malformed dates" do
49
- created_at = "foo"
50
- template = Liquid::Template.parse("{{ created_at | days_until }}")
51
- result = render_with_filter(template, { "created_at" => created_at })
52
- result.must_equal ""
48
+ it 'should handle malformed dates' do
49
+ created_at = 'foo'
50
+ template = Liquid::Template.parse('{{ created_at | days_until }}')
51
+ result = render_with_filter(template, 'created_at' => created_at)
52
+ result.must_equal ''
53
53
  end
54
54
 
55
- it "should be zero for days in the past" do
56
- created_at = "2014-05-01T20:00:00Z"
57
- template = Liquid::Template.parse("{{ created_at | days_until }}")
58
- result = render_with_filter(template, { "created_at" => created_at })
59
- result.must_equal "0"
55
+ it 'should be zero for days in the past' do
56
+ created_at = '2014-05-01T20:00:00Z'
57
+ template = Liquid::Template.parse('{{ created_at | days_until }}')
58
+ result = render_with_filter(template, 'created_at' => created_at)
59
+ result.must_equal '0'
60
60
  end
61
61
 
62
- it "should handle empty string input" do
63
- created_at = ""
64
- template = Liquid::Template.parse("{{ created_at | days_until }}")
65
- result = render_with_filter(template, { "created_at" => created_at })
66
- result.must_equal ""
62
+ it 'should handle empty string input' do
63
+ created_at = ''
64
+ template = Liquid::Template.parse('{{ created_at | days_until }}')
65
+ result = render_with_filter(template, 'created_at' => created_at)
66
+ result.must_equal ''
67
67
  end
68
68
 
69
- it "should handle nil input" do
69
+ it 'should handle nil input' do
70
70
  created_at = nil
71
- template = Liquid::Template.parse("{{ created_at | days_until }}")
72
- result = render_with_filter(template, { "created_at" => created_at })
73
- result.must_equal ""
71
+ template = Liquid::Template.parse('{{ created_at | days_until }}')
72
+ result = render_with_filter(template, 'created_at' => created_at)
73
+ result.must_equal ''
74
74
  end
75
75
  end
@@ -2,42 +2,42 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  describe Condensation::Filters::Default do
4
4
  def render_with_filter(template, context)
5
- template.render(context, :filters => [Condensation::Filters::Default])
5
+ template.render(context, filters: [Condensation::Filters::Default])
6
6
  end
7
7
 
8
- it "should return input if it is not blank" do
8
+ it 'should return input if it is not blank' do
9
9
  template = Liquid::Template.parse("{{ name | default: 'Bar' }}")
10
- result = render_with_filter(template, { "name" => "Foo" })
11
- result.must_equal "Foo"
10
+ result = render_with_filter(template, 'name' => 'Foo')
11
+ result.must_equal 'Foo'
12
12
  end
13
13
 
14
- it "should return default value if input is nil" do
14
+ it 'should return default value if input is nil' do
15
15
  template = Liquid::Template.parse("{{ name | default: 'Bar' }}")
16
- result = render_with_filter(template, { "name" => nil })
17
- result.must_equal "Bar"
16
+ result = render_with_filter(template, 'name' => nil)
17
+ result.must_equal 'Bar'
18
18
  end
19
19
 
20
- it "should return default value if input is an empty string" do
20
+ it 'should return default value if input is an empty string' do
21
21
  template = Liquid::Template.parse("{{ name | default: 'Bar' }}")
22
- result = render_with_filter(template, { "name" => "" })
23
- result.must_equal "Bar"
22
+ result = render_with_filter(template, 'name' => '')
23
+ result.must_equal 'Bar'
24
24
  end
25
25
 
26
- it "should return default value if input is an empty hash" do
26
+ it 'should return default value if input is an empty hash' do
27
27
  template = Liquid::Template.parse("{{ name | default: 'Bar' }}")
28
- result = render_with_filter(template, { "name" => {} })
29
- result.must_equal "Bar"
28
+ result = render_with_filter(template, 'name' => {})
29
+ result.must_equal 'Bar'
30
30
  end
31
31
 
32
- it "should return default value if input is an empty array" do
32
+ it 'should return default value if input is an empty array' do
33
33
  template = Liquid::Template.parse("{{ name | default: 'Bar' }}")
34
- result = render_with_filter(template, { "name" => [] })
35
- result.must_equal "Bar"
34
+ result = render_with_filter(template, 'name' => [])
35
+ result.must_equal 'Bar'
36
36
  end
37
37
 
38
- it "should return default value if input is false" do
38
+ it 'should return default value if input is false' do
39
39
  template = Liquid::Template.parse("{{ name | default: 'Bar' }}")
40
- result = render_with_filter(template, { "name" => false })
41
- result.must_equal "Bar"
40
+ result = render_with_filter(template, 'name' => false)
41
+ result.must_equal 'Bar'
42
42
  end
43
43
  end