Commit 45ee9867 by Rémi Prévost

Make decode regex work with codes that have dashes in them

parent c3b98d3d
......@@ -14,7 +14,7 @@ module Rumoji
# Transform a cheat-sheet code into an Emoji
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
def encode_io(readable, writeable=StringIO.new(""))
......
......@@ -9,6 +9,7 @@ describe Rumoji do
@smile = "😄"
@zero = "0⃣"
@us = "🇺🇸"
@non_potable_water = "🚱"
end
describe "#encode" do
......@@ -22,6 +23,10 @@ describe Rumoji do
it "transforms a cheat-sheet code into an emoji" do
Rumoji.decode(":poop:").must_equal @poop
end
it "transforms a cheat-sheet code with a dash into an emoji" do
Rumoji.decode(":non-potable_water:").must_equal @non_potable_water
end
end
describe "#encode_io" do
......
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