ree_lib 1.0.16 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/ree_lib/packages/ree_enum/package/ree_enum/dsl.rb +12 -8
  4. data/lib/ree_lib/packages/ree_enum/spec/ree_enum/dsl_spec.rb +1 -1
  5. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/mapper.rb +7 -6
  6. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/abstract_type.rb +4 -4
  7. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/array.rb +20 -20
  8. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/bool.rb +12 -12
  9. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/date.rb +13 -13
  10. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/date_time.rb +13 -13
  11. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/float.rb +13 -13
  12. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/integer.rb +13 -13
  13. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb +12 -12
  14. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/time.rb +13 -13
  15. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/array_spec.rb +15 -6
  16. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/bool_spec.rb +9 -9
  17. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/date_spec.rb +11 -11
  18. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/date_time_spec.rb +17 -17
  19. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/float_spec.rb +14 -14
  20. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/hash_spec.rb +5 -1
  21. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/integer_spec.rb +15 -15
  22. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/string_spec.rb +13 -13
  23. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/time_spec.rb +17 -17
  24. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/type_options_spec.rb +2 -2
  25. data/lib/ree_lib/version.rb +1 -1
  26. metadata +2 -4
  27. data/lib/ree_lib/packages/ree_dao/package/ree_dao/types/pg_array.rb +0 -43
  28. data/lib/ree_lib/packages/ree_dao/spec/ree_dao/types/pg_array_spec.rb +0 -19
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe ReeMapper::Array do
3
+ RSpec.describe 'ReeMapper::Array' do
4
4
  link :build_mapper_factory, from: :ree_mapper
5
5
  link :build_mapper_strategy, from: :ree_mapper
6
6
 
@@ -18,16 +18,25 @@ RSpec.describe ReeMapper::Array do
18
18
  let(:mapper) {
19
19
  mapper_factory.call.use(:cast).use(:serialize).use(:db_dump).use(:db_load) {
20
20
  array :tags, each: integer
21
+ array? :ary_of_ary, each: array(each: integer)
21
22
  }
22
23
  }
23
24
 
24
25
  describe '#serialize' do
25
26
  it {
26
- expect(mapper.serialize({ tags: [1, 2] })).to eq({ tags: [1, 2] })
27
+ expect(mapper.serialize({ tags: [1, 2], ary_of_ary: [[1]] })).to eq({ tags: [1, 2], ary_of_ary: [[1]] })
27
28
  }
28
29
 
29
30
  it {
30
- expect { mapper.serialize({ tags: 1 }) }.to raise_error(ReeMapper::TypeError)
31
+ expect { mapper.serialize({ tags: 1 }) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array")
32
+ }
33
+
34
+ it {
35
+ expect { mapper.serialize({tags: [1], ary_of_ary: ["1"] }) }.to raise_error(ReeMapper::TypeError, "`ary_of_ary[0]` should be an array")
36
+ }
37
+
38
+ it {
39
+ expect { mapper.serialize({tags: [1], ary_of_ary: [[1, "1"]] }) }.to raise_error(ReeMapper::TypeError, "`ary_of_ary[0][1]` should be an integer")
31
40
  }
32
41
  end
33
42
 
@@ -37,7 +46,7 @@ RSpec.describe ReeMapper::Array do
37
46
  }
38
47
 
39
48
  it {
40
- expect { mapper.cast({ 'tags' => 1 }) }.to raise_error(ReeMapper::TypeError)
49
+ expect { mapper.cast({ 'tags' => 1 }) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array")
41
50
  }
42
51
  end
43
52
 
@@ -47,7 +56,7 @@ RSpec.describe ReeMapper::Array do
47
56
  }
48
57
 
49
58
  it {
50
- expect { mapper.db_dump(OpenStruct.new({ tags: 1 })) }.to raise_error(ReeMapper::TypeError)
59
+ expect { mapper.db_dump(OpenStruct.new({ tags: 1 })) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array")
51
60
  }
52
61
  end
53
62
 
@@ -57,7 +66,7 @@ RSpec.describe ReeMapper::Array do
57
66
  }
58
67
 
