Sha256: fee1be96028c0c3512410b6b185694aed31a1eb02741ae661849cdf326d8cb8a
Contents?: true
Size: 749 Bytes
Versions: 1
Compression:
Stored size: 749 Bytes
Contents
require 'minitest_helper' describe Rasti::Form::Types::String, 'Formatted' do email_regexp = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i ['user@mail.com'.to_sym, 'user.name-123@mail-test.com.ar'].each do |value| it "#{value.inspect} -> #{value.to_s}" do Rasti::Form::Types::String[email_regexp].cast(value).must_equal value end end [nil, '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::Form::Types::String[email_regexp].cast(value) }.must_raise Rasti::Form::CastError error.message.must_equal "Invalid cast: #{as_string(value)} -> Rasti::Form::Types::String[#{as_string(email_regexp)}]" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rasti-form-3.0.0 | spec/types/string_formatted_spec.rb |