File: environment_test.rb

package info (click to toggle)
ruby-liquid 5.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,444 kB
  • sloc: ruby: 14,571; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 675 bytes parent folder | download
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
# frozen_string_literal: true

require 'test_helper'

class EnvironmentTest < Minitest::Test
  include Liquid

  class UnsubscribeFooter < Liquid::Tag
    def render(_context)
      'Unsubscribe Footer'
    end
  end

  def test_custom_tag
    email_environment = Liquid::Environment.build do |environment|
      environment.register_tag("unsubscribe_footer", UnsubscribeFooter)
    end

    assert(email_environment.tags["unsubscribe_footer"])
    assert(email_environment.tag_for_name("unsubscribe_footer"))
    template = Liquid::Template.parse("{% unsubscribe_footer %}", environment: email_environment)

    assert_equal('Unsubscribe Footer', template.render)
  end
end