ree_lib 1.0.85 → 1.0.86
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/lib/ree_lib/packages/ree_actions/package/ree_actions/dsl.rb +11 -3
- data/lib/ree_lib/packages/ree_actions/package/ree_actions/errors.rb +3 -0
- data/lib/ree_lib/packages/ree_actions/package/ree_actions.rb +1 -0
- data/lib/ree_lib/packages/ree_actions/spec/ree_actions/dsl_spec.rb +5 -1
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/wrappers/pg_array.rb +2 -2
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/wrappers/pg_jsonb.rb +2 -2
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/wrappers/pg_array_spec.rb +2 -2
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/wrappers/pg_jsonb_spec.rb +8 -6
- data/lib/ree_lib/packages/ree_enum/package/ree_enum/base_enum_mapper.rb +1 -6
- data/lib/ree_lib/packages/ree_enum/package/ree_enum/integer_value_enum_mapper.rb +1 -1
- data/lib/ree_lib/packages/ree_enum/package/ree_enum/string_value_enum_mapper.rb +1 -1
- data/lib/ree_lib/packages/ree_enum/spec/ree_enum/dsl_spec.rb +9 -1
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/abstract_type.rb +6 -0
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/bool.rb +2 -2
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/date.rb +3 -3
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/date_time.rb +3 -3
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/float.rb +3 -3
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/integer.rb +6 -6
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/rational.rb +3 -3
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb +1 -1
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/time.rb +3 -3
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/wrappers/abstract_wrapper.rb +7 -0
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/wrappers/array.rb +4 -4
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper.rb +1 -0
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/mapper_factory_spec.rb +2 -2
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/bool_spec.rb +10 -8
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/date_spec.rb +12 -10
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/date_time_spec.rb +20 -16
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/float_spec.rb +17 -13
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/hash_spec.rb +1 -1
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/integer_spec.rb +14 -14
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/rational_spec.rb +16 -12
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/string_spec.rb +24 -12
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/time_spec.rb +20 -16
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/type_options_spec.rb +4 -4
- data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/wrappers/array_spec.rb +6 -6
- data/lib/ree_lib/packages/ree_roda/package/ree_roda/app.rb +3 -2
- data/lib/ree_lib/packages/ree_roda/spec/ree_roda/app_spec.rb +28 -0
- data/lib/ree_lib/version.rb +1 -1
- metadata +3 -2
@@ -27,23 +27,24 @@ 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, "`date_time` should be a datetime")
|
30
|
+
expect { mapper.serialize({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Time.new(2020).inspect}`")
|
31
31
|
}
|
32
32
|
|
33
33
|
it {
|
34
|
-
expect { mapper.serialize({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
|
34
|
+
expect { mapper.serialize({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Date.new(2020).inspect}`")
|
35
35
|
}
|
36
36
|
|
37
37
|
it {
|
38
|
-
expect { mapper.serialize({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
|
38
|
+
expect { mapper.serialize({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `\"#{DateTime.new(2020).to_s}\"`")
|
39
39
|
}
|
40
40
|
|
41
41
|
it {
|
42
|
-
expect { mapper.serialize({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
|
42
|
+
expect { mapper.serialize({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `\"2020-01-01\"`")
|
43
43
|
}
|
44
44
|
|
45
45
|
it {
|
46
|
-
|
46
|
+
object = Object.new
|
47
|
+
expect { mapper.serialize({ date_time: object }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{object.inspect}`")
|
47
48
|
}
|
48
49
|
end
|
49
50
|
|
@@ -65,15 +66,16 @@ RSpec.describe 'ReeMapper::DateTime' do
|
|
65
66
|
}
|
66
67
|
|
67
68
|
it {
|
68
|
-
expect { mapper.cast({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
|
69
|
+
expect { mapper.cast({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Date.new(2020).inspect}`")
|
69
70
|
}
|
70
71
|
|
71
72
|
it {
|
72
|
-
|
73
|
+
object = Object.new
|
74
|
+
expect { mapper.cast({ 'date_time' => object }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{object.inspect}`")
|
73
75
|
}
|
74
76
|
|
75
77
|
it {
|
76
|
-
expect { mapper.cast({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`date_time` is invalid datetime")
|
78
|
+
expect { mapper.cast({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`date_time` is invalid datetime, got `\"no date time\"`")
|
77
79
|
}
|
78
80
|
end
|
79
81
|
|
@@ -83,23 +85,24 @@ RSpec.describe 'ReeMapper::DateTime' do
|
|
83
85
|
}
|
84
86
|
|
85
87
|
it {
|
86
|
-
expect { mapper.db_dump OpenStruct.new({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
|
88
|
+
expect { mapper.db_dump OpenStruct.new({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Time.new(2020).inspect}`")
|
87
89
|
}
|
88
90
|
|
89
91
|
it {
|
90
|
-
expect { mapper.db_dump OpenStruct.new({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
|
92
|
+
expect { mapper.db_dump OpenStruct.new({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Date.new(2020).inspect}`")
|
91
93
|
}
|
92
94
|
|
93
95
|
it {
|
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")
|
96
|
+
expect { mapper.db_dump OpenStruct.new({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `\"#{DateTime.new(2020).to_s}\"`")
|
95
97
|
}
|
96
98
|
|
97
99
|
it {
|
98
|
-
expect { mapper.db_dump OpenStruct.new({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
|
100
|
+
expect { mapper.db_dump OpenStruct.new({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `\"2020-01-01\"`")
|
99
101
|
}
|
100
102
|
|
101
103
|
it {
|
102
|
-
|
104
|
+
object = Object.new
|
105
|
+
expect { mapper.db_dump OpenStruct.new({ date_time: object }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{object.inspect}`")
|
103
106
|
}
|
104
107
|
end
|
105
108
|
|
@@ -121,15 +124,16 @@ RSpec.describe 'ReeMapper::DateTime' do
|
|
121
124
|
}
|
122
125
|
|
123
126
|
it {
|
124
|
-
expect { mapper.db_load({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime")
|
127
|
+
expect { mapper.db_load({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Date.new(2020).inspect}`")
|
125
128
|
}
|
126
129
|
|
127
130
|
it {
|
128
|
-
|
131
|
+
object = Object.new
|
132
|
+
expect { mapper.db_load({ 'date_time' => object }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{object.inspect}`")
|
129
133
|
}
|
130
134
|
|
131
135
|
it {
|
132
|
-
expect { mapper.db_load({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`date_time` is invalid datetime")
|
136
|
+
expect { mapper.db_load({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`date_time` is invalid datetime, got `\"no date time\"`")
|
133
137
|
}
|
134
138
|
end
|
135
139
|
end
|
@@ -40,15 +40,16 @@ RSpec.describe 'ReeMapper::Float' do
|
|
40
40
|
}
|
41
41
|
|
42
42
|
it {
|
43
|
-
expect { mapper.cast({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float')
|
43
|
+
expect { mapper.cast({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float, got `"a1.1"`')
|
44
44
|
}
|
45
45
|
|
46
46
|
it {
|
47
|
-
expect { mapper.cast({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float')
|
47
|
+
expect { mapper.cast({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float, got `"1.1a"`')
|
48
48
|
}
|
49
49
|
|
50
50
|
it {
|
51
|
-
|
51
|
+
object = Object.new
|
52
|
+
expect { mapper.cast({ float: object }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `#{object.inspect}`")
|
52
53
|
}
|
53
54
|
end
|
54
55
|
|
@@ -58,15 +59,16 @@ RSpec.describe 'ReeMapper::Float' do
|
|
58
59
|
}
|
59
60
|
|
60
61
|
it {
|
61
|
-
expect { mapper.serialize({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
|
62
|
+
expect { mapper.serialize({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `\"1.1\"`")
|
62
63
|
}
|
63
64
|
|
64
65
|
it {
|
65
|
-
expect { mapper.serialize({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
|
66
|
+
expect { mapper.serialize({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `nil`")
|
66
67
|
}
|
67
68
|
|
68
69
|
it {
|
69
|
-
|
70
|
+
object = Object.new
|
71
|
+
expect { mapper.serialize({ float: object }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `#{object.inspect}`")
|
70
72
|
}
|
71
73
|
end
|
72
74
|
|
@@ -76,15 +78,16 @@ RSpec.describe 'ReeMapper::Float' do
|
|
76
78
|
}
|
77
79
|
|
78
80
|
it {
|
79
|
-
expect { mapper.db_dump({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
|
81
|
+
expect { mapper.db_dump({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `\"1.1\"`")
|
80
82
|
}
|
81
83
|
|
82
84
|
it {
|
83
|
-
expect { mapper.db_dump({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
|
85
|
+
expect { mapper.db_dump({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `nil`")
|
84
86
|
}
|
85
87
|
|
86
88
|
it {
|
87
|
-
|
89
|
+
object = Object.new
|
90
|
+
expect { mapper.db_dump({ float: object }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `#{object.inspect}`")
|
88
91
|
}
|
89
92
|
end
|
90
93
|
|
@@ -106,19 +109,20 @@ RSpec.describe 'ReeMapper::Float' do
|
|
106
109
|
}
|
107
110
|
|
108
111
|
it {
|
109
|
-
expect { mapper.db_load({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float')
|
112
|
+
expect { mapper.db_load({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float, got `"a1.1"`')
|
110
113
|
}
|
111
114
|
|
112
115
|
it {
|
113
|
-
expect { mapper.db_load({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float')
|
116
|
+
expect { mapper.db_load({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float, got `"1.1a"`')
|
114
117
|
}
|
115
118
|
|
116
119
|
it {
|
117
|
-
expect { mapper.db_load({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float")
|
120
|
+
expect { mapper.db_load({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `nil`")
|
118
121
|
}
|
119
122
|
|
120
123
|
it {
|
121
|
-
|
124
|
+
object = Object.new
|
125
|
+
expect { mapper.db_load({ float: object }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `#{object.inspect}`")
|
122
126
|
}
|
123
127
|
end
|
124
128
|
end
|
@@ -31,7 +31,7 @@ RSpec.describe 'Mapper Hash' do
|
|
31
31
|
}
|
32
32
|
|
33
33
|
it {
|
34
|
-
expect { mapper.cast({ point: { x: 1, y: 'not integer' } }) }.to raise_error(ReeMapper::CoercionError, '`point[y]` is invalid integer')
|
34
|
+
expect { mapper.cast({ point: { x: 1, y: 'not integer' } }) }.to raise_error(ReeMapper::CoercionError, '`point[y]` is invalid integer, got `"not integer"`')
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
@@ -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, '`number` is invalid integer')
|
34
|
+
expect { mapper.cast({ number: 'b1' }) }.to raise_error(ReeMapper::CoercionError, '`number` is invalid integer, got `"b1"`')
|
35
35
|
}
|
36
36
|
|
37
37
|
it {
|
38
|
-
expect { mapper.cast({ number: '1b' }) }.to raise_error(ReeMapper::CoercionError, '`number` is invalid integer')
|
38
|
+
expect { mapper.cast({ number: '1b' }) }.to raise_error(ReeMapper::CoercionError, '`number` is invalid integer, got `"1b"`')
|
39
39
|
}
|
40
40
|
|
41
41
|
it {
|
42
|
-
expect { mapper.cast({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
|
42
|
+
expect { mapper.cast({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `1.1`')
|
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, '`number` should be an integer')
|
52
|
+
expect { mapper.serialize({ number: '1' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `"1"`')
|
53
53
|
}
|
54
54
|
|
55
55
|
it {
|
56
|
-
expect { mapper.serialize({ number: 'b1' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
|
56
|
+
expect { mapper.serialize({ number: 'b1' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `"b1"`')
|
57
57
|
}
|
58
58
|
|
59
59
|
it {
|
60
|
-
expect { mapper.serialize({ number: '1b' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
|
60
|
+
expect { mapper.serialize({ number: '1b' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `"1b"`')
|
61
61
|
}
|
62
62
|
|
63
63
|
it {
|
64
|
-
expect { mapper.serialize({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
|
64
|
+
expect { mapper.serialize({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `1.1`')
|
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, '`number` should be an integer')
|
74
|
+
expect { mapper.db_dump({ number: '1' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `"1"`')
|
75
75
|
}
|
76
76
|
|
77
77
|
it {
|
78
|
-
expect { mapper.db_dump({ number: 'b1' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
|
78
|
+
expect { mapper.db_dump({ number: 'b1' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `"b1"`')
|
79
79
|
}
|
80
80
|
|
81
81
|
it {
|
82
|
-
expect { mapper.db_dump({ number: '1b' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
|
82
|
+
expect { mapper.db_dump({ number: '1b' }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `"1b"`')
|
83
83
|
}
|
84
84
|
|
85
85
|
it {
|
86
|
-
expect { mapper.db_dump({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
|
86
|
+
expect { mapper.db_dump({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `1.1`')
|
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, '`number` is invalid integer')
|
100
|
+
expect { mapper.db_load({ number: 'b1' }) }.to raise_error(ReeMapper::CoercionError, '`number` is invalid integer, got `"b1"`')
|
101
101
|
}
|
102
102
|
|
103
103
|
it {
|
104
|
-
expect { mapper.db_load({ number: '1b' }) }.to raise_error(ReeMapper::CoercionError, '`number` is invalid integer')
|
104
|
+
expect { mapper.db_load({ number: '1b' }) }.to raise_error(ReeMapper::CoercionError, '`number` is invalid integer, got `"1b"`')
|
105
105
|
}
|
106
106
|
|
107
107
|
it {
|
108
|
-
expect { mapper.db_load({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
|
108
|
+
expect { mapper.db_load({ number: 1.1 }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `1.1`')
|
109
109
|
}
|
110
110
|
end
|
111
111
|
end
|
@@ -40,15 +40,16 @@ RSpec.describe 'ReeMapper::Rational' do
|
|
40
40
|
}
|
41
41
|
|
42
42
|
it {
|
43
|
-
expect { mapper.cast({ rational: 'a333' }) }.to raise_error(ReeMapper::CoercionError, '`rational` is invalid rational')
|
43
|
+
expect { mapper.cast({ rational: 'a333' }) }.to raise_error(ReeMapper::CoercionError, '`rational` is invalid rational, got `"a333"`')
|
44
44
|
}
|
45
45
|
|
46
46
|
it {
|
47
|
-
expect { mapper.cast({ rational: '333a' }) }.to raise_error(ReeMapper::CoercionError, '`rational` is invalid rational')
|
47
|
+
expect { mapper.cast({ rational: '333a' }) }.to raise_error(ReeMapper::CoercionError, '`rational` is invalid rational, got `"333a"`')
|
48
48
|
}
|
49
49
|
|
50
50
|
it {
|
51
|
-
|
51
|
+
object = Object.new
|
52
|
+
expect { mapper.cast({ rational: object }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational, got `#{object.inspect}`")
|
52
53
|
}
|
53
54
|
end
|
54
55
|
|
@@ -58,15 +59,16 @@ RSpec.describe 'ReeMapper::Rational' do
|
|
58
59
|
}
|
59
60
|
|
60
61
|
it {
|
61
|
-
expect { mapper.serialize({ rational: '1/3' }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational")
|
62
|
+
expect { mapper.serialize({ rational: '1/3' }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational, got `\"1/3\"`")
|
62
63
|
}
|
63
64
|
|
64
65
|
it {
|
65
|
-
expect { mapper.serialize({ rational: nil }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational")
|
66
|
+
expect { mapper.serialize({ rational: nil }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational, got `nil`")
|
66
67
|
}
|
67
68
|
|
68
69
|
it {
|
69
|
-
|
70
|
+
object = Object.new
|
71
|
+
expect { mapper.serialize({ rational: object }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational, got `#{object.inspect}`")
|
70
72
|
}
|
71
73
|
end
|
72
74
|
|
@@ -76,15 +78,16 @@ RSpec.describe 'ReeMapper::Rational' do
|
|
76
78
|
}
|
77
79
|
|
78
80
|
it {
|
79
|
-
expect { mapper.db_dump({ rational: '1/3' }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational")
|
81
|
+
expect { mapper.db_dump({ rational: '1/3' }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational, got `\"1/3\"`")
|
80
82
|
}
|
81
83
|
|
82
84
|
it {
|
83
|
-
expect { mapper.db_dump({ rational: nil }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational")
|
85
|
+
expect { mapper.db_dump({ rational: nil }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational, got `nil`")
|
84
86
|
}
|
85
87
|
|
86
88
|
it {
|
87
|
-
|
89
|
+
object = Object.new
|
90
|
+
expect { mapper.db_dump({ rational: object }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational, got `#{object.inspect}`")
|
88
91
|
}
|
89
92
|
end
|
90
93
|
|
@@ -106,15 +109,16 @@ RSpec.describe 'ReeMapper::Rational' do
|
|
106
109
|
}
|
107
110
|
|
108
111
|
it {
|
109
|
-
expect { mapper.db_load({ rational: 'a333' }) }.to raise_error(ReeMapper::CoercionError, '`rational` is invalid rational')
|
112
|
+
expect { mapper.db_load({ rational: 'a333' }) }.to raise_error(ReeMapper::CoercionError, '`rational` is invalid rational, got `"a333"`')
|
110
113
|
}
|
111
114
|
|
112
115
|
it {
|
113
|
-
expect { mapper.db_load({ rational: '333a' }) }.to raise_error(ReeMapper::CoercionError, '`rational` is invalid rational')
|
116
|
+
expect { mapper.db_load({ rational: '333a' }) }.to raise_error(ReeMapper::CoercionError, '`rational` is invalid rational, got `"333a"`')
|
114
117
|
}
|
115
118
|
|
116
119
|
it {
|
117
|
-
|
120
|
+
object = Object.new
|
121
|
+
expect { mapper.db_load({ rational: object }) }.to raise_error(ReeMapper::TypeError, "`rational` should be a rational, got `#{object.inspect}`")
|
118
122
|
}
|
119
123
|
end
|
120
124
|
end
|
@@ -24,40 +24,52 @@ 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, "`str` should be a string") }
|
27
|
+
it { expect { mapper.serialize({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `nil`") }
|
28
28
|
|
29
|
-
it { expect { mapper.serialize({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
|
29
|
+
it { expect { mapper.serialize({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `:sym`") }
|
30
30
|
|
31
|
-
it {
|
31
|
+
it {
|
32
|
+
object = Object.new
|
33
|
+
expect { mapper.serialize({ str: object }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `#{object.inspect}`")
|
34
|
+
}
|
32
35
|
end
|
33
36
|
|
34
37
|
describe '#cast' do
|
35
38
|
it { expect(mapper.cast({ str: 'str' })).to eq({ str: 'str' }) }
|
36
39
|
|
37
|
-
it { expect { mapper.cast({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
|
40
|
+
it { expect { mapper.cast({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `nil`") }
|
38
41
|
|
39
|
-
it { expect { mapper.cast({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
|
42
|
+
it { expect { mapper.cast({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `:sym`") }
|
40
43
|
|
41
|
-
it {
|
44
|
+
it {
|
45
|
+
object = Object.new
|
46
|
+
expect { mapper.cast({ str: object }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `#{object.inspect}`")
|
47
|
+
}
|
42
48
|
end
|
43
49
|
|
44
50
|
describe '#db_dump' do
|
45
51
|
it { expect(mapper.db_dump({ str: 'str' })).to eq({ str: 'str' }) }
|
46
52
|
|
47
|
-
it { expect { mapper.db_dump({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
|
53
|
+
it { expect { mapper.db_dump({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `nil`") }
|
48
54
|
|
49
|
-
it { expect { mapper.db_dump({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
|
55
|
+
it { expect { mapper.db_dump({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `:sym`") }
|
50
56
|
|
51
|
-
it {
|
57
|
+
it {
|
58
|
+
object = Object.new
|
59
|
+
expect { mapper.db_dump({ str: object }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `#{object.inspect}`")
|
60
|
+
}
|
52
61
|
end
|
53
62
|
|
54
63
|
describe '#db_load' do
|
55
64
|
it { expect(mapper.db_load({ str: 'str' })).to eq({ str: 'str' }) }
|
56
65
|
|
57
|
-
it { expect { mapper.db_load({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
|
66
|
+
it { expect { mapper.db_load({ str: nil }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `nil`") }
|
58
67
|
|
59
|
-
it { expect { mapper.db_load({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string") }
|
68
|
+
it { expect { mapper.db_load({ str: :sym }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `:sym`") }
|
60
69
|
|
61
|
-
it {
|
70
|
+
it {
|
71
|
+
object = Object.new
|
72
|
+
expect { mapper.db_load({ str: object }) }.to raise_error(ReeMapper::TypeError, "`str` should be a string, got `#{object.inspect}`")
|
73
|
+
}
|
62
74
|
end
|
63
75
|
end
|
@@ -27,23 +27,24 @@ 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, "`time` should be a time")
|
30
|
+
expect { mapper.serialize({ time: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `#{DateTime.new(2020).inspect}`")
|
31
31
|
}
|
32
32
|
|
33
33
|
it {
|
34
|
-
expect { mapper.serialize({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
|
34
|
+
expect { mapper.serialize({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `#{Date.new(2020).inspect}`")
|
35
35
|
}
|
36
36
|
|
37
37
|
it {
|
38
|
-
expect { mapper.serialize({ time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
|
38
|
+
expect { mapper.serialize({ time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `\"2020-01-01T00:00:00+00:00\"`")
|
39
39
|
}
|
40
40
|
|
41
41
|
it {
|
42
|
-
expect { mapper.serialize({ time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
|
42
|
+
expect { mapper.serialize({ time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `\"2020-01-01\"`")
|
43
43
|
}
|
44
44
|
|
45
45
|
it {
|
46
|
-
|
46
|
+
object = Object.new
|
47
|
+
expect { mapper.serialize({ time: object }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `#{object.inspect}`")
|
47
48
|
}
|
48
49
|
end
|
49
50
|
|
@@ -65,15 +66,16 @@ RSpec.describe 'ReeMapper::Time' do
|
|
65
66
|
}
|
66
67
|
|
67
68
|
it {
|
68
|
-
expect { mapper.cast({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
|
69
|
+
expect { mapper.cast({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `#{Date.new(2020).inspect}`")
|
69
70
|
}
|
70
71
|
|
71
72
|
it {
|
72
|
-
|
73
|
+
object = Object.new
|
74
|
+
expect { mapper.cast({ time: object }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `#{object.inspect}`")
|
73
75
|
}
|
74
76
|
|
75
77
|
it {
|
76
|
-
expect { mapper.cast({ time: 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`time` is invalid time")
|
78
|
+
expect { mapper.cast({ time: 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`time` is invalid time, got `\"no date time\"`")
|
77
79
|
}
|
78
80
|
end
|
79
81
|
|
@@ -83,23 +85,24 @@ RSpec.describe 'ReeMapper::Time' do
|
|
83
85
|
}
|
84
86
|
|
85
87
|
it {
|
86
|
-
expect { mapper.serialize({ time: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
|
88
|
+
expect { mapper.serialize({ time: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `#{DateTime.new(2020).inspect}`")
|
87
89
|
}
|
88
90
|
|
89
91
|
it {
|
90
|
-
expect { mapper.db_dump({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
|
92
|
+
expect { mapper.db_dump({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `#{Date.new(2020).inspect}`")
|
91
93
|
}
|
92
94
|
|
93
95
|
it {
|
94
|
-
expect { mapper.db_dump({ time: Time.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
|
96
|
+
expect { mapper.db_dump({ time: Time.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `\"2020-01-01 00:00:00 +0000\"`")
|
95
97
|
}
|
96
98
|
|
97
99
|
it {
|
98
|
-
expect { mapper.db_dump({ time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
|
100
|
+
expect { mapper.db_dump({ time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `\"2020-01-01\"`")
|
99
101
|
}
|
100
102
|
|
101
103
|
it {
|
102
|
-
|
104
|
+
object = Object.new
|
105
|
+
expect { mapper.db_dump({ time: object }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `#{object.inspect}`")
|
103
106
|
}
|
104
107
|
end
|
105
108
|
|
@@ -121,15 +124,16 @@ RSpec.describe 'ReeMapper::Time' do
|
|
121
124
|
}
|
122
125
|
|
123
126
|
it {
|
124
|
-
expect { mapper.db_load({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time")
|
127
|
+
expect { mapper.db_load({ time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `#{Date.new(2020).inspect}`")
|
125
128
|
}
|
126
129
|
|
127
130
|
it {
|
128
|
-
|
131
|
+
object = Object.new
|
132
|
+
expect { mapper.db_load({ time: object }) }.to raise_error(ReeMapper::TypeError, "`time` should be a time, got `#{object.inspect}`")
|
129
133
|
}
|
130
134
|
|
131
135
|
it {
|
132
|
-
expect { mapper.db_load({ time: 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`time` is invalid time")
|
136
|
+
expect { mapper.db_load({ time: 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`time` is invalid time, got `\"no date time\"`")
|
133
137
|
}
|
134
138
|
end
|
135
139
|
end
|
@@ -193,7 +193,7 @@ RSpec.describe 'ReeMapper::MapperFactory type options' do
|
|
193
193
|
}
|
194
194
|
|
195
195
|
it {
|
196
|
-
expect { mapper.cast({}) }.to raise_error(ReeMapper::TypeError)
|
196
|
+
expect { mapper.cast({}) }.to raise_error(ReeMapper::TypeError, "Missing required field `number` for `root`")
|
197
197
|
}
|
198
198
|
|
199
199
|
it {
|
@@ -226,7 +226,7 @@ RSpec.describe 'ReeMapper::MapperFactory type options' do
|
|
226
226
|
}
|
227
227
|
|
228
228
|
it {
|
229
|
-
expect { mapper.cast({ number: nil, number_or_nil: 1 }) }.to raise_error(ReeMapper::TypeError)
|
229
|
+
expect { mapper.cast({ number: nil, number_or_nil: 1 }) }.to raise_error(ReeMapper::TypeError, "`number` should be an integer, got `nil`")
|
230
230
|
}
|
231
231
|
end
|
232
232
|
|
@@ -306,7 +306,7 @@ RSpec.describe 'ReeMapper::MapperFactory type options' do
|
|
306
306
|
}
|
307
307
|
|
308
308
|
it {
|
309
|
-
expect { mapper.cast({ number: nil }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
|
309
|
+
expect { mapper.cast({ number: nil }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `nil`')
|
310
310
|
}
|
311
311
|
|
312
312
|
it {
|
@@ -319,7 +319,7 @@ RSpec.describe 'ReeMapper::MapperFactory type options' do
|
|
319
319
|
let(:mapper) { mapper_factory.call.use(:cast) { integer? :number, default: :not_number } }
|
320
320
|
|
321
321
|
it {
|
322
|
-
expect { mapper.cast({}) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
|
322
|
+
expect { mapper.cast({}) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer, got `:not_number`')
|
323
323
|
}
|
324
324
|
end
|
325
325
|
end
|
@@ -28,15 +28,15 @@ RSpec.describe 'ReeMapper::Array' do
|
|
28
28
|
}
|
29
29
|
|
30
30
|
it {
|
31
|
-
expect { mapper.serialize({ tags: 1 }) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array")
|
31
|
+
expect { mapper.serialize({ tags: 1 }) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array, got `1`")
|
32
32
|
}
|
33
33
|
|
34
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")
|
35
|
+
expect { mapper.serialize({tags: [1], ary_of_ary: ["1"] }) }.to raise_error(ReeMapper::TypeError, "`ary_of_ary[0]` should be an array, got `\"1\"`")
|
36
36
|
}
|
37
37
|
|
38
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")
|
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, got `\"1\"`")
|
40
40
|
}
|
41
41
|
end
|
42
42
|
|
@@ -46,7 +46,7 @@ RSpec.describe 'ReeMapper::Array' do
|
|
46
46
|
}
|
47
47
|
|
48
48
|
it {
|
49
|
-
expect { mapper.cast({ 'tags' => 1 }) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array")
|
49
|
+
expect { mapper.cast({ 'tags' => 1 }) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array, got `1`")
|
50
50
|
}
|
51
51
|
end
|
52
52
|
|
@@ -56,7 +56,7 @@ RSpec.describe 'ReeMapper::Array' do
|
|
56
56
|
}
|
57
57
|
|
58
58
|
it {
|
59
|
-
expect { mapper.db_dump(OpenStruct.new({ tags: 1 })) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array")
|
59
|
+
expect { mapper.db_dump(OpenStruct.new({ tags: 1 })) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array, got `1`")
|
60
60
|
}
|
61
61
|
end
|
62
62
|
|
@@ -66,7 +66,7 @@ RSpec.describe 'ReeMapper::Array' do
|
|
66
66
|
}
|
67
67
|
|
68
68
|
it {
|
69
|
-
expect { mapper.db_load({ 'tags' => 1 }) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array")
|
69
|
+
expect { mapper.db_load({ 'tags' => 1 }) }.to raise_error(ReeMapper::TypeError, "`tags` should be an array, got `1`")
|
70
70
|
}
|
71
71
|
end
|
72
72
|
|
@@ -1,5 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
package_require("ree_errors/error")
|
2
|
-
package_require("
|
3
|
+
package_require("ree_actions/errors")
|
3
4
|
|
4
5
|
class ReeRoda::App < Roda
|
5
6
|
include Ree::LinkDSL
|
@@ -25,7 +26,7 @@ class ReeRoda::App < Roda
|
|
25
26
|
response.status = status_from_error(e.type)
|
26
27
|
response.write(to_json(body))
|
27
28
|
response.finish
|
28
|
-
elsif e.is_a?(
|
29
|
+
elsif e.is_a?(ReeActions::ParamError)
|
29
30
|
body = {
|
30
31
|
code: "param",
|
31
32
|
message: e.message,
|