Sha256: 81b632e92f75fd186f4e24d9cf5fe310bb8e0be3a2bd74de9f671206de26268f
Contents?: true
Size: 826 Bytes
Versions: 2
Compression:
Stored size: 826 Bytes
Contents
require 'minitest_helper' describe Rasti::Types::String, 'Formatted' do let(:email_regexp) { /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i } it 'nil -> nil' do Rasti::Types::String[email_regexp].cast(nil).must_equal nil end ['user@mail.com'.to_sym, 'user.name-123@mail-test.com.ar'].each do |value| it "#{value.inspect} -> #{value.to_s}" do Rasti::Types::String[email_regexp].cast(value).must_equal value.to_s end end ['text', :symbol, '999'.to_sym, [1,2], {a: 1, b: 2}, Object.new, 5].each do |value| it "#{value.inspect} -> CastError" do error = proc { Rasti::Types::String[email_regexp].cast(value) }.must_raise Rasti::Types::CastError error.message.must_equal "Invalid cast: #{as_string(value)} -> Rasti::Types::String[#{as_string(email_regexp)}]" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rasti-types-2.0.1 | spec/string_formatted_spec.rb |
rasti-types-2.0.0 | spec/string_formatted_spec.rb |