schemacop 2.1.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +58 -0
  3. data/LICENSE +1 -1
  4. data/README.md +250 -16
  5. data/RUBY_VERSION +1 -1
  6. data/Rakefile +6 -1
  7. data/VERSION +1 -1
  8. data/doc/Schemacop.html +32 -5
  9. data/doc/Schemacop/ArrayValidator.html +4 -4
  10. data/doc/Schemacop/BooleanValidator.html +4 -4
  11. data/doc/Schemacop/Caster.html +379 -0
  12. data/doc/Schemacop/Collector.html +298 -46
  13. data/doc/Schemacop/Exceptions.html +3 -3
  14. data/doc/Schemacop/Exceptions/InvalidSchemaError.html +3 -3
  15. data/doc/Schemacop/Exceptions/ValidationError.html +3 -3
  16. data/doc/Schemacop/FieldNode.html +19 -7
  17. data/doc/Schemacop/FloatValidator.html +4 -4
  18. data/doc/Schemacop/HashValidator.html +33 -7
  19. data/doc/Schemacop/IntegerValidator.html +4 -4
  20. data/doc/Schemacop/NilValidator.html +4 -4
  21. data/doc/Schemacop/Node.html +97 -85
  22. data/doc/Schemacop/NodeResolver.html +28 -12
  23. data/doc/Schemacop/NodeSupportingField.html +4 -4
  24. data/doc/Schemacop/NodeSupportingType.html +5 -7
  25. data/doc/Schemacop/NodeWithBlock.html +4 -4
  26. data/doc/Schemacop/NumberValidator.html +4 -4
  27. data/doc/Schemacop/ObjectValidator.html +20 -10
  28. data/doc/Schemacop/RootNode.html +4 -4
  29. data/doc/Schemacop/Schema.html +6 -6
  30. data/doc/Schemacop/StringValidator.html +3 -3
  31. data/doc/Schemacop/SymbolValidator.html +4 -4
  32. data/doc/ScopedEnv.html +3 -3
  33. data/doc/_index.html +11 -4
  34. data/doc/class_list.html +1 -1
  35. data/doc/css/style.css +10 -6
  36. data/doc/file.README.html +255 -29
  37. data/doc/frames.html +1 -1
  38. data/doc/index.html +255 -29
  39. data/doc/js/app.js +55 -0
  40. data/doc/method_list.html +99 -51
  41. data/doc/top-level-namespace.html +3 -3
  42. data/lib/schemacop.rb +15 -0
  43. data/lib/schemacop/caster.rb +38 -0
  44. data/lib/schemacop/collector.rb +53 -6
  45. data/lib/schemacop/field_node.rb +25 -3
  46. data/lib/schemacop/node.rb +16 -4
  47. data/lib/schemacop/node_resolver.rb +10 -2
  48. data/lib/schemacop/node_supporting_field.rb +0 -2
  49. data/lib/schemacop/node_supporting_type.rb +21 -1
  50. data/lib/schemacop/schema.rb +3 -3
  51. data/lib/schemacop/validator/array_validator.rb +1 -1
  52. data/lib/schemacop/validator/float_validator.rb +1 -1
  53. data/lib/schemacop/validator/hash_validator.rb +15 -2
  54. data/lib/schemacop/validator/integer_validator.rb +1 -1
  55. data/lib/schemacop/validator/object_validator.rb +7 -1
  56. data/schemacop.gemspec +15 -9
  57. data/test/casting_test.rb +90 -0
  58. data/test/collector_test.rb +45 -0
  59. data/test/custom_check_test.rb +20 -13
  60. data/test/custom_if_test.rb +12 -12
  61. data/test/defaults_test.rb +71 -0
  62. data/test/nil_dis_allow_test.rb +6 -6
  63. data/test/node_resolver_test.rb +26 -0
  64. data/test/short_forms_test.rb +86 -64
  65. data/test/test_helper.rb +7 -0
  66. data/test/types_test.rb +5 -5
  67. data/test/validator_array_test.rb +16 -16
  68. data/test/validator_boolean_test.rb +2 -2
  69. data/test/validator_float_test.rb +15 -15
  70. data/test/validator_hash_test.rb +5 -5
  71. data/test/validator_integer_test.rb +9 -9
  72. data/test/validator_nil_test.rb +1 -1
  73. data/test/validator_number_test.rb +19 -19
  74. data/test/validator_object_test.rb +33 -15
  75. data/test/validator_string_test.rb +12 -12
  76. data/test/validator_symbol_test.rb +2 -2
  77. metadata +43 -6
