Sha256: b1ccce88ca82b678f8fd040b22f62b1094e2798e0ee94513be17ffda9fe6e3ff

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe DataMapper::Property::Date do
  before :all do
    @name          = :created_on
    @type          = described_class
    @value         = Date.today
    @other_value   = Date.today + 1
    @invalid_value = 1
  end

  it_should_behave_like 'A semipublic Property'

  describe '#typecast' do
    describe 'and value given as a hash with keys like :year, :month, etc' do
      it 'builds a Date instance from hash values' do
        result = @property.typecast(
          :year  => '2007',
          :month => '3',
          :day   => '25'
        )

        result.should be_kind_of(Date)
        result.year.should eql(2007)
        result.month.should eql(3)
        result.day.should eql(25)
      end
    end

    describe 'and value is a string' do
      it 'parses the string' do
        result = @property.typecast('Dec 20th, 2006')
        result.month.should == 12
        result.day.should == 20
        result.year.should == 2006
      end
    end

    it 'does not typecast non-date values' do
      @property.typecast('not-date').should eql('not-date')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ghost_dm-core-1.3.0.beta spec/semipublic/property/date_spec.rb