Sha256: 719123b7b14b886e1ba3207fa4e492957d1192199b54999ed31d154b048d503f

Contents?: true

Size: 1.09 KB

Versions: 12

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Emojidex::Emoji do
  let(:emoji) do
    Emojidex::Emoji.new moji: '🌠', code: 'shooting_star',
                        code_ja: '流れ星', category: 'cosmos',
                        unicode: '1f320', uri: '/dummy/uri'
  end

  describe '.to_s' do
    it 'outputs UTF moji when present' do
      expect(emoji.to_s).to eq('🌠')
    end

    it 'outputs emoji code when UTF is not present' do
      emoji.moji = nil
      expect(emoji.to_s).to eq(':shooting_star:')
    end
  end

  describe '.to_hash' do
    it 'gets a hash containing emoji info' do
      expect(emoji.to_hash).to be_an_instance_of(Hash)
    end
  end

  describe '[]' do
    it 'acts like hash for lookup by key' do
      expect(emoji[:moji]).to eq(emoji.moji)
    end
  end

  describe '[]=' do
    it 'assigns a value in a hash by a key' do
      emoji[:code] = 'star_shot'
      expect(emoji.code).to eq('star_shot')
    end
  end

  describe '.to_json' do
    it 'outputs JSON info from the emoji' do
      expect(JSON.parse(emoji.to_json)).to be_an_instance_of(Hash)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
emojidex-0.0.23 spec/emoji_spec.rb
emojidex-0.0.22 spec/emoji_spec.rb
emojidex-0.0.21 spec/emoji_spec.rb
emojidex-0.0.20 spec/emoji_spec.rb
emojidex-0.0.19 spec/emoji_spec.rb
emojidex-0.0.18 spec/emoji_spec.rb
emojidex-0.0.17 spec/emoji_spec.rb
emojidex-0.0.16 spec/emoji_spec.rb
emojidex-0.0.15 spec/emoji_spec.rb
emojidex-0.0.14 spec/emoji_spec.rb
emojidex-0.0.13 spec/emoji_spec.rb
emojidex-0.0.12 spec/emoji_spec.rb