Permalink
Browse files

Add ability to use `Emoji.create` without a block

  • Loading branch information...
mislav committed Jul 4, 2014
1 parent 3935375 commit 0bea2df7ba13b2b5c981a2ea9d9faa94bd87af1d
Showing with 14 additions and 1 deletion.
  1. +1 −1 lib/emoji.rb
  2. +13 −0 test/emoji_test.rb
View
@@ -25,7 +25,7 @@ def all
# The character is added to the `Emoji.all` set.
def create(name)
emoji = Emoji::Character.new(name)
- self.all << edit_emoji(emoji) { yield emoji }
+ self.all << edit_emoji(emoji) { yield emoji if block_given? }
emoji
end
View
@@ -108,6 +108,19 @@ class EmojiTest < TestCase
end
end
+ test "create without block" do
+ emoji = Emoji.create("music")
+
+ begin
+ assert_equal emoji, Emoji.find_by_alias("music")
+ assert_equal [], emoji.unicode_aliases
+ assert_equal [], emoji.tags
+ assert_equal "music.png", emoji.image_filename
+ ensure
+ Emoji.all.pop
+ end
+ end
+
test "edit" do
emoji = Emoji.find_by_alias("weary")

0 comments on commit 0bea2df

Please sign in to comment.