diff options
author | Carlos Goce <carlosgoce@gmail.com> | 2015-01-23 18:24:52 +0100 |
---|---|---|
committer | Carlos Goce <carlosgoce@gmail.com> | 2015-01-23 18:24:52 +0100 |
commit | 03f5e6ba6e23a7d5c748414637a637edfc670a13 (patch) | |
tree | dca7b6b8ea5f5eff7bccc058c53eaa0d94737153 | |
parent | 621eb6150b6d92def2d2bae4968bbe4f35b0a754 (diff) | |
download | pdf-calendars-03f5e6ba6e23a7d5c748414637a637edfc670a13.tar.gz pdf-calendars-03f5e6ba6e23a7d5c748414637a637edfc670a13.tar.bz2 pdf-calendars-03f5e6ba6e23a7d5c748414637a637edfc670a13.zip |
New spec to check array of available days for each month
-rw-r--r-- | lib/carlosgoce/calendar.rb | 2 | ||||
-rw-r--r-- | spec/calendar_spec.rb | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/carlosgoce/calendar.rb b/lib/carlosgoce/calendar.rb index 28ed542..e06b61b 100644 --- a/lib/carlosgoce/calendar.rb +++ b/lib/carlosgoce/calendar.rb @@ -14,7 +14,7 @@ module CarlosGoce Hash.new.tap {|h| (1..12).each do |month| h[month] = Hash.new.tap {|m| - m[:days] = (1...Time.days_in_month(month, @year)).to_a.each_slice(7).to_a + m[:days] = (1..Time.days_in_month(month, @year)).to_a m[:name] = I18n.t('date.month_names')[month].downcase } end diff --git a/spec/calendar_spec.rb b/spec/calendar_spec.rb index e7fe00b..e37e18d 100644 --- a/spec/calendar_spec.rb +++ b/spec/calendar_spec.rb @@ -11,7 +11,7 @@ describe 'Calendar' do end it 'should be initialized with the current year' do - expect(@calendar.year).to eq(Date.today.year) + expect(@calendar.year).to eq Date.today.year end describe 'Return a data structure with all needed data to generate a pdf' do @@ -20,9 +20,15 @@ describe 'Calendar' do end it 'return month names localized' do - expect(@calendar.to_h[1][:name]).to eq('january') + expect(@calendar.to_h[1][:name]).to eq 'january' I18n.locale = 'es' - expect(@calendar.to_h[1][:name]).to eq('enero') + expect(@calendar.to_h[1][:name]).to eq 'enero' end + + it 'return the numbers of available days for each month' do + @calendar = CarlosGoce::Calendar.new 2015 + expect(@calendar.to_h[1][:days]).to eq (1..31).to_a + end + end end
\ No newline at end of file |