Sha256: 3cffabae3e812479d16e3fa2a6e008567b42307c252b70d0896192ed4fc5ccf9
Contents?: true
Size: 841 Bytes
Versions: 2
Compression:
Stored size: 841 Bytes
Contents
require "test_helper" class ValidatesDatetimeDefaultsTest < Minitest::Test let(:user) { User.new } setup do User.validates_datetime :registered_at User.validates :birthday, datetime: true end VALID_DATES.each do |date| test "accepts #{date.inspect} as valid date" do user.registered_at = date user.birthday = date assert user.valid? end end INVALID_DATES.each do |date| test "rejects #{date.inspect} as valid date" do user.registered_at = date user.birthday = date refute user.valid? refute user.errors[:registered_at].empty? refute user.errors[:birthday].empty? end end test "includes default error message" do user.registered_at = nil refute user.valid? assert_includes user.errors[:registered_at], "is not a valid date" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
validators-2.8.1 | test/validators/validates_datetime/defaults_test.rb |
validators-2.8.0 | test/validators/validates_datetime/defaults_test.rb |