Sha256: fb3d716fe1ab91ceeb5d57eff1020fe9037075526c03f2068efd0bddae442a0b

Contents?: true

Size: 1008 Bytes

Versions: 9

Compression:

Stored size: 1008 Bytes

Contents

require File.expand_path('../../spec_helper', __FILE__)

describe "Parsi::Date#step" do

  it "steps forward in time" do
    ds = Parsi::Date.civil(1391, 10, 11)
    de = Parsi::Date.civil(1391, 9, 29)
    count = 0
    de.step(ds) do |d|
      d.should <= ds
      d.should >= de
      count += 1
    end
    count.should == 13

    count = 0
    de.step(ds, 5) do |d|
      d.should <= ds
      d.should >= de
      count += 1
    end
    count.should == 3

    count = 0
    ds.step(de) do |d|; count += 1; end
    count.should == 0
  end

  it "steps backward in time" do
    ds = Parsi::Date.civil(1390, 4, 14)
    de = Parsi::Date.civil(1390, 3, 29)
    count = 0
    ds.step(de, -1) do |d|
      d.should <= ds
      d.should >= de
      count += 1
    end
    count.should == 17

    count = 0
    ds.step(de, -5) do |d|
      d.should <= ds
      d.should >= de
      count += 1
    end
    count.should == 4

    count = 0
    de.step(ds, -1) do |d|; count += 1; end
    count.should == 0
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
parsi-date-0.2.6 spec/parsi-date/step_spec.rb
parsi-date-0.2.5 spec/parsi-date/step_spec.rb
parsi-date-0.2.4 spec/parsi-date/step_spec.rb
parsi-date-0.2.3 spec/parsi-date/step_spec.rb
parsi-date-0.2.2 spec/parsi-date/step_spec.rb
parsi-date-0.2.1 spec/parsi-date/step_spec.rb
parsi-date-0.2 spec/parsi-date/step_spec.rb
parsi-date-0.1 spec/parsi-date/step_spec.rb
parsi-date-0.1.pre spec/parsi-date/step_spec.rb