Commit 49caf6a0 by amacou

fix colon with emoji problem

parent d247e616
...@@ -14,7 +14,7 @@ module Rumoji ...@@ -14,7 +14,7 @@ module Rumoji
# Transform a cheat-sheet code into an Emoji # Transform a cheat-sheet code into an Emoji
def decode(str) def decode(str)
str.gsub(/:(\S?[\w-]+):/) {|sym| Emoji.find($1.intern).to_s } str.gsub(/:([^s:]?[\w-]+):/) {|sym| Emoji.find($1.intern).to_s }
end end
def encode_io(readable, writeable=StringIO.new("")) def encode_io(readable, writeable=StringIO.new(""))
......
...@@ -25,6 +25,10 @@ describe Rumoji do ...@@ -25,6 +25,10 @@ describe Rumoji do
Rumoji.decode(":poop:").must_equal @poop Rumoji.decode(":poop:").must_equal @poop
end end
it "transforms a cheat-sheet code into an emoji with colon" do
Rumoji.decode("::poop:").must_equal ':' + @poop
end
it "transforms a cheat-sheet code with a dash into an emoji" do it "transforms a cheat-sheet code with a dash into an emoji" do
Rumoji.decode(":non-potable_water:").must_equal @non_potable_water Rumoji.decode(":non-potable_water:").must_equal @non_potable_water
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment