mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Localize errors in Liquid
This commit is contained in:
@@ -18,4 +18,10 @@ class AssignTest < Test::Unit::TestCase
|
||||
'{% assign foo = values | split: "," %}.{{ foo[1] }}.',
|
||||
'values' => "foo,bar,baz")
|
||||
end
|
||||
|
||||
def test_assign_syntax_error
|
||||
assert_match_syntax_error(/assign/,
|
||||
'{% assign foo not values %}.',
|
||||
'values' => "foo,bar,baz")
|
||||
end
|
||||
end # AssignTest
|
||||
|
||||
@@ -146,6 +146,7 @@ class TemplateTest < Test::Unit::TestCase
|
||||
|
||||
def test_sets_default_localization_in_document
|
||||
t = Template.new
|
||||
t.parse('')
|
||||
assert_instance_of I18n, t.root.options[:locale]
|
||||
end
|
||||
|
||||
|
||||
@@ -40,6 +40,13 @@ module Test
|
||||
assert_match expected, Template.parse(template).render(assigns)
|
||||
end
|
||||
|
||||
def assert_match_syntax_error(match, template, registers = {})
|
||||
exception = assert_raise(Liquid::SyntaxError) {
|
||||
Template.parse(template).render(assigns)
|
||||
}
|
||||
assert_match match, exception.message
|
||||
end
|
||||
|
||||
def with_error_mode(mode)
|
||||
old_mode = Liquid::Template.error_mode
|
||||
Liquid::Template.error_mode = mode
|
||||
|
||||
Reference in New Issue
Block a user