@@ -1,6 +1,13 @@
1
1
  require 'minitest/autorun'
2
2
  require 'schemacop'
3
+ require 'pry'
4
+ require 'colorize'
3
5
 
4
6
  def assert_verr(&_block)
5
7
  assert_raises(Schemacop::Exceptions::ValidationError) { yield }
6
8
  end
9
+
10
+ def assert_nothing_raised(&_block)
11
+ yield
12
+ assert true
13
+ end
@@ -40,9 +40,9 @@ module Schemacop
40
40
  type :integer, min: 5
41
41
  end
42
42
 
43
- assert_nil s.validate! true
44
- assert_nil s.validate! false
45
- assert_nil s.validate! 5
43
+ assert_nothing_raised { s.validate! true }
44
+ assert_nothing_raised { s.validate! false }
45
+ assert_nothing_raised { s.validate! 5 }
46
46
 
47
47
  assert_verr { s.validate! 'sali' }
48
48
  assert_verr { s.validate! 4 }
@@ -55,7 +55,7 @@ module Schemacop
55
55
  type :integer
56
56
  end
57
57
  end
58
- assert_nil s.validate! [5]
58
+ assert_nothing_raised { s.validate! [5] }
59
59
  assert_verr { s.validate! [nil] }
60
60
  assert_verr { s.validate! ['a'] }
61
61
  assert_verr { s.validate! [5, 'a'] }
@@ -74,7 +74,7 @@ module Schemacop
74
74
  (type == :number && allowed_types.include?(:float)) ||
75
75
  allowed_types.include?(:object)
76
76
 
77
- assert_nil schema.validate! data
77
+ assert_nothing_raised { schema.validate! data }
78
78
  else
79
79
  assert_verr { schema.validate! data }
80
80
  end
@@ -8,9 +8,9 @@ module Schemacop
8
8
  type :integer
9
9
  end
10
10
  end
11
- assert_nil s.validate!([])
12
- assert_nil s.validate!([0])
13
- assert_nil s.validate!([0, 1])
11
+ assert_nothing_raised { s.validate!([]) }
12
+ assert_nothing_raised { s.validate!([0]) }
13
+ assert_nothing_raised { s.validate!([0, 1]) }
14
14
  assert_verr { s.validate!(['string']) }
15
15
  end
16
16
 
@@ -19,8 +19,8 @@ module Schemacop
19
19
  type :array, min: 2
20
20
  end
21
21
 
22
- assert_nil s.validate!([0, 1])
23
- assert_nil s.validate!([0, 1, 2])
22
+ assert_nothing_raised { s.validate!([0, 1]) }
23
+ assert_nothing_raised { s.validate!([0, 1, 2]) }
24
24
  assert_verr { s.validate!([]) }
25
25
  assert_verr { s.validate!([0]) }
26
26
  end
@@ -30,9 +30,9 @@ module Schemacop
30
30
  type :array, max: 2
31
31
  end
32
32
 
33
- assert_nil s.validate!([])
34
- assert_nil s.validate!([0])
35
- assert_nil s.validate!([0, 1])
33
+ assert_nothing_raised { s.validate!([]) }
34
+ assert_nothing_raised { s.validate!([0]) }
35
+ assert_nothing_raised { s.validate!([0, 1]) }
36
36
  assert_verr { s.validate!([0, 1, 2]) }
37
37
  end
38
38
 
@@ -43,8 +43,8 @@ module Schemacop
43
43
  end
44
44
  end
45
45
 
46
- assert_nil s.validate!([1, 2])
47
- assert_nil s.validate!([1, 2, 3])
46
+ assert_nothing_raised { s.validate!([1, 2]) }
47
+ assert_nothing_raised { s.validate!([1, 2, 3]) }
48
48
  assert_verr { s.validate!([]) }
49
49
  assert_verr { s.validate!([1]) }
50
50
  assert_verr { s.validate!([1, 2, 3, 4]) }
@@ -57,7 +57,7 @@ module Schemacop
57
57
  end
58
58
  end
59
59
 
60
- assert_nil s.validate!([1, nil, 2])
60
+ assert_nothing_raised { s.validate!([1, nil, 2]) }
61
61
  assert_verr { s.validate!([1, nil, 'nope']) }
62
62
  end
63
63
 
@@ -71,8 +71,8 @@ module Schemacop
71
71
  end
