Skip to content

Commit

Permalink
Add Typecast::String.to_date specs
Browse files Browse the repository at this point in the history
  • Loading branch information
solnic committed Jul 22, 2011
1 parent d4b07df commit eedb1ff
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/unit/virtus/typecast/string/class_methods/to_date_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'

describe Virtus::Typecast::String, '.to_date' do
subject { described_class.to_date(string) }

context 'with a valid date string' do
let(:string) { "July, 22th, 2011" }

it { should be_instance_of(Date) }

its(:year) { should == 2011 }
its(:month) { should == 7 }
its(:day) { should == 22 }
end

context 'with an invalid date string' do
let(:string) { 'non-date' }
it { should == string }
end
end

0 comments on commit eedb1ff

Please sign in to comment.