From 9b6510c9461f26fa94d1e5b82a5b826c5bcf7c03 Mon Sep 17 00:00:00 2001 From: Tim Craft Date: Thu, 2 Jan 2025 11:32:47 +0000 Subject: [PATCH] Add Month#inspect method --- lib/month.rb | 4 ++++ spec/month_spec.rb | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/month.rb b/lib/month.rb index 1f4d18d..7f89ee9 100644 --- a/lib/month.rb +++ b/lib/month.rb @@ -37,6 +37,10 @@ def to_s alias_method :iso8601, :to_s + def inspect + "" + end + def name NAMES.fetch(@number) end diff --git a/spec/month_spec.rb b/spec/month_spec.rb index 6733aa1..0ef0892 100644 --- a/spec/month_spec.rb +++ b/spec/month_spec.rb @@ -36,17 +36,23 @@ end describe '#to_s' do - it 'returns a string containing the year and zero padded number of the month' do + it 'returns a string containing the year and number' do expect(Month.new(2014, 1).to_s).to eq('2014-01') end end describe '#iso8601' do - it 'returns a string containing the year and zero padded number of the month' do + it 'returns a string containing the year and number' do expect(Month.new(2014, 1).iso8601).to eq('2014-01') end end + describe '#inspect' do + it 'returns a string containing the year and number' do + expect(Month.new(2014, 1).inspect).to eq('') + end + end + describe '#name' do it 'returns the name of the month' do expect(Month.new(2014, 1).name).to eq(:January)