validates_timeliness/spec/validates_timeliness/attribute_methods_spec.rb
Adam Meehan 34a2d4b558 methods for validated attributes for write cache and before type cast
cache raw value in @attributes_cache which is AR convention but should
work fine with non-AR ORM
before type cast method for reading back cached raw value
2010-08-03 15:01:57 +10:00

23 lines
694 B
Ruby

require 'spec_helper'
describe ValidatesTimeliness::AttributeMethods do
before do
Employee.validates_datetime :birth_datetime
Employee.define_attribute_methods
end
it 'should define attribute write method for validated attributes' do
Employee.instance_methods(false).should include("birth_datetime=")
end
it 'should define attribute before_type_cast method for validated attributes' do
Employee.instance_methods(false).should include("birth_datetime_before_type_cast")
end
it 'should store original raw value on attribute write' do
r = Employee.new
r.birth_datetime = '2010-01-01'
r.birth_datetime_before_type_cast.should == '2010-01-01'
end
end