deimos-ruby 1.13.2 → 1.14.1
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/CHANGELOG.md +15 -0
- data/README.md +6 -0
- data/deimos-ruby.gemspec +1 -0
- data/lib/deimos/active_record_consume/message_consumption.rb +2 -1
- data/lib/deimos/config/configuration.rb +4 -0
- data/lib/deimos/schema_backends/avro_base.rb +1 -1
- data/lib/deimos/schema_class/base.rb +17 -0
- data/lib/deimos/test_helpers.rb +1 -1
- data/lib/deimos/version.rb +1 -1
- data/lib/generators/deimos/active_record/templates/migration.rb.tt +5 -3
- data/lib/generators/deimos/active_record_generator.rb +1 -1
- data/lib/generators/deimos/schema_class/templates/schema_class.rb.tt +0 -7
- data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +10 -1
- data/lib/generators/deimos/schema_class_generator.rb +19 -7
- data/spec/active_record_consumer_spec.rb +21 -0
- data/spec/generators/active_record_generator_spec.rb +4 -2
- data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +37 -24
- data/spec/generators/schema_class_generator_spec.rb +93 -55
- data/spec/producer_spec.rb +1 -1
- data/spec/schemas/com/my-namespace/MySchemaId_key.avsc +12 -0
- data/spec/schemas/generated.rb +159 -0
- data/spec/schemas/my_nested_schema.rb +117 -0
- data/spec/{schema_classes → schemas}/my_schema.rb +1 -0
- data/spec/{schema_classes → schemas}/my_schema_key.rb +1 -0
- data/spec/schemas/my_schema_with_circular_reference.rb +77 -0
- data/spec/schemas/my_schema_with_complex_type.rb +239 -0
- data/spec/{schema_classes/generated.rb → snapshots/consumers-no-nest.snap} +20 -1
- data/spec/snapshots/consumers.snap +161 -0
- data/spec/snapshots/consumers_and_producers-no-nest.snap +397 -0
- data/spec/snapshots/consumers_and_producers.snap +377 -0
- data/spec/{schema_classes/my_schema_with_circular_reference.rb → snapshots/consumers_circular-no-nest.snap} +37 -26
- data/spec/snapshots/consumers_circular.snap +79 -0
- data/spec/{schema_classes/my_schema_with_complex_types.rb → snapshots/consumers_complex_types-no-nest.snap} +57 -22
- data/spec/snapshots/consumers_complex_types.snap +241 -0
- data/spec/{schema_classes/my_nested_schema.rb → snapshots/consumers_nested-no-nest.snap} +12 -1
- data/spec/snapshots/consumers_nested.snap +119 -0
- data/spec/snapshots/producers_with_key-no-nest.snap +95 -0
- data/spec/snapshots/producers_with_key.snap +95 -0
- data/spec/spec_helper.rb +4 -1
- metadata +54 -14
@@ -0,0 +1,241 @@
|
|
1
|
+
spec/app/lib/schema_classes/my_schema_with_complex_type.rb:
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# This file is autogenerated by Deimos, Do NOT modify
|
5
|
+
module Schemas
|
6
|
+
### Primary Schema Class ###
|
7
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchemaWithComplexTypes
|
8
|
+
class MySchemaWithComplexType < Deimos::SchemaClass::Record
|
9
|
+
|
10
|
+
### Secondary Schema Classes ###
|
11
|
+
# Autogenerated Schema for Record at com.my-namespace.ARecord
|
12
|
+
class ARecord < Deimos::SchemaClass::Record
|
13
|
+
|
14
|
+
### Attribute Accessors ###
|
15
|
+
# @param value [String]
|
16
|
+
attr_accessor :a_record_field
|
17
|
+
|
18
|
+
# @override
|
19
|
+
def initialize(a_record_field: nil)
|
20
|
+
super
|
21
|
+
self.a_record_field = a_record_field
|
22
|
+
end
|
23
|
+
|
24
|
+
# @override
|
25
|
+
def schema
|
26
|
+
'ARecord'
|
27
|
+
end
|
28
|
+
|
29
|
+
# @override
|
30
|
+
def namespace
|
31
|
+
'com.my-namespace'
|
32
|
+
end
|
33
|
+
|
34
|
+
# @override
|
35
|
+
def to_h
|
36
|
+
{
|
37
|
+
'a_record_field' => @a_record_field
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Autogenerated Schema for Enum at com.my-namespace.AnEnum
|
43
|
+
class AnEnum < Deimos::SchemaClass::Enum
|
44
|
+
# @return ['sym1', 'sym2']
|
45
|
+
attr_accessor :an_enum
|
46
|
+
|
47
|
+
# :nodoc:
|
48
|
+
def initialize(an_enum)
|
49
|
+
super
|
50
|
+
self.an_enum = an_enum
|
51
|
+
end
|
52
|
+
|
53
|
+
# @override
|
54
|
+
def symbols
|
55
|
+
%w(sym1 sym2)
|
56
|
+
end
|
57
|
+
|
58
|
+
# @override
|
59
|
+
def to_h
|
60
|
+
@an_enum
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Autogenerated Schema for Enum at com.my-namespace.AnotherEnum
|
65
|
+
class AnotherEnum < Deimos::SchemaClass::Enum
|
66
|
+
# @return ['sym3', 'sym4']
|
67
|
+
attr_accessor :another_enum
|
68
|
+
|
69
|
+
# :nodoc:
|
70
|
+
def initialize(another_enum)
|
71
|
+
super
|
72
|
+
self.another_enum = another_enum
|
73
|
+
end
|
74
|
+
|
75
|
+
# @override
|
76
|
+
def symbols
|
77
|
+
%w(sym3 sym4)
|
78
|
+
end
|
79
|
+
|
80
|
+
# @override
|
81
|
+
def to_h
|
82
|
+
@another_enum
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Autogenerated Schema for Enum at com.my-namespace.YetAnotherEnum
|
87
|
+
class YetAnotherEnum < Deimos::SchemaClass::Enum
|
88
|
+
# @return ['sym5', 'sym6']
|
89
|
+
attr_accessor :yet_another_enum
|
90
|
+
|
91
|
+
# :nodoc:
|
92
|
+
def initialize(yet_another_enum)
|
93
|
+
super
|
94
|
+
self.yet_another_enum = yet_another_enum
|
95
|
+
end
|
96
|
+
|
97
|
+
# @override
|
98
|
+
def symbols
|
99
|
+
%w(sym5 sym6)
|
100
|
+
end
|
101
|
+
|
102
|
+
# @override
|
103
|
+
def to_h
|
104
|
+
@yet_another_enum
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
### Attribute Readers ###
|
110
|
+
# @return [ARecord]
|
111
|
+
attr_reader :some_record
|
112
|
+
# @return [nil, ARecord]
|
113
|
+
attr_reader :some_optional_record
|
114
|
+
# @return [Array<ARecord>]
|
115
|
+
attr_reader :some_record_array
|
116
|
+
# @return [Hash<String, ARecord>]
|
117
|
+
attr_reader :some_record_map
|
118
|
+
# @return [Array<AnEnum>]
|
119
|
+
attr_reader :some_enum_array
|
120
|
+
# @return [nil, AnotherEnum]
|
121
|
+
attr_reader :some_optional_enum
|
122
|
+
# @return [YetAnotherEnum]
|
123
|
+
attr_reader :some_enum_with_default
|
124
|
+
|
125
|
+
### Attribute Accessors ###
|
126
|
+
# @param value [String]
|
127
|
+
attr_accessor :test_id
|
128
|
+
# @param value [Float]
|
129
|
+
attr_accessor :test_float
|
130
|
+
# @param values [Array<String>]
|
131
|
+
attr_accessor :test_string_array
|
132
|
+
# @param values [Array<Integer>]
|
133
|
+
attr_accessor :test_int_array
|
134
|
+
# @param value [Integer, nil]
|
135
|
+
attr_accessor :test_optional_int
|
136
|
+
# @param values [Hash<String, Integer>]
|
137
|
+
attr_accessor :some_integer_map
|
138
|
+
|
139
|
+
### Attribute Writers ###
|
140
|
+
# @param value [ARecord]
|
141
|
+
def some_record=(value)
|
142
|
+
@some_record = ARecord.initialize_from_value(value)
|
143
|
+
end
|
144
|
+
|
145
|
+
# @param value [nil, ARecord]
|
146
|
+
def some_optional_record=(value)
|
147
|
+
@some_optional_record = ARecord.initialize_from_value(value)
|
148
|
+
end
|
149
|
+
|
150
|
+
# @param values [Array<ARecord>]
|
151
|
+
def some_record_array=(values)
|
152
|
+
@some_record_array = values.map do |value|
|
153
|
+
ARecord.initialize_from_value(value)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# @param values [Hash<String, ARecord>]
|
158
|
+
def some_record_map=(values)
|
159
|
+
@some_record_map = values.transform_values do |value|
|
160
|
+
ARecord.initialize_from_value(value)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# @param values [Array<AnEnum>]
|
165
|
+
def some_enum_array=(values)
|
166
|
+
@some_enum_array = values.map do |value|
|
167
|
+
AnEnum.initialize_from_value(value)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# @param value [nil, AnotherEnum]
|
172
|
+
def some_optional_enum=(value)
|
173
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
174
|
+
end
|
175
|
+
|
176
|
+
# @param value [YetAnotherEnum]
|
177
|
+
def some_enum_with_default=(value)
|
178
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
179
|
+
end
|
180
|
+
|
181
|
+
# @override
|
182
|
+
def initialize(test_id: nil,
|
183
|
+
test_float: nil,
|
184
|
+
test_string_array: ["test"],
|
185
|
+
test_int_array: [123],
|
186
|
+
test_optional_int: 123,
|
187
|
+
some_integer_map: {"abc"=>123},
|
188
|
+
some_record: {"a_record_field"=>"Test String"},
|
189
|
+
some_optional_record: nil,
|
190
|
+
some_record_array: nil,
|
191
|
+
some_record_map: nil,
|
192
|
+
some_enum_array: nil,
|
193
|
+
some_optional_enum: nil,
|
194
|
+
some_enum_with_default: "sym6")
|
195
|
+
super
|
196
|
+
self.test_id = test_id
|
197
|
+
self.test_float = test_float
|
198
|
+
self.test_string_array = test_string_array
|
199
|
+
self.test_int_array = test_int_array
|
200
|
+
self.test_optional_int = test_optional_int
|
201
|
+
self.some_integer_map = some_integer_map
|
202
|
+
self.some_record = some_record
|
203
|
+
self.some_optional_record = some_optional_record
|
204
|
+
self.some_record_array = some_record_array
|
205
|
+
self.some_record_map = some_record_map
|
206
|
+
self.some_enum_array = some_enum_array
|
207
|
+
self.some_optional_enum = some_optional_enum
|
208
|
+
self.some_enum_with_default = some_enum_with_default
|
209
|
+
end
|
210
|
+
|
211
|
+
# @override
|
212
|
+
def schema
|
213
|
+
'MySchemaWithComplexTypes'
|
214
|
+
end
|
215
|
+
|
216
|
+
# @override
|
217
|
+
def namespace
|
218
|
+
'com.my-namespace'
|
219
|
+
end
|
220
|
+
|
221
|
+
# @override
|
222
|
+
def to_h
|
223
|
+
{
|
224
|
+
'test_id' => @test_id,
|
225
|
+
'test_float' => @test_float,
|
226
|
+
'test_string_array' => @test_string_array,
|
227
|
+
'test_int_array' => @test_int_array,
|
228
|
+
'test_optional_int' => @test_optional_int,
|
229
|
+
'some_integer_map' => @some_integer_map,
|
230
|
+
'some_record' => @some_record&.to_h,
|
231
|
+
'some_optional_record' => @some_optional_record&.to_h,
|
232
|
+
'some_record_array' => @some_record_array.map { |v| v&.to_h },
|
233
|
+
'some_record_map' => @some_record_map.transform_values { |v| v&.to_h },
|
234
|
+
'some_enum_array' => @some_enum_array.map { |v| v&.to_h },
|
235
|
+
'some_optional_enum' => @some_optional_enum&.to_h,
|
236
|
+
'some_enum_with_default' => @some_enum_with_default&.to_h
|
237
|
+
}
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
@@ -1,10 +1,12 @@
|
|
1
|
+
spec/app/lib/schema_classes/my_nested_record.rb:
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
# This file is autogenerated by Deimos, Do NOT modify
|
4
5
|
module Schemas
|
5
|
-
###
|
6
|
+
### Primary Schema Class ###
|
6
7
|
# Autogenerated Schema for Record at com.my-namespace.MyNestedRecord
|
7
8
|
class MyNestedRecord < Deimos::SchemaClass::Record
|
9
|
+
|
8
10
|
### Attribute Accessors ###
|
9
11
|
# @param value [Integer]
|
10
12
|
attr_accessor :some_int
|
@@ -47,10 +49,18 @@ module Schemas
|
|
47
49
|
}
|
48
50
|
end
|
49
51
|
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
spec/app/lib/schema_classes/my_nested_schema.rb:
|
56
|
+
# frozen_string_literal: true
|
50
57
|
|
58
|
+
# This file is autogenerated by Deimos, Do NOT modify
|
59
|
+
module Schemas
|
51
60
|
### Primary Schema Class ###
|
52
61
|
# Autogenerated Schema for Record at com.my-namespace.MyNestedSchema
|
53
62
|
class MyNestedSchema < Deimos::SchemaClass::Record
|
63
|
+
|
54
64
|
### Attribute Readers ###
|
55
65
|
# @return [MyNestedRecord]
|
56
66
|
attr_reader :some_nested_record
|
@@ -112,3 +122,4 @@ module Schemas
|
|
112
122
|
end
|
113
123
|
end
|
114
124
|
end
|
125
|
+
|
@@ -0,0 +1,119 @@
|
|
1
|
+
spec/app/lib/schema_classes/my_nested_schema.rb:
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# This file is autogenerated by Deimos, Do NOT modify
|
5
|
+
module Schemas
|
6
|
+
### Primary Schema Class ###
|
7
|
+
# Autogenerated Schema for Record at com.my-namespace.MyNestedSchema
|
8
|
+
class MyNestedSchema < Deimos::SchemaClass::Record
|
9
|
+
|
10
|
+
### Secondary Schema Classes ###
|
11
|
+
# Autogenerated Schema for Record at com.my-namespace.MyNestedRecord
|
12
|
+
class MyNestedRecord < Deimos::SchemaClass::Record
|
13
|
+
|
14
|
+
### Attribute Accessors ###
|
15
|
+
# @param value [Integer]
|
16
|
+
attr_accessor :some_int
|
17
|
+
# @param value [Float]
|
18
|
+
attr_accessor :some_float
|
19
|
+
# @param value [String]
|
20
|
+
attr_accessor :some_string
|
21
|
+
# @param value [nil, Integer]
|
22
|
+
attr_accessor :some_optional_int
|
23
|
+
|
24
|
+
# @override
|
25
|
+
def initialize(some_int: nil,
|
26
|
+
some_float: nil,
|
27
|
+
some_string: nil,
|
28
|
+
some_optional_int: nil)
|
29
|
+
super
|
30
|
+
self.some_int = some_int
|
31
|
+
self.some_float = some_float
|
32
|
+
self.some_string = some_string
|
33
|
+
self.some_optional_int = some_optional_int
|
34
|
+
end
|
35
|
+
|
36
|
+
# @override
|
37
|
+
def schema
|
38
|
+
'MyNestedRecord'
|
39
|
+
end
|
40
|
+
|
41
|
+
# @override
|
42
|
+
def namespace
|
43
|
+
'com.my-namespace'
|
44
|
+
end
|
45
|
+
|
46
|
+
# @override
|
47
|
+
def to_h
|
48
|
+
{
|
49
|
+
'some_int' => @some_int,
|
50
|
+
'some_float' => @some_float,
|
51
|
+
'some_string' => @some_string,
|
52
|
+
'some_optional_int' => @some_optional_int
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
### Attribute Readers ###
|
59
|
+
# @return [MyNestedRecord]
|
60
|
+
attr_reader :some_nested_record
|
61
|
+
# @return [nil, MyNestedRecord]
|
62
|
+
attr_reader :some_optional_record
|
63
|
+
|
64
|
+
### Attribute Accessors ###
|
65
|
+
# @param value [String]
|
66
|
+
attr_accessor :test_id
|
67
|
+
# @param value [Float]
|
68
|
+
attr_accessor :test_float
|
69
|
+
# @param values [Array<String>]
|
70
|
+
attr_accessor :test_array
|
71
|
+
|
72
|
+
### Attribute Writers ###
|
73
|
+
# @param value [MyNestedRecord]
|
74
|
+
def some_nested_record=(value)
|
75
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
76
|
+
end
|
77
|
+
|
78
|
+
# @param value [nil, MyNestedRecord]
|
79
|
+
def some_optional_record=(value)
|
80
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
81
|
+
end
|
82
|
+
|
83
|
+
# @override
|
84
|
+
def initialize(test_id: nil,
|
85
|
+
test_float: nil,
|
86
|
+
test_array: nil,
|
87
|
+
some_nested_record: nil,
|
88
|
+
some_optional_record: nil)
|
89
|
+
super
|
90
|
+
self.test_id = test_id
|
91
|
+
self.test_float = test_float
|
92
|
+
self.test_array = test_array
|
93
|
+
self.some_nested_record = some_nested_record
|
94
|
+
self.some_optional_record = some_optional_record
|
95
|
+
end
|
96
|
+
|
97
|
+
# @override
|
98
|
+
def schema
|
99
|
+
'MyNestedSchema'
|
100
|
+
end
|
101
|
+
|
102
|
+
# @override
|
103
|
+
def namespace
|
104
|
+
'com.my-namespace'
|
105
|
+
end
|
106
|
+
|
107
|
+
# @override
|
108
|
+
def to_h
|
109
|
+
{
|
110
|
+
'test_id' => @test_id,
|
111
|
+
'test_float' => @test_float,
|
112
|
+
'test_array' => @test_array,
|
113
|
+
'some_nested_record' => @some_nested_record&.to_h,
|
114
|
+
'some_optional_record' => @some_optional_record&.to_h
|
115
|
+
}
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
spec/app/lib/schema_classes/my_schema.rb:
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# This file is autogenerated by Deimos, Do NOT modify
|
5
|
+
module Schemas
|
6
|
+
### Primary Schema Class ###
|
7
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchema
|
8
|
+
class MySchema < Deimos::SchemaClass::Record
|
9
|
+
|
10
|
+
### Attribute Readers ###
|
11
|
+
# @return [MySchemaKey]
|
12
|
+
attr_reader :payload_key
|
13
|
+
|
14
|
+
### Attribute Accessors ###
|
15
|
+
# @param value [String]
|
16
|
+
attr_accessor :test_id
|
17
|
+
# @param value [Integer]
|
18
|
+
attr_accessor :some_int
|
19
|
+
|
20
|
+
### Attribute Writers ###
|
21
|
+
# @param value [MySchemaKey]
|
22
|
+
def payload_key=(value)
|
23
|
+
@payload_key = MySchemaKey.initialize_from_value(value)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @override
|
27
|
+
def initialize(test_id: nil,
|
28
|
+
some_int: nil,
|
29
|
+
payload_key: nil)
|
30
|
+
super
|
31
|
+
self.test_id = test_id
|
32
|
+
self.some_int = some_int
|
33
|
+
self.payload_key = payload_key
|
34
|
+
end
|
35
|
+
|
36
|
+
# @override
|
37
|
+
def schema
|
38
|
+
'MySchema'
|
39
|
+
end
|
40
|
+
|
41
|
+
# @override
|
42
|
+
def namespace
|
43
|
+
'com.my-namespace'
|
44
|
+
end
|
45
|
+
|
46
|
+
# @override
|
47
|
+
def to_h
|
48
|
+
{
|
49
|
+
'test_id' => @test_id,
|
50
|
+
'some_int' => @some_int,
|
51
|
+
'payload_key' => @payload_key&.to_h
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
spec/app/lib/schema_classes/my_schema_key.rb:
|
59
|
+
# frozen_string_literal: true
|
60
|
+
|
61
|
+
# This file is autogenerated by Deimos, Do NOT modify
|
62
|
+
module Schemas
|
63
|
+
### Primary Schema Class ###
|
64
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchema_key
|
65
|
+
class MySchemaKey < Deimos::SchemaClass::Record
|
66
|
+
|
67
|
+
### Attribute Accessors ###
|
68
|
+
# @param value [String]
|
69
|
+
attr_accessor :test_id
|
70
|
+
|
71
|
+
# @override
|
72
|
+
def initialize(test_id: nil)
|
73
|
+
super
|
74
|
+
self.test_id = test_id
|
75
|
+
end
|
76
|
+
|
77
|
+
# @override
|
78
|
+
def schema
|
79
|
+
'MySchema_key'
|
80
|
+
end
|
81
|
+
|
82
|
+
# @override
|
83
|
+
def namespace
|
84
|
+
'com.my-namespace'
|
85
|
+
end
|
86
|
+
|
87
|
+
# @override
|
88
|
+
def to_h
|
89
|
+
{
|
90
|
+
'test_id' => @test_id
|
91
|
+
}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
spec/app/lib/schema_classes/my_schema.rb:
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# This file is autogenerated by Deimos, Do NOT modify
|
5
|
+
module Schemas
|
6
|
+
### Primary Schema Class ###
|
7
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchema
|
8
|
+
class MySchema < Deimos::SchemaClass::Record
|
9
|
+
|
10
|
+
### Attribute Readers ###
|
11
|
+
# @return [MySchemaKey]
|
12
|
+
attr_reader :payload_key
|
13
|
+
|
14
|
+
### Attribute Accessors ###
|
15
|
+
# @param value [String]
|
16
|
+
attr_accessor :test_id
|
17
|
+
# @param value [Integer]
|
18
|
+
attr_accessor :some_int
|
19
|
+
|
20
|
+
### Attribute Writers ###
|
21
|
+
# @param value [MySchemaKey]
|
22
|
+
def payload_key=(value)
|
23
|
+
@payload_key = MySchemaKey.initialize_from_value(value)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @override
|
27
|
+
def initialize(test_id: nil,
|
28
|
+
some_int: nil,
|
29
|
+
payload_key: nil)
|
30
|
+
super
|
31
|
+
self.test_id = test_id
|
32
|
+
self.some_int = some_int
|
33
|
+
self.payload_key = payload_key
|
34
|
+
end
|
35
|
+
|
36
|
+
# @override
|
37
|
+
def schema
|
38
|
+
'MySchema'
|
39
|
+
end
|
40
|
+
|
41
|
+
# @override
|
42
|
+
def namespace
|
43
|
+
'com.my-namespace'
|
44
|
+
end
|
45
|
+
|
46
|
+
# @override
|
47
|
+
def to_h
|
48
|
+
{
|
49
|
+
'test_id' => @test_id,
|
50
|
+
'some_int' => @some_int,
|
51
|
+
'payload_key' => @payload_key&.to_h
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
spec/app/lib/schema_classes/my_schema_key.rb:
|
59
|
+
# frozen_string_literal: true
|
60
|
+
|
61
|
+
# This file is autogenerated by Deimos, Do NOT modify
|
62
|
+
module Schemas
|
63
|
+
### Primary Schema Class ###
|
64
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchema_key
|
65
|
+
class MySchemaKey < Deimos::SchemaClass::Record
|
66
|
+
|
67
|
+
### Attribute Accessors ###
|
68
|
+
# @param value [String]
|
69
|
+
attr_accessor :test_id
|
70
|
+
|
71
|
+
# @override
|
72
|
+
def initialize(test_id: nil)
|
73
|
+
super
|
74
|
+
self.test_id = test_id
|
75
|
+
end
|
76
|
+
|
77
|
+
# @override
|
78
|
+
def schema
|
79
|
+
'MySchema_key'
|
80
|
+
end
|
81
|
+
|
82
|
+
# @override
|
83
|
+
def namespace
|
84
|
+
'com.my-namespace'
|
85
|
+
end
|
86
|
+
|
87
|
+
# @override
|
88
|
+
def to_h
|
89
|
+
{
|
90
|
+
'test_id' => @test_id
|
91
|
+
}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,8 @@ require 'activerecord-import'
|
|
13
13
|
require 'handlers/my_batch_consumer'
|
14
14
|
require 'handlers/my_consumer'
|
15
15
|
require 'rspec/rails'
|
16
|
-
|
16
|
+
require 'rspec/snapshot'
|
17
|
+
Dir['./spec/schemas/**/*.rb'].sort.each { |f| require f }
|
17
18
|
|
18
19
|
# Constants used for consumer specs
|
19
20
|
SCHEMA_CLASS_SETTINGS = { off: false, on: true }.freeze
|
@@ -156,6 +157,8 @@ RSpec.configure do |config|
|
|
156
157
|
config.include TestRunners
|
157
158
|
config.full_backtrace = true
|
158
159
|
|
160
|
+
config.snapshot_dir = "spec/snapshots"
|
161
|
+
|
159
162
|
# true by default for RSpec 4.0
|
160
163
|
config.shared_context_metadata_behavior = :apply_to_host_groups
|
161
164
|
|