Sha256: 24632153c36a91647c120b8fcdb0e22028dc323ee787c50337b7d7259a559dc9
Contents?: true
Size: 705 Bytes
Versions: 6
Compression:
Stored size: 705 Bytes
Contents
require 'test_helper' class DatetimeValidatorTest < ActiveSupport::TestCase class ModelWithDate include ActiveModel::Validations attr_accessor :timestamp validates :timestamp, :datetime => true end setup do @record = ModelWithDate.new end [ "1/1/2012", "1/1/12", "1-1-12", "12-1-1", "Jan 1, 2012", "January 1 2012" ].each do |date| should "validate #{date} as valid" do @record.timestamp = date assert @record.valid? end end [ "1", "dec 1" "11 111 11", "2012-1", "99/99", "tomorrow", "NOW" ].each do |date| should "validate #{date} as invalid" do @record.timestamp = date assert_equal false, @record.valid? end end end
Version data entries
6 entries across 6 versions & 2 rubygems