59
68
  it {
60
- expect { mapper.db_load({ 'tags' => 1 }) }.to raise_error(ReeMapper::TypeError)
69
+ expect { mapper.db_load({ 'tags' => 1 }) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array")
61
70
  }
62
71
  end
63
72
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe ReeMapper::Bool do
3
+ RSpec.describe 'ReeMapper::Bool' do
4
4
  link :build_mapper_factory, from: :ree_mapper
5
5
  link :build_mapper_strategy, from: :ree_mapper
6
6
 
@@ -31,11 +31,11 @@ RSpec.describe ReeMapper::Bool do
31
31
  }
32
32
 
33
33
  it {
34
- expect { mapper.serialize({ bool: 'true' }) }.to raise_error(ReeMapper::TypeError)
34
+ expect { mapper.serialize({ bool: 'true' }) }.to raise_error(ReeMapper::TypeError, "`bool` should be a boolean")
35
35
  }
36
36
 
37
37
  it {
38
- expect { mapper.serialize({ bool: 1 }) }.to raise_error(ReeMapper::TypeError)
38
+ expect { mapper.serialize({ bool: 1 }) }.to raise_error(ReeMapper::TypeError, "`bool` should be a boolean")
39
39
  }
40
40
  end
41
41
 
@@ -81,11 +81,11 @@ RSpec.describe ReeMapper::Bool do
81
81
  }
82
82
 
83
83
  it {
84
- expect { mapper.cast({ 'bool' => 'right' }) }.to raise_error(ReeMapper::CoercionError)
84
+ expect { mapper.cast({ 'bool' => 'right' }) }.to raise_error(ReeMapper::CoercionError, "`bool` is invalid boolean")
85
85
  }
86
86
 
87
87
  it {
88
- expect { mapper.cast({ 'bool' => Object.new }) }.to raise_error(ReeMapper::CoercionError)
88
+ expect { mapper.cast({ 'bool' => Object.new }) }.to raise_error(ReeMapper::CoercionError, "`bool` is invalid boolean")
89
89
  }
90
90
  end
91
91
 
@@ -99,11 +99,11 @@ RSpec.describe ReeMapper::Bool do
99
99
  }
100
100
 
101
101
  it {
102
- expect { mapper.db_dump(OpenStruct.new({ bool: 'true' })) }.to raise_error(ReeMapper::TypeError)
102
+ expect { mapper.db_dump(OpenStruct.new({ bool: 'true' })) }.to raise_error(ReeMapper::TypeError, "`bool` should be a boolean")
103
103
  }
104
104
 
105
105
  it {
106
- expect { mapper.db_dump(OpenStruct.new({ bool: 1 })) }.to raise_error(ReeMapper::TypeError)
106
+ expect { mapper.db_dump(OpenStruct.new({ bool: 1 })) }.to raise_error(ReeMapper::TypeError, "`bool` should be a boolean")
107
107
  }
108
108
  end
109
109
 
@@ -149,11 +149,11 @@ RSpec.describe ReeMapper::Bool do
149
149
  }
150
150
 
151
151
  it {
152
- expect { mapper.db_load({ 'bool' => 'right' }) }.to raise_error(ReeMapper::CoercionError)
152
+ expect { mapper.db_load({ 'bool' => 'right' }) }.to raise_error(ReeMapper::CoercionError, "`bool` is invalid boolean")
153
153
  }
154
154
 
155
155
  it {
156
- expect { mapper.db_load({ 'bool' => Object.new }) }.to raise_error(ReeMapper::CoercionError)
156
+ expect { mapper.db_load({ 'bool' => Object.new }) }.to raise_error(ReeMapper::CoercionError, "`bool` is invalid boolean")
157
157
  }
158
158
  end
159
159
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe ReeMapper::Date do
3
+ RSpec.describe 'ReeMapper::Date' do
4
4
  link :build_mapper_factory, from: :ree_mapper
5
5
  link :build_mapper_strategy, from: :ree_mapper
6
6
 
@@ -27,19 +27,19 @@ RSpec.describe ReeMapper::Date do
27
27
  }
28
28
 
