active_interaction 5.1.0 → 5.5.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 +61 -0
- data/README.md +11 -12
- data/lib/active_interaction/base.rb +2 -0
- data/lib/active_interaction/errors.rb +16 -16
- data/lib/active_interaction/filter.rb +9 -12
- data/lib/active_interaction/filters/array_filter.rb +1 -1
- data/lib/active_interaction/filters/hash_filter.rb +5 -1
- data/lib/active_interaction/grouped_input.rb +23 -3
- data/lib/active_interaction/locale/es.yml +23 -0
- data/lib/active_interaction/version.rb +1 -1
- metadata +13 -115
- data/spec/active_interaction/array_input_spec.rb +0 -166
- data/spec/active_interaction/base_spec.rb +0 -537
- data/spec/active_interaction/concerns/active_modelable_spec.rb +0 -45
- data/spec/active_interaction/concerns/active_recordable_spec.rb +0 -49
- data/spec/active_interaction/concerns/hashable_spec.rb +0 -46
- data/spec/active_interaction/concerns/missable_spec.rb +0 -99
- data/spec/active_interaction/concerns/runnable_spec.rb +0 -397
- data/spec/active_interaction/errors_spec.rb +0 -196
- data/spec/active_interaction/filter/column_spec.rb +0 -87
- data/spec/active_interaction/filter_spec.rb +0 -39
- data/spec/active_interaction/filters/abstract_date_time_filter_spec.rb +0 -13
- data/spec/active_interaction/filters/abstract_numeric_filter_spec.rb +0 -13
- data/spec/active_interaction/filters/array_filter_spec.rb +0 -245
- data/spec/active_interaction/filters/boolean_filter_spec.rb +0 -87
- data/spec/active_interaction/filters/date_filter_spec.rb +0 -178
- data/spec/active_interaction/filters/date_time_filter_spec.rb +0 -189
- data/spec/active_interaction/filters/decimal_filter_spec.rb +0 -126
- data/spec/active_interaction/filters/file_filter_spec.rb +0 -40
- data/spec/active_interaction/filters/float_filter_spec.rb +0 -110
- data/spec/active_interaction/filters/hash_filter_spec.rb +0 -129
- data/spec/active_interaction/filters/integer_filter_spec.rb +0 -104
- data/spec/active_interaction/filters/interface_filter_spec.rb +0 -461
- data/spec/active_interaction/filters/object_filter_spec.rb +0 -237
- data/spec/active_interaction/filters/record_filter_spec.rb +0 -206
- data/spec/active_interaction/filters/string_filter_spec.rb +0 -60
- data/spec/active_interaction/filters/symbol_filter_spec.rb +0 -46
- data/spec/active_interaction/filters/time_filter_spec.rb +0 -251
- data/spec/active_interaction/grouped_input_spec.rb +0 -17
- data/spec/active_interaction/hash_input_spec.rb +0 -58
- data/spec/active_interaction/i18n_spec.rb +0 -113
- data/spec/active_interaction/inputs_spec.rb +0 -266
- data/spec/active_interaction/integration/array_interaction_spec.rb +0 -88
- data/spec/active_interaction/integration/boolean_interaction_spec.rb +0 -5
- data/spec/active_interaction/integration/date_interaction_spec.rb +0 -5
- data/spec/active_interaction/integration/date_time_interaction_spec.rb +0 -5
- data/spec/active_interaction/integration/file_interaction_spec.rb +0 -18
- data/spec/active_interaction/integration/float_interaction_spec.rb +0 -5
- data/spec/active_interaction/integration/hash_interaction_spec.rb +0 -76
- data/spec/active_interaction/integration/integer_interaction_spec.rb +0 -5
- data/spec/active_interaction/integration/interface_interaction_spec.rb +0 -19
- data/spec/active_interaction/integration/object_interaction_spec.rb +0 -14
- data/spec/active_interaction/integration/record_integration_spec.rb +0 -5
- data/spec/active_interaction/integration/string_interaction_spec.rb +0 -5
- data/spec/active_interaction/integration/symbol_interaction_spec.rb +0 -5
- data/spec/active_interaction/integration/time_interaction_spec.rb +0 -88
- data/spec/active_interaction/modules/validation_spec.rb +0 -57
- data/spec/spec_helper.rb +0 -20
- data/spec/support/concerns.rb +0 -13
- data/spec/support/filters.rb +0 -227
- data/spec/support/interactions.rb +0 -124
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
TestInteraction = Class.new(ActiveInteraction::Base) do
|
|
2
|
-
def self.name
|
|
3
|
-
SecureRandom.hex
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
def execute
|
|
7
|
-
inputs
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
shared_context 'interactions' do
|
|
12
|
-
let(:inputs) { {} }
|
|
13
|
-
let(:outcome) { described_class.run(inputs) }
|
|
14
|
-
let(:result) { outcome.result }
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
shared_examples_for 'an interaction' do |type, generator, adjust_output = nil, **filter_options|
|
|
18
|
-
include_context 'interactions'
|
|
19
|
-
|
|
20
|
-
let(:described_class) do
|
|
21
|
-
Class.new(TestInteraction) do
|
|
22
|
-
public_send(type, :required, filter_options)
|
|
23
|
-
public_send(type, :optional,
|
|
24
|
-
filter_options.merge(
|
|
25
|
-
default: nil
|
|
26
|
-
)
|
|
27
|
-
)
|
|
28
|
-
public_send(type, :default,
|
|
29
|
-
filter_options.merge(
|
|
30
|
-
default: generator.call
|
|
31
|
-
)
|
|
32
|
-
)
|
|
33
|
-
public_send(type, :defaults1, :defaults2,
|
|
34
|
-
filter_options.merge(
|
|
35
|
-
default: generator.call
|
|
36
|
-
)
|
|
37
|
-
)
|
|
38
|
-
public_send(type, :defaults3,
|
|
39
|
-
filter_options.merge(
|
|
40
|
-
default: -> { required }
|
|
41
|
-
)
|
|
42
|
-
)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context 'with an invalid lazy default' do
|
|
47
|
-
let(:described_class) do
|
|
48
|
-
Class.new(TestInteraction) do
|
|
49
|
-
public_send(type, :default,
|
|
50
|
-
filter_options.merge(default: -> { Object.new })
|
|
51
|
-
)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'raises an error' do
|
|
56
|
-
expect { outcome }.to raise_error ActiveInteraction::InvalidDefaultError
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
context 'without required inputs' do
|
|
61
|
-
it 'is invalid' do
|
|
62
|
-
expect(outcome).to be_invalid
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context 'with inputs[:required]' do
|
|
67
|
-
let(:required) { generator.call }
|
|
68
|
-
|
|
69
|
-
before { inputs[:required] = required }
|
|
70
|
-
|
|
71
|
-
it 'is valid' do
|
|
72
|
-
expect(outcome).to be_valid
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it 'returns the correct value for :required' do
|
|
76
|
-
expect(result[:required]).to eql(adjust_output ? adjust_output.call(required) : required)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it 'returns nil for :optional' do
|
|
80
|
-
expect(result[:optional]).to be_nil
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it 'does not return nil for :default' do
|
|
84
|
-
expect(result[:default]).to_not be_nil
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it 'does not return nil for :default when given nil' do
|
|
88
|
-
inputs[:default] = nil
|
|
89
|
-
expect(result[:default]).to_not be_nil
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it 'does not return nil for :defaults1' do
|
|
93
|
-
expect(result[:defaults1]).to_not be_nil
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it 'does not return nil for :defaults2' do
|
|
97
|
-
expect(result[:defaults2]).to_not be_nil
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it 'evaluates :defaults3 in the interaction binding' do
|
|
101
|
-
expect(result[:defaults3]).to eql result[:required]
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
context 'with inputs[:optional]' do
|
|
105
|
-
let(:optional) { generator.call }
|
|
106
|
-
|
|
107
|
-
before { inputs[:optional] = optional }
|
|
108
|
-
|
|
109
|
-
it 'returns the correct value for :optional' do
|
|
110
|
-
expect(result[:optional]).to eql(adjust_output ? adjust_output.call(optional) : optional)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
context 'with inputs[:default]' do
|
|
115
|
-
let(:default) { generator.call }
|
|
116
|
-
|
|
117
|
-
before { inputs[:default] = default }
|
|
118
|
-
|
|
119
|
-
it 'returns the correct value for :default' do
|
|
120
|
-
expect(result[:default]).to eql(adjust_output ? adjust_output.call(default) : default)
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|