spec/timespan/mongoid/mongoid_timespan_spec.rb in timespan-0.5.0 vs spec/timespan/mongoid/mongoid_timespan_spec.rb in timespan-0.5.1

- old
+ new

@@ -1,7 +1,10 @@ require 'timespan/mongoid/spec_helper' +Mongoid::Timespanned.log = true +load_models! + describe TimeSpan do subject { account } def tomorrow Date.today + 1.day @@ -11,13 +14,21 @@ let(:to) { Time.now } context 'factory method #from' do describe ':today' do let(:account) do - Account.create period: Timespan.from(:today, 5.days) + Account.create period: ::Timespan.from(:today, 5.days) end + describe '.to_s' do + it 'should return a non-empty String starting with from' do + subject.period.to_s.should be_a String + subject.period.to_s.should_not be_empty + subject.period.to_s.should match(/^from/) + end + end + describe '.start_date' do it 'should default to today' do DateTime.parse(subject.period.start_date.to_s).strftime('%d %b %Y').should == Date.today.strftime('%d %b %Y') end end @@ -152,9 +163,10 @@ describe 'set new start_date' do before :each do subject.period_start = tomorrow subject.period_end = tomorrow + 5.days + subject.time_period.dates_end = tomorrow + 3.days subject.end_date = tomorrow + 3.days end specify do Date.parse(subject.time_period.end_date.to_s).should == tomorrow + 3.days \ No newline at end of file