29
29
  it {
30
- expect { mapper.serialize({ date: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError)
30
+ expect { mapper.serialize({ date: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date")
31
31
  }
32
32
 
33
33
  it {
34
- expect { mapper.serialize({ date: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError)
34
+ expect { mapper.serialize({ date: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date")
35
35
  }
36
36
 
37
37
  it {
38
- expect { mapper.serialize({ date: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError)
38
+ expect { mapper.serialize({ date: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date")
39
39
  }
40
40
 
41
41
  it {
42
- expect { mapper.serialize({ date: Object.new }) }.to raise_error(ReeMapper::TypeError)
42
+ expect { mapper.serialize({ date: Object.new }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date")
43
43
  }
44
44
  end
45
45
 
@@ -61,7 +61,7 @@ RSpec.describe ReeMapper::Date do
61
61
  }
62
62
 
63
63
  it {
64
- expect { mapper.cast({ 'date' => 'no date' }) }.to raise_error(ReeMapper::CoercionError)
64
+ expect { mapper.cast({ 'date' => 'no date' }) }.to raise_error(ReeMapper::CoercionError, "`date` is invalid date")
65
65
  }
66
66
  end
67
67
 
@@ -83,7 +83,7 @@ RSpec.describe ReeMapper::Date do
83
83
  }
84
84
 
85
85
  it {
86
- expect { mapper.db_load({ 'date' => 'no date' }) }.to raise_error(ReeMapper::CoercionError)
86
+ expect { mapper.db_load({ 'date' => 'no date' }) }.to raise_error(ReeMapper::CoercionError, "`date` is invalid date")
87
87
  }
88
88
  end
89
89
 
@@ -93,19 +93,19 @@ RSpec.describe ReeMapper::Date do
93
93
  }
94
94
 
95
95
  it {
96
- expect { mapper.db_dump OpenStruct.new({ date: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError)
96
+ expect { mapper.db_dump OpenStruct.new({ date: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date")
97
97
  }
98
98
 
99
99
  it {
100
- expect { mapper.db_dump OpenStruct.new({ date: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError)
100
+ expect { mapper.db_dump OpenStruct.new({ date: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date")
101
101
  }
102
102
 
103
103
  it {
104
- expect { mapper.db_dump OpenStruct.new({ date: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError)
104
+ expect { mapper.db_dump OpenStruct.new({ date: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date")
105
105
  }
106
106
 
107
107
  it {
108
- expect { mapper.db_dump OpenStruct.new({ date: Object.new }) }.to raise_error(ReeMapper::TypeError)
108
+ expect { mapper.db_dump OpenStruct.new({ date: Object.new }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date")
109
109
  }
110
110
  end
111
111
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe ReeMapper::DateTime do
3
+ RSpec.describe 'ReeMapper::DateTime' do
4
4
  link :build_mapper_factory, from: :ree_mapper
5
5
  link :build_mapper_strategy, from: :ree_mapper
6
6
 
@@ -27,23 +27,23 @@ RSpec.describe ReeMapper::DateTime do
27
27
  }
28
28
 
29
29
  it {
30
- expect { mapper.serialize({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError)
30
+ expect { mapper.serialize({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
31
31
  }
32
32
 
33
33
  it {
34
- expect { mapper.serialize({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError)
34
+ expect { mapper.serialize({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
35
35
  }
36
36
 
37
37
  it {
38
- expect { mapper.serialize({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError)
38
+ expect { mapper.serialize({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
39
39
  }
40
40
 
41
41
  it {
42
- expect { mapper.serialize({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError)
42
+ expect { mapper.serialize({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
43
43
  }
44
44
 
45
45
  it {
46
- expect { mapper.serialize({ date_time: Object.new }) }.to raise_error(ReeMapper::TypeError)
46
+ expect { mapper.serialize({ date_time: Object.new }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
47
47
  }
48
48
  end
49
49
 
@@ -65,15 +65,15 @@ RSpec.describe ReeMapper::DateTime do
65
65
  }
66
66
 
67
67
  it {
68
- expect { mapper.cast({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError)
68
+ expect { mapper.cast({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
69
69
  }
70
70
 
71
71
  it {
72
- expect { mapper.cast({ 'date_time' => Object.new }) }.to raise_error(ReeMapper::TypeError)
72
+ expect { mapper.cast({ 'date_time' => Object.new }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
73
73
  }
74
74
 
75
75
  it {
76
- expect { mapper.cast({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError)
76
+ expect { mapper.cast({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`date_time` is invalid datetime")
77
77
  }
78
78
  end
79
79
 
@@ -83,23 +83,23 @@ RSpec.describe ReeMapper::DateTime do
83
83
  }
84
84
 
85
85
  it {
86
- expect { mapper.db_dump OpenStruct.new({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError)
86
+ expect { mapper.db_dump OpenStruct.new({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
87
87
  }
88
88
 
89
89
  it {
90
- expect { mapper.db_dump OpenStruct.new({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError)
90
+ expect { mapper.db_dump OpenStruct.new({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
91
91
  }
92
92
 
93
93
  it {
94
- expect { mapper.db_dump OpenStruct.new({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError)
94
+ expect { mapper.db_dump OpenStruct.new({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
95
95
  }
96
96
 
97
97
  it {
98
- expect { mapper.db_dump OpenStruct.new({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError)
98
+ expect { mapper.db_dump OpenStruct.new({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
99
99
  }
100
100
 
101
101
  it {
102
- expect { mapper.db_dump OpenStruct.new({ date_time: Object.new }) }.to raise_error(ReeMapper::TypeError)
102
+ expect { mapper.db_dump OpenStruct.new({ date_time: Object.new }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
103
103
  }
104
104
  end
105
105
 
@@ -121,15 +121,15 @@ RSpec.describe ReeMapper::DateTime do
121
121
  }
122
122
 
123
123
  it {
124
- expect { mapper.db_load({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError)
124
+ expect { mapper.db_load({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
125
125
  }
126
126
 
127
127
  it {
128
- expect { mapper.db_load({ 'date_time' => Object.new }) }.to raise_error(ReeMapper::TypeError)
128
+ expect { mapper.db_load({ 'date_time' => Object.new }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
129
129
  }
130
130
 
131
131
  it {
132
- expect { mapper.db_load({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError)
132
+ expect { mapper.db_load({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`date_time` is invalid datetime")
133
133
  }
134
134
  end
135
135
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe ReeMapper::Float do
3
+ RSpec.describe 'ReeMapper::Float' do
4
4
  link :build_mapper_factory, from: :ree_mapper
5
5
  link :build_mapper_strategy, from: :ree_mapper
6
6
 
@@ -31,15 +31,15 @@ RSpec.describe ReeMapper::Float do
31
31
  }
32
32
 
33
33
  it {
34
- expect { mapper.cast({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError)
34
+ expect { mapper.cast({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float')
35
35
  }
36
36
 
37
37
  it {
38
- expect { mapper.db_load({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError)
38
+ expect { mapper.db_load({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float')
39
39
  }
40
40
 
41
41
  it {
42
- expect { mapper.cast({ float: Object.new }) }.to raise_error(ReeMapper::TypeError)
42
+ expect { mapper.cast({ float: Object.new }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
43
43
  }
44
44
  end
45
45
 
@@ -49,15 +49,15 @@ RSpec.describe ReeMapper::Float do
49
49
  }
50
50
 
51
51
  it {
52
- expect { mapper.serialize({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError)
52
+ expect { mapper.serialize({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
53
53
  }
54
54
 
55
55
  it {
56
- expect { mapper.serialize({ float: nil }) }.to raise_error(ReeMapper::TypeError)
56
+ expect { mapper.serialize({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
57
57
  }
58
58
 
59
59
  it {
60
- expect { mapper.serialize({ float: Object.new }) }.to raise_error(ReeMapper::TypeError)
60
+ expect { mapper.serialize({ float: Object.new }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
61
61
  }
62
62
  end
63
63
 
@@ -67,15 +67,15 @@ RSpec.describe ReeMapper::Float do
67
67
  }
68
68
 
69
69
  it {
70
- expect { mapper.db_dump({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError)
70
+ expect { mapper.db_dump({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
71
71
  }
72
72
 
73
73
  it {
74
- expect { mapper.db_dump({ float: nil }) }.to raise_error(ReeMapper::TypeError)
74
+ expect { mapper.db_dump({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
75
75
  }
76
76
 
77
77
  it {
78
- expect { mapper.db_dump({ float: Object.new }) }.to raise_error(ReeMapper::TypeError)
78
+ expect { mapper.db_dump({ float: Object.new }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
79
79
  }
80
80
  end
81
81
 
@@ -89,19 +89,19 @@ RSpec.describe ReeMapper::Float do
89
89
  }
90
90
 
91
91
  it {
92
- expect { mapper.db_load({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError)
92
+ expect { mapper.db_load({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float')
93
93
  }
94
94
 
95
95
  it {
96
- expect { mapper.db_load({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError)
96
+ expect { mapper.db_load({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float')
97
97
  }
98
98
 
99
99
  it {
100
- expect { mapper.db_load({ float: nil }) }.to raise_error(ReeMapper::TypeError)
100
+ expect { mapper.db_load({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
101
101
  }
102
102
 
103
103
  it {
104
- expect { mapper.db_load({ float: Object.new }) }.to raise_error(ReeMapper::TypeError)
104
+ expect { mapper.db_load({ float: Object.new }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
105
105
  }
106
106
  end
107
107
  end
@@ -27,7 +27,11 @@ RSpec.describe 'Mapper Hash' do
27
27
  }
28
28
 
29
29
  it {
30
- expect { mapper.cast({ point: 1 }) }.to raise_error(ReeMapper::TypeError, 'Missing required field `x`')
30
+ expect { mapper.cast({ point: 1 }) }.to raise_error(ReeMapper::TypeError, 'Missing required field `x` for `point`')
31
+ }
32
+
33
+ it {
34
+ expect { mapper.cast({ point: { x: 1, y: 'not integer' } }) }.to raise_error(ReeMapper::CoercionError, '`point[y]` is invalid integer')
31
35
  }
32
36
  end
33
37
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe ReeMapper::Integer do
3
+ RSpec.describe 'ReeMapper::Integer' do
4
4
  link :build_mapper_factory, from: :ree_mapper
5
5
  link :build_mapper_strategy, from: :ree_mapper
6
6
 
@@ -31,15 +31,15 @@ RSpec.describe ReeMapper::Integer do
31
31
  }
32
32
 
33
33
  it {
34
- expect { mapper.cast({ number: 'b1' }) }.to raise_error(ReeMapper::CoercionError)
34
+ expect { mapper.cast({ number: 'b1' }) }.to raise_error(ReeMapper::CoercionError, '`number` is invalid integer')
35
35
  }
36
36
 
37
37
  it {
38
- expect { mapper.cast({ number: '1b' }) }.to raise_error(ReeMapper::CoercionError)
38
+ expect { mapper.cast({ number: '1b' }) }.to raise_error(ReeMapper::CoercionError, '`number` is invalid integer')
39
39
  }
40
40
 
41
41
  it {
42
- expect { mapper.cast({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError)
42
+ expect { mapper.cast({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
43
43
  }
44
44
  end
45
45
 
@@ -49,19 +49,19 @@ RSpec.describe ReeMapper::Integer do
49
49
  }
50
50
 
51
51
  it {
52
- expect { mapper.serialize({ number: '1' }) }.to raise_error(ReeMapper::TypeError)
52
+ expect { mapper.serialize({ number: '1' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
53
53
  }
54
54
 
55
55
  it {
56
- expect { mapper.serialize({ number: 'b1' }) }.to raise_error(ReeMapper::TypeError)
56
+ expect { mapper.serialize({ number: 'b1' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
57
57
  }
58
58
 
59
59
  it {
60
- expect { mapper.serialize({ number: '1b' }) }.to raise_error(ReeMapper::TypeError)
60
+ expect { mapper.serialize({ number: '1b' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
61
61
  }
62
62
 
63
63
  it {
64
- expect { mapper.serialize({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError)
64
+ expect { mapper.serialize({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
65
65
  }
66
66
  end
67
67
 
@@ -71,19 +71,19 @@ RSpec.describe ReeMapper::Integer do
71
71
  }
72
72
 
73
73
  it {
74
- expect { mapper.db_dump({ number: '1' }) }.to raise_error(ReeMapper::TypeError)
74
+ expect { mapper.db_dump({ number: '1' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
75
75
  }
76
76
 
77
77
  it {
78
- expect { mapper.db_dump({ number: 'b1' }) }.to raise_error(ReeMapper::TypeError)
78
+ expect { mapper.db_dump({ number: 'b1' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
79
79
  }
80
80
 
81
81
  it {
82
- expect { mapper.db_dump({ number: '1b' }) }.to raise_error(ReeMapper::TypeError)
82
+ expect { mapper.db_dump({ number: '1b' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
83
83
  }
84
84
 
85
85
  it {
86
- expect { mapper.db_dump({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError)
86
+ expect { mapper.db_dump({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
87
87
  }
88
88
  end
89
89
 
@@ -97,15 +97,15 @@ RSpec.describe ReeMapper::Integer do
97
97
  }
98
98
 
99
99
  it {
100
- expect { mapper.db_load({ number: 'b1' }) }.to raise_error(ReeMapper::CoercionError)
100
+ expect { mapper.db_load({ number: 'b1' }) }.to raise_error(ReeMapper::CoercionError, '`number` is invalid integer')
101
101
  }
102
102
 
103
103
  it {
104
- expect { mapper.db_load({ number: '1b' }) }.to raise_error(ReeMapper::CoercionError)
104
+ expect { mapper.db_load({ number: '1b' }) }.to raise_error(ReeMapper::CoercionError, '`number` is invalid integer')
105
105
  }
106
106
 
107
107
  it {
108
- expect { mapper.db_load({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError)
108
+ expect { mapper.db_load({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
109
109
  }
110
110
  end
111
111
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe ReeMapper::String do
3
+ RSpec.describe 'ReeMapper::String' do
4
4
  link :build_mapper_factory, from: :ree_mapper
5
5
  link :build_mapper_strategy, from: :ree_mapper
6
6
 
@@ -24,40 +24,40 @@ RSpec.describe ReeMapper::String do
24
24
  describe '#serialize' do
25
25
  it { expect(mapper.serialize({ str: 'str' })).to eq({ str: 'str' }) }
26
26
 
27
- it { expect { mapper.serialize({ str: nil }) }.to raise_error(ReeMapper::TypeError) }
27
+ it { expect { mapper.serialize({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
28
28
 
29
- it { expect { mapper.serialize({ str: :sym }) }.to raise_error(ReeMapper::TypeError) }
29
+ it { expect { mapper.serialize({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
30
30
 
31
- it { expect { mapper.serialize({ str: Object.new }) }.to raise_error(ReeMapper::TypeError) }
31
+ it { expect { mapper.serialize({ str: Object.new }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
32
32
  end
33
33
 
34
34
  describe '#cast' do
35
35
  it { expect(mapper.cast({ str: 'str' })).to eq({ str: 'str' }) }
36
36
 
37
- it { expect { mapper.cast({ str: nil }) }.to raise_error(ReeMapper::TypeError) }
37
+ it { expect { mapper.cast({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
38
38
 
39
- it { expect { mapper.cast({ str: :sym }) }.to raise_error(ReeMapper::TypeError) }
39
+ it { expect { mapper.cast({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
40
40
 
41
- it { expect { mapper.cast({ str: Object.new }) }.to raise_error(ReeMapper::TypeError) }
41
+ it { expect { mapper.cast({ str: Object.new }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
42
42
  end
43
43
 
44
44
  describe '#db_dump' do
45
45
  it { expect(mapper.db_dump({ str: 'str' })).to eq({ str: 'str' }) }
46
46
 
47
- it { expect { mapper.db_dump({ str: nil }) }.to raise_error(ReeMapper::TypeError) }
47
+ it { expect { mapper.db_dump({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
48
48
 
49
- it { expect { mapper.db_dump({ str: :sym }) }.to raise_error(ReeMapper::TypeError) }
49
+ it { expect { mapper.db_dump({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
50
50
 
51
- it { expect { mapper.db_dump({ str: Object.new }) }.to raise_error(ReeMapper::TypeError) }
51
+ it { expect { mapper.db_dump({ str: Object.new }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
52
52
  end
53
53
 
54
54
  describe '#db_load' do
55
55
  it { expect(mapper.db_load({ str: 'str' })).to eq({ str: 'str' }) }
56
56
 
57
- it { expect { mapper.db_load({ str: nil }) }.to raise_error(ReeMapper::TypeError) }
57
+ it { expect { mapper.db_load({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
58
58
 
59
- it { expect { mapper.db_load({ str: :sym }) }.to raise_error(ReeMapper::TypeError) }
59
+ it { expect { mapper.db_load({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
60
60
 
61
- it { expect { mapper.db_load({ str: Object.new }) }.to raise_error(ReeMapper::TypeError) }
61
+ it { expect { mapper.db_load({ str: Object.new }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
62
62
  end
63
63
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe ReeMapper::Time do
3
+ RSpec.describe 'ReeMapper::Time' do
4
4
  link :build_mapper_factory, from: :ree_mapper
5
5
  link :build_mapper_strategy, from: :ree_mapper
6
6
 
@@ -27,23 +27,23 @@ RSpec.describe ReeMapper::Time do
27
27
  }
28
28
 
29
29
  it {
30
- expect { mapper.serialize({ time: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError)
30
+ expect { mapper.serialize({ time: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
31
31
  }
32
32
 
33
33
  it {
34
- expect { mapper.serialize({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError)
34
+ expect { mapper.serialize({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
35
35
  }
36
36
 
37
37
  it {
38
- expect { mapper.serialize({ time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError)
38
+ expect { mapper.serialize({ time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
39
39
  }
40
40
 
41
41
  it {
42
- expect { mapper.serialize({ time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError)
42
+ expect { mapper.serialize({ time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
43
43
  }
44
44
 
45
45
  it {
46
- expect { mapper.serialize({ time: Object.new }) }.to raise_error(ReeMapper::TypeError)
46
+ expect { mapper.serialize({ time: Object.new }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
47
47
  }
48
48
  end
49
49
 
@@ -65,15 +65,15 @@ RSpec.describe ReeMapper::Time do
65
65
  }
66
66
 
67
67
  it {
68
- expect { mapper.cast({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError)
68
+ expect { mapper.cast({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
69
69
  }
70
70
 
71
71
  it {
72
- expect { mapper.cast({ time: Object.new }) }.to raise_error(ReeMapper::TypeError)
72
+ expect { mapper.cast({ time: Object.new }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
73
73
  }
74
74
 
75
75
  it {
76
- expect { mapper.cast({ time: 'no date time' }) }.to raise_error(ReeMapper::CoercionError)
76
+ expect { mapper.cast({ time: 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`time` is invalid time")
77
77
  }
78
78
  end
79
79
 
@@ -83,23 +83,23 @@ RSpec.describe ReeMapper::Time do
83
83
  }
84
84
 
85
85
  it {
86
- expect { mapper.serialize({ time: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError)
86
+ expect { mapper.serialize({ time: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
87
87
  }
88
88
 
89
89
  it {
90
- expect { mapper.db_dump({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError)
90
+ expect { mapper.db_dump({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
91
91
  }
92
92
 
93
93
  it {
94
- expect { mapper.db_dump({ time: Time.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError)
94
+ expect { mapper.db_dump({ time: Time.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
95
95
  }
96
96
 
97
97
  it {
98
- expect { mapper.db_dump({ time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError)
98
+ expect { mapper.db_dump({ time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
99
99
  }
100
100
 
101
101
  it {
102
- expect { mapper.db_dump({ time: Object.new }) }.to raise_error(ReeMapper::TypeError)
102
+ expect { mapper.db_dump({ time: Object.new }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
103
103
  }
104
104
  end
105
105
 
@@ -121,15 +121,15 @@ RSpec.describe ReeMapper::Time do
121
121
  }
122
122
 
123
123
  it {
124
- expect { mapper.db_load({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError)
124
+ expect { mapper.db_load({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
125
125
  }
126
126
 
127
127
  it {
128
- expect { mapper.db_load({ time: Object.new }) }.to raise_error(ReeMapper::TypeError)
128
+ expect { mapper.db_load({ time: Object.new }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
129
129
  }
130
130
 
131
131
  it {
132
- expect { mapper.db_load({ time: 'no date time' }) }.to raise_error(ReeMapper::CoercionError)
132
+ expect { mapper.db_load({ time: 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`time` is invalid time")
133
133
  }
134
134
  end
135
135
  end