Check changes

This commit is contained in:
darthjee
2024-07-29 16:22:37 -03:00
parent e0841aad72
commit d91640c394
6 changed files with 20 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
# frozen_string_literal: true
require 'sinclair'
class FontHelper
autoload :Font, 'font_helper/font'
autoload :Character, 'font_helper/character'

View File

@@ -4,7 +4,7 @@ class FontHelper
class Character
attr_reader :code
def initialize(code)
def initialize(code:)
@code = code
end

View File

@@ -25,5 +25,9 @@ class FontHelper
def quantity
characters.size
end
def character(code)
characters[code]
end
end
end

View File

@@ -3,7 +3,7 @@
require 'spec_helper'
describe FontHelper::Character do
subject(:character) { described_class.new(code) }
subject(:character) { described_class.new(code:) }
describe '#character' do
context 'when code is a valid character' do

View File

@@ -29,6 +29,12 @@ describe FontHelper::Font do
.to change(font, :quantity)
.from(1).to(2)
end
it do
expect { font << character }
.to change(font, :quantity)
.from(1).to(2)
end
end
context 'when there is already the same character' do
@@ -38,6 +44,11 @@ describe FontHelper::Font do
expect { font << character }
.not_to change(font, :quantity)
end
it do
expect { font << character }
.to change { font.character(character.code) }
end
end
end
end

View File

@@ -3,7 +3,7 @@
FactoryBot.define do
factory :character, class: FontHelper::Character do
initialize_with do
FontHelper::Character.new(code)
FontHelper::Character.new(code:)
end
transient do