72
72
  end
73
73
 
74
- assert_nil s.validate!([1, 2, 3])
75
- assert_nil s.validate!(%w(one two three))
74
+ assert_nothing_raised { s.validate!([1, 2, 3]) }
75
+ assert_nothing_raised { s.validate!(%w(one two three)) }
76
76
  assert_verr { s.validate!([1, 'mix']) }
77
77
  assert_verr { s.validate!([]) }
78
78
  end
@@ -88,9 +88,9 @@ module Schemacop
88
88
  type :array
89
89
  end
90
90
 
91
- assert_nil s.validate!([])
92
- assert_nil s.validate!([1, 2, 3])
93
- assert_nil s.validate!(%w(one two three))
91
+ assert_nothing_raised { s.validate!([]) }
92
+ assert_nothing_raised { s.validate!([1, 2, 3]) }
93
+ assert_nothing_raised { s.validate!(%w(one two three)) }
94
94
  assert_verr { s.validate!([1, 'mix']) }
95
95
  end
96
96
  end
@@ -6,8 +6,8 @@ module Schemacop
6
6
  s = Schema.new do
7
7
  type :boolean
8
8
  end
9
- assert_nil s.validate! true
10
- assert_nil s.validate! false
9
+ assert_nothing_raised { s.validate! true }
10
+ assert_nothing_raised { s.validate! false }
11
11
  assert_verr { s.validate! nil }
12
12
  assert_verr { s.validate! 1 }
13
13
  end
@@ -6,11 +6,11 @@ module Schemacop
6
6
  s = Schema.new do
7
7
  type :float
8
8
  end
9
- assert_nil s.validate!(-3.0)
10
- assert_nil s.validate!(-3.123)
11
- assert_nil s.validate!(0.0)
12
- assert_nil s.validate!(15.0)
13
- assert_nil s.validate!(15.13)
9
+ assert_nothing_raised { s.validate!(-3.0) }
10
+ assert_nothing_raised { s.validate!(-3.123) }
11
+ assert_nothing_raised { s.validate!(0.0) }
12
+ assert_nothing_raised { s.validate!(15.0) }
13
+ assert_nothing_raised { s.validate!(15.13) }
14
14
  assert_verr { s.validate!(-3) }
15
15
  assert_verr { s.validate!(0) }
16
16
  assert_verr { s.validate!(15) }
@@ -21,9 +21,9 @@ module Schemacop
21
21
  type :float, min: -2
22
22
  end
23
23
 
24
- assert_nil s.validate!(-2.0)
25
- assert_nil s.validate!(-1.99999)
26
- assert_nil s.validate!(1.2)
24
+ assert_nothing_raised { s.validate!(-2.0) }
25
+ assert_nothing_raised { s.validate!(-1.99999) }
26
+ assert_nothing_raised { s.validate!(1.2) }
27
27
  assert_verr { s.validate!(-5.2) }
28
28
  assert_verr { s.validate!(-2.00001) }
29
29
  end
@@ -33,8 +33,8 @@ module Schemacop
33
33
  type :float, max: 5.2
34
34
  end
35
35
 
36
- assert_nil s.validate!(-2.0)
37
- assert_nil s.validate!(5.2)
36
+ assert_nothing_raised { s.validate!(-2.0) }
37
+ assert_nothing_raised { s.validate!(5.2) }
38
38
  assert_verr { s.validate!(5.200001) }
39
39
  end
40
40
 
@@ -43,11 +43,11 @@ module Schemacop
43
43
  type :float, min: -2, max: 5.2
44
44
  end
45
45
 
46
- assert_nil s.validate!(-2.0)
47
- assert_nil s.validate!(-1.99999)
48
- assert_nil s.validate!(0.0)
49
- assert_nil s.validate!(1.2)
50
- assert_nil s.validate!(5.2)
46
+ assert_nothing_raised { s.validate!(-2.0) }
47
+ assert_nothing_raised { s.validate!(-1.99999) }
48
+ assert_nothing_raised { s.validate!(0.0) }
49
+ assert_nothing_raised { s.validate!(1.2) }
50
+ assert_nothing_raised { s.validate!(5.2) }
51
51
  assert_verr { s.validate!(-2.00001) }
52
52
  assert_verr { s.validate!(5.200001) }
53
53
  assert_verr { s.validate!(6) }
@@ -13,7 +13,7 @@ module Schemacop
13
13
  end
14
14
  end
15
15
  end
