spec/timespan/mongoid/mongoid_timespan_spec.rb in timespan-0.2.8 vs spec/timespan/mongoid/mongoid_timespan_spec.rb in timespan-0.3.1
- old
+ new
@@ -1,8 +1,8 @@
require 'timespan/mongoid/spec_helper'
-describe Timespan do
+describe TimeSpan do
subject { account }
let(:from) { Chronic.parse("1 day ago") }
let(:to) { Time.now }
@@ -16,23 +16,35 @@
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 integer' do
+ 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 duration using :duration => integer via ActiveSupport::Duration' do
+ let(:account) do
Account.create :period => {: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' do
+ context '2 days using integer via ActiveSupport::Duration' do
let(:account) do
Account.create :period => 2.days
end
describe '.start_date' do
@@ -40,10 +52,10 @@
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 (from now - default)' do
+ context '2 days duration using string' do
let(:account) do
Account.create :period => {:duration => '2 days'}
end
describe '.start_date' do
\ No newline at end of file