aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorRobert2017-06-21 11:57:46 +0200
committerRobert2017-06-21 11:57:46 +0200
commit400898d14514aaf6df991dd2cb73e10b991ae34b (patch)
tree5f8667bc7ff839459ca774aa2b7dea5434936514 /spec
parentf42ea52d0f7f6fd6cab7f9179f93e189dd90bdca (diff)
downloadchouette-core-400898d14514aaf6df991dd2cb73e10b991ae34b.tar.bz2
Refs: #3595@2h; calendars#new/edit covered
Diffstat (limited to 'spec')
-rw-r--r--spec/models/calendar/calendar_date_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/calendar/calendar_date_spec.rb b/spec/models/calendar/calendar_date_spec.rb
new file mode 100644
index 000000000..25fe8ba8d
--- /dev/null
+++ b/spec/models/calendar/calendar_date_spec.rb
@@ -0,0 +1,38 @@
+RSpec.describe Calendar::CalendarDate do
+
+ subject { described_class.new(year, month, day) }
+ let( :year ){ 2000 }
+ let( :month ){ 2 }
+
+ let( :str_repr ){ %r{#{year}-0?#{month}-0?#{day}} }
+
+
+
+ shared_examples_for "date accessors" do
+ it "accesses year" do
+ expect( subject.year ).to eq(year)
+ end
+ it "accesses month" do
+ expect( subject.month ).to eq(month)
+ end
+ it "accesses day" do
+ expect( subject.day ).to eq(day)
+ end
+ it "converts to a string" do
+ expect( subject.to_s ).to match(str_repr)
+ end
+ end
+
+ context 'legal' do
+ let( :day ){ 29 }
+ it { expect_it.to be_legal }
+ it_should_behave_like "date accessors"
+ end
+
+ context 'illegal' do
+ let( :day ){ 30 }
+ it { expect_it.not_to be_legal }
+ it_should_behave_like "date accessors"
+ end
+
+end