Sha256: 11233bac695df680c68aeffb5dba3663ec20fa813dde6aeb5499b5db698e84c8
Contents?: true
Size: 1.36 KB
Versions: 7
Compression:
Stored size: 1.36 KB
Contents
require 'spec_helper' module Roqua module CoreApi module Models describe ActiveVirtus do class Foo < ActiveVirtus attribute :datetime, DateTime attribute :date, Date end subject { Foo.new } describe 'Date' do it 'can be set by date(i1) params' do subject.attributes = { 'date(1i)' => '1999', 'date(2i)' => '12', 'date(3i)' => '8'} expect(subject.date).to eq Date.new(1999, 12, 8) end it 'sets an error if the date is invalid' do subject.attributes = { 'date(1i)' => '1999', 'date(2i)' => '12', 'date(3i)' => '32'} expect(subject.errors[:date][0]).to match 'invalid_date' end it 'can create new with date(i1) params' do foo = Foo.new('date(1i)' => '1999', 'date(2i)' => '12', 'date(3i)' => '8') expect(foo.date).to eq Date.new(1999, 12, 8) end end describe 'DateTime' do it 'can be set by datetime(i1) params' do subject.attributes = { 'datetime(1i)' => '1999', 'datetime(2i)' => '12', 'datetime(3i)' => '8', 'datetime(4i)' => '22', 'datetime(5i)' => '23', 'datetime(6i)' => '24'} expect(subject.datetime).to eq DateTime.new(1999, 12, 8, 22, 23, 24) end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems