Sha256: 4f357d0fcd349014f0797313e214c559e09879f6d3746906402cea7a585b83f6
Contents?: true
Size: 1.3 KB
Versions: 5
Compression:
Stored size: 1.3 KB
Contents
require 'pr/fields/invalid_value' require 'pr/fields/date_field' describe 'a date field' do let(:klass) { PR::Fields::DateField } let(:value) { double "value" } let(:options) { Hash.new } let(:field) { klass.new value, options } describe "default value" do subject { klass.new } its(:raw) { should == '' } specify { expect { subject.convert }.to raise_error PR::Fields::InvalidValue } its(:options) { should == {} } end describe '#options' do it 'has retrievable options' do expect(field.options).to eq options end end describe "raw" do it "returns the value the field was initialized with" do field.raw.should == value end end describe "#populate" do let(:value) { Date.civil 2011, 6, 1 } subject { field.populate value } specify { subject; field.raw.should == '01/06/2011' } end describe "convert" do it "should attempt to parse the value as a uk formatted date" do Date.should_receive(:strptime).with(value,'%d/%m/%Y') field.convert end context "where value is not a valid date" do it "should raise an InvalidFieldValueError" do Date.should_receive(:strptime).and_raise(ArgumentError) expect { field.convert }.to raise_error PR::Fields::InvalidValue end end end end
Version data entries
5 entries across 5 versions & 1 rubygems