interaktor 0.4.0 → 0.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/.github/workflows/tests.yml +1 -1
- data/.ruby-version +1 -1
- data/.standard.yml +1 -0
- data/Gemfile +2 -5
- data/README.md +25 -4
- data/bin/_guard-core +16 -0
- data/bin/guard +16 -0
- data/bin/rspec +16 -0
- data/bin/standardrb +16 -0
- data/interaktor.gemspec +3 -4
- data/lib/interaktor/callable.rb +63 -76
- data/lib/interaktor/error/invalid_method_for_state_error.rb +10 -0
- data/lib/interaktor/error/organizer_missing_passed_attribute_error.rb +1 -1
- data/lib/interaktor/error/organizer_success_attribute_missing_error.rb +1 -1
- data/lib/interaktor/error/unknown_attribute_error.rb +16 -0
- data/lib/interaktor/failure.rb +8 -8
- data/lib/interaktor/hooks.rb +53 -3
- data/lib/interaktor/interaction.rb +154 -0
- data/lib/interaktor/organizer.rb +9 -1
- data/lib/interaktor.rb +41 -53
- data/spec/integration_spec.rb +1874 -1874
- data/spec/interaktor/context_spec.rb +185 -185
- data/spec/interaktor/hooks_spec.rb +17 -17
- data/spec/interaktor/organizer_spec.rb +58 -90
- data/spec/support/helpers.rb +5 -7
- data/spec/support/lint.rb +33 -60
- metadata +20 -22
- data/.rubocop.yml +0 -245
- data/lib/interaktor/context.rb +0 -116
|
@@ -11,8 +11,8 @@ RSpec.describe Interaktor::Organizer do
|
|
|
11
11
|
expect {
|
|
12
12
|
organizer.organize(interaktor2, interaktor3)
|
|
13
13
|
}.to change(organizer, :organized)
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
.from([])
|
|
15
|
+
.to([interaktor2, interaktor3])
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "sets interaktors given an array of classes" do
|
|
@@ -21,8 +21,8 @@ RSpec.describe Interaktor::Organizer do
|
|
|
21
21
|
expect {
|
|
22
22
|
organizer.organize([interaktor2, interaktor3])
|
|
23
23
|
}.to change(organizer, :organized)
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
.from([])
|
|
25
|
+
.to([interaktor2, interaktor3])
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "allows multiple organize calls" do
|
|
@@ -33,8 +33,8 @@ RSpec.describe Interaktor::Organizer do
|
|
|
33
33
|
organizer.organize(interaktor2, interaktor3)
|
|
34
34
|
organizer.organize(interaktor4)
|
|
35
35
|
}.to change(organizer, :organized)
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
.from([])
|
|
37
|
+
.to([interaktor2, interaktor3, interaktor4])
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -50,51 +50,41 @@ RSpec.describe Interaktor::Organizer do
|
|
|
50
50
|
it "calls each interaktor in order" do
|
|
51
51
|
organizer = FakeInteraktor.build_interaktor(type: described_class) do
|
|
52
52
|
input { required(:foo) }
|
|
53
|
-
success { required(:
|
|
53
|
+
success { required(:baz) }
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
interaktor1 = FakeInteraktor.build_interaktor("Interaktor1") do
|
|
57
57
|
input { required(:foo) }
|
|
58
|
-
success { required(:
|
|
58
|
+
success { required(:bar) }
|
|
59
59
|
|
|
60
60
|
def call
|
|
61
|
-
success!(
|
|
61
|
+
success!(bar: "whatever")
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
interaktor2 = FakeInteraktor.build_interaktor("Interaktor2") do
|
|
66
|
-
input { required(:
|
|
67
|
-
success { required(:
|
|
68
|
-
|
|
69
|
-
def call
|
|
70
|
-
success!(foo: "baz")
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
interaktor3 = FakeInteraktor.build_interaktor("Interaktor3") do
|
|
75
|
-
input { required(:foo) }
|
|
76
|
-
success { required(:foo) }
|
|
66
|
+
input { required(:bar) }
|
|
67
|
+
success { required(:baz) }
|
|
77
68
|
|
|
78
69
|
def call
|
|
79
|
-
success!(
|
|
70
|
+
success!(baz: "whatever")
|
|
80
71
|
end
|
|
81
72
|
end
|
|
82
73
|
|
|
83
|
-
allow(organizer).to receive(:organized)
|
|
84
|
-
[interaktor1, interaktor2, interaktor3]
|
|
85
|
-
}
|
|
74
|
+
allow(organizer).to receive(:organized).and_return([interaktor1, interaktor2])
|
|
86
75
|
|
|
87
76
|
expect(interaktor1).to receive(:call!).once.ordered.and_call_original
|
|
88
77
|
expect(interaktor2).to receive(:call!).once.ordered.and_call_original
|
|
89
|
-
expect(interaktor3).to receive(:call!).once.ordered.and_call_original
|
|
90
78
|
|
|
91
79
|
result = organizer.call(foo: "asdf")
|
|
92
80
|
|
|
93
|
-
expect(result.
|
|
81
|
+
expect(result.baz).to eq "whatever"
|
|
94
82
|
end
|
|
95
83
|
|
|
96
|
-
it "
|
|
97
|
-
organizer = FakeInteraktor.build_interaktor(type: described_class)
|
|
84
|
+
it "allows an interaktor to accept input attributes from an organizer" do
|
|
85
|
+
organizer = FakeInteraktor.build_interaktor(type: described_class) do
|
|
86
|
+
input { required(:foo) }
|
|
87
|
+
end
|
|
98
88
|
|
|
99
89
|
interaktor1 = FakeInteraktor.build_interaktor("Interaktor1") do
|
|
100
90
|
input { required(:foo) }
|
|
@@ -105,119 +95,97 @@ RSpec.describe Interaktor::Organizer do
|
|
|
105
95
|
end
|
|
106
96
|
end
|
|
107
97
|
|
|
108
|
-
interaktor2 = FakeInteraktor.build_interaktor("
|
|
98
|
+
interaktor2 = FakeInteraktor.build_interaktor("Interaktor2") do
|
|
109
99
|
input { required(:bar) }
|
|
110
100
|
|
|
111
101
|
def call
|
|
112
|
-
self.bar = "wadus"
|
|
113
102
|
end
|
|
114
103
|
end
|
|
115
104
|
|
|
116
|
-
allow(organizer).to receive(:organized)
|
|
117
|
-
[interaktor1, interaktor2]
|
|
118
|
-
}
|
|
105
|
+
allow(organizer).to receive(:organized).and_return([interaktor1, interaktor2])
|
|
119
106
|
|
|
120
107
|
expect(interaktor1).to receive(:call!).once.ordered.and_call_original
|
|
121
108
|
expect(interaktor2).to receive(:call!).once.ordered.and_call_original
|
|
122
109
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
expect(result.bar).to eq "wadus"
|
|
110
|
+
organizer.call(foo: "whatever")
|
|
126
111
|
end
|
|
127
112
|
|
|
128
|
-
it "allows an interaktor to accept
|
|
129
|
-
organizer = FakeInteraktor.build_interaktor(type: described_class)
|
|
130
|
-
interaktor1 = FakeInteraktor.build_interaktor("Interaktor1")
|
|
131
|
-
success { required(:foo) }
|
|
132
|
-
|
|
133
|
-
def call
|
|
134
|
-
success!(foo: "whatever")
|
|
135
|
-
end
|
|
136
|
-
end
|
|
113
|
+
it "allows an interaktor to accept input attributes from the previous organized interaktor's input attributes" do
|
|
114
|
+
organizer = FakeInteraktor.build_interaktor(type: described_class) { input { required(:foo) } }
|
|
115
|
+
interaktor1 = FakeInteraktor.build_interaktor("Interaktor1") { input { required(:foo) } }
|
|
137
116
|
interaktor2 = FakeInteraktor.build_interaktor("Interaktor2") do
|
|
117
|
+
input { required(:foo) }
|
|
138
118
|
success { required(:bar) }
|
|
139
119
|
|
|
140
120
|
def call
|
|
141
|
-
success!(bar:
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
interaktor3 = FakeInteraktor.build_interaktor("Interaktor3") do
|
|
145
|
-
input do
|
|
146
|
-
required(:foo)
|
|
147
|
-
required(:bar)
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
allow(organizer).to receive(:organized).and_return([interaktor1, interaktor2, interaktor3])
|
|
152
|
-
|
|
153
|
-
expect(interaktor1).to receive(:call!).once.ordered.and_call_original
|
|
154
|
-
expect(interaktor2).to receive(:call!).once.ordered.and_call_original
|
|
155
|
-
expect(interaktor3).to receive(:call!).once.ordered.and_call_original
|
|
156
|
-
|
|
157
|
-
organizer.call
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
it "allows an interaktor to accept required attributes from the original organizer" do
|
|
161
|
-
organizer = FakeInteraktor.build_interaktor(type: described_class) do
|
|
162
|
-
input do
|
|
163
|
-
required(:foo)
|
|
164
|
-
required(:bar)
|
|
121
|
+
success!(bar: foo)
|
|
165
122
|
end
|
|
166
123
|
end
|
|
167
|
-
interaktor1 = FakeInteraktor.build_interaktor("Interaktor1")
|
|
168
|
-
interaktor2 = FakeInteraktor.build_interaktor("Interaktor2") { input { required(:foo) } }
|
|
169
|
-
interaktor3 = FakeInteraktor.build_interaktor("Interaktor3") { input { required(:bar) } }
|
|
170
124
|
|
|
171
|
-
allow(organizer).to receive(:organized).and_return([interaktor1, interaktor2
|
|
125
|
+
allow(organizer).to receive(:organized).and_return([interaktor1, interaktor2])
|
|
172
126
|
|
|
173
127
|
expect(interaktor1).to receive(:call!).once.ordered.and_call_original
|
|
174
128
|
expect(interaktor2).to receive(:call!).once.ordered.and_call_original
|
|
175
|
-
expect(interaktor3).to receive(:call!).once.ordered.and_call_original
|
|
176
129
|
|
|
177
|
-
organizer.call(foo: "whatever"
|
|
130
|
+
organizer.call(foo: "whatever")
|
|
178
131
|
end
|
|
179
132
|
|
|
180
|
-
it "allows an interaktor to accept
|
|
133
|
+
it "allows an interaktor to accept input attributes from the previous organized interaktor's success attributes" do
|
|
181
134
|
organizer = FakeInteraktor.build_interaktor(type: described_class) { input { required(:foo) } }
|
|
135
|
+
|
|
182
136
|
interaktor1 = FakeInteraktor.build_interaktor("Interaktor1") do
|
|
137
|
+
input { required(:foo) }
|
|
183
138
|
success { required(:bar) }
|
|
184
139
|
|
|
185
140
|
def call
|
|
186
|
-
success!(bar:
|
|
141
|
+
success!(bar: foo)
|
|
187
142
|
end
|
|
188
143
|
end
|
|
144
|
+
|
|
189
145
|
interaktor2 = FakeInteraktor.build_interaktor("Interaktor2") do
|
|
146
|
+
input { required(:bar) }
|
|
190
147
|
success { required(:baz) }
|
|
191
148
|
|
|
192
149
|
def call
|
|
193
|
-
success!(baz:
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
interaktor3 = FakeInteraktor.build_interaktor("Interaktor3") do
|
|
197
|
-
input do
|
|
198
|
-
required(:foo)
|
|
199
|
-
required(:bar)
|
|
200
|
-
required(:baz)
|
|
150
|
+
success!(baz: bar)
|
|
201
151
|
end
|
|
202
152
|
end
|
|
203
153
|
|
|
204
|
-
allow(organizer).to receive(:organized).and_return([interaktor1, interaktor2
|
|
154
|
+
allow(organizer).to receive(:organized).and_return([interaktor1, interaktor2])
|
|
205
155
|
|
|
206
156
|
expect(interaktor1).to receive(:call!).once.ordered.and_call_original
|
|
207
157
|
expect(interaktor2).to receive(:call!).once.ordered.and_call_original
|
|
208
|
-
expect(interaktor3).to receive(:call!).once.ordered.and_call_original
|
|
209
158
|
|
|
210
159
|
organizer.call(foo: "whatever")
|
|
211
160
|
end
|
|
212
161
|
|
|
213
|
-
it "raises an exception if an interaktor requires an input attribute not provided by
|
|
162
|
+
it "raises an exception if an interaktor requires an input attribute not provided by the organizer" do
|
|
163
|
+
organizer = FakeInteraktor.build_interaktor(type: described_class)
|
|
164
|
+
interaktor1 = FakeInteraktor.build_interaktor("Interaktor1") { input { required(:foo) } }
|
|
165
|
+
|
|
166
|
+
allow(organizer).to receive(:organized).and_return([interaktor1])
|
|
167
|
+
|
|
168
|
+
expect(interaktor1).not_to receive(:call!)
|
|
169
|
+
|
|
170
|
+
expect {
|
|
171
|
+
organizer.call
|
|
172
|
+
}.to raise_error(
|
|
173
|
+
an_instance_of(Interaktor::Error::OrganizerMissingPassedAttributeError)
|
|
174
|
+
.and(having_attributes(
|
|
175
|
+
attribute: :foo,
|
|
176
|
+
interaktor: interaktor1
|
|
177
|
+
))
|
|
178
|
+
)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it "raises an exception if an interaktor requires an input attribute not provided by the previous interaktor" do
|
|
214
182
|
organizer = FakeInteraktor.build_interaktor(type: described_class)
|
|
215
183
|
interaktor1 = FakeInteraktor.build_interaktor("Interaktor1")
|
|
216
184
|
interaktor2 = FakeInteraktor.build_interaktor("Interaktor2") { input { required(:foo) } }
|
|
217
185
|
|
|
218
186
|
allow(organizer).to receive(:organized).and_return([interaktor1, interaktor2])
|
|
219
187
|
|
|
220
|
-
expect(
|
|
188
|
+
expect(interaktor2).not_to receive(:call!)
|
|
221
189
|
|
|
222
190
|
expect {
|
|
223
191
|
organizer.call
|
|
@@ -225,7 +193,7 @@ RSpec.describe Interaktor::Organizer do
|
|
|
225
193
|
an_instance_of(Interaktor::Error::OrganizerMissingPassedAttributeError)
|
|
226
194
|
.and(having_attributes(
|
|
227
195
|
attribute: :foo,
|
|
228
|
-
interaktor: interaktor2
|
|
196
|
+
interaktor: interaktor2
|
|
229
197
|
))
|
|
230
198
|
)
|
|
231
199
|
end
|
data/spec/support/helpers.rb
CHANGED
|
@@ -3,12 +3,10 @@ class FakeInteraktor
|
|
|
3
3
|
def self.build_interaktor(name = nil, type: Interaktor, &block)
|
|
4
4
|
name ||= "MyTest#{type}"
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
result
|
|
6
|
+
Class.new.include(type).tap do |klass|
|
|
7
|
+
klass.class_eval(&block) if block
|
|
8
|
+
klass.define_singleton_method(:inspect) { name.to_s }
|
|
9
|
+
klass.define_singleton_method(:to_s) { inspect }
|
|
10
|
+
end
|
|
13
11
|
end
|
|
14
12
|
end
|
data/spec/support/lint.rb
CHANGED
|
@@ -9,12 +9,12 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
9
9
|
expect(result.success?).to be true
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
it "
|
|
12
|
+
it "raises an exception for unknown provided attributes" do
|
|
13
13
|
interaktor = FakeInteraktor.build_interaktor(type: interaktor_class)
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
expect {
|
|
16
|
+
interaktor.call(baz: "wadus")
|
|
17
|
+
}.to raise_error(Interaktor::Error::UnknownAttributeError)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "fails when a non-hash or non-context argument is passed" do
|
|
@@ -36,12 +36,12 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
36
36
|
expect(result.success?).to be true
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
it "
|
|
39
|
+
it "raises an exception for unknown provided attributes" do
|
|
40
40
|
interaktor = FakeInteraktor.build_interaktor(type: interaktor_class)
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
expect {
|
|
43
|
+
interaktor.call!(baz: "wadus")
|
|
44
|
+
}.to raise_error(Interaktor::Error::UnknownAttributeError)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "fails when a non-hash or non-context argument is passed" do
|
|
@@ -302,16 +302,12 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
302
302
|
end
|
|
303
303
|
|
|
304
304
|
expect(interaktor.input_schema).to be_a Dry::Schema::Params
|
|
305
|
-
expect(interaktor.input_schema.info).to eq(
|
|
306
|
-
keys: { bar: { required: true, type: "string" } },
|
|
307
|
-
)
|
|
308
|
-
|
|
309
305
|
expect(interaktor.required_input_attributes).to contain_exactly(:bar)
|
|
310
306
|
|
|
311
307
|
result = interaktor.call(bar: "baz")
|
|
312
308
|
|
|
313
309
|
expect(result.success?).to be true
|
|
314
|
-
expect
|
|
310
|
+
expect { result.bar }.to raise_error(NoMethodError)
|
|
315
311
|
end
|
|
316
312
|
|
|
317
313
|
it "accepts a schema definition block" do
|
|
@@ -320,16 +316,12 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
320
316
|
end
|
|
321
317
|
|
|
322
318
|
expect(interaktor.input_schema).to be_a Dry::Schema::Params
|
|
323
|
-
expect(interaktor.input_schema.info).to eq(
|
|
324
|
-
keys: { bar: { required: true, type: "string" } },
|
|
325
|
-
)
|
|
326
|
-
|
|
327
319
|
expect(interaktor.required_input_attributes).to contain_exactly(:bar)
|
|
328
320
|
|
|
329
321
|
result = interaktor.call(bar: "baz")
|
|
330
322
|
|
|
331
323
|
expect(result.success?).to be true
|
|
332
|
-
expect
|
|
324
|
+
expect { result.bar }.to raise_error(NoMethodError)
|
|
333
325
|
end
|
|
334
326
|
|
|
335
327
|
it "raises an exception when the attribute is required and not provided" do
|
|
@@ -343,20 +335,20 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
343
335
|
an_instance_of(Interaktor::Error::AttributeSchemaValidationError).and(
|
|
344
336
|
having_attributes(
|
|
345
337
|
interaktor: interaktor,
|
|
346
|
-
validation_errors: {
|
|
338
|
+
validation_errors: {bar: ["is missing"]}
|
|
347
339
|
)
|
|
348
340
|
)
|
|
349
341
|
)
|
|
350
342
|
end
|
|
351
343
|
|
|
352
|
-
it "
|
|
344
|
+
it "raises an exception for unknown provided attributes" do
|
|
353
345
|
interaktor = FakeInteraktor.build_interaktor(type: interaktor_class) do
|
|
354
346
|
input { required(:bar).filled(:string) }
|
|
355
347
|
end
|
|
356
348
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
349
|
+
expect {
|
|
350
|
+
interaktor.call!(bar: "baz", foo: "unexpected")
|
|
351
|
+
}.to raise_error Interaktor::Error::UnknownAttributeError
|
|
360
352
|
end
|
|
361
353
|
|
|
362
354
|
it "allows provided optional attributes" do
|
|
@@ -369,7 +361,7 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
369
361
|
result = interaktor.call(bar: "baz")
|
|
370
362
|
|
|
371
363
|
expect(result.success?).to be true
|
|
372
|
-
expect
|
|
364
|
+
expect { result.bar }.to raise_error(NoMethodError)
|
|
373
365
|
end
|
|
374
366
|
|
|
375
367
|
it "allows missing optional attributes" do
|
|
@@ -382,10 +374,10 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
382
374
|
result = interaktor.call
|
|
383
375
|
|
|
384
376
|
expect(result.success?).to be true
|
|
385
|
-
expect
|
|
377
|
+
expect { result.bar }.to raise_error(NoMethodError)
|
|
386
378
|
end
|
|
387
379
|
|
|
388
|
-
it "creates attribute getters
|
|
380
|
+
it "creates attribute getters" do
|
|
389
381
|
interaktor = FakeInteraktor.build_interaktor(type: interaktor_class) do
|
|
390
382
|
input do
|
|
391
383
|
required(:foo).filled(:string)
|
|
@@ -395,17 +387,14 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
395
387
|
def call
|
|
396
388
|
foo
|
|
397
389
|
bar
|
|
398
|
-
|
|
399
|
-
self.foo = "one"
|
|
400
|
-
self.bar = "two"
|
|
401
390
|
end
|
|
402
391
|
end
|
|
403
392
|
|
|
404
393
|
result = interaktor.call(foo: "bar", bar: "baz")
|
|
405
394
|
|
|
406
395
|
expect(result.success?).to be true
|
|
407
|
-
expect
|
|
408
|
-
expect
|
|
396
|
+
expect { result.foo }.to raise_error(NoMethodError)
|
|
397
|
+
expect { result.bar }.to raise_error(NoMethodError)
|
|
409
398
|
end
|
|
410
399
|
end
|
|
411
400
|
|
|
@@ -420,10 +409,6 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
420
409
|
end
|
|
421
410
|
|
|
422
411
|
expect(interaktor.success_schema).to be_a Dry::Schema::Params
|
|
423
|
-
expect(interaktor.success_schema.info).to eq(
|
|
424
|
-
keys: { bar: { required: true, type: "string" } },
|
|
425
|
-
)
|
|
426
|
-
|
|
427
412
|
expect(interaktor.required_success_attributes).to contain_exactly(:bar)
|
|
428
413
|
|
|
429
414
|
result = interaktor.call
|
|
@@ -442,10 +427,6 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
442
427
|
end
|
|
443
428
|
|
|
444
429
|
expect(interaktor.success_schema).to be_a Dry::Schema::Params
|
|
445
|
-
expect(interaktor.success_schema.info).to eq(
|
|
446
|
-
keys: { bar: { required: true, type: "string" } },
|
|
447
|
-
)
|
|
448
|
-
|
|
449
430
|
expect(interaktor.required_success_attributes).to contain_exactly(:bar)
|
|
450
431
|
|
|
451
432
|
result = interaktor.call
|
|
@@ -464,18 +445,18 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
464
445
|
end
|
|
465
446
|
|
|
466
447
|
expect {
|
|
467
|
-
|
|
448
|
+
interaktor.call
|
|
468
449
|
}.to raise_error(
|
|
469
450
|
an_instance_of(Interaktor::Error::AttributeSchemaValidationError).and(
|
|
470
451
|
having_attributes(
|
|
471
452
|
interaktor: interaktor,
|
|
472
|
-
validation_errors: {
|
|
453
|
+
validation_errors: {bar: ["is missing"]}
|
|
473
454
|
)
|
|
474
455
|
)
|
|
475
456
|
)
|
|
476
457
|
end
|
|
477
458
|
|
|
478
|
-
it "
|
|
459
|
+
it "raises an exception for unknown provided attributes" do
|
|
479
460
|
interaktor = FakeInteraktor.build_interaktor(type: interaktor_class) do
|
|
480
461
|
success { required(:bar).filled(:string) }
|
|
481
462
|
|
|
@@ -484,9 +465,9 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
484
465
|
end
|
|
485
466
|
end
|
|
486
467
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
468
|
+
expect {
|
|
469
|
+
interaktor.call
|
|
470
|
+
}.to raise_error Interaktor::Error::UnknownAttributeError
|
|
490
471
|
end
|
|
491
472
|
|
|
492
473
|
it "allows missing optional attributes" do
|
|
@@ -517,7 +498,7 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
517
498
|
|
|
518
499
|
expect { interaktor.call }.to(
|
|
519
500
|
raise_error(
|
|
520
|
-
an_instance_of(Interaktor::Error::MissingExplicitSuccessError).and
|
|
501
|
+
an_instance_of(Interaktor::Error::MissingExplicitSuccessError).and(having_attributes(attributes: [:bar]))
|
|
521
502
|
)
|
|
522
503
|
)
|
|
523
504
|
end
|
|
@@ -534,10 +515,6 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
534
515
|
end
|
|
535
516
|
|
|
536
517
|
expect(interaktor.failure_schema).to be_a Dry::Schema::Params
|
|
537
|
-
expect(interaktor.failure_schema.info).to eq(
|
|
538
|
-
keys: { bar: { required: true, type: "string" } },
|
|
539
|
-
)
|
|
540
|
-
|
|
541
518
|
expect(interaktor.required_failure_attributes).to contain_exactly(:bar)
|
|
542
519
|
|
|
543
520
|
result = interaktor.call
|
|
@@ -556,10 +533,6 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
556
533
|
end
|
|
557
534
|
|
|
558
535
|
expect(interaktor.failure_schema).to be_a Dry::Schema::Params
|
|
559
|
-
expect(interaktor.failure_schema.info).to eq(
|
|
560
|
-
keys: { bar: { required: true, type: "string" } },
|
|
561
|
-
)
|
|
562
|
-
|
|
563
536
|
expect(interaktor.required_failure_attributes).to contain_exactly(:bar)
|
|
564
537
|
|
|
565
538
|
result = interaktor.call
|
|
@@ -578,18 +551,18 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
578
551
|
end
|
|
579
552
|
|
|
580
553
|
expect {
|
|
581
|
-
|
|
554
|
+
interaktor.call
|
|
582
555
|
}.to raise_error(
|
|
583
556
|
an_instance_of(Interaktor::Error::AttributeSchemaValidationError).and(
|
|
584
557
|
having_attributes(
|
|
585
558
|
interaktor: interaktor,
|
|
586
|
-
validation_errors: {
|
|
559
|
+
validation_errors: {bar: ["is missing"]}
|
|
587
560
|
)
|
|
588
561
|
)
|
|
589
562
|
)
|
|
590
563
|
end
|
|
591
564
|
|
|
592
|
-
it "
|
|
565
|
+
it "raises an exception for unknown provided attributes" do
|
|
593
566
|
interaktor = FakeInteraktor.build_interaktor(type: interaktor_class) do
|
|
594
567
|
failure { required(:bar).filled(:string) }
|
|
595
568
|
|
|
@@ -598,9 +571,9 @@ RSpec.shared_examples "lint" do |interaktor_class|
|
|
|
598
571
|
end
|
|
599
572
|
end
|
|
600
573
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
574
|
+
expect {
|
|
575
|
+
interaktor.call
|
|
576
|
+
}.to raise_error Interaktor::Error::UnknownAttributeError
|
|
604
577
|
end
|
|
605
578
|
|
|
606
579
|
it "allows missing optional attributes" do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: interaktor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Taylor Thurlow
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-11-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dry-schema
|
|
@@ -28,16 +28,16 @@ dependencies:
|
|
|
28
28
|
name: zeitwerk
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '2
|
|
33
|
+
version: '2'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '2
|
|
40
|
+
version: '2'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -62,25 +62,31 @@ files:
|
|
|
62
62
|
- ".github/workflows/tests.yml"
|
|
63
63
|
- ".gitignore"
|
|
64
64
|
- ".rspec"
|
|
65
|
-
- ".rubocop.yml"
|
|
66
65
|
- ".ruby-version"
|
|
66
|
+
- ".standard.yml"
|
|
67
67
|
- Gemfile
|
|
68
68
|
- Gemfile.ci
|
|
69
69
|
- Guardfile
|
|
70
70
|
- README.md
|
|
71
71
|
- Rakefile
|
|
72
|
+
- bin/_guard-core
|
|
73
|
+
- bin/guard
|
|
74
|
+
- bin/rspec
|
|
75
|
+
- bin/standardrb
|
|
72
76
|
- interaktor.gemspec
|
|
73
77
|
- lib/interaktor.rb
|
|
74
78
|
- lib/interaktor/callable.rb
|
|
75
|
-
- lib/interaktor/context.rb
|
|
76
79
|
- lib/interaktor/error/attribute_error.rb
|
|
77
80
|
- lib/interaktor/error/attribute_schema_validation_error.rb
|
|
78
81
|
- lib/interaktor/error/base.rb
|
|
82
|
+
- lib/interaktor/error/invalid_method_for_state_error.rb
|
|
79
83
|
- lib/interaktor/error/missing_explicit_success_error.rb
|
|
80
84
|
- lib/interaktor/error/organizer_missing_passed_attribute_error.rb
|
|
81
85
|
- lib/interaktor/error/organizer_success_attribute_missing_error.rb
|
|
86
|
+
- lib/interaktor/error/unknown_attribute_error.rb
|
|
82
87
|
- lib/interaktor/failure.rb
|
|
83
88
|
- lib/interaktor/hooks.rb
|
|
89
|
+
- lib/interaktor/interaction.rb
|
|
84
90
|
- lib/interaktor/organizer.rb
|
|
85
91
|
- spec/integration_spec.rb
|
|
86
92
|
- spec/interaktor/context_spec.rb
|
|
@@ -94,7 +100,7 @@ homepage: https://github.com/taylorthurlow/interaktor
|
|
|
94
100
|
licenses:
|
|
95
101
|
- MIT
|
|
96
102
|
metadata: {}
|
|
97
|
-
post_install_message:
|
|
103
|
+
post_install_message:
|
|
98
104
|
rdoc_options: []
|
|
99
105
|
require_paths:
|
|
100
106
|
- lib
|
|
@@ -102,23 +108,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
102
108
|
requirements:
|
|
103
109
|
- - ">="
|
|
104
110
|
- !ruby/object:Gem::Version
|
|
105
|
-
version: '
|
|
111
|
+
version: '3.0'
|
|
106
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
113
|
requirements:
|
|
108
114
|
- - ">="
|
|
109
115
|
- !ruby/object:Gem::Version
|
|
110
116
|
version: '0'
|
|
111
117
|
requirements: []
|
|
112
|
-
rubygems_version: 3.4.
|
|
113
|
-
signing_key:
|
|
118
|
+
rubygems_version: 3.4.19
|
|
119
|
+
signing_key:
|
|
114
120
|
specification_version: 4
|
|
115
121
|
summary: Simple service object implementation
|
|
116
|
-
test_files:
|
|
117
|
-
- spec/integration_spec.rb
|
|
118
|
-
- spec/interaktor/context_spec.rb
|
|
119
|
-
- spec/interaktor/hooks_spec.rb
|
|
120
|
-
- spec/interaktor/organizer_spec.rb
|
|
121
|
-
- spec/interaktor_spec.rb
|
|
122
|
-
- spec/spec_helper.rb
|
|
123
|
-
- spec/support/helpers.rb
|
|
124
|
-
- spec/support/lint.rb
|
|
122
|
+
test_files: []
|