Sha256: dbaa2d7240d5d067e53fcbeb372b4b2d72dbf284be289508df5f9c6aca0c7423
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
require 'timespan/mongoid/spec_helper' describe TimeSpan do subject { account } def tomorrow Date.today + 1.day end let(:from) { Chronic.parse("1 day ago") } let(:to) { Time.now } context '2 days duration using factory method' do let(:account) do Account.create_it! '2 days' 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 end context '2 days duration using Timespan' do let(:account) do Account.create :period => Timespan.new(:duration => 2.days) 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 end context '2 days using integer via ActiveSupport::Duration' do let(:account) do Account.create :period => Timespan.new(2.days) 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 describe 'set new start_date' do before :each do subject.period_start = tomorrow end specify do subject.start_date.should == subject.period.start_date end specify do Date.parse(subject.start_date.to_s).should == tomorrow end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timespan-0.4.3 | spec/timespan/mongoid/mongoid_timespan_spec.rb |