with_global_filter test helper

This commit is contained in:
Florian Weingarten
2014-07-28 19:28:22 +00:00
parent 57d5426eed
commit a2f0f2547d
6 changed files with 25 additions and 24 deletions
+11
View File
@@ -47,10 +47,21 @@ module Minitest
assert_match match, exception.message
end
def with_global_filter(*globals)
original_filters = Array.new(Liquid::Strainer.class_variable_get(:@@filters))
globals.each do |global|
Liquid::Template.register_filter(global)
end
yield
ensure
Liquid::Strainer.class_variable_set(:@@filters, original_filters)
end
def with_error_mode(mode)
old_mode = Liquid::Template.error_mode
Liquid::Template.error_mode = mode
yield
ensure
Liquid::Template.error_mode = old_mode
end
end