Sha256: f4776a2da8519c1277fb68b951f0d048dd0ef9debdaa1a0d4ab7d9f71aa97729
Contents?: true
Size: 773 Bytes
Versions: 3
Compression:
Stored size: 773 Bytes
Contents
require 'minitest_helper' describe Rasti::Types::Model do it 'Class' do result = Rasti::Types::Model[Point].cast x: 1, y: 2 result.must_be_instance_of Point result.x.must_equal 1 result.y.must_equal 2 end it 'Hash -> CastError' do error = proc { Rasti::Types::Model[Point].cast(z: 'text') }.must_raise Rasti::Types::CompoundError error.message.must_equal "Errors:\n- x: [\"not present\"]\n- y: [\"not present\"]" end [nil, 'text', :symbol, 1, [1,2], Object.new].each do |value| it "#{value.inspect} -> CastError" do error = proc { Rasti::Types::Model[Point].cast(value) }.must_raise Rasti::Types::CastError error.message.must_equal "Invalid cast: #{as_string(value)} -> #{Rasti::Types::Model[Point]}" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rasti-types-1.1.1 | spec/model_spec.rb |
rasti-types-1.1.0 | spec/model_spec.rb |
rasti-types-1.0.0 | spec/model_spec.rb |