Sha256: 1de604b60e624e7be5c3d21982d4e70a36bcbe7e59838a4b2be556a38a8dab3e

Contents?: true

Size: 1012 Bytes

Versions: 2

Compression:

Stored size: 1012 Bytes

Contents

require 'spec_helper'
require 'chronic'

describe "Timespan" do
	subject { timespan }

	let(:timespan) { TimeSpan.new :from => from, :to => to}

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

  it "spans 1 day" do
		timespan.to_d.should == 1
  end

  it "spans 86400 sec" do
		timespan.to_secs.should == 86400
  end

  it "spans 86400 sec" do
		timespan.to_mils.should be_within(10).of(86400000)
  end

  describe 'set with duration' do
  	let(:duration) { Duration.new(:days => 3)  }
		let(:timespan)  { TimeSpan.new :from => from, :duration => duration }

  	it 'should be 3 days' do
  		timespan.to_d.should == 3
  	end
  end

  describe 'set start_time to new' do
		let(:timespan) { TimeSpan.new :from => from, :to => to }  	

		before :each do
			@old_timespan = timespan.clone
			@new_timespan = timespan.clone
			@new_timespan.start_date = Chronic.parse("2 days ago")
		end

		it 'should have diff timespans' do
			@old_timespan.to_d.should_not == @new_timespan.to_d
		end
  end  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
timespan-0.1.3 spec/timespan_spec.rb
timespan-0.1.2 spec/timespan_spec.rb