16
- assert_nil s.validate!(one: 3, two: true)
16
+ assert_nothing_raised { s.validate!(one: 3, two: true) }
17
17
  assert_verr { s.validate!(one: 3) }
18
18
  assert_verr { s.validate!(two: true) }
19
19
  assert_verr { s.validate!({}) }
@@ -59,10 +59,10 @@ module Schemacop
59
59
  end
60
60
  end
61
61
 
62
- assert_nil s.validate!(r: true, r_nil: false)
63
- assert_nil s.validate!(r: true, r_nil: nil)
64
- assert_nil s.validate!(r: true, r_nil: false, o: false)
65
- assert_nil s.validate!(r: true, r_nil: false, o: nil)
62
+ assert_nothing_raised { s.validate!(r: true, r_nil: false) }
63
+ assert_nothing_raised { s.validate!(r: true, r_nil: nil) }
64
+ assert_nothing_raised { s.validate!(r: true, r_nil: false, o: false) }
65
+ assert_nothing_raised { s.validate!(r: true, r_nil: false, o: nil) }
66
66
  assert_verr { s.validate!(r: true, r_nil: false, o_nonnil: nil) }
67
67
  assert_verr { s.validate!(o: true) }
68
68
  assert_verr { s.validate!(r: nil, r_nil: false, o: true) }
@@ -6,9 +6,9 @@ module Schemacop
6
6
  s = Schema.new do
7
7
  type :integer
8
8
  end
9
- assert_nil s.validate!(-3)
10
- assert_nil s.validate!(0)
11
- assert_nil s.validate!(15)
9
+ assert_nothing_raised { s.validate!(-3) }
10
+ assert_nothing_raised { s.validate!(0) }
11
+ assert_nothing_raised { s.validate!(15) }
12
12
  assert_verr { s.validate!(0.0) }
13
13
  end
14
14
 
@@ -17,8 +17,8 @@ module Schemacop
17
17
  type :integer, min: 6
18
18
  end
19
19
 
20
- assert_nil s.validate!(6)
21
- assert_nil s.validate!(7)
20
+ assert_nothing_raised { s.validate!(6) }
21
+ assert_nothing_raised { s.validate!(7) }
22
22
  assert_verr { s.validate!(5) }
23
23
  end
24
24
 
@@ -27,8 +27,8 @@ module Schemacop
27
27
  type :integer, max: 7
28
28
  end
29
29
 
30
- assert_nil s.validate!(6)
31
- assert_nil s.validate!(7)
30
+ assert_nothing_raised { s.validate!(6) }
31
+ assert_nothing_raised { s.validate!(7) }
32
32
  assert_verr { s.validate!(8) }
33
33
  end
34
34
 
@@ -37,8 +37,8 @@ module Schemacop
37
37
  type :integer, min: 6, max: 7
38
38
  end
39
39
 
40
- assert_nil s.validate!(6)
41
- assert_nil s.validate!(7)
40
+ assert_nothing_raised { s.validate!(6) }
41
+ assert_nothing_raised { s.validate!(7) }
42
42
  assert_verr { s.validate!(5) }
43
43
  assert_verr { s.validate!(8) }
44
44
  end
@@ -6,7 +6,7 @@ module Schemacop
6
6
  s = Schema.new do
7
7
  type :nil
8
8
  end
9
- assert_nil s.validate! nil
9
+ assert_nothing_raised { s.validate! nil }
10
10
  assert_verr { s.validate! false }
11
11
  end
12
12
  end
@@ -6,11 +6,11 @@ module Schemacop
6
6
  s = Schema.new do
7
7
  type :number
8
8
  end
9
- assert_nil s.validate!(-3)
10
- assert_nil s.validate!(-3.123)
11
- assert_nil s.validate!(0)
12
- assert_nil s.validate!(15)
13
- assert_nil s.validate!(15.13)
9
+ assert_nothing_raised { s.validate!(-3) }
10
+ assert_nothing_raised { s.validate!(-3.123) }
11
+ assert_nothing_raised { s.validate!(0) }
12
+ assert_nothing_raised { s.validate!(15) }
13
+ assert_nothing_raised { s.validate!(15.13) }
14
14
  assert_verr { s.validate!('0.12') }
15
15
  end
16
16
 
@@ -19,10 +19,10 @@ module Schemacop
19
19
  type :number, min: -2
20
20
  end
21
21
 
