Sha256: 50c9706ea269cf3b17baa3031c013d8c00020925c0cdc59e7a2c8554e34d2cca
Contents?: true
Size: 1.16 KB
Versions: 5
Compression:
Stored size: 1.16 KB
Contents
require 'spec_helper' describe Virtus::Coercion::String, '.to_datetime' do subject { object.to_datetime(string) } let(:object) { described_class } shared_examples_for 'a correct datetime object' do it { should be_instance_of(DateTime) } its(:year) { should == year } its(:month) { should == month } its(:day) { should == day } its(:hour) { should == hour } its(:min) { should == min } its(:sec) { should == sec } end context 'with a valid date string' do let(:year) { 2011 } let(:month) { 7 } let(:day) { 22 } context 'not including time part' do let(:string) { "July, #{day}th, #{year}" } let(:hour) { 0 } let(:min) { 0 } let(:sec) { 0 } it_behaves_like 'a correct datetime object' end context 'including time part' do let(:string) { "July, #{day}, #{year}, #{hour}:#{min}:#{sec}" } let(:hour) { 13 } let(:min) { 44 } let(:sec) { 50 } it_behaves_like 'a correct datetime object' end end context 'with an invalid date time string' do let(:string) { 'non-datetime' } it { should equal(string) } end end
Version data entries
5 entries across 5 versions & 1 rubygems