Sha256: 99a519030e8e645ab76f6b08a906e86cc6e6da99ce3afd60d42372fabebe651e
Contents?: true
Size: 778 Bytes
Versions: 4
Compression:
Stored size: 778 Bytes
Contents
require 'minitest_helper' describe Rasti::Types::Time do time = Time.new 2016, 8, 18 it "#{time.inspect} -> #{time.inspect}" do Rasti::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::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::Types::Time['%F'].cast(value) }.must_raise Rasti::Types::CastError error.message.must_equal "Invalid cast: #{as_string(value)} -> Rasti::Types::Time['%F']" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rasti-types-1.1.2 | spec/time_spec.rb |
rasti-types-1.1.1 | spec/time_spec.rb |
rasti-types-1.1.0 | spec/time_spec.rb |
rasti-types-1.0.0 | spec/time_spec.rb |