22
- assert_nil s.validate!(-2)
23
- assert_nil s.validate!(-1.99999)
24
- assert_nil s.validate!(0)
25
- assert_nil s.validate!(1.2)
22
+ assert_nothing_raised { s.validate!(-2) }
23
+ assert_nothing_raised { s.validate!(-1.99999) }
24
+ assert_nothing_raised { s.validate!(0) }
25
+ assert_nothing_raised { s.validate!(1.2) }
26
26
  assert_verr { s.validate!(-3) }
27
27
  assert_verr { s.validate!(-2.00001) }
28
28
  end
@@ -32,11 +32,11 @@ module Schemacop
32
32
  type :number, max: 5.2
33
33
  end
34
34
 
35
- assert_nil s.validate!(-2)
36
- assert_nil s.validate!(-1.9)
37
- assert_nil s.validate!(0)
38
- assert_nil s.validate!(5.19999)
39
- assert_nil s.validate!(5.2)
35
+ assert_nothing_raised { s.validate!(-2) }
36
+ assert_nothing_raised { s.validate!(-1.9) }
37
+ assert_nothing_raised { s.validate!(0) }
38
+ assert_nothing_raised { s.validate!(5.19999) }
39
+ assert_nothing_raised { s.validate!(5.2) }
40
40
  assert_verr { s.validate!(5.200001) }
41
41
  assert_verr { s.validate!(6) }
42
42
  end
@@ -46,11 +46,11 @@ module Schemacop
46
46
  type :number, min: -2, max: 5.2
47
47
  end
48
48
 
49
- assert_nil s.validate!(-2)
50
- assert_nil s.validate!(-1.99999)
51
- assert_nil s.validate!(0)
52
- assert_nil s.validate!(1.2)
53
- assert_nil s.validate!(5.2)
49
+ assert_nothing_raised { s.validate!(-2) }
50
+ assert_nothing_raised { s.validate!(-1.99999) }
51
+ assert_nothing_raised { s.validate!(0) }
52
+ assert_nothing_raised { s.validate!(1.2) }
53
+ assert_nothing_raised { s.validate!(5.2) }
54
54
  assert_verr { s.validate!(-3) }
55
55
  assert_verr { s.validate!(-2.00001) }
56
56
  assert_verr { s.validate!(5.200001) }
@@ -12,7 +12,7 @@ module Schemacop
12
12
  type :object, classes: User
13
13
  end
14
14
 
15
- assert_nil s.validate!(User.new)
15
+ assert_nothing_raised { s.validate!(User.new) }
16
16
  assert_verr { s.validate!(SubUser.new) }
17
17
  assert_verr { s.validate!(AdminUser.new) }
18
18
  end
@@ -23,8 +23,8 @@ module Schemacop
23
23
  type :object, classes: AdminUser
24
24
  end
25
25
 
26
- assert_nil s.validate!(User.new)
27
- assert_nil s.validate!(AdminUser.new)
26
+ assert_nothing_raised { s.validate!(User.new) }
27
+ assert_nothing_raised { s.validate!(AdminUser.new) }
28
28
  assert_verr { s.validate!(SubUser.new) }
29
29
  assert_verr { s.validate!([User.new, AdminUser.new]) }
30
30
  end
@@ -34,8 +34,8 @@ module Schemacop
34
34
  type :object, classes: [User, AdminUser]
35
35
  end
36
36
 
37
- assert_nil s.validate!(User.new)
38
- assert_nil s.validate!(AdminUser.new)
37
+ assert_nothing_raised { s.validate!(User.new) }
38
+ assert_nothing_raised { s.validate!(AdminUser.new) }
39
39
  assert_verr { s.validate!(SubUser.new) }
40
40
  assert_verr { s.validate!([User.new, AdminUser.new]) }
41
41
  end
@@ -50,9 +50,9 @@ module Schemacop
50
50
  end
51
51
  end
52
52
 
53
- assert_nil s.validate!(user: User.new)
54
- assert_nil s.validate!(user: User.new, multitype: AdminUser.new)
55
- assert_nil s.validate!(user: User.new, multitype: User.new)
53
+ assert_nothing_raised { s.validate!(user: User.new) }
54
+ assert_nothing_raised { s.validate!(user: User.new, multitype: AdminUser.new) }
55
+ assert_nothing_raised { s.validate!(user: User.new, multitype: User.new) }
56
56
  assert_verr { s.validate!(user: AdminUser.new) }
57
57
  assert_verr { s.validate!(user: User.new, multitype: 12) }
