aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/carlosgoce/calendar.rb8
-rw-r--r--spec/calendar_spec.rb8
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/carlosgoce/calendar.rb b/lib/carlosgoce/calendar.rb
index 1166f55..6a5d8f6 100644
--- a/lib/carlosgoce/calendar.rb
+++ b/lib/carlosgoce/calendar.rb
@@ -27,6 +27,14 @@ module CarlosGoce
}
}
end
+
+ h[:formatted_days] = Array.new.tap {|a|
+ # todo Why I need to use 1?
+ days_before_week_start = Date.new(@year, 1, h[1][:days].first).wday
+ empty_days = [''] * (days_before_week_start - 1)
+
+ a << (empty_days + h[1][:days])
+ }
}
end
diff --git a/spec/calendar_spec.rb b/spec/calendar_spec.rb
index 6739a9f..8d8e346 100644
--- a/spec/calendar_spec.rb
+++ b/spec/calendar_spec.rb
@@ -41,12 +41,18 @@ describe 'Calendar' do
I18n.locale = 'es'
expect(@calendar.to_h[1][:days_names].first).to eq 'jueves'
end
+
+ # todo Improve spec description
+ it 'return the days available formated as array leaving blank days for the starting week\'s day' do
+ days_for_january_2015 = ['', '', ''] + (1..31).to_a
+ expect(@calendar.to_h[:formatted_days].first).to eq days_for_january_2015
+ end
end
describe 'Can generate a pdfs' do
it 'should receive a layout and pass it the data to create the specified file' do
layout = instance_double('CarlosGoce::Layout::Simple')
- file = 'destionation.pdf'
+ file = 'destination.pdf'
year = 2015
expect(layout).to receive(:create).with(file, @calendar.to_h, year)