ree_lib 1.0.16 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/mapper.rb +7 -6
  4. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/abstract_type.rb +4 -4
  5. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/array.rb +20 -20
  6. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/bool.rb +12 -12
  7. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/date.rb +13 -13
  8. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/date_time.rb +13 -13
  9. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/float.rb +13 -13
  10. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/integer.rb +13 -13
  11. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/string.rb +12 -12
  12. data/lib/ree_lib/packages/ree_mapper/package/ree_mapper/types/time.rb +13 -13
  13. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/array_spec.rb +15 -6
  14. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/bool_spec.rb +9 -9
  15. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/date_spec.rb +11 -11
  16. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/date_time_spec.rb +17 -17
  17. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/float_spec.rb +14 -14
  18. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/hash_spec.rb +5 -1
  19. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/integer_spec.rb +15 -15
  20. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/string_spec.rb +13 -13
  21. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/time_spec.rb +17 -17
  22. data/lib/ree_lib/packages/ree_mapper/spec/ree_mapper/types/type_options_spec.rb +2 -2
  23. data/lib/ree_lib/version.rb +1 -1
  24. metadata +2 -4
  25. data/lib/ree_lib/packages/ree_dao/package/ree_dao/types/pg_array.rb +0 -43
  26. 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::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
@@ -170,7 +170,7 @@ RSpec.describe 'ReeMapper::MapperFactory type options' do
170
170
  }
171
171
 
172
172
  it {
173
- expect { mapper.cast({ number: nil }) }.to raise_error(ReeMapper::TypeError, 'should be an integer')
173
+ expect { mapper.cast({ number: nil }) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
174
174
  }
175
175
 
176
176
  it {
@@ -183,7 +183,7 @@ RSpec.describe 'ReeMapper::MapperFactory type options' do
183
183
  let(:mapper) { mapper_factory.call.use(:cast) { integer? :number, default: :not_number } }
184
184
 
185
185
  it {
186
- expect { mapper.cast({}) }.to raise_error(ReeMapper::TypeError, 'should be an integer')
186
+ expect { mapper.cast({}) }.to raise_error(ReeMapper::TypeError, '`number` should be an integer')
187
187
  }
188
188
  end
189
189
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.16"
4
+ VERSION = "1.0.17"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ree_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.16
4
+ version: 1.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-15 00:00:00.000000000 Z
11
+ date: 2022-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ree
@@ -249,7 +249,6 @@ files:
249
249
  - lib/ree_lib/packages/ree_dao/package/ree_dao/functions/build_pg_connection.rb
250
250
  - lib/ree_lib/packages/ree_dao/package/ree_dao/functions/build_sqlite_connection.rb
251
251
  - lib/ree_lib/packages/ree_dao/package/ree_dao/functions/persist_assoc.rb
252
- - lib/ree_lib/packages/ree_dao/package/ree_dao/types/pg_array.rb
253
252
  - lib/ree_lib/packages/ree_dao/schemas/ree_dao/beans/connections.schema.json
254
253
  - lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/build_connection.schema.json
255
254
  - lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/build_dao.schema.json
@@ -259,7 +258,6 @@ files:
259
258
  - lib/ree_lib/packages/ree_dao/spec/package_schema_spec.rb
260
259
  - lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/build_sqlite_connection_spec.rb
261
260
  - lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/persist_assoc_spec.rb
262
- - lib/ree_lib/packages/ree_dao/spec/ree_dao/types/pg_array_spec.rb
263
261
  - lib/ree_lib/packages/ree_dao/spec/spec_helper.rb
264
262
  - lib/ree_lib/packages/ree_date/.gitignore
265
263
  - lib/ree_lib/packages/ree_date/.rspec
@@ -1,43 +0,0 @@
1
- require "sequel/extensions/pg_array"
2
-
3
- class ReeDao::PgArray < ReeMapper::AbstractType
4
- contract(
5
- ReeEnum::Value,
6
- Kwargs[
7
- role: Nilor[Symbol, ArrayOf[Symbol]]
8
- ] => String
9
- )
10
- def serialize(value, role: nil)
11
- raise ArgumentError.new("not supported")
12
- end
13
-
14
- contract(
15
- Any,
16
- Kwargs[
17
- role: Nilor[Symbol, ArrayOf[Symbol]]
18
- ] => ReeEnum::Value
19
- ).throws(ReeMapper::CoercionError)
20
- def cast(value, role: nil)
21
- raise ArgumentError.new("not supported")
22
- end
23
-
24
- contract(
25
- ArrayOf[Any],
26
- Kwargs[
27
- role: Nilor[Symbol, ArrayOf[Symbol]]
28
- ] => Sequel::Postgres::PGArray
29
- )
30
- def db_dump(value, role: nil)
31
- Sequel.pg_array(value)
32
- end
33
-
34
- contract(
35
- Sequel::Postgres::PGArray,
36
- Kwargs[
37
- role: Nilor[Symbol, ArrayOf[Symbol]]
38
- ] => ArrayOf[Any]
39
- ).throws(ReeMapper::TypeError)
40
- def db_load(value, role: nil)
41
- value.to_a
42
- end
43
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal = true
2
- package_require("ree_dao/types/pg_array")
3
-
4
- RSpec.describe ReeDao::PgArray do
5
- it {
6
- type = ReeDao::PgArray.new
7
-
8
- result = type.db_dump([1], role: nil)
9
- expect(result).to be_a(Sequel::Postgres::PGArray)
10
- }
11
-
12
- it {
13
- type = ReeDao::PgArray.new
14
-
15
- result = type.db_dump([1], role: nil)
16
- result = type.db_load(result, role: nil)
17
- expect(result).to eq([1])
18
- }
19
- end