58
58
  assert_verr { s.validate!(user: User.new, multitype: self) }
@@ -63,11 +63,11 @@ module Schemacop
63
63
  type :object
64
64
  end
65
65
 
66
- assert_nil s.validate!(User.new)
67
- assert_nil s.validate!(123)
68
- assert_nil s.validate!('sali')
69
- assert_nil s.validate!(self)
70
- assert_nil s.validate!(self.class)
66
+ assert_nothing_raised { s.validate!(User.new) }
67
+ assert_nothing_raised { s.validate!(123) }
68
+ assert_nothing_raised { s.validate!('sali') }
69
+ assert_nothing_raised { s.validate!(self) }
70
+ assert_nothing_raised { s.validate!(self.class) }
71
71
  assert_verr { s.validate!(nil) }
72
72
  end
73
73
 
@@ -78,10 +78,28 @@ module Schemacop
78
78
  end
79
79
  end
80
80
 
81
- assert_nil s.validate!(fld: User.new)
82
- assert_nil s.validate!(fld: self)
81
+ assert_nothing_raised { s.validate!(fld: User.new) }
82
+ assert_nothing_raised { s.validate!(fld: self) }
83
83
  assert_verr { s.validate!(fld: nil) }
84
84
  assert_verr { s.validate!({}) }
85
85
  end
86
+
87
+ def test_strict_option
88
+ s = Schema.new do
89
+ req :o_strict do
90
+ type :object, classes: User, strict: true
91
+ end
92
+ opt :o_ns do
93
+ type :object, classes: User, strict: false
94
+ end
95
+ end
96
+
97
+ assert_nothing_raised { s.validate!(o_strict: User.new, o_ns: User.new) }
98
+ assert_nothing_raised { s.validate!(o_strict: User.new, o_ns: SubUser.new) }
99
+ assert_nothing_raised { s.validate!(o_strict: User.new) }
100
+ assert_verr { s.validate!(o_strict: SubUser.new) }
101
+ assert_verr { s.validate!(o_strict: User.new, o_ns: AdminUser.new) }
102
+ assert_verr { s.validate!(o_strict: SubUser.new, o_ns: User.new) }
103
+ end
86
104
  end
87
105
  end
@@ -6,10 +6,10 @@ module Schemacop
6
6
  s = Schema.new do
7
7
  type :string
8
8
  end
9
- assert_nil s.validate! ''
10
- assert_nil s.validate! 'abc'
11
- assert_nil s.validate! 123.to_s
12
- assert_nil s.validate! inspect
9
+ assert_nothing_raised { s.validate! '' }
10
+ assert_nothing_raised { s.validate! 'abc' }
11
+ assert_nothing_raised { s.validate! 123.to_s }
12
+ assert_nothing_raised { s.validate! inspect }
13
13
  end
14
14
 
15
15
  def test_option_min
@@ -17,8 +17,8 @@ module Schemacop
17
17
  type :string, min: 3
18
18
  end
19
19
 
20
- assert_nil s.validate!('abc')
21
- assert_nil s.validate!('abcd')
20
+ assert_nothing_raised { s.validate!('abc') }
21
+ assert_nothing_raised { s.validate!('abcd') }
22
22
  assert_verr { s.validate!('ab') }
23
23
  assert_verr { s.validate!('') }
24
24
  end
@@ -28,9 +28,9 @@ module Schemacop
28
28
  type :string, max: 5
29
29
  end
30
30
 
31
- assert_nil s.validate!('')
32
- assert_nil s.validate!('abcd')
33
- assert_nil s.validate!('abcde')
31
+ assert_nothing_raised { s.validate!('') }
32
+ assert_nothing_raised { s.validate!('abcd') }
33
+ assert_nothing_raised { s.validate!('abcde') }
34
34
  assert_verr { s.validate!('abcdef') }
35
35
  end
36
36
 
@@ -39,9 +39,9 @@ module Schemacop
39
39
  type :string, min: 3, max: 5
40
40
  end
41
41
 
42
- assert_nil s.validate!('abc')
43
- assert_nil s.validate!('abcd')
44
- assert_nil s.validate!('abcde')
42
+ assert_nothing_raised { s.validate!('abc') }
43
+ assert_nothing_raised { s.validate!('abcd') }
44
+ assert_nothing_raised { s.validate!('abcde') }
45
45
  assert_verr { s.validate!('ab') }
46
46
  assert_verr { s.validate!('abcdef') }
47
47
  assert_verr { s.validate!('') }