active_interaction 5.3.0 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/README.md +2 -2
  4. data/lib/active_interaction/errors.rb +1 -1
  5. data/lib/active_interaction/grouped_input.rb +23 -3
  6. data/lib/active_interaction/version.rb +1 -1
  7. metadata +12 -115
  8. data/spec/active_interaction/array_input_spec.rb +0 -164
  9. data/spec/active_interaction/base_spec.rb +0 -536
  10. data/spec/active_interaction/concerns/active_modelable_spec.rb +0 -43
  11. data/spec/active_interaction/concerns/active_recordable_spec.rb +0 -47
  12. data/spec/active_interaction/concerns/hashable_spec.rb +0 -44
  13. data/spec/active_interaction/concerns/missable_spec.rb +0 -97
  14. data/spec/active_interaction/concerns/runnable_spec.rb +0 -395
  15. data/spec/active_interaction/errors_spec.rb +0 -223
  16. data/spec/active_interaction/filter/column_spec.rb +0 -85
  17. data/spec/active_interaction/filter_spec.rb +0 -58
  18. data/spec/active_interaction/filters/abstract_date_time_filter_spec.rb +0 -11
  19. data/spec/active_interaction/filters/abstract_numeric_filter_spec.rb +0 -11
  20. data/spec/active_interaction/filters/array_filter_spec.rb +0 -248
  21. data/spec/active_interaction/filters/boolean_filter_spec.rb +0 -85
  22. data/spec/active_interaction/filters/date_filter_spec.rb +0 -176
  23. data/spec/active_interaction/filters/date_time_filter_spec.rb +0 -187
  24. data/spec/active_interaction/filters/decimal_filter_spec.rb +0 -124
  25. data/spec/active_interaction/filters/file_filter_spec.rb +0 -38
  26. data/spec/active_interaction/filters/float_filter_spec.rb +0 -109
  27. data/spec/active_interaction/filters/hash_filter_spec.rb +0 -127
  28. data/spec/active_interaction/filters/integer_filter_spec.rb +0 -102
  29. data/spec/active_interaction/filters/interface_filter_spec.rb +0 -459
  30. data/spec/active_interaction/filters/object_filter_spec.rb +0 -235
  31. data/spec/active_interaction/filters/record_filter_spec.rb +0 -204
  32. data/spec/active_interaction/filters/string_filter_spec.rb +0 -58
  33. data/spec/active_interaction/filters/symbol_filter_spec.rb +0 -44
  34. data/spec/active_interaction/filters/time_filter_spec.rb +0 -249
  35. data/spec/active_interaction/grouped_input_spec.rb +0 -15
  36. data/spec/active_interaction/hash_input_spec.rb +0 -56
  37. data/spec/active_interaction/i18n_spec.rb +0 -111
  38. data/spec/active_interaction/inputs_spec.rb +0 -264
  39. data/spec/active_interaction/integration/array_interaction_spec.rb +0 -87
  40. data/spec/active_interaction/integration/boolean_interaction_spec.rb +0 -11
  41. data/spec/active_interaction/integration/date_interaction_spec.rb +0 -3
  42. data/spec/active_interaction/integration/date_time_interaction_spec.rb +0 -3
  43. data/spec/active_interaction/integration/file_interaction_spec.rb +0 -17
  44. data/spec/active_interaction/integration/float_interaction_spec.rb +0 -3
  45. data/spec/active_interaction/integration/hash_interaction_spec.rb +0 -106
  46. data/spec/active_interaction/integration/integer_interaction_spec.rb +0 -3
  47. data/spec/active_interaction/integration/interface_interaction_spec.rb +0 -18
  48. data/spec/active_interaction/integration/object_interaction_spec.rb +0 -12
  49. data/spec/active_interaction/integration/record_integration_spec.rb +0 -3
  50. data/spec/active_interaction/integration/string_interaction_spec.rb +0 -3
  51. data/spec/active_interaction/integration/symbol_interaction_spec.rb +0 -3
  52. data/spec/active_interaction/integration/time_interaction_spec.rb +0 -86
  53. data/spec/active_interaction/modules/validation_spec.rb +0 -55
  54. data/spec/spec_helper.rb +0 -22
  55. data/spec/support/concerns.rb +0 -13
  56. data/spec/support/filters.rb +0 -227
  57. data/spec/support/interactions.rb +0 -124
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b454bfd8df636194b206bcac24dba1e52dd88b6cd5b45322e6d769c7eeebe8d
4
- data.tar.gz: 8624a4b45f3f198528a24e7994af331fde5d66c7c7b732db2e1efeb63a72c9cc
3
+ metadata.gz: 9e3c0c4b273d6133644463ea773ea4551331ee7a9eb92c9dc9b3ff4b069aff55
4
+ data.tar.gz: bc874a3de1e5557e2baf01a59b62822fb073721f4e639559e47ce72ce50c41ad
5
5
  SHA512:
