Commit 3c2bf28a by amacou

fix line brake bug

parent 344433e1
...@@ -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) || sym).to_s } str.gsub(/:([^\s:]?[\w-]+):/) {|sym| (Emoji.find($1.intern) || sym).to_s }
end end
def encode_io(readable, writeable=StringIO.new("")) def encode_io(readable, writeable=StringIO.new(""))
......
...@@ -32,10 +32,14 @@ describe Rumoji do ...@@ -32,10 +32,14 @@ describe Rumoji do
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
it "does not transform an arbitrary string wrapped in colons" do it "does not transform an arbitrary string wrapped in colons" do
Rumoji.decode(":this-is-just-a-string:").must_equal ":this-is-just-a-string:" Rumoji.decode(":this-is-just-a-string:").must_equal ":this-is-just-a-string:"
end end
it "transforms a cheat-sheet code into an emoji with line brake" do
Rumoji.decode(":\nabc:poop:").must_equal ":\nabc" + @poop
end
end end
describe "#encode_io" do 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