diff options
author | wilddima <dtopornin@gmail.com> | 2018-10-21 10:05:48 +0200 |
---|---|---|
committer | wilddima <dtopornin@gmail.com> | 2018-10-21 10:05:48 +0200 |
commit | 26cdd01eab5daf9ae17544ef44d3830dadeb8d23 (patch) | |
tree | 97fede0dc8e733609c45509559a47cf786fe7db1 /activemodel/test | |
parent | 86a12b6f2932ba1a3b5f0417688ffe34ea6bab25 (diff) | |
download | rails-26cdd01eab5daf9ae17544ef44d3830dadeb8d23.tar.gz rails-26cdd01eab5daf9ae17544ef44d3830dadeb8d23.tar.bz2 rails-26cdd01eab5daf9ae17544ef44d3830dadeb8d23.zip |
Add new exception message to datetime from hash cast
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/type/date_time_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activemodel/test/cases/type/date_time_test.rb b/activemodel/test/cases/type/date_time_test.rb index 60f62becc2..74b47d1b4d 100644 --- a/activemodel/test/cases/type/date_time_test.rb +++ b/activemodel/test/cases/type/date_time_test.rb @@ -25,6 +25,17 @@ module ActiveModel end end + def test_hash_to_time + type = Type::DateTime.new + assert_equal ::Time.utc(2018, 10, 15, 0, 0, 0), type.cast(1 => 2018, 2 => 10, 3 => 15) + end + + def test_hash_with_wrong_keys + type = Type::DateTime.new + error = assert_raises(ArgumentError) { type.cast(a: 1) } + assert_equal "Provided hash {:a=>1} doesn't contain necessary keys: [1, 2, 3]", error.message + end + private def with_timezone_config(default:) |