Sha256: 870b64fd561443906951bfbff5e8bd8eb0417ad61f21d90edd9c4103390c0574
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
require 'spec_helper' describe ValidatesTimeliness, 'ActiveRecord' do it 'should define _timeliness_raw_value_for instance method' do Employee.instance_methods.should include('_timeliness_raw_value_for') end context "attribute write method" do class EmployeeWithCache < ActiveRecord::Base set_table_name 'employees' validates_datetime :birth_datetime end it 'should cache attribute raw value' do r = EmployeeWithCache.new r.birth_datetime = date_string = '2010-01-01' r._timeliness_raw_value_for(:birth_datetime).should == date_string end context "with plugin parser" do class EmployeeWithParser < ActiveRecord::Base set_table_name 'employees' validates_date :birth_date validates_datetime :birth_datetime end before :all do ValidatesTimeliness.use_plugin_parser = true end it 'should parse a string value' do ValidatesTimeliness::Parser.should_receive(:parse) r = EmployeeWithParser.new r.birth_date = '2010-01-01' end it 'should parse string as current timezone' do r = EmployeeWithParser.new r.birth_datetime = '2010-01-01 12:00' r.birth_datetime.zone == Time.zone.name end after :all do ValidatesTimeliness.use_plugin_parser = false end end end context "before_type_cast method" do it 'should be defined on class if ORM supports it' do Employee.instance_methods(false).should include("birth_datetime_before_type_cast") end it 'should return original value' do r = Employee.new r.birth_datetime = date_string = '2010-01-01' r.birth_datetime_before_type_cast.should == date_string end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
validates_timeliness-3.0.0.beta.3 | spec/validates_timeliness/orm/active_record_spec.rb |