0
@@ -2,80 +2,93 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
0
+ describe "next meeting date" do
0
+ @mock_today = Date.new(2008,1,1)
0
+ it "should call meeting date helper" do
0
+ Date.stub!(:today).and_return(@mock_today)
0
+ should_receive(:meeting_date).with(@mock_today).and_return(@mock_today)
0
+ it "should format the output" do
0
+ stub!(:meeting_date).and_return(@mock_today)
0
+ @mock_today.should_receive(:to_s).with(:rfc822)
0
# TODO: change the tests so that it is not tied to the particular day of the week
0
- describe "
next_meeting_date (Wednesday)" do
0
+ describe "
meeting date" do
0
- it "should return last Wednesday for month ending on a Wednesday" do
0
- mock_today = Date.new(2008,12,1)
0
- last_wednesday = mock_today.end_of_month
0
- Date.stub!(:today).and_return(mock_today)
0
- next_meeting_date.should eql(last_wednesday)
0
+ describe "for current month has not passed" do
0
+ it "should return last Wednesday for month ending on a Wednesday" do
0
+ mock_today = Date.new(2008,12,1)
0
+ last_wednesday = mock_today.end_of_month
0
+ meeting_date(mock_today).should eql(last_wednesday)
0
- it "should return last Wednesday for month ending on a Thursday" do
0
- mock_today = Date.new(2008,7,1)
0
- last_wednesday = mock_today.end_of_month - 1.day
0
- Date.stub!(:today).and_return(mock_today)
0
- next_meeting_date.should eql(last_wednesday)
0
+ it "should return last Wednesday for month ending on a Thursday" do
0
+ mock_today = Date.new(2008,7,1)
0
+ last_wednesday = mock_today.end_of_month - 1.day
0
+ meeting_date(mock_today).should eql(last_wednesday)
0
- it "should return last Wednesday for month ending on a Friday" do
0
- mock_today = Date.new(2008,10,1)
0
- last_wednesday = mock_today.end_of_month - 2.days
0
- Date.stub!(:today).and_return(mock_today)
0
- next_meeting_date.should eql(last_wednesday)
0
+ it "should return last Wednesday for month ending on a Friday" do
0
+ mock_today = Date.new(2008,10,1)
0
+ last_wednesday = mock_today.end_of_month - 2.days
0
+ meeting_date(mock_today).should eql(last_wednesday)
0
- it "should return last Wednesday for month ending on a Saturday" do
0
- mock_today = Date.new(2008,5,1)
0
- last_wednesday = mock_today.end_of_month - 3.days
0
- Date.stub!(:today).and_return(mock_today)
0
- next_meeting_date.should eql(last_wednesday)
0
+ it "should return last Wednesday for month ending on a Saturday" do
0
+ mock_today = Date.new(2008,5,1)
0
+ last_wednesday = mock_today.end_of_month - 3.days
0
+ meeting_date(mock_today).should eql(last_wednesday)
0
- it "should return last Wednesday for month ending on a Sunday" do
0
- mock_today = Date.new(2008,8,1)
0
- last_wednesday = mock_today.end_of_month - 4.days
0
- Date.stub!(:today).and_return(mock_today)
0
- next_meeting_date.should eql(last_wednesday)
0
+ it "should return last Wednesday for month ending on a Sunday" do
0
+ mock_today = Date.new(2008,8,1)
0
+ last_wednesday = mock_today.end_of_month - 4.days
0
+ meeting_date(mock_today).should eql(last_wednesday)
0
- it "should return last Wednesday for month ending on a Monday" do
0
- mock_today = Date.new(2008,6,1)
0
- last_wednesday = mock_today.end_of_month - 5.days
0
- Date.stub!(:today).and_return(mock_today)
0
- next_meeting_date.should eql(last_wednesday)
0
+ it "should return last Wednesday for month ending on a Monday" do
0
+ mock_today = Date.new(2008,6,1)
0
+ last_wednesday = mock_today.end_of_month - 5.days
0
+ meeting_date(mock_today).should eql(last_wednesday)
0
- it "should return last Wednesday for month ending on a Tuesday" do
0
- mock_today = Date.new(2008,9,1)
0
- last_wednesday = mock_today.end_of_month - 6.days
0
- Date.stub!(:today).and_return(mock_today)
0
- next_meeting_date.should eql(last_wednesday)
0
+ it "should return last Wednesday for month ending on a Tuesday" do
0
+ mock_today = Date.new(2008,9,1)
0
+ last_wednesday = mock_today.end_of_month - 6.days
0
+ meeting_date(mock_today).should eql(last_wednesday)
0
+ describe "for current month is today" do
0
+ it "should return today as the last Wednesday for the month" do
0
+ mock_today = Date.new(2008,3,26) # last Wednesday of the month
0
+ last_wednesday = mock_today
0
+ meeting_date(mock_today).should eql(last_wednesday)
0
+ describe "for current month has passed" do
0
+ it "should return last Wednesday for next month" do
0
+ mock_today = Date.new(2008,9,25) # day after the last wednesday
0
+ last_wednesday = Date.new(2008,10,29) # last wednesday of next month
0
+ meeting_date(mock_today).should eql(last_wednesday)
0
+ describe "is passed an invalid date" do
0
+ it "should return empty string" do
0
+ meeting_date(mock_today).should eql("")