Sha256: ebe689ee6c792608b2f342e14e18470d10f931247a10ff3d48e5dca73643fce6
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
require 'test_helper' class AutoTrimTest < Minitest::Test def setup @validator = LIVR.new({ 'code' => 'required', 'password' => ['required', { 'min_length' => 3 }], 'address' => { 'nested_object' => { 'street' => { 'min_length' => 5 }, }} }, 'is_auto_trim') end def test_auto_trim_negative output = @validator.validate({ 'code' => ' ', 'password' => ' 12 ', 'address' => { 'street' => ' happ ' } }) assert(!output, 'should return false due to validation errors fot trimmed values') assert_equal(@validator.get_errors, { 'code' =>'REQUIRED', 'password' => 'TOO_SHORT', 'address' => { 'street' => 'TOO_SHORT', } }, 'Should contain error codes' ) end def test_auto_trim_positive output = @validator.validate({ 'code' => ' A ', 'password' => ' 123 ', 'address' => { 'street' => ' hello ' } }) assert(!@validator.get_errors, 'Validator should contain no errors') assert_equal(output, { 'code' =>'A', 'password' => '123', 'address' => { 'street' => 'hello', } }, 'Should contain trimmed data' ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
livr-0.0.2 | test/02-test_auto_trim.rb |