Sha256: 146a3b16a0196c6d5c94322cdf7092c05cebdb95bbfa80e573f46bc9a9ecffba

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe ValidatesTimeliness::Extensions::MultiparameterHandler do
  let(:employee) { Employee.new }

  context "time column" do
    it 'should return string value for invalid date portion' do
      multiparameter_attribute(:birth_datetime, [2000, 2, 31, 12, 0, 0])
      employee.birth_datetime_before_type_cast.should == '2000-02-31 12:00:00'
    end
     
    it 'should return Time value for valid datetimes' do
      multiparameter_attribute(:birth_datetime, [2000, 2, 28, 12, 0, 0])
      employee.birth_datetime_before_type_cast.should be_kind_of(Time)
    end
  end

  context "date column" do
    it 'should return string value for invalid date' do
      multiparameter_attribute(:birth_date, [2000, 2, 31])
      employee.birth_date_before_type_cast.should == '2000-02-31'
    end

    it 'should return Date value for valid date' do
      multiparameter_attribute(:birth_date, [2000, 2, 28])
      employee.birth_date_before_type_cast.should be_kind_of(Date)
    end
  end

  def multiparameter_attribute(name, values)
    employee.send(:execute_callstack_for_multiparameter_attributes, name.to_s => values)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
validates_timeliness-3.0.8 spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
validates_timeliness-3.0.7 spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
validates_timeliness-3.0.6 spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
validates_timeliness-3.0.5 spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
validates_timeliness-3.0.4 spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
validates_timeliness-3.0.3 spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
validates_timeliness-3.0.2 spec/validates_timeliness/extensions/multiparameter_handler_spec.rb