6
- metadata.gz: cc07f6e2d9b5cea926350d72a061be59b0101a301ba1bee2a6cfab10485a4b83bed85445efc02f919936f2e3b34edc7bdf7890ca04869db5a58cc88cc2bb1d6e
7
- data.tar.gz: 4b582ae18497b4abb6f3a287ec3bfaff08fbc0cbef7e0ab33c35a9345ebd1fd9fd437f96b870e88760dfa82a056467df17b18b326698310e711ced0c4b5a0996
6
+ metadata.gz: b3af5f93ea4049897a6d10bf3da4e11d3eccfa14fd8a0180eeb84c6e695fadd9bc2990c0058bb605a9f7667c0759e32187797984128d3ab36b4e06ff176e26ea
7
+ data.tar.gz: 4b3fdc8b15977f1e0e46f654e97574581da9ebbdd851b7c91355c5ea32906fdd9b68e220bf89cc57973041995e47b3f9a8183155fbf5a1e8167d3be213c3ad8e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # [5.5.0][] (2025-02-02)
2
+
3
+ ## Added
4
+
5
+ - Support for Ruby 3.4.
6
+
7
+ ## Fixed
8
+
9
+ - OStruct was listed as a development dependency instead of a runtime dependency.
10
+ The need for OStruct has been removed entirely.
11
+
12
+ # [5.4.0][] (2024-11-23)
13
+
14
+ ## Added
15
+
16
+ - [#579][] Support for Rails 8. Thanks @bvalentino!
17
+
18
+ ## Fixed
19
+
20
+ - [#577][] Manually pull in the `ostruct` gem since it's being removed from stdlib.
21
+
1
22
  # [5.3.0][] (2023-05-06)
2
23
 
3
24
  ## Added
@@ -1141,6 +1162,9 @@ Example.run
1141
1162
 
1142
1163
  - Initial release.
1143
1164
 
1165
+ [5.5.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.4.0...v5.5.0
1166
+ [5.4.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.3.0...v5.4.0
1167
+ [5.3.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.2.0...v5.3.0
1144
1168
  [5.2.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.1.1...v5.2.0
1145
1169
  [5.1.1]: https://github.com/AaronLasseigne/active_interaction/compare/v5.1.0...v5.1.1
1146
1170
  [5.1.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.0.0...v5.1.0
@@ -1374,3 +1398,5 @@ Example.run
1374
1398
  [#545]: https://github.com/AaronLasseigne/active_interaction/issues/545
1375
1399
  [#554]: https://github.com/AaronLasseigne/active_interaction/issues/554
1376
1400
  [#553]: https://github.com/AaronLasseigne/active_interaction/issues/553
1401
+ [#577]: https://github.com/AaronLasseigne/active_interaction/issues/577
1402
+ [#579]: https://github.com/AaronLasseigne/active_interaction/pull/579
data/README.md CHANGED
@@ -60,13 +60,13 @@ If ActiveModel deals with your nouns, then ActiveInteraction handles your verbs.
60
60
  Add it to your Gemfile:
61
61
 
62
62
  ``` rb
63
- gem 'active_interaction', '~> 5.3'
63
+ gem 'active_interaction', '~> 5.5'
64
64
  ```
65
65
 
66
66
  Or install it manually:
67
67
 
68
68
  ``` sh
69
- $ gem install active_interaction --version '~> 5.3'
69
+ $ gem install active_interaction --version '~> 5.5'
70
70
  ```
71
71
 
72
72
  This project uses [Semantic Versioning][]. Check out [GitHub releases][] for a
@@ -56,7 +56,7 @@ module ActiveInteraction
56
56
  options = detail.dup
57
57
  error = options.delete(:error)
58
58
 
59
- add(attribute, error, **options.merge(message: message)) unless added?(attribute, error, **options)
59
+ add(attribute, error, **options, message: message) unless added?(attribute, error, **options)
60
60
  else
61
61
  merge_message!(attribute, detail, message)
62
62
  end
@@ -1,11 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ostruct'
4
-
5
3
  module ActiveInteraction
6
4
  # Holds a group of inputs together for passing from {Base} to {Filter}s.
7
5
  #
8
6
  # @private
9
- class GroupedInput < OpenStruct
7
+ class GroupedInput
8
+ include Comparable
9
+
10
+ attr_reader :data
11
+ protected :data
12
+
13
+ def initialize(**data)
14
+ @data = data
15
+ end
16
+
17
+ def [](key)
18
+ @data[key]
19
+ end
20
+
21
+ def []=(key, value)
22
+ @data[key] = value
23
+ end
24
+
25
+ def <=>(other)
26
+ return nil unless other.is_a?(self.class)
27
+
28
+ data <=> other.data
29
+ end
10
30
  end
11
31
  end
@@ -4,5 +4,5 @@ module ActiveInteraction
4
4
  # The version number.
5
5
  #
6
6
  # @return [Gem::Version]
7
- VERSION = Gem::Version.new('5.3.0')
7
+ VERSION = Gem::Version.new('5.5.0')
8
8
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_interaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.0
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lasseigne
8
8
  - Taylor Fausak
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2023-05-06 00:00:00.000000000 Z
11
+ date: 2025-02-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activemodel
@@ -20,7 +19,7 @@ dependencies:
20
19
  version: '5.2'
21
20
  - - "<"
22
21
  - !ruby/object:Gem::Version
23
- version: '8'
22
+ version: '9'
24
23
  type: :runtime
25
24
  prerelease: false
26
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +29,7 @@ dependencies:
30
29
  version: '5.2'
31
30
  - - "<"
32
31
  - !ruby/object:Gem::Version
33
- version: '8'
32
+ version: '9'
34
33
  - !ruby/object:Gem::Dependency
35
34
  name: activesupport
36
35
  requirement: !ruby/object:Gem::Requirement
@@ -40,7 +39,7 @@ dependencies:
40
39
  version: '5.2'
41
40
  - - "<"
42
41
  - !ruby/object:Gem::Version
43
- version: '8'
42
+ version: '9'
44
43
  type: :runtime
45
44
  prerelease: false
46
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -50,7 +49,7 @@ dependencies:
50
49
  version: '5.2'
51
50
  - - "<"
52
51
  - !ruby/object:Gem::Version
53
- version: '8'
52
+ version: '9'
54
53
  - !ruby/object:Gem::Dependency
55
54
  name: actionpack
56
55
  requirement: !ruby/object:Gem::Requirement
@@ -127,14 +126,14 @@ dependencies:
127
126
  requirements:
128
127
  - - "~>"
129
128
  - !ruby/object:Gem::Version
130
- version: 1.26.1
129
+ version: 1.68.0
131
130
  type: :development
132
131
  prerelease: false
133
132
  version_requirements: !ruby/object:Gem::Requirement
134
133
  requirements:
135
134
  - - "~>"
136
135
  - !ruby/object:Gem::Version
137
- version: 1.26.1
136
+ version: 1.68.0
138
137
  - !ruby/object:Gem::Dependency
139
138
  name: rubocop-rake
140
139
  requirement: !ruby/object:Gem::Requirement
@@ -155,14 +154,14 @@ dependencies:
155
154
  requirements:
156
155
  - - "~>"
157
156
  - !ruby/object:Gem::Version
158
- version: 2.9.0
157
+ version: 3.2.0
159
158
  type: :development
160
159
  prerelease: false
161
160
  version_requirements: !ruby/object:Gem::Requirement
162
161
  requirements:
163
162
  - - "~>"
164
163
  - !ruby/object:Gem::Version
165
- version: 2.9.0
164
+ version: 3.2.0
166
165
  - !ruby/object:Gem::Dependency
167
166
  name: sqlite3
168
167
  requirement: !ruby/object:Gem::Requirement
@@ -249,56 +248,6 @@ files:
249
248
  - lib/active_interaction/locale/pt-BR.yml
250
249
  - lib/active_interaction/modules/validation.rb
251
250
  - lib/active_interaction/version.rb
252
- - spec/active_interaction/array_input_spec.rb
253
- - spec/active_interaction/base_spec.rb
254
- - spec/active_interaction/concerns/active_modelable_spec.rb
255
- - spec/active_interaction/concerns/active_recordable_spec.rb
256
- - spec/active_interaction/concerns/hashable_spec.rb
257
- - spec/active_interaction/concerns/missable_spec.rb
258
- - spec/active_interaction/concerns/runnable_spec.rb
259
- - spec/active_interaction/errors_spec.rb
260
- - spec/active_interaction/filter/column_spec.rb
261
- - spec/active_interaction/filter_spec.rb
262
- - spec/active_interaction/filters/abstract_date_time_filter_spec.rb
263
- - spec/active_interaction/filters/abstract_numeric_filter_spec.rb
264
- - spec/active_interaction/filters/array_filter_spec.rb
265
- - spec/active_interaction/filters/boolean_filter_spec.rb
266
- - spec/active_interaction/filters/date_filter_spec.rb
267
- - spec/active_interaction/filters/date_time_filter_spec.rb
268
- - spec/active_interaction/filters/decimal_filter_spec.rb
269
- - spec/active_interaction/filters/file_filter_spec.rb
270
- - spec/active_interaction/filters/float_filter_spec.rb
271
- - spec/active_interaction/filters/hash_filter_spec.rb
272
- - spec/active_interaction/filters/integer_filter_spec.rb
273
- - spec/active_interaction/filters/interface_filter_spec.rb
274
- - spec/active_interaction/filters/object_filter_spec.rb
275
- - spec/active_interaction/filters/record_filter_spec.rb
276
- - spec/active_interaction/filters/string_filter_spec.rb
277
- - spec/active_interaction/filters/symbol_filter_spec.rb
278
- - spec/active_interaction/filters/time_filter_spec.rb
279
- - spec/active_interaction/grouped_input_spec.rb
280
- - spec/active_interaction/hash_input_spec.rb
281
- - spec/active_interaction/i18n_spec.rb
282
- - spec/active_interaction/inputs_spec.rb
283
- - spec/active_interaction/integration/array_interaction_spec.rb
284
- - spec/active_interaction/integration/boolean_interaction_spec.rb
285
- - spec/active_interaction/integration/date_interaction_spec.rb
286
- - spec/active_interaction/integration/date_time_interaction_spec.rb
287
- - spec/active_interaction/integration/file_interaction_spec.rb
288
- - spec/active_interaction/integration/float_interaction_spec.rb
289
- - spec/active_interaction/integration/hash_interaction_spec.rb
290
- - spec/active_interaction/integration/integer_interaction_spec.rb
291
- - spec/active_interaction/integration/interface_interaction_spec.rb
292
- - spec/active_interaction/integration/object_interaction_spec.rb
293
- - spec/active_interaction/integration/record_integration_spec.rb
294
- - spec/active_interaction/integration/string_interaction_spec.rb
295
- - spec/active_interaction/integration/symbol_interaction_spec.rb
296
- - spec/active_interaction/integration/time_interaction_spec.rb
297
- - spec/active_interaction/modules/validation_spec.rb
298
- - spec/spec_helper.rb
299
- - spec/support/concerns.rb
300
- - spec/support/filters.rb
301
- - spec/support/interactions.rb
302
251
  homepage: https://github.com/AaronLasseigne/active_interaction
303
252
  licenses:
304
253
  - MIT
@@ -307,7 +256,6 @@ metadata:
307
256
  source_code_uri: https://github.com/AaronLasseigne/active_interaction
308
257
  changelog_uri: https://github.com/AaronLasseigne/active_interaction/blob/main/CHANGELOG.md
309
258
  rubygems_mfa_required: 'true'
310
- post_install_message:
311
259
  rdoc_options: []
312
260
  require_paths:
313
261
  - lib
@@ -322,58 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
270
  - !ruby/object:Gem::Version
323
271
  version: '0'
324
272
  requirements: []
325
- rubygems_version: 3.4.1
326
- signing_key:
273
+ rubygems_version: 3.6.2
327
274
  specification_version: 4
328
275
  summary: Manage application specific business logic.
329
- test_files:
330
- - spec/active_interaction/array_input_spec.rb
331
- - spec/active_interaction/base_spec.rb
332
- - spec/active_interaction/concerns/active_modelable_spec.rb
333
- - spec/active_interaction/concerns/active_recordable_spec.rb
334
- - spec/active_interaction/concerns/hashable_spec.rb
335
- - spec/active_interaction/concerns/missable_spec.rb
336
- - spec/active_interaction/concerns/runnable_spec.rb
337
- - spec/active_interaction/errors_spec.rb
338
- - spec/active_interaction/filter/column_spec.rb
339
- - spec/active_interaction/filter_spec.rb
340
- - spec/active_interaction/filters/abstract_date_time_filter_spec.rb
341
- - spec/active_interaction/filters/abstract_numeric_filter_spec.rb
342
- - spec/active_interaction/filters/array_filter_spec.rb
343
- - spec/active_interaction/filters/boolean_filter_spec.rb
344
- - spec/active_interaction/filters/date_filter_spec.rb
345
- - spec/active_interaction/filters/date_time_filter_spec.rb
346
- - spec/active_interaction/filters/decimal_filter_spec.rb
347
- - spec/active_interaction/filters/file_filter_spec.rb
348
- - spec/active_interaction/filters/float_filter_spec.rb
349
- - spec/active_interaction/filters/hash_filter_spec.rb
350
- - spec/active_interaction/filters/integer_filter_spec.rb
351
- - spec/active_interaction/filters/interface_filter_spec.rb
352
- - spec/active_interaction/filters/object_filter_spec.rb
353
- - spec/active_interaction/filters/record_filter_spec.rb
354
- - spec/active_interaction/filters/string_filter_spec.rb
355
- - spec/active_interaction/filters/symbol_filter_spec.rb
356
- - spec/active_interaction/filters/time_filter_spec.rb
357
- - spec/active_interaction/grouped_input_spec.rb
358
- - spec/active_interaction/hash_input_spec.rb
359
- - spec/active_interaction/i18n_spec.rb
360
- - spec/active_interaction/inputs_spec.rb
361
- - spec/active_interaction/integration/array_interaction_spec.rb
362
- - spec/active_interaction/integration/boolean_interaction_spec.rb
363
- - spec/active_interaction/integration/date_interaction_spec.rb
364
- - spec/active_interaction/integration/date_time_interaction_spec.rb
365
- - spec/active_interaction/integration/file_interaction_spec.rb
366
- - spec/active_interaction/integration/float_interaction_spec.rb
367
- - spec/active_interaction/integration/hash_interaction_spec.rb
368
- - spec/active_interaction/integration/integer_interaction_spec.rb
369
- - spec/active_interaction/integration/interface_interaction_spec.rb
370
- - spec/active_interaction/integration/object_interaction_spec.rb
371
- - spec/active_interaction/integration/record_integration_spec.rb
372
- - spec/active_interaction/integration/string_interaction_spec.rb
373
- - spec/active_interaction/integration/symbol_interaction_spec.rb
374
- - spec/active_interaction/integration/time_interaction_spec.rb
375
- - spec/active_interaction/modules/validation_spec.rb
376
- - spec/spec_helper.rb
377
- - spec/support/concerns.rb
378
- - spec/support/filters.rb
379
- - spec/support/interactions.rb
276
+ test_files: []
@@ -1,164 +0,0 @@
1
- RSpec.describe ActiveInteraction::ArrayInput do
2
- subject(:input) do
3
- described_class.new(filter,
4
- value: value,
5
- error: error,
6
- index_errors: index_errors,
7
- children: children
8
- )
9
- end
10
-
11
- let(:filter) do
12
- ActiveInteraction::ArrayFilter.new(:a, &block)
13
- end
14
- let(:block) { proc { integer } }
15
- let(:value) { nil }
16
- let(:error) { nil }
17
- let(:index_errors) { false }
18
- let(:children) { [] }
19
-
20
- describe '#errors' do
21
- context 'with no errors' do
22
- it 'returns an empty array' do
23
- expect(input.errors).to be_empty
24
- end
25
- end
26
-
27
- context 'with an error on the array' do
28
- let(:error) { ActiveInteraction::Filter::Error.new(filter, :invalid_type) }
29
-
30
- it 'returns one error in the array' do
31
- expect(input.errors.size).to be 1
32
-
33
- error = input.errors.first
34
- expect(error.name).to be filter.name
35
- expect(error.type).to be :invalid_type
36
- end
37
- end
38
-
39
- context 'with children with errors' do
40
- let(:child_filter) { ActiveInteraction::IntegerFilter.new(:'') }
41
- let(:child_error) { ActiveInteraction::Filter::Error.new(child_filter, :invalid_type) }
42
- let(:child1) { ActiveInteraction::Input.new(child_filter, value: 'a', error: child_error) }
43
- let(:child2) { ActiveInteraction::Input.new(child_filter, value: 'b', error: child_error) }
44
- let(:children) { [child1, child2] }
45
-
46
- context 'with an error on the array' do
47
- let(:error) { ActiveInteraction::Filter::Error.new(filter, :invalid_type) }
48
-
49
- it 'returns one error in the array' do
50
- expect(input.errors.size).to be 1
51
-
52
- error = input.errors.first
53
- expect(error.name).to be filter.name
54
- expect(error.type).to be :invalid_type
55
- end
56
- end
57
-
58
- context 'without :index_errors' do
59
- it 'promotes the first child error and returns it in the array' do
60
- expect(input.errors.size).to be 1
61
-
62
- error = input.errors.first
63
- expect(error.name).to be filter.name
64
- expect(error.type).to be :invalid_type
65
- end
66
- end
67
-
68
- context 'with :index_errors' do
69
- let(:index_errors) { true }
70
-
71
- it 'lists all child errors in the array' do
72
- expect(input.errors.size).to be 2
73
-
74
- input.errors.each_with_index do |error, i|
75
- expect(error.name).to be :"#{filter.name}[#{i}]"
76
- expect(error.type).to be :invalid_type
77
- end
78
- end
79
-
80
- context 'with a nested array' do
81
- let(:invalid_value) { Object.new }
82
- let(:array_child) do
83
- filter = ActiveInteraction::IntegerFilter.new(:'')
84
- ActiveInteraction::Input.new(filter,
85
- value: invalid_value,
86
- error: ActiveInteraction::Filter::Error.new(filter, :invalid_type)
87
- )
88
- end
89
- let(:child_filter) { ActiveInteraction::ArrayFilter.new(:'') { integer } }
90
- let(:child) do
91
- described_class.new(child_filter,
92
- value: [invalid_value],
93
- index_errors: index_errors,
94
- children: [array_child]
95
- )
96
- end
97
- let(:children) { [child] }
98
-
99
- it 'returns the error' do
100
- expect(input.errors.size).to be 1
101
-
102
- error = input.errors.first
103
- expect(error.name).to be :"#{filter.name}[0][0]"
104
- expect(error.type).to be :invalid_type
105
- end
106
- end
107
-
108
- context 'with a nested hash' do
109
- let(:hash_child_a) do
110
- filter = ActiveInteraction::IntegerFilter.new(:a)
111
- ActiveInteraction::Input.new(filter,
112
- value: nil,
113
- error: ActiveInteraction::Filter::Error.new(filter, :missing)
114
- )
115
- end
116
- let(:hash_child_b) do
117
- filter = ActiveInteraction::IntegerFilter.new(:b)
118
- ActiveInteraction::Input.new(filter,
119
- value: nil,
120
- error: ActiveInteraction::Filter::Error.new(filter, :missing)
121
- )
122
- end
123
- let(:child_filter) { ActiveInteraction::HashFilter.new(:'') { integer :a, :b } }
124
- let(:child) do
125
- ActiveInteraction::HashInput.new(child_filter, value: {}, children: { a: hash_child_a, b: hash_child_b })
126
- end
127
- let(:children) { [child] }
128
-
129
- it 'list all child errors' do
130
- expect(input.errors.size).to be 2
131
-
132
- error = input.errors.first
133
- expect(error.name).to be :"#{filter.name}[0].a"
134
- expect(error.type).to be :missing
135
-
136
- error = input.errors.last
137
- expect(error.name).to be :"#{filter.name}[0].b"
138
- expect(error.type).to be :missing
139
- end
140
-
141
- context 'with an invalid hash' do
142
- let(:child_filter) { ActiveInteraction::HashFilter.new(:'') }
143
- let(:child) do
144
- ActiveInteraction::HashInput.new(child_filter,
145
- value: Object.new,
146
- error: ActiveInteraction::Filter::Error.new(child_filter, :invalid_type),
147
- children: {}
148
- )
149
- end
150
- let(:children) { [child] }
151
-
152
- it 'list all child errors' do
153
- expect(input.errors.size).to be 1
154
-
155
- error = input.errors.first
156
- expect(error.name).to be :"#{filter.name}[0]"
157
- expect(error.type).to be :invalid_type
158
- end
159
- end
160
- end
161
- end
162
- end
163
- end
164
- end