Sha256: 96ed21a099e9faa5ee9ee9b822ae130b5ea0f05023d2f9e6fffa3e5c93712ec0
Contents?: true
Size: 809 Bytes
Versions: 14
Compression:
Stored size: 809 Bytes
Contents
require 'minitest_helper' describe Rasti::Form::Types::Time do time = Time.new 2016, 8, 18 it "#{time.inspect} -> #{time.inspect}" do Rasti::Form::Types::Time['%F %T %z'].cast(time).must_equal time end ['%d/%m/%y', '%Y-%m-%d'].each do |format| time_string = time.strftime(format) it "#{time_string.inspect} -> #{time.inspect}" do Rasti::Form::Types::Time[format].cast(time_string).must_equal time end end [time.strftime('%d/%m/%y'), 'text', nil, 1, :symbol, [1,2], {a: 1, b: 2}, Object.new].each do |value| it "#{value.inspect} -> CastError" do error = proc { Rasti::Form::Types::Time['%F'].cast(value) }.must_raise Rasti::Form::CastError error.message.must_equal "Invalid cast: #{as_string(value)} -> Rasti::Form::Types::Time['%F']" end end end
Version data entries
14 entries across 14 versions & 1 rubygems