Skip to content
Snippets Groups Projects
Commit 744b6053 authored by Kerri Miller's avatar Kerri Miller
Browse files

Merge branch '9-use-gitlab-styles-gem' into 'main'

Use gitlab-styles gem

Closes #9

See merge request !71



Merged-by: default avatarKerri Miller <kerrizor@kerrizor.com>
Approved-by: default avatarKerri Miller <kerrizor@kerrizor.com>
Co-authored-by: default avatarBrett Walker <bwalker@gitlab.com>
parents 22dbf1b0 053e534b
No related branches found
No related tags found
1 merge request!71Use gitlab-styles gem
Pipeline #1480906727 passed with warnings
Showing
with 284 additions and 222 deletions
[Maintainers]
* @brodock @cablett @mwoolf @kerrizor @brytannia @splattael @digitalmoksha @smcgivern @jlear
* @brodock @mwoolf @kerrizor @brytannia @splattael @digitalmoksha @smcgivern @jlear
inherit_gem:
gitlab-styles:
- rubocop-bundler.yml
- rubocop-gemspec.yml
- rubocop-layout.yml
- rubocop-lint.yml
- rubocop-metrics.yml
- rubocop-naming.yml
- rubocop-performance.yml
- rubocop-rspec.yml
- rubocop-security.yml
- rubocop-style.yml
AllCops:
NewCops: enable
TargetRubyVersion: 3.0
Exclude:
- '*.gemspec'
......@@ -17,3 +31,12 @@ Layout/LineLength:
Metrics:
Enabled: false
RSpec/BeEq:
Enabled: false
InternalAffairs/MissingCopDepartment:
Enabled: false
RSpec/MultipleMemoizedHelpers:
Enabled: false
......@@ -7,9 +7,21 @@ PATH
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
activesupport (7.1.4)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
byebug (11.1.3)
claide (1.1.0)
claide-plugins (0.9.2)
......@@ -19,137 +31,159 @@ GEM
coderay (1.1.3)
colored2 (3.1.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
cork (0.3.0)
colored2 (~> 3.1)
danger (8.4.5)
csv (3.3.0)
danger (9.5.0)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (>= 0.9.0, < 2.0)
faraday (>= 0.9.0, < 3.0)
faraday-http-cache (~> 2.0)
git (~> 1.7)
git (~> 1.13)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (~> 4.7)
octokit (>= 4.0)
terminal-table (>= 1, < 4)
danger-gitlab (8.0.0)
danger
gitlab (~> 4.2, >= 4.2.0)
diff-lcs (1.4.4)
docile (1.4.0)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-http-cache (2.2.0)
diff-lcs (1.5.1)
docile (1.4.1)
drb (2.2.1)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-http-cache (2.5.1)
faraday (>= 0.8)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.3)
multipart-post (>= 1.2, < 3)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
git (1.10.2)
faraday-net_http (3.3.0)
net-http
git (1.19.1)
addressable (~> 2.8)
rchardet (~> 1.8)
gitlab (4.18.0)
httparty (~> 0.18)
gitlab (4.20.1)
httparty (~> 0.20)
terminal-table (>= 1.5.1)
gitlab-dangerfiles (2.11.0)
danger (>= 8.4.5)
danger-gitlab (>= 8.0.0)
httparty (0.20.0)
mime-types (~> 3.0)
gitlab-styles (12.0.1)
rubocop (~> 1.62.1)
rubocop-factory_bot (~> 2.25.1)
rubocop-graphql (~> 1.5.0)
rubocop-performance (~> 1.20.2)
rubocop-rails (~> 2.24.0)
rubocop-rspec (~> 2.27.1)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
kramdown (2.3.1)
json (2.7.2)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.3)
logger (1.6.1)
method_source (1.1.0)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2022.0105)
mini_mime (1.1.5)
minitest (5.25.1)
multi_xml (0.6.0)
multipart-post (2.1.1)
mutex_m (0.2.0)
nap (1.1.0)
no_proxy_fix (0.1.2)
octokit (4.22.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
net-http (0.4.1)
uri
octokit (9.1.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
open4 (1.3.4)
parallel (1.20.1)
parser (3.0.2.0)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
public_suffix (4.0.6)
rainbow (3.0.0)
rake (13.0.6)
public_suffix (6.0.1)
racc (1.8.1)
rack (3.1.7)
rainbow (3.1.1)
rake (13.2.1)
rchardet (1.8.0)
regexp_parser (2.1.1)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
regexp_parser (2.9.2)
rexml (3.3.8)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.1)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.18.4)
rubocop (1.62.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.8.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.8.0)
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
sawyer (0.8.2)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-graphql (1.5.4)
rubocop (>= 1.50, < 2)
rubocop-performance (1.20.2)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-rails (2.24.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.27.1)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
simplecov (0.21.2)
faraday (>= 0.17.3, < 3)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-cobertura (1.4.2)
simplecov (~> 0.8)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.1.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (0.13.1)
PLATFORMS
ruby
......@@ -158,11 +192,12 @@ PLATFORMS
DEPENDENCIES
gitlab-dangerfiles (~> 2.11.0)
gitlab-styles (~> 12.0)
pry-byebug
rake (~> 13.0)
rspec (~> 3.0)
rspec_junit_formatter (~> 0.4.0)
rubocop (~> 1.7)
rubocop (~> 1.62)
simplecov
simplecov-cobertura (~> 1.4.2)
tanuki_emoji!
......
......@@ -43,10 +43,10 @@ module TanukiEmoji
# @return [TanukiEmoji::Character]
def self.add(name, codepoints:, alpha_code:, description:, category:)
emoji = Character.new(name,
codepoints: codepoints,
alpha_code: alpha_code,
description: description,
category: category)
codepoints: codepoints,
alpha_code: alpha_code,
description: description,
category: category)
index.add(emoji)
end
......
......@@ -25,6 +25,20 @@ module TanukiEmoji
attr_accessor :unicode_version, :sort_key, :noto_image
# Ensure alpha code is formatted with colons
#
# @param [String] alpha_code
# @return [String] formatted alpha code
def self.format_alpha_code(alpha_code)
alpha_code.to_s.match?(ALPHA_CODE_REGEXP) ? alpha_code.to_s : ":#{alpha_code}:"
end
def self.format_name(raw_name)
matched = raw_name.match(ALPHA_CODE_REGEXP)
matched ? matched['alpha_text'] : raw_name
end
# @param [String] name
# @param [String] codepoints
# @param [String] alpha_code
......@@ -131,20 +145,6 @@ module TanukiEmoji
description == other.description
end
# Ensure alpha code is formatted with colons
#
# @param [String] alpha_code
# @return [String] formatted alpha code
def self.format_alpha_code(alpha_code)
alpha_code.to_s.match?(ALPHA_CODE_REGEXP) ? alpha_code.to_s : ":#{alpha_code}:"
end
def self.format_name(raw_name)
matched = raw_name.match(ALPHA_CODE_REGEXP)
matched ? matched['alpha_text'] : raw_name
end
private
# Return each codepoint converted to its hex value as string
......
......@@ -24,7 +24,7 @@ module TanukiEmoji
JSON.parse(file.read, symbolize_names: true)
end
db.each do |_alpha_code, emoji_data|
db.each_value do |emoji_data|
emoji = @index.find_by_codepoints(emoji_data[:emoji])
next unless emoji
......
......@@ -3,7 +3,7 @@
module TanukiEmoji
module Db
UNICODE_VERSION = '15.1'
UNICODE_DATA_DIR = "vendor/unicode/#{UNICODE_VERSION}"
UNICODE_DATA_DIR = "vendor/unicode/#{UNICODE_VERSION}".freeze
EmojiData = Struct.new(:codepoints, :property, :version, :range_size, :examples, :description)
EmojiTestData = Struct.new(:codepoints, :qualification, :emoji, :version, :description, :group_category)
......
......@@ -8,7 +8,7 @@ module TanukiEmoji
module Db
# Reads and extract content from emoji-data.txt and its metadata
class EmojiDataParser
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-data.txt"
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-data.txt".freeze
PROPERTIES = {
'Emoji' => :emoji,
'Emoji_Presentation' => :emoji_presentation,
......
......@@ -10,7 +10,7 @@ module TanukiEmoji
module Db
# Reads and extract content from emoji-test.txt
class EmojiTestParser
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-test.txt"
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-test.txt".freeze
# https://www.unicode.org/reports/tr51/#Versioning
EMOJI_UNICODE_VERSION = {
......@@ -87,10 +87,10 @@ module TanukiEmoji
else
# not found, add a new emoji
emoji = Character.new(alpha_code,
codepoints: emoji_data.codepoints,
alpha_code: alpha_code,
description: emoji_data.description,
category: emoji_data.group_category)
codepoints: emoji_data.codepoints,
alpha_code: alpha_code,
description: emoji_data.description,
category: emoji_data.group_category)
emoji.unicode_version = emoji_data.version
......
......@@ -24,7 +24,7 @@ module TanukiEmoji
JSON.parse(file.read, symbolize_names: true)
end
db.each do |_emoji_name, emoji_data|
db.each_value do |emoji_data|
emoji = @index.find_by_codepoints(emoji_data[:moji])
# if it's not found, don't try to add something that isn't in the
......
......@@ -6,7 +6,7 @@ module TanukiEmoji
module Db
# Emoji Unicode Ordering database
class UnicodeOrdering
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-ordering.txt"
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-ordering.txt".freeze
def self.data_file
File.expand_path(File.join(__dir__, '../../../', DATA_FILE))
......
# frozen_string_literal: true
module TanukiEmoji
class Error < StandardError; end
Error = Class.new(StandardError)
# Error: An Emoji with the same alpha code has been previously indexed
class AlphaCodeAlreadyIndexedError < Error
......@@ -14,7 +14,7 @@ module TanukiEmoji
@alpha_code = alpha_code
message = "Cannot index Emoji '#{name}' with alpha code '#{alpha_code}'. " \
"An Emoji with that alpha code has already been indexed."
"An Emoji with that alpha code has already been indexed."
super(message)
end
......@@ -31,7 +31,7 @@ module TanukiEmoji
@codepoint = codepoint
message = "Cannot index '#{name}' Emoji with codepoint: '#{codepoint}'. " \
"An Emoji with that codepoint has already been indexed."
"An Emoji with that codepoint has already been indexed."
super(message)
end
......
......@@ -82,7 +82,7 @@ module TanukiEmoji
# @return [Regexp] regular expression that matches indexed `:alpha_code:`
def alpha_code_pattern
/(?<=[^[:alnum:]:]|\n|^)
:(#{@name_index.keys.map { |name| Regexp.escape(name) }.join('|')}):
:(#{@name_index.keys.map { |name| Regexp.escape(name) }.join("|")}):
(?=[^[:alnum:]:]|$)/x
end
......@@ -93,18 +93,20 @@ module TanukiEmoji
def codepoints_pattern(exclude_text_presentation: false)
possible_codepoints = sorted_codepoints.map { |moji, _| Regexp.escape(moji) }.join('|')
variation_selector = ""
variation_selector = /(?!#{TanukiEmoji::Character::PLAIN_VARIATION_SELECTOR_STRING})/ if exclude_text_presentation
variation_selector = /(?!#{TanukiEmoji::Character::PLAIN_VARIATION_SELECTOR_STRING})/o if exclude_text_presentation
/(#{possible_codepoints})#{variation_selector}/
end
private
# rubocop:disable Layout/ClassStructure
def initialize
@all = []
load_data_files
end
# rubocop:enable Layout/ClassStructure
def insertion_mutex
@insertion_mutex ||= Mutex.new
......
......@@ -6,9 +6,9 @@ require 'simplecov-cobertura'
require 'pry-byebug'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::CoberturaFormatter
])
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::CoberturaFormatter
])
SimpleCov.start { add_filter '/spec/' }
RSpec.configure do |config|
......
......@@ -3,52 +3,55 @@
require './spec/spec_helper'
RSpec.describe TanukiEmoji::Character do
subject do
subject(:character) do
described_class.new('horse',
codepoints: "\u{1f434}",
alpha_code: 'horse',
description: 'horse face',
category: 'nature')
codepoints: "\u{1f434}",
alpha_code: 'horse',
description: 'horse face',
category: 'nature')
end
let(:mage_emoji) do
described_class.new('mage',
codepoints: "\u{1f9d9}\u{1f3fb}",
alpha_code: ':mage_tone1:',
description: 'mage with lighter skin',
category: 'people')
codepoints: "\u{1f9d9}\u{1f3fb}",
alpha_code: ':mage_tone1:',
description: 'mage with lighter skin',
category: 'people')
end
let(:brazillian_flag) do
described_class.new('flag_br',
codepoints: "\u{1f1e7}\u{1f1f7}",
alpha_code: ':flag_br:',
description: 'brazil',
category: 'flags')
codepoints: "\u{1f1e7}\u{1f1f7}",
alpha_code: ':flag_br:',
description: 'brazil',
category: 'flags')
end
let(:england_flag) do
described_class.new('flag_england',
codepoints: "\u{1f3f4}\u{e0067}\u{e0062}\u{e0065}\u{e006e}\u{e0067}\u{e007f}",
alpha_code: ':flag_england:',
description: 'flag: England',
category: 'flags')
codepoints: "\u{1f3f4}\u{e0067}\u{e0062}\u{e0065}\u{e006e}\u{e0067}\u{e007f}",
alpha_code: ':flag_england:',
description: 'flag: England',
category: 'flags')
end
describe '#initialize' do
it 'formats the name' do
emoji = described_class.new(':mage:',
codepoints: "\u{1f9d9}\u{1f3fb}",
alpha_code: ':mage_tone1:',
description: 'mage with lighter skin',
category: 'people')
codepoints: "\u{1f9d9}\u{1f3fb}",
alpha_code: ':mage_tone1:',
description: 'mage with lighter skin',
category: 'people')
expect(emoji.name).to eq('mage')
end
it 'formats the alpha_code' do
emoji = described_class.new(':mage:',
codepoints: "\u{1f9d9}\u{1f3fb}",
alpha_code: 'mage_tone1',
description: 'mage with lighter skin',
category: 'people')
codepoints: "\u{1f9d9}\u{1f3fb}",
alpha_code: 'mage_tone1',
description: 'mage with lighter skin',
category: 'people')
expect(emoji.alpha_code).to eq(':mage_tone1:')
end
......@@ -56,68 +59,68 @@ RSpec.describe TanukiEmoji::Character do
describe '#category' do
it 'returns category associated with emoji' do
expect(subject.category).to eq('nature')
expect(character.category).to eq('nature')
end
end
context '#inspect' do
describe '#inspect' do
it 'returns a formatted string' do
expect(subject.inspect).to eq('#<TanukiEmoji::Character: 🐴 (1f434) :horse: aliases: []>')
expect(character.inspect).to eq('#<TanukiEmoji::Character: 🐴 (1f434) :horse: aliases: []>')
end
end
context '#to_s' do
describe '#to_s' do
it 'returns the codepoints' do
expect(subject.to_s).to eq subject.codepoints
expect(character.to_s).to eq character.codepoints
end
end
context '#add_codepoints' do
describe '#add_codepoints' do
it 'adds codepoints to codepoints_alternate' do
expect { subject.add_codepoints("\u{1f434}\u{fe0f}") }.to change { subject.codepoints_alternates.count }.by(1)
expect(subject.codepoints_alternates).to include("\u{1f434}\u{fe0f}")
expect { character.add_codepoints("\u{1f434}\u{fe0f}") }.to change { character.codepoints_alternates.count }.by(1)
expect(character.codepoints_alternates).to include("\u{1f434}\u{fe0f}")
end
it 'does not add duplicates' do
expect { subject.add_codepoints("\u{1f434}\u{fe0f}") }.to change(subject.codepoints_alternates, :count).by(1)
expect { subject.add_codepoints("\u{1f434}\u{fe0f}") }.not_to change(subject.codepoints_alternates, :count)
expect { character.add_codepoints("\u{1f434}\u{fe0f}") }.to change { character.codepoints_alternates.count }.by(1)
expect { character.add_codepoints("\u{1f434}\u{fe0f}") }.not_to change { character.codepoints_alternates.count }
end
end
context '#add_alias' do
describe '#add_alias' do
it 'adds a alpha_code to aliases' do
expect { subject.add_alias(':horse_face:') }.to change { subject.aliases.count }.by(1)
expect(subject.aliases).to include(':horse_face:')
expect { character.add_alias(':horse_face:') }.to change { character.aliases.count }.by(1)
expect(character.aliases).to include(':horse_face:')
end
it 'converts `shortname` to `:alpha_code:` when inserting' do
subject.add_alias('horse_face')
character.add_alias('horse_face')
expect(subject.aliases).to include(':horse_face:')
expect(character.aliases).to include(':horse_face:')
end
it 'does not add duplicates' do
expect { mage_emoji.add_alias('wizard') }.to change(mage_emoji.aliases, :count)
expect { mage_emoji.add_alias('wizard') }.not_to change(mage_emoji.aliases, :count)
expect { mage_emoji.add_alias('wizard') }.to change { mage_emoji.aliases.count }
expect { mage_emoji.add_alias('wizard') }.not_to change { mage_emoji.aliases.count }
end
end
context '#add_ascii_alias' do
describe '#add_ascii_alias' do
it 'adds an ASCII alias to ascii_aliases' do
expect { subject.add_ascii_alias(':)') }.to change { subject.ascii_aliases.count }.by(1)
expect(subject.ascii_aliases).to include(':)')
expect { character.add_ascii_alias(':)') }.to change { character.ascii_aliases.count }.by(1)
expect(character.ascii_aliases).to include(':)')
end
it 'does not add duplicates' do
expect { subject.add_ascii_alias(':)') }.to change(subject.ascii_aliases, :count).by(1)
expect { subject.add_ascii_alias(':)') }.not_to change(subject.ascii_aliases, :count)
expect { character.add_ascii_alias(':)') }.to change { character.ascii_aliases.count }.by(1)
expect { character.add_ascii_alias(':)') }.not_to change { character.ascii_aliases.count }
end
end
context '#hex' do
describe '#hex' do
context 'with a character with a single codepoint' do
it 'returns a formatted hex representation of the codepoint' do
expect(subject.hex).to eq('1f434')
expect(character.hex).to eq('1f434')
end
end
......@@ -129,18 +132,18 @@ RSpec.describe TanukiEmoji::Character do
context 'with a passed in codepoint' do
it 'returns a formatted hex representation of the codepoint' do
expect(subject.hex(mage_emoji.codepoints)).to eq('1f9d9-1f3fb')
expect(character.hex(mage_emoji.codepoints)).to eq('1f9d9-1f3fb')
end
end
end
context '#image_name' do
describe '#image_name' do
context 'with all indexed emojis' do
let(:noto_emoji_base_path) { File.expand_path(File.join(__dir__, '../../vendor/noto-emoji')) }
let(:noto_emoji_path) { File.join(noto_emoji_base_path, 'png/32') }
let(:noto_flag_path) { File.join(noto_emoji_base_path, 'third_party/region-flags/png') }
before do
it 'checks if setup run' do
expect(Dir).to exist(noto_emoji_path), 'Please run `bin/setup`'
end
......@@ -170,7 +173,7 @@ RSpec.describe TanukiEmoji::Character do
end
end
context '#flag?' do
describe '#flag?' do
it 'returns true when character is made of flag-like A-Z characters' do
expect(brazillian_flag.flag?).to be_truthy
end
......@@ -184,45 +187,45 @@ RSpec.describe TanukiEmoji::Character do
end
end
context '#==' do
describe '#==' do
it 'returns true for the same instance of character' do
expect(mage_emoji).to eq(mage_emoji)
expect(mage_emoji).to eq(mage_emoji) # rubocop:disable RSpec/IdenticalEqualityAssertion
end
it 'returns true to different instances that share the same attributes' do
one_horse = described_class.new('horse',
codepoints: "\u{1f434}",
alpha_code: 'horse',
description: 'horse face',
category: 'nature')
codepoints: "\u{1f434}",
alpha_code: 'horse',
description: 'horse face',
category: 'nature')
similar_horse = described_class.new('horse',
codepoints: "\u{1f434}",
alpha_code: 'horse',
description: 'horse face',
category: 'nature')
codepoints: "\u{1f434}",
alpha_code: 'horse',
description: 'horse face',
category: 'nature')
expect(one_horse).to eq(similar_horse)
end
it 'returns false when at least one attributes is different' do
one_horse = described_class.new('horse',
codepoints: "\u{1f434}",
alpha_code: 'horse',
description: 'horse face',
category: 'nature')
codepoints: "\u{1f434}",
alpha_code: 'horse',
description: 'horse face',
category: 'nature')
another_horse = described_class.new('horse',
codepoints: "\u{1f434}",
alpha_code: 'another_horse',
description: 'horse face',
category: 'nature')
codepoints: "\u{1f434}",
alpha_code: 'another_horse',
description: 'horse face',
category: 'nature')
expect(one_horse).not_to eq(another_horse)
end
end
context '.format_alpha_code' do
describe '.format_alpha_code' do
it 'adds columns when provided alpha code doesnt have it yet' do
expect(described_class.format_alpha_code('horse')).to eq(':horse:')
end
......@@ -239,7 +242,7 @@ RSpec.describe TanukiEmoji::Character do
end
end
context '.format_name' do
describe '.format_name' do
it 'removes columns when provided an alpha_code' do
expect(described_class.format_name(':horse:')).to eq('horse')
end
......
......@@ -3,7 +3,7 @@
require 'rspec'
RSpec.describe TanukiEmoji::Db::AdditionalAliases do
subject { described_class.new(index: TanukiEmoji.index) }
subject(:index) { described_class.new(index: TanukiEmoji.index) }
before do
TanukiEmoji.index.reset!(reload: false)
......@@ -18,7 +18,7 @@ RSpec.describe TanukiEmoji::Db::AdditionalAliases do
expect(emoji.aliases).not_to include(':england:')
expect(emoji.noto_image).to be_nil
subject.load!
index.load!
emoji = TanukiEmoji.find_by_alpha_code('flag_england')
......
......@@ -9,34 +9,34 @@ RSpec.describe TanukiEmoji::Db::EmojiDataParser do
subject(:emoji_data) { described_class.new.data }
it 'returns an array of EmojiData' do
is_expected.to be_a(Array)
is_expected.to all(be_an(TanukiEmoji::Db::EmojiData))
expect(emoji_data).to be_a(Array)
expect(emoji_data).to all(be_an(TanukiEmoji::Db::EmojiData))
end
it 'sum of parsed ranges matches metadata[:total_elements] value' do
total_parsed_ranges = emoji_data.map { |d| d.range_size.to_i }.sum
total_parsed_ranges = emoji_data.sum { |d| d.range_size.to_i }
total_elements = described_class.new.metadata[:total_elements]
expect(total_parsed_ranges).to eq(total_elements)
end
context 'for each EmojiData item' do
context 'when each EmojiData item' do
it 'has a codepoint filled' do
emoji_data.each do |data|
expect(data.codepoints).to_not be_empty
expect(data.codepoints).not_to be_empty
end
end
it 'has a known property filled' do
emoji_data.each do |data|
expect(data.property).to_not be_empty
expect(data.property).not_to be_empty
expect(known_properties).to include(data.property)
end
end
it 'has a version filled and following a known version pattern' do
emoji_data.each do |data|
expect(data.version).to_not be_empty
expect(data.version).not_to be_empty
expect(data.version).to match(/[0-9]+\.[0-9]+/)
end
end
......@@ -55,8 +55,8 @@ RSpec.describe TanukiEmoji::Db::EmojiDataParser do
it 'has description filled' do
emoji_data.each do |data|
expect(data.description).to_not be_nil
expect(data.description).to_not be_empty
expect(data.description).not_to be_nil
expect(data.description).not_to be_empty
end
end
end
......@@ -64,8 +64,9 @@ RSpec.describe TanukiEmoji::Db::EmojiDataParser do
describe '#metadata' do
subject(:metadata) { described_class.new.metadata }
it 'returns a hash containing specific keys' do
is_expected.to be_a(Hash)
expect(metadata).to be_a(Hash)
expect(metadata.keys).to include(:date, :version, :total_elements)
end
......@@ -75,7 +76,7 @@ RSpec.describe TanukiEmoji::Db::EmojiDataParser do
subject(:data_file) { described_class.data_file }
it 'returns a Pathname to the default data file' do
is_expected.to be_a(Pathname)
expect(data_file).to be_a(Pathname)
expect(File.exist?(data_file)).to be_truthy
end
end
......
......@@ -10,46 +10,46 @@ RSpec.describe TanukiEmoji::Db::EmojiTestParser do
TanukiEmoji.index.reset!(reload: false)
end
it 'returns an array of EmojiData' do
is_expected.to be_a(Array)
is_expected.to all(be_an(TanukiEmoji::Db::EmojiTestData))
describe 'returns an array of EmojiData' do
it { is_expected.to be_a(Array) }
it { is_expected.to all(be_an(TanukiEmoji::Db::EmojiTestData)) }
end
context 'for each EmojiTestData item' do
context 'when each EmojiTestData item' do
it 'has codepoints filled' do
emoji_data.each do |data|
expect(data.codepoints).to_not be_empty
expect(data.codepoints).not_to be_empty
end
end
it 'has emoji filled' do
emoji_data.each do |data|
expect(data.emoji).to_not be_empty
expect(data.emoji).not_to be_empty
end
end
it 'has version filled and following a known version pattern' do
emoji_data.each do |data|
expect(data.version).to_not be_empty
expect(data.version).not_to be_empty
expect(data.version).to match(/[0-9]+\.[0-9]+/)
end
end
it 'has description filled' do
emoji_data.each do |data|
expect(data.description).to_not be_empty
expect(data.description).not_to be_empty
end
end
it 'has qualification filled' do
emoji_data.each do |data|
expect(data.qualification).to_not be_empty
expect(data.qualification).not_to be_empty
end
end
it 'has group_category filled' do
emoji_data.each do |data|
expect(data.group_category).to_not be_empty
expect(data.group_category).not_to be_empty
end
end
end
......
......@@ -3,8 +3,6 @@
require 'rspec'
RSpec.describe TanukiEmoji::Db::Gemojione do
subject { TanukiEmoji::Index.instance }
# These codes from gemojione 3.3.0 are no longer found in the Unicode emojis,
# nor are they in gemojione 4.1.0. So ignore them
let(:emoji_exceptions) do
......@@ -31,7 +29,7 @@ RSpec.describe TanukiEmoji::Db::Gemojione do
# rubocop:enable Style/AsciiComments
before do
subject.reset!
TanukiEmoji::Index.instance.reset!
end
it 'contains all codepoints', :aggregate_failures do
......@@ -39,8 +37,8 @@ RSpec.describe TanukiEmoji::Db::Gemojione do
JSON.parse(file.read, symbolize_names: true)
end
db.each do |_emoji_name, emoji_data|
next if emoji_exceptions.keys.include?(emoji_data[:moji])
db.each_value do |emoji_data|
next if emoji_exceptions.key?(emoji_data[:moji])
emoji = TanukiEmoji.find_by_codepoints(emoji_data[:moji])
......@@ -53,8 +51,8 @@ RSpec.describe TanukiEmoji::Db::Gemojione do
JSON.parse(file.read, symbolize_names: true)
end
db.each do |_emoji_name, emoji_data|
next if emoji_exceptions.keys.include?(emoji_data[:moji])
db.each_value do |emoji_data|
next if emoji_exceptions.key?(emoji_data[:moji])
emoji = TanukiEmoji.find_by_alpha_code(emoji_data[:shortname])
......
......@@ -4,6 +4,6 @@ require 'rspec'
RSpec.describe TanukiEmoji::Db::UnicodeOrdering do
it 'populates indexed emojis with unicode ordering data' do
expect(TanukiEmoji.index.all.none? { _1.sort_key.nil? }).to be_truthy
expect(TanukiEmoji.index.all.none? { |item| item.sort_key.nil? }).to be_truthy
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment