Sha256: d2fbac9626db991f6042324ef57bc85a267306376cf113fde256ce7f7644b2d6

Contents?: true

Size: 1.73 KB

Versions: 30

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

describe Timespan::Span do
  subject { timespan }

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

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

    before :each do
      @old_timespan = timespan.clone
      @new_timespan = timespan.clone
      @new_timespan.seconds = 120
    end

    its(:duration) { should be_a Duration }
    specify { subject.send(:dirty).should be_empty }

    it 'should have diff durations' do
      @old_timespan.duration.should_not == @new_timespan.duration
    end

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

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

    before :each do
      @old_timespan = timespan.clone
      @new_timespan = timespan.clone
      @new_timespan.minutes = 50
    end

    its(:duration) { should be_a Duration }
    specify { subject.send(:dirty).should be_empty }

    it 'should have diff durations' do
      @old_timespan.duration.should_not == @new_timespan.duration
    end

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

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

    before :each do
      @old_timespan = timespan.clone
      @new_timespan = timespan.clone
      @new_timespan.duration = "7 days"
    end

    its(:duration) { should be_a Duration }
    specify { subject.send(:dirty).should be_empty }

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

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
timespan-0.6.0 spec/timespan/span_spec.rb
timespan-0.5.9 spec/timespan/span_spec.rb
timespan-0.5.7 spec/timespan/span_spec.rb
timespan-0.5.6.1 spec/timespan/span_spec.rb
timespan-0.5.6 spec/timespan/span_spec.rb
timespan-0.5.5 spec/timespan/span_spec.rb
timespan-0.5.4 spec/timespan/span_spec.rb
timespan-0.5.3 spec/timespan/span_spec.rb
timespan-0.5.2 spec/timespan/span_spec.rb
timespan-0.5.1 spec/timespan/span_spec.rb
timespan-0.5.0 spec/timespan/span_spec.rb
timespan-0.4.9 spec/timespan/span_spec.rb
timespan-0.4.6 spec/timespan/span_spec.rb
timespan-0.4.5 spec/timespan/span_spec.rb
timespan-0.4.4 spec/timespan/span_spec.rb
timespan-0.4.3 spec/timespan/span_spec.rb
timespan-0.4.2 spec/timespan/span_spec.rb
timespan-0.4.1 spec/timespan/span_spec.rb
timespan-0.4.0 spec/timespan/span_spec.rb
timespan-0.3.2 spec/timespan/span_spec.rb