mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Adds EnvironmentTest to verify custom tag registration and rendering.
26 lines
675 B
Ruby
26 lines
675 B
Ruby
# 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
|