add global_filter

add a global filter using a proc
only add one proc and not an array
add tests to make sure the global_filter is applied after native filters
This commit is contained in:
Loren Hale
2015-07-04 15:24:36 +08:00
parent b42d35ff36
commit 0b11b573d9
5 changed files with 49 additions and 15 deletions

View File

@@ -466,4 +466,18 @@ class ContextUnitTest < Minitest::Test
assert contx
assert_nil contx['poutine']
end
def test_apply_global_filter
global_filter_proc = ->(output) { "#{output} filtered" }
context = Context.new
context.global_filter = global_filter_proc
assert_equal 'hi filtered', context.apply_global_filter('hi')
end
def test_apply_global_filter_when_no_global_filter_exist
context = Context.new
assert_equal 'hi', context.apply_global_filter('hi')
end
end # ContextTest