active_interaction 4.1.0 → 5.0.0
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 +128 -1
- data/README.md +63 -28
- data/lib/active_interaction/array_input.rb +77 -0
- data/lib/active_interaction/base.rb +14 -98
- data/lib/active_interaction/concerns/active_recordable.rb +3 -3
- data/lib/active_interaction/concerns/missable.rb +2 -2
- data/lib/active_interaction/errors.rb +6 -88
- data/lib/active_interaction/exceptions.rb +47 -0
- data/lib/active_interaction/filter/column.rb +59 -0
- data/lib/active_interaction/filter/error.rb +40 -0
- data/lib/active_interaction/filter.rb +44 -53
- data/lib/active_interaction/filters/abstract_date_time_filter.rb +9 -6
- data/lib/active_interaction/filters/abstract_numeric_filter.rb +7 -3
- data/lib/active_interaction/filters/array_filter.rb +34 -6
- data/lib/active_interaction/filters/boolean_filter.rb +4 -3
- data/lib/active_interaction/filters/date_filter.rb +1 -1
- data/lib/active_interaction/filters/date_time_filter.rb +1 -1
- data/lib/active_interaction/filters/decimal_filter.rb +1 -1
- data/lib/active_interaction/filters/float_filter.rb +1 -1
- data/lib/active_interaction/filters/hash_filter.rb +23 -15
- data/lib/active_interaction/filters/integer_filter.rb +1 -1
- data/lib/active_interaction/filters/interface_filter.rb +12 -12
- data/lib/active_interaction/filters/object_filter.rb +9 -3
- data/lib/active_interaction/filters/record_filter.rb +21 -11
- data/lib/active_interaction/filters/string_filter.rb +1 -1
- data/lib/active_interaction/filters/symbol_filter.rb +1 -1
- data/lib/active_interaction/filters/time_filter.rb +4 -4
- data/lib/active_interaction/hash_input.rb +43 -0
- data/lib/active_interaction/input.rb +23 -0
- data/lib/active_interaction/inputs.rb +157 -46
- data/lib/active_interaction/locale/en.yml +0 -1
- data/lib/active_interaction/locale/fr.yml +0 -1
- data/lib/active_interaction/locale/it.yml +0 -1
- data/lib/active_interaction/locale/ja.yml +0 -1
- data/lib/active_interaction/locale/pt-BR.yml +0 -1
- data/lib/active_interaction/modules/validation.rb +6 -17
- data/lib/active_interaction/version.rb +1 -1
- data/lib/active_interaction.rb +43 -36
- data/spec/active_interaction/array_input_spec.rb +166 -0
- data/spec/active_interaction/base_spec.rb +15 -240
- data/spec/active_interaction/concerns/active_modelable_spec.rb +3 -3
- data/spec/active_interaction/concerns/active_recordable_spec.rb +7 -7
- data/spec/active_interaction/concerns/hashable_spec.rb +8 -8
- data/spec/active_interaction/concerns/missable_spec.rb +9 -9
- data/spec/active_interaction/concerns/runnable_spec.rb +34 -32
- data/spec/active_interaction/errors_spec.rb +60 -43
- data/spec/active_interaction/{filter_column_spec.rb → filter/column_spec.rb} +3 -10
- data/spec/active_interaction/filter_spec.rb +6 -6
- data/spec/active_interaction/filters/abstract_date_time_filter_spec.rb +2 -2
- data/spec/active_interaction/filters/abstract_numeric_filter_spec.rb +2 -2
- data/spec/active_interaction/filters/array_filter_spec.rb +99 -16
- data/spec/active_interaction/filters/boolean_filter_spec.rb +12 -11
- data/spec/active_interaction/filters/date_filter_spec.rb +32 -27
- data/spec/active_interaction/filters/date_time_filter_spec.rb +34 -29
- data/spec/active_interaction/filters/decimal_filter_spec.rb +20 -18
- data/spec/active_interaction/filters/file_filter_spec.rb +7 -7
- data/spec/active_interaction/filters/float_filter_spec.rb +19 -17
- data/spec/active_interaction/filters/hash_filter_spec.rb +16 -18
- data/spec/active_interaction/filters/integer_filter_spec.rb +24 -22
- data/spec/active_interaction/filters/interface_filter_spec.rb +105 -82
- data/spec/active_interaction/filters/object_filter_spec.rb +52 -36
- data/spec/active_interaction/filters/record_filter_spec.rb +61 -39
- data/spec/active_interaction/filters/string_filter_spec.rb +7 -7
- data/spec/active_interaction/filters/symbol_filter_spec.rb +6 -6
- data/spec/active_interaction/filters/time_filter_spec.rb +57 -34
- data/spec/active_interaction/hash_input_spec.rb +58 -0
- data/spec/active_interaction/i18n_spec.rb +22 -17
- data/spec/active_interaction/inputs_spec.rb +167 -23
- data/spec/active_interaction/integration/array_interaction_spec.rb +3 -7
- data/spec/active_interaction/modules/validation_spec.rb +8 -31
- data/spec/spec_helper.rb +8 -0
- data/spec/support/concerns.rb +2 -2
- data/spec/support/filters.rb +27 -51
- data/spec/support/interactions.rb +4 -4
- metadata +40 -91
- data/lib/active_interaction/filter_column.rb +0 -57
@@ -4,14 +4,14 @@ describe ActiveInteraction::IntegerFilter, :filter do
|
|
4
4
|
include_context 'filters'
|
5
5
|
it_behaves_like 'a filter'
|
6
6
|
|
7
|
-
describe '#
|
8
|
-
let(:result) { filter.
|
7
|
+
describe '#process' do
|
8
|
+
let(:result) { filter.process(value, nil) }
|
9
9
|
|
10
10
|
context 'with an Integer' do
|
11
11
|
let(:value) { rand(1 << 16) }
|
12
12
|
|
13
13
|
it 'returns the Integer' do
|
14
|
-
expect(result).to eql value
|
14
|
+
expect(result.value).to eql value
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,7 +19,7 @@ describe ActiveInteraction::IntegerFilter, :filter do
|
|
19
19
|
let(:value) { rand(1 << 16) + rand }
|
20
20
|
|
21
21
|
it 'returns an Integer' do
|
22
|
-
expect(result).to eql value.to_i
|
22
|
+
expect(result.value).to eql value.to_i
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -27,17 +27,18 @@ describe ActiveInteraction::IntegerFilter, :filter do
|
|
27
27
|
let(:value) { rand(1 << 16).to_s }
|
28
28
|
|
29
29
|
it 'returns an Integer' do
|
30
|
-
expect(result).to eql Integer(value, 10)
|
30
|
+
expect(result.value).to eql Integer(value, 10)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'with an invalid String' do
|
35
35
|
let(:value) { 'invalid' }
|
36
36
|
|
37
|
-
it '
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
it 'indicates an error' do
|
38
|
+
error = result.errors.first
|
39
|
+
|
40
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
41
|
+
expect(error.type).to be :invalid_type
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
@@ -51,8 +52,7 @@ describe ActiveInteraction::IntegerFilter, :filter do
|
|
51
52
|
end
|
52
53
|
|
53
54
|
it 'returns an Integer' do
|
54
|
-
|
55
|
-
expect(result).to eql Integer(value.to_str, 10)
|
55
|
+
expect(result.value).to eql Integer(value.to_str, 10)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -69,34 +69,36 @@ describe ActiveInteraction::IntegerFilter, :filter do
|
|
69
69
|
include_context 'optional'
|
70
70
|
|
71
71
|
it 'returns the default' do
|
72
|
-
expect(result).to eql options[:default]
|
72
|
+
expect(result.value).to eql options[:default]
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
context 'required' do
|
77
77
|
include_context 'required'
|
78
78
|
|
79
|
-
it '
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
it 'indicates an error' do
|
80
|
+
error = result.errors.first
|
81
|
+
|
82
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
83
|
+
expect(error.type).to be :missing
|
83
84
|
end
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
88
|
it 'supports different bases' do
|
88
89
|
expect(
|
89
|
-
described_class.new(name, base: 8).
|
90
|
-
).to
|
91
|
-
|
92
|
-
|
93
|
-
|
90
|
+
described_class.new(name, base: 8).process('071', nil).value
|
91
|
+
).to be 57
|
92
|
+
error = described_class.new(name, base: 8).process('081', nil).errors.first
|
93
|
+
|
94
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
95
|
+
expect(error.type).to be :invalid_type
|
94
96
|
end
|
95
97
|
end
|
96
98
|
|
97
99
|
describe '#database_column_type' do
|
98
100
|
it 'returns :integer' do
|
99
|
-
expect(filter.database_column_type).to
|
101
|
+
expect(filter.database_column_type).to be :integer
|
100
102
|
end
|
101
103
|
end
|
102
104
|
end
|
@@ -10,8 +10,8 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
10
10
|
let(:name) { :interface_module }
|
11
11
|
end
|
12
12
|
|
13
|
-
describe '#
|
14
|
-
let(:result) { filter.
|
13
|
+
describe '#process' do
|
14
|
+
let(:result) { filter.process(value, nil) }
|
15
15
|
|
16
16
|
context 'with an implicit constant name' do
|
17
17
|
context 'passed an instance' do
|
@@ -24,7 +24,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'returns a the value' do
|
27
|
-
expect(result).to eql value
|
27
|
+
expect(result.value).to eql value
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -35,7 +35,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'returns a the value' do
|
38
|
-
expect(result).to eql value
|
38
|
+
expect(result.value).to eql value
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -46,7 +46,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'returns a the value' do
|
49
|
-
expect(result).to eql value
|
49
|
+
expect(result.value).to eql value
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -54,10 +54,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
54
54
|
let(:name) { :interface_module }
|
55
55
|
let(:value) { Class.new }
|
56
56
|
|
57
|
-
it '
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
it 'indicates an error' do
|
58
|
+
error = result.errors.first
|
59
|
+
|
60
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
61
|
+
expect(error.type).to be :invalid_type
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
@@ -65,10 +66,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
65
66
|
let(:name) { :interface_module }
|
66
67
|
let(:value) { nil }
|
67
68
|
|
68
|
-
it '
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
it 'indicates an error' do
|
70
|
+
error = result.errors.first
|
71
|
+
|
72
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
73
|
+
expect(error.type).to be :missing
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
@@ -78,10 +80,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
78
80
|
InterfaceClass.new
|
79
81
|
end
|
80
82
|
|
81
|
-
it '
|
82
|
-
|
83
|
-
|
84
|
-
|
83
|
+
it 'indicates an error' do
|
84
|
+
error = result.errors.first
|
85
|
+
|
86
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
87
|
+
expect(error.type).to be :invalid_type
|
85
88
|
end
|
86
89
|
end
|
87
90
|
end
|
@@ -94,7 +97,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
94
97
|
end
|
95
98
|
|
96
99
|
it 'returns a the value' do
|
97
|
-
expect(result).to eql value
|
100
|
+
expect(result.value).to eql value
|
98
101
|
end
|
99
102
|
end
|
100
103
|
|
@@ -107,7 +110,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
107
110
|
end
|
108
111
|
|
109
112
|
it 'returns a the value' do
|
110
|
-
expect(result).to eql value
|
113
|
+
expect(result.value).to eql value
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
@@ -115,10 +118,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
115
118
|
let(:name) { :interface_class }
|
116
119
|
let(:value) { Class }
|
117
120
|
|
118
|
-
it '
|
119
|
-
|
120
|
-
|
121
|
-
|
121
|
+
it 'indicates an error' do
|
122
|
+
error = result.errors.first
|
123
|
+
|
124
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
125
|
+
expect(error.type).to be :invalid_type
|
122
126
|
end
|
123
127
|
end
|
124
128
|
|
@@ -126,10 +130,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
126
130
|
let(:name) { :interface_class }
|
127
131
|
let(:value) { InterfaceClass }
|
128
132
|
|
129
|
-
it '
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
+
it 'indicates an error' do
|
134
|
+
error = result.errors.first
|
135
|
+
|
136
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
137
|
+
expect(error.type).to be :invalid_type
|
133
138
|
end
|
134
139
|
end
|
135
140
|
end
|
@@ -144,7 +149,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
144
149
|
end
|
145
150
|
|
146
151
|
it 'returns a the value' do
|
147
|
-
expect(result).to eql value
|
152
|
+
expect(result.value).to eql value
|
148
153
|
end
|
149
154
|
end
|
150
155
|
|
@@ -152,10 +157,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
152
157
|
let(:name) { :interface_module }
|
153
158
|
let(:value) { Module.new }
|
154
159
|
|
155
|
-
it '
|
156
|
-
|
157
|
-
|
158
|
-
|
160
|
+
it 'indicates an error' do
|
161
|
+
error = result.errors.first
|
162
|
+
|
163
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
164
|
+
expect(error.type).to be :invalid_type
|
159
165
|
end
|
160
166
|
end
|
161
167
|
|
@@ -163,10 +169,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
163
169
|
let(:name) { :interface_module }
|
164
170
|
let(:value) { InterfaceModule }
|
165
171
|
|
166
|
-
it '
|
167
|
-
|
168
|
-
|
169
|
-
|
172
|
+
it 'indicates an error' do
|
173
|
+
error = result.errors.first
|
174
|
+
|
175
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
176
|
+
expect(error.type).to be :invalid_type
|
170
177
|
end
|
171
178
|
end
|
172
179
|
end
|
@@ -187,6 +194,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
187
194
|
context 'passed an instance' do
|
188
195
|
context 'with the module included' do
|
189
196
|
before { options.merge!(from: :interface_module) }
|
197
|
+
|
190
198
|
let(:value) do
|
191
199
|
Class.new do
|
192
200
|
include InterfaceModule
|
@@ -194,29 +202,31 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
194
202
|
end
|
195
203
|
|
196
204
|
it 'returns a the value' do
|
197
|
-
expect(result).to eql value
|
205
|
+
expect(result.value).to eql value
|
198
206
|
end
|
199
207
|
end
|
200
208
|
|
201
209
|
context 'with the class inherited from' do
|
202
210
|
before { options.merge!(from: :interface_class) }
|
211
|
+
|
203
212
|
let(:value) do
|
204
213
|
Class.new(InterfaceClass) {}.new # rubocop:disable Lint/EmptyBlock
|
205
214
|
end
|
206
215
|
|
207
216
|
it 'returns a the value' do
|
208
|
-
expect(result).to eql value
|
217
|
+
expect(result.value).to eql value
|
209
218
|
end
|
210
219
|
end
|
211
220
|
|
212
221
|
context 'that is extended by the ancestor' do
|
213
222
|
before { options.merge!(from: :interface_module) }
|
223
|
+
|
214
224
|
let(:value) do
|
215
225
|
Class.new {}.new.extend(InterfaceModule) # rubocop:disable Lint/EmptyBlock
|
216
226
|
end
|
217
227
|
|
218
228
|
it 'returns a the value' do
|
219
|
-
expect(result).to eql value
|
229
|
+
expect(result.value).to eql value
|
220
230
|
end
|
221
231
|
end
|
222
232
|
|
@@ -224,10 +234,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
224
234
|
let(:name) { :interface_class }
|
225
235
|
let(:value) { Class.new }
|
226
236
|
|
227
|
-
it '
|
228
|
-
|
229
|
-
|
230
|
-
|
237
|
+
it 'indicates an error' do
|
238
|
+
error = result.errors.first
|
239
|
+
|
240
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
241
|
+
expect(error.type).to be :invalid_type
|
231
242
|
end
|
232
243
|
end
|
233
244
|
|
@@ -235,10 +246,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
235
246
|
let(:name) { :interface_class }
|
236
247
|
let(:value) { InterfaceClass.new }
|
237
248
|
|
238
|
-
it '
|
239
|
-
|
240
|
-
|
241
|
-
|
249
|
+
it 'indicates an error' do
|
250
|
+
error = result.errors.first
|
251
|
+
|
252
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
253
|
+
expect(error.type).to be :invalid_type
|
242
254
|
end
|
243
255
|
end
|
244
256
|
end
|
@@ -246,17 +258,19 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
246
258
|
context 'passed a class' do
|
247
259
|
context 'with the class inherited from' do
|
248
260
|
before { options.merge!(from: :interface_class) }
|
261
|
+
|
249
262
|
let(:value) do
|
250
263
|
Class.new(InterfaceClass) {} # rubocop:disable Lint/EmptyBlock
|
251
264
|
end
|
252
265
|
|
253
266
|
it 'returns a the value' do
|
254
|
-
expect(result).to eql value
|
267
|
+
expect(result.value).to eql value
|
255
268
|
end
|
256
269
|
end
|
257
270
|
|
258
271
|
context 'that is extended by the ancestor' do
|
259
272
|
before { options.merge!(from: :interface_module) }
|
273
|
+
|
260
274
|
let(:value) do
|
261
275
|
Class.new do
|
262
276
|
extend InterfaceModule
|
@@ -264,7 +278,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
264
278
|
end
|
265
279
|
|
266
280
|
it 'returns a the value' do
|
267
|
-
expect(result).to eql value
|
281
|
+
expect(result.value).to eql value
|
268
282
|
end
|
269
283
|
end
|
270
284
|
|
@@ -272,10 +286,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
272
286
|
let(:name) { :interface_class }
|
273
287
|
let(:value) { Class }
|
274
288
|
|
275
|
-
it '
|
276
|
-
|
277
|
-
|
278
|
-
|
289
|
+
it 'indicates an error' do
|
290
|
+
error = result.errors.first
|
291
|
+
|
292
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
293
|
+
expect(error.type).to be :invalid_type
|
279
294
|
end
|
280
295
|
end
|
281
296
|
|
@@ -283,10 +298,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
283
298
|
let(:name) { :interface_class }
|
284
299
|
let(:value) { InterfaceClass }
|
285
300
|
|
286
|
-
it '
|
287
|
-
|
288
|
-
|
289
|
-
|
301
|
+
it 'indicates an error' do
|
302
|
+
error = result.errors.first
|
303
|
+
|
304
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
305
|
+
expect(error.type).to be :invalid_type
|
290
306
|
end
|
291
307
|
end
|
292
308
|
end
|
@@ -294,6 +310,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
294
310
|
context 'passed a module' do
|
295
311
|
context 'that is extended by the ancestor' do
|
296
312
|
before { options.merge!(from: :interface_module) }
|
313
|
+
|
297
314
|
let(:value) do
|
298
315
|
Module.new do
|
299
316
|
extend InterfaceModule
|
@@ -301,7 +318,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
301
318
|
end
|
302
319
|
|
303
320
|
it 'returns a the value' do
|
304
|
-
expect(result).to eql value
|
321
|
+
expect(result.value).to eql value
|
305
322
|
end
|
306
323
|
end
|
307
324
|
|
@@ -309,10 +326,11 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
309
326
|
let(:name) { :interface_module }
|
310
327
|
let(:value) { Module.new }
|
311
328
|
|
312
|
-
it '
|
313
|
-
|
314
|
-
|
315
|
-
|
329
|
+
it 'indicates an error' do
|
330
|
+
error = result.errors.first
|
331
|
+
|
332
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
333
|
+
expect(error.type).to be :invalid_type
|
316
334
|
end
|
317
335
|
end
|
318
336
|
|
@@ -320,16 +338,18 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
320
338
|
let(:name) { :interface_module }
|
321
339
|
let(:value) { InterfaceModule }
|
322
340
|
|
323
|
-
it '
|
324
|
-
|
325
|
-
|
326
|
-
|
341
|
+
it 'indicates an error' do
|
342
|
+
error = result.errors.first
|
343
|
+
|
344
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
345
|
+
expect(error.type).to be :invalid_type
|
327
346
|
end
|
328
347
|
end
|
329
348
|
end
|
330
349
|
|
331
350
|
context 'given an invalid name' do
|
332
351
|
before { options.merge!(from: :invalid) }
|
352
|
+
|
333
353
|
let(:value) { Object }
|
334
354
|
|
335
355
|
it 'raises an error' do
|
@@ -353,17 +373,18 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
353
373
|
end
|
354
374
|
|
355
375
|
it 'returns a the value' do
|
356
|
-
expect(result).to eql value
|
376
|
+
expect(result.value).to eql value
|
357
377
|
end
|
358
378
|
end
|
359
379
|
|
360
380
|
context 'passed an invalid instance' do
|
361
381
|
let(:value) { Class.new }
|
362
382
|
|
363
|
-
it '
|
364
|
-
|
365
|
-
|
366
|
-
|
383
|
+
it 'indicates an error' do
|
384
|
+
error = result.errors.first
|
385
|
+
|
386
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
387
|
+
expect(error.type).to be :invalid_type
|
367
388
|
end
|
368
389
|
end
|
369
390
|
|
@@ -377,17 +398,18 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
377
398
|
end
|
378
399
|
|
379
400
|
it 'returns a the value' do
|
380
|
-
expect(result).to eql value
|
401
|
+
expect(result.value).to eql value
|
381
402
|
end
|
382
403
|
end
|
383
404
|
|
384
405
|
context 'passed an invalid class' do
|
385
406
|
let(:value) { Class }
|
386
407
|
|
387
|
-
it '
|
388
|
-
|
389
|
-
|
390
|
-
|
408
|
+
it 'indicates an error' do
|
409
|
+
error = result.errors.first
|
410
|
+
|
411
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
412
|
+
expect(error.type).to be :invalid_type
|
391
413
|
end
|
392
414
|
end
|
393
415
|
|
@@ -401,17 +423,18 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
401
423
|
end
|
402
424
|
|
403
425
|
it 'returns a the value' do
|
404
|
-
expect(result).to eql value
|
426
|
+
expect(result.value).to eql value
|
405
427
|
end
|
406
428
|
end
|
407
429
|
|
408
430
|
context 'passed an invalid module' do
|
409
431
|
let(:value) { Module.new }
|
410
432
|
|
411
|
-
it '
|
412
|
-
|
413
|
-
|
414
|
-
|
433
|
+
it 'indicates an error' do
|
434
|
+
error = result.errors.first
|
435
|
+
|
436
|
+
expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
|
437
|
+
expect(error.type).to be :invalid_type
|
415
438
|
end
|
416
439
|
end
|
417
440
|
end
|
@@ -432,7 +455,7 @@ describe ActiveInteraction::InterfaceFilter, :filter do
|
|
432
455
|
|
433
456
|
describe '#database_column_type' do
|
434
457
|
it 'returns :string' do
|
435
|
-
expect(filter.database_column_type).to
|
458
|
+
expect(filter.database_column_type).to be :string
|
436
459
|
end
|
437
460
|
end
|
438
461
|
end
|