Sha256: 536394483106b3f57372000f023c42f6e6c4acf22d4f985a5ea69dc9bcc9eb0c

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

require 'timespan/mongoid/spec_helper'

describe Range do
  subject { timerange }

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

  describe 'create TimespanRange' do
    
    let (:timerange) { range.months(:timespan) }
  
    specify { subject.should be_a TimespanRange }
    its(:range) { should be_a Timespan }
  end
end

describe TimespanRange do
  subject { timerange }

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

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

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

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

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

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

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

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

    its(:range) { should be_a Timespan }
    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/timespan_range_spec.rb
timespan-0.5.0 spec/timespan/core_ext/timespan_range_spec.rb
timespan-0.4.9 spec/timespan/core_ext/timespan_range_spec.rb