Sha256: 5aaad213be9bc5f9b22793b550f0c3120a63d78fd5b9d7d6d67b58fdacd70a50

Contents?: true

Size: 1.09 KB

Versions: 22

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Timespan do
  subject { timespan }

  let(:from) { Chronic.parse("1 day ago") }
  let(:to)   { Time.now }

  context 'End date only - use Today as from (start_date)' do
    let(:timespan) { Timespan.new :to => 1.day.from_now}

    describe '.start_date' do
      it 'should default to today' do
        DateTime.parse(subject.start_date.to_s).strftime('%d %b %Y').should == Date.today.strftime('%d %b %Y')
      end
    end

    describe '.duration' do
      specify { subject.duration.should_not be_nil }

      it 'should be 1 day' do
        subject.to_d.should == 1
      end
    end    
  end

  context 'Start date only - use Today as to (end_date)' do
    let(:timespan) { Timespan.new :from => 1.day.ago}

    describe '.end_date' do
      it 'should default to today' do
        DateTime.parse(subject.end_date.to_s).strftime('%d %b %Y').should == Date.today.strftime('%d %b %Y')
      end
    end

    describe '.duration' do
      specify { subject.duration.should_not be_nil }

      it 'should be 1 day' do
        subject.to_d.should == 1
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
timespan-0.3.1 spec/timespan_init_spec.rb
timespan-0.2.8 spec/timespan_init_spec.rb