Sha256: aa7d21cc4cf9652d54c38c4fafeb7db9330e22a916d599b5fdff2f10c3b21dc9

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

require 'timespan/mongoid/spec_helper'

describe Range do
  subject { timerange }

  describe 'create DurationRange' do
    let(:range) { (1..5) }
    let (:timerange) { range.days }
  
    specify { subject.should be_a DurationRange }

    its(:min) { should be_a Fixnum }
    its(:max) { should be_a Fixnum }

    specify { subject.min.should == 1.day }
    specify { subject.max.should == 5.days }
  end
end

describe DurationRange do
  subject { timerange }

  let(:range) { (1..5) }

  context 'day range' do
    let (:timerange) { range.days }

    its(:range) { should be_a Range }
    its(:min) { should == 1.day }
    its(:max) { should == 5.days }
    its(:unit) { should == :day }

    specify { subject.between?(4.days).should be_true }
  end

  context 'week range' do
    let (:timerange) { range.weeks }

    its(:range) { should be_a Range }
    its(:min) { should == 1.week }
    its(:max) { should == 5.weeks }
    its(:unit) { should == :week }
  end

  context 'month range' do
    let (:timerange) { range.months }

    its(:min) { should == 1.month }
    its(:max) { should == 5.months }
    its(:unit) { should == :month }
  end

  context 'year range' do
    let (:timerange) { range.years }

    its(:min) { should == 1.year }
    its(:max) { should == 5.years }
    its(:unit) { should == :year }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
timespan-0.5.1 spec/timespan/core_ext/duration_range_spec.rb
timespan-0.5.0 spec/timespan/core_ext/duration_range_spec.rb
timespan-0.4.9 spec/timespan/core_ext/duration_range_spec.rb