diff --git a/lib/html/pipeline/emoji_filter.rb b/lib/html/pipeline/emoji_filter.rb index 5ccedab2..45180881 100644 --- a/lib/html/pipeline/emoji_filter.rb +++ b/lib/html/pipeline/emoji_filter.rb @@ -31,8 +31,16 @@ def emoji_image_filter(text) text.gsub EmojiPattern do |match| name = $1 - ":#{name}:" + ":#{name}:" end end + + # The base url to link emoji sprites + # + # Raises ArgumentError if context option has not been provided. + # Returns the context's asset_root. + def asset_root + context[:asset_root] or raise ArgumentError, "Missing context :asset_root" + end end end diff --git a/lib/html/pipeline/version.rb b/lib/html/pipeline/version.rb index cbeaed13..178ba803 100644 --- a/lib/html/pipeline/version.rb +++ b/lib/html/pipeline/version.rb @@ -1,5 +1,5 @@ module HTML module Pipeline - VERSION = "0.0.2" + VERSION = "0.0.3" end end diff --git a/test/html/pipeline/emoji_filter_test.rb b/test/html/pipeline/emoji_filter_test.rb index dfd13774..ac9d4d58 100644 --- a/test/html/pipeline/emoji_filter_test.rb +++ b/test/html/pipeline/emoji_filter_test.rb @@ -6,4 +6,11 @@ def test_emojify doc = filter.call assert_match "https://foo.com/emoji/shipit.png", doc.search('img').attr('src').value end + + def test_missing_context + filter = HTML::Pipeline::EmojiFilter.new("

:shipit:

", {}) + assert_raises ArgumentError do + filter.call + end + end end \ No newline at end of file