interaktor 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish.yml +0 -1
- data/.github/workflows/tests.yml +5 -5
- data/.gitignore +3 -0
- data/Gemfile +1 -1
- data/Gemfile.ci +6 -0
- data/README.md +65 -29
- data/interaktor.gemspec +3 -2
- data/lib/interaktor.rb +11 -16
- data/lib/interaktor/callable.rb +235 -108
- data/lib/interaktor/error/attribute_error.rb +3 -1
- data/lib/interaktor/error/attribute_schema_validation_error.rb +54 -0
- data/lib/interaktor/error/missing_explicit_success_error.rb +5 -0
- data/lib/interaktor/error/option_error.rb +3 -1
- data/lib/interaktor/error/organizer_missing_passed_attribute_error.rb +21 -0
- data/lib/interaktor/error/organizer_success_attribute_missing_error.rb +20 -0
- data/lib/interaktor/organizer.rb +33 -7
- data/spec/integration_spec.rb +142 -71
- data/spec/{interactor → interaktor}/context_spec.rb +1 -1
- data/spec/{interactor → interaktor}/hooks_spec.rb +1 -1
- data/spec/interaktor/organizer_spec.rb +249 -0
- data/spec/interaktor_spec.rb +2 -2
- data/spec/spec_helper.rb +20 -0
- data/spec/support/helpers.rb +14 -0
- data/spec/support/lint.rb +403 -166
- metadata +31 -12
- data/.travis.yml +0 -14
- data/lib/interaktor/error/missing_attribute_error.rb +0 -5
- data/spec/interactor/organizer_spec.rb +0 -128
@@ -0,0 +1,54 @@
|
|
1
|
+
class Interaktor::Error::AttributeSchemaValidationError < Interaktor::Error::Base
|
2
|
+
# @return [Hash{Symbol=>Array<String>}]
|
3
|
+
attr_reader :validation_errors
|
4
|
+
|
5
|
+
# @param interaktor [Class]
|
6
|
+
# @param validation_errors [Hash{Symbol=>Array<String>}]
|
7
|
+
def initialize(interaktor, validation_errors)
|
8
|
+
super(interaktor)
|
9
|
+
|
10
|
+
@validation_errors = validation_errors
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String]
|
14
|
+
# @abstract
|
15
|
+
def message
|
16
|
+
"Interaktor attribute schema failed validation:\n #{error_list}"
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
def error_list
|
23
|
+
result = ""
|
24
|
+
|
25
|
+
validation_errors.each do |attribute, errors|
|
26
|
+
result << error_entry(attribute, errors)
|
27
|
+
end
|
28
|
+
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
def error_entry(key, value, depth = 0)
|
33
|
+
result = " " * depth * 2
|
34
|
+
|
35
|
+
case value
|
36
|
+
when Hash
|
37
|
+
result << "#{key}:\n"
|
38
|
+
value.each do |sub_key, sub_value|
|
39
|
+
result << " "
|
40
|
+
result << error_entry(sub_key, sub_value, depth + 1)
|
41
|
+
end
|
42
|
+
when Array
|
43
|
+
result << "#{key}:\n"
|
44
|
+
value.each do |error_message|
|
45
|
+
result << " "
|
46
|
+
result << error_entry(nil, error_message, depth + 1)
|
47
|
+
end
|
48
|
+
else
|
49
|
+
result << "- #{value}\n"
|
50
|
+
end
|
51
|
+
|
52
|
+
result
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Interaktor::Error::OrganizerMissingPassedAttributeError < Interaktor::Error::AttributeError
|
2
|
+
# @return [Symbol]
|
3
|
+
attr_reader :attribute
|
4
|
+
|
5
|
+
# @param next_interaktor [Class]
|
6
|
+
# @param attribute [Symbol]
|
7
|
+
def initialize(interaktor, attribute)
|
8
|
+
super(interaktor, [attribute])
|
9
|
+
|
10
|
+
@attribute = attribute
|
11
|
+
end
|
12
|
+
|
13
|
+
def message
|
14
|
+
<<~MESSAGE.strip.tr("\n", "")
|
15
|
+
An organized #{interaktor} interaktor requires a '#{attribute}' input
|
16
|
+
attribute, but none of the interaktors that come before it in the
|
17
|
+
organizer list it as a success attribute, and the organizer does not list
|
18
|
+
it as a required attribute.
|
19
|
+
MESSAGE
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Interaktor::Error::OrganizerSuccessAttributeMissingError < Interaktor::Error::AttributeError
|
2
|
+
# @return [Symbol]
|
3
|
+
attr_reader :attribute
|
4
|
+
|
5
|
+
# @param interaktor [Class]
|
6
|
+
# @param attribute [Symbol]
|
7
|
+
def initialize(interaktor, attribute)
|
8
|
+
super(interaktor, [attribute])
|
9
|
+
|
10
|
+
@attribute = attribute
|
11
|
+
end
|
12
|
+
|
13
|
+
def message
|
14
|
+
<<~MESSAGE.strip.tr("\n", "")
|
15
|
+
A #{interaktor} organizer requires a '#{attribute}' success attribute,
|
16
|
+
but none of the success attributes provided by any of the organized
|
17
|
+
interaktors list it.
|
18
|
+
MESSAGE
|
19
|
+
end
|
20
|
+
end
|
data/lib/interaktor/organizer.rb
CHANGED
@@ -39,16 +39,42 @@ module Interaktor::Organizer
|
|
39
39
|
#
|
40
40
|
# @return [void]
|
41
41
|
def call
|
42
|
-
|
43
|
-
# Take the context that is being passed to each interaktor and remove
|
44
|
-
# any attributes from it that are not required by the interactor.
|
45
|
-
@context.to_h
|
46
|
-
.keys
|
47
|
-
.reject { |attr| interaktor.input_attributes.include?(attr) }
|
48
|
-
.each { |attr| @context.delete_field(attr) }
|
42
|
+
check_attribute_flow_valid
|
49
43
|
|
44
|
+
self.class.organized.each do |interaktor|
|
50
45
|
catch(:early_return) { interaktor.call!(@context) }
|
51
46
|
end
|
52
47
|
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# @return [void]
|
52
|
+
def check_attribute_flow_valid
|
53
|
+
interaktors = self.class.organized
|
54
|
+
|
55
|
+
# @type [Array<Symbol>]
|
56
|
+
success_attributes_so_far = []
|
57
|
+
|
58
|
+
success_attributes_so_far += self.class.required_input_attributes
|
59
|
+
|
60
|
+
# @param interaktor [Class]
|
61
|
+
interaktors.each do |interaktor|
|
62
|
+
interaktor.required_input_attributes.each do |required_attr|
|
63
|
+
unless success_attributes_so_far.include?(required_attr)
|
64
|
+
raise Interaktor::Error::OrganizerMissingPassedAttributeError.new(interaktor, required_attr)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
success_attributes_so_far += interaktor.success_attributes
|
69
|
+
|
70
|
+
next unless interaktor == interaktors.last
|
71
|
+
|
72
|
+
self.class.success_attributes.each do |success_attr|
|
73
|
+
unless success_attributes_so_far.include?(success_attr)
|
74
|
+
raise Interaktor::Error::OrganizerSuccessAttributeMissingError.new(interaktor, success_attr)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
53
79
|
end
|
54
80
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -3,37 +3,7 @@
|
|
3
3
|
# rubocop:disable RSpec/ScatteredSetup
|
4
4
|
# rubocop:disable Style/DocumentationMethod
|
5
5
|
|
6
|
-
describe "Integration" do
|
7
|
-
def build_interaktor(&block)
|
8
|
-
Class.new.tap do |interaktor|
|
9
|
-
interaktor.send(:include, Interaktor)
|
10
|
-
interaktor.class_eval(&block) if block
|
11
|
-
interaktor.class_eval do
|
12
|
-
optional :steps
|
13
|
-
|
14
|
-
def unexpected_error!
|
15
|
-
raise "foo"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def build_organizer(options = {}, &block)
|
22
|
-
Class.new.tap do |organizer|
|
23
|
-
organizer.send(:include, Interaktor::Organizer)
|
24
|
-
|
25
|
-
organizer.organize(options[:organize]) if options[:organize]
|
26
|
-
organizer.class_eval(&block) if block
|
27
|
-
organizer.class_eval do
|
28
|
-
optional :steps
|
29
|
-
|
30
|
-
def unexpected_error!
|
31
|
-
raise "foo"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
6
|
+
RSpec.describe "Integration" do
|
37
7
|
# rubocop:disable Style/AsciiComments
|
38
8
|
#
|
39
9
|
# organizer
|
@@ -52,7 +22,10 @@ describe "Integration" do
|
|
52
22
|
|
53
23
|
let(:organizer) {
|
54
24
|
interaktors = [organizer2, interaktor3, organizer4, interaktor5]
|
55
|
-
|
25
|
+
|
26
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
27
|
+
organize(interaktors)
|
28
|
+
|
56
29
|
around do |interaktor|
|
57
30
|
@context.steps << :around_before
|
58
31
|
interaktor.call
|
@@ -70,7 +43,11 @@ describe "Integration" do
|
|
70
43
|
}
|
71
44
|
|
72
45
|
let(:organizer2) {
|
73
|
-
|
46
|
+
interaktors = [interaktor2a, interaktor2b, interaktor2c]
|
47
|
+
|
48
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
49
|
+
organize(interaktors)
|
50
|
+
|
74
51
|
around do |interaktor|
|
75
52
|
@context.steps << :around_before2
|
76
53
|
interaktor.call
|
@@ -88,7 +65,7 @@ describe "Integration" do
|
|
88
65
|
}
|
89
66
|
|
90
67
|
let(:interaktor2a) {
|
91
|
-
build_interaktor do
|
68
|
+
FakeInteraktor.build_interaktor do
|
92
69
|
around do |interaktor|
|
93
70
|
@context.steps << :around_before2a
|
94
71
|
interaktor.call
|
@@ -114,7 +91,7 @@ describe "Integration" do
|
|
114
91
|
}
|
115
92
|
|
116
93
|
let(:interaktor2b) {
|
117
|
-
build_interaktor do
|
94
|
+
FakeInteraktor.build_interaktor do
|
118
95
|
around do |interaktor|
|
119
96
|
@context.steps << :around_before2b
|
120
97
|
interaktor.call
|
@@ -140,7 +117,7 @@ describe "Integration" do
|
|
140
117
|
}
|
141
118
|
|
142
119
|
let(:interaktor2c) {
|
143
|
-
build_interaktor do
|
120
|
+
FakeInteraktor.build_interaktor do
|
144
121
|
around do |interaktor|
|
145
122
|
@context.steps << :around_before2c
|
146
123
|
interaktor.call
|
@@ -166,7 +143,7 @@ describe "Integration" do
|
|
166
143
|
}
|
167
144
|
|
168
145
|
let(:interaktor3) {
|
169
|
-
build_interaktor do
|
146
|
+
FakeInteraktor.build_interaktor do
|
170
147
|
around do |interaktor|
|
171
148
|
@context.steps << :around_before3
|
172
149
|
interaktor.call
|
@@ -192,7 +169,11 @@ describe "Integration" do
|
|
192
169
|
}
|
193
170
|
|
194
171
|
let(:organizer4) {
|
195
|
-
|
172
|
+
interaktors = [interaktor4a, interaktor4b, interaktor4c]
|
173
|
+
|
174
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
175
|
+
organize(interaktors)
|
176
|
+
|
196
177
|
around do |interaktor|
|
197
178
|
@context.steps << :around_before4
|
198
179
|
interaktor.call
|
@@ -210,7 +191,7 @@ describe "Integration" do
|
|
210
191
|
}
|
211
192
|
|
212
193
|
let(:interaktor4a) {
|
213
|
-
build_interaktor do
|
194
|
+
FakeInteraktor.build_interaktor do
|
214
195
|
around do |interaktor|
|
215
196
|
@context.steps << :around_before4a
|
216
197
|
interaktor.call
|
@@ -236,7 +217,7 @@ describe "Integration" do
|
|
236
217
|
}
|
237
218
|
|
238
219
|
let(:interaktor4b) {
|
239
|
-
build_interaktor do
|
220
|
+
FakeInteraktor.build_interaktor do
|
240
221
|
around do |interaktor|
|
241
222
|
@context.steps << :around_before4b
|
242
223
|
interaktor.call
|
@@ -262,7 +243,7 @@ describe "Integration" do
|
|
262
243
|
}
|
263
244
|
|
264
245
|
let(:interaktor4c) {
|
265
|
-
build_interaktor do
|
246
|
+
FakeInteraktor.build_interaktor do
|
266
247
|
around do |interaktor|
|
267
248
|
@context.steps << :around_before4c
|
268
249
|
interaktor.call
|
@@ -288,7 +269,7 @@ describe "Integration" do
|
|
288
269
|
}
|
289
270
|
|
290
271
|
let(:interaktor5) {
|
291
|
-
build_interaktor do
|
272
|
+
FakeInteraktor.build_interaktor do
|
292
273
|
around do |interaktor|
|
293
274
|
@context.steps << :around_before5
|
294
275
|
interaktor.call
|
@@ -341,7 +322,10 @@ describe "Integration" do
|
|
341
322
|
context "when an around hook fails early" do
|
342
323
|
let(:organizer) {
|
343
324
|
interaktors = [organizer2, interaktor3, organizer4, interaktor5]
|
344
|
-
|
325
|
+
|
326
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
327
|
+
organize(interaktors)
|
328
|
+
|
345
329
|
around do |interaktor|
|
346
330
|
@context.fail!
|
347
331
|
@context.steps << :around_before
|
@@ -370,7 +354,10 @@ describe "Integration" do
|
|
370
354
|
context "when an around hook errors early" do
|
371
355
|
let(:organizer) {
|
372
356
|
interaktors = [organizer2, interaktor3, organizer4, interaktor5]
|
373
|
-
|
357
|
+
|
358
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
359
|
+
organize(interaktors)
|
360
|
+
|
374
361
|
around do |interaktor|
|
375
362
|
unexpected_error!
|
376
363
|
@context.steps << :around_before
|
@@ -386,6 +373,10 @@ describe "Integration" do
|
|
386
373
|
after do
|
387
374
|
@context.steps << :after
|
388
375
|
end
|
376
|
+
|
377
|
+
def unexpected_error!
|
378
|
+
raise "foo"
|
379
|
+
end
|
389
380
|
end
|
390
381
|
}
|
391
382
|
|
@@ -409,7 +400,10 @@ describe "Integration" do
|
|
409
400
|
context "when a before hook fails" do
|
410
401
|
let(:organizer) {
|
411
402
|
interaktors = [organizer2, interaktor3, organizer4, interaktor5]
|
412
|
-
|
403
|
+
|
404
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
405
|
+
organize(interaktors)
|
406
|
+
|
413
407
|
around do |interaktor|
|
414
408
|
@context.steps << :around_before
|
415
409
|
interaktor.call
|
@@ -439,7 +433,10 @@ describe "Integration" do
|
|
439
433
|
context "when a before hook errors" do
|
440
434
|
let(:organizer) {
|
441
435
|
interaktors = [organizer2, interaktor3, organizer4, interaktor5]
|
442
|
-
|
436
|
+
|
437
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
438
|
+
organize(interaktors)
|
439
|
+
|
443
440
|
around do |interaktor|
|
444
441
|
@context.steps << :around_before
|
445
442
|
interaktor.call
|
@@ -454,6 +451,10 @@ describe "Integration" do
|
|
454
451
|
after do
|
455
452
|
@context.steps << :after
|
456
453
|
end
|
454
|
+
|
455
|
+
def unexpected_error!
|
456
|
+
raise "foo"
|
457
|
+
end
|
457
458
|
end
|
458
459
|
}
|
459
460
|
|
@@ -479,7 +480,10 @@ describe "Integration" do
|
|
479
480
|
context "when an after hook fails" do
|
480
481
|
let(:organizer) {
|
481
482
|
interaktors = [organizer2, interaktor3, organizer4, interaktor5]
|
482
|
-
|
483
|
+
|
484
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
485
|
+
organize(interaktors)
|
486
|
+
|
483
487
|
around do |interaktor|
|
484
488
|
@context.steps << :around_before
|
485
489
|
interaktor.call
|
@@ -529,7 +533,10 @@ describe "Integration" do
|
|
529
533
|
context "when an after hook errors" do
|
530
534
|
let(:organizer) {
|
531
535
|
interaktors = [organizer2, interaktor3, organizer4, interaktor5]
|
532
|
-
|
536
|
+
|
537
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
538
|
+
organize(interaktors)
|
539
|
+
|
533
540
|
around do |interaktor|
|
534
541
|
@context.steps << :around_before
|
535
542
|
interaktor.call
|
@@ -544,6 +551,10 @@ describe "Integration" do
|
|
544
551
|
unexpected_error!
|
545
552
|
@context.steps << :after
|
546
553
|
end
|
554
|
+
|
555
|
+
def unexpected_error!
|
556
|
+
raise "foo"
|
557
|
+
end
|
547
558
|
end
|
548
559
|
}
|
549
560
|
|
@@ -589,7 +600,10 @@ describe "Integration" do
|
|
589
600
|
context "when an around hook fails late" do
|
590
601
|
let(:organizer) {
|
591
602
|
interaktors = [organizer2, interaktor3, organizer4, interaktor5]
|
592
|
-
|
603
|
+
|
604
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
605
|
+
organize(interaktors)
|
606
|
+
|
593
607
|
around do |interaktor|
|
594
608
|
@context.steps << :around_before
|
595
609
|
interaktor.call
|
@@ -640,7 +654,10 @@ describe "Integration" do
|
|
640
654
|
context "when an around hook errors late" do
|
641
655
|
let(:organizer) {
|
642
656
|
interaktors = [organizer2, interaktor3, organizer4, interaktor5]
|
643
|
-
|
657
|
+
|
658
|
+
FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
659
|
+
organize(interaktors)
|
660
|
+
|
644
661
|
around do |interaktor|
|
645
662
|
@context.steps << :around_before
|
646
663
|
interaktor.call
|
@@ -655,6 +672,10 @@ describe "Integration" do
|
|
655
672
|
after do
|
656
673
|
@context.steps << :after
|
657
674
|
end
|
675
|
+
|
676
|
+
def unexpected_error!
|
677
|
+
raise "foo"
|
678
|
+
end
|
658
679
|
end
|
659
680
|
}
|
660
681
|
|
@@ -700,7 +721,7 @@ describe "Integration" do
|
|
700
721
|
|
701
722
|
context "when a nested around hook fails early" do
|
702
723
|
let(:interaktor3) {
|
703
|
-
build_interaktor do
|
724
|
+
FakeInteraktor.build_interaktor do
|
704
725
|
around do |interaktor|
|
705
726
|
@context.fail!
|
706
727
|
@context.steps << :around_before3
|
@@ -745,7 +766,7 @@ describe "Integration" do
|
|
745
766
|
|
746
767
|
context "when a nested around hook errors early" do
|
747
768
|
let(:interaktor3) {
|
748
|
-
build_interaktor do
|
769
|
+
FakeInteraktor.build_interaktor do
|
749
770
|
around do |interaktor|
|
750
771
|
unexpected_error!
|
751
772
|
@context.steps << :around_before3
|
@@ -768,6 +789,10 @@ describe "Integration" do
|
|
768
789
|
def rollback
|
769
790
|
@context.steps << :rollback3
|
770
791
|
end
|
792
|
+
|
793
|
+
def unexpected_error!
|
794
|
+
raise "foo"
|
795
|
+
end
|
771
796
|
end
|
772
797
|
}
|
773
798
|
|
@@ -800,7 +825,7 @@ describe "Integration" do
|
|
800
825
|
|
801
826
|
context "when a nested before hook fails" do
|
802
827
|
let(:interaktor3) {
|
803
|
-
build_interaktor do
|
828
|
+
FakeInteraktor.build_interaktor do
|
804
829
|
around do |interaktor|
|
805
830
|
@context.steps << :around_before3
|
806
831
|
interaktor.call
|
@@ -846,7 +871,7 @@ describe "Integration" do
|
|
846
871
|
|
847
872
|
context "when a nested before hook errors" do
|
848
873
|
let(:interaktor3) {
|
849
|
-
build_interaktor do
|
874
|
+
FakeInteraktor.build_interaktor do
|
850
875
|
around do |interaktor|
|
851
876
|
@context.steps << :around_before3
|
852
877
|
interaktor.call
|
@@ -869,6 +894,10 @@ describe "Integration" do
|
|
869
894
|
def rollback
|
870
895
|
@context.steps << :rollback3
|
871
896
|
end
|
897
|
+
|
898
|
+
def unexpected_error!
|
899
|
+
raise "foo"
|
900
|
+
end
|
872
901
|
end
|
873
902
|
}
|
874
903
|
|
@@ -902,7 +931,7 @@ describe "Integration" do
|
|
902
931
|
|
903
932
|
context "when a nested call fails" do
|
904
933
|
let(:interaktor3) {
|
905
|
-
build_interaktor do
|
934
|
+
FakeInteraktor.build_interaktor do
|
906
935
|
around do |interaktor|
|
907
936
|
@context.steps << :around_before3
|
908
937
|
interaktor.call
|
@@ -948,7 +977,7 @@ describe "Integration" do
|
|
948
977
|
|
949
978
|
context "when a nested call errors" do
|
950
979
|
let(:interaktor3) {
|
951
|
-
build_interaktor do
|
980
|
+
FakeInteraktor.build_interaktor do
|
952
981
|
around do |interaktor|
|
953
982
|
@context.steps << :around_before3
|
954
983
|
interaktor.call
|
@@ -971,6 +1000,10 @@ describe "Integration" do
|
|
971
1000
|
def rollback
|
972
1001
|
@context.steps << :rollback3
|
973
1002
|
end
|
1003
|
+
|
1004
|
+
def unexpected_error!
|
1005
|
+
raise "foo"
|
1006
|
+
end
|
974
1007
|
end
|
975
1008
|
}
|
976
1009
|
|
@@ -1004,7 +1037,7 @@ describe "Integration" do
|
|
1004
1037
|
|
1005
1038
|
context "when a nested after hook fails" do
|
1006
1039
|
let(:interaktor3) {
|
1007
|
-
build_interaktor do
|
1040
|
+
FakeInteraktor.build_interaktor do
|
1008
1041
|
around do |interaktor|
|
1009
1042
|
@context.steps << :around_before3
|
1010
1043
|
interaktor.call
|
@@ -1051,7 +1084,7 @@ describe "Integration" do
|
|
1051
1084
|
|
1052
1085
|
context "when a nested after hook errors" do
|
1053
1086
|
let(:interaktor3) {
|
1054
|
-
build_interaktor do
|
1087
|
+
FakeInteraktor.build_interaktor do
|
1055
1088
|
around do |interaktor|
|
1056
1089
|
@context.steps << :around_before3
|
1057
1090
|
interaktor.call
|
@@ -1074,6 +1107,10 @@ describe "Integration" do
|
|
1074
1107
|
def rollback
|
1075
1108
|
@context.steps << :rollback3
|
1076
1109
|
end
|
1110
|
+
|
1111
|
+
def unexpected_error!
|
1112
|
+
raise "foo"
|
1113
|
+
end
|
1077
1114
|
end
|
1078
1115
|
}
|
1079
1116
|
|
@@ -1108,7 +1145,7 @@ describe "Integration" do
|
|
1108
1145
|
|
1109
1146
|
context "when a nested around hook fails late" do
|
1110
1147
|
let(:interaktor3) {
|
1111
|
-
build_interaktor do
|
1148
|
+
FakeInteraktor.build_interaktor do
|
1112
1149
|
around do |interaktor|
|
1113
1150
|
@context.steps << :around_before3
|
1114
1151
|
interaktor.call
|
@@ -1155,7 +1192,7 @@ describe "Integration" do
|
|
1155
1192
|
|
1156
1193
|
context "when a nested around hook errors late" do
|
1157
1194
|
let(:interaktor3) {
|
1158
|
-
build_interaktor do
|
1195
|
+
FakeInteraktor.build_interaktor do
|
1159
1196
|
around do |interaktor|
|
1160
1197
|
@context.steps << :around_before3
|
1161
1198
|
interaktor.call
|
@@ -1178,6 +1215,10 @@ describe "Integration" do
|
|
1178
1215
|
def rollback
|
1179
1216
|
@context.steps << :rollback3
|
1180
1217
|
end
|
1218
|
+
|
1219
|
+
def unexpected_error!
|
1220
|
+
raise "foo"
|
1221
|
+
end
|
1181
1222
|
end
|
1182
1223
|
}
|
1183
1224
|
|
@@ -1212,7 +1253,7 @@ describe "Integration" do
|
|
1212
1253
|
|
1213
1254
|
context "when a deeply nested around hook fails early" do
|
1214
1255
|
let(:interaktor4b) {
|
1215
|
-
build_interaktor do
|
1256
|
+
FakeInteraktor.build_interaktor do
|
1216
1257
|
around do |interaktor|
|
1217
1258
|
@context.fail!
|
1218
1259
|
@context.steps << :around_before4b
|
@@ -1262,7 +1303,7 @@ describe "Integration" do
|
|
1262
1303
|
|
1263
1304
|
context "when a deeply nested around hook errors early" do
|
1264
1305
|
let(:interaktor4b) {
|
1265
|
-
build_interaktor do
|
1306
|
+
FakeInteraktor.build_interaktor do
|
1266
1307
|
around do |interaktor|
|
1267
1308
|
unexpected_error!
|
1268
1309
|
@context.steps << :around_before4b
|
@@ -1285,6 +1326,10 @@ describe "Integration" do
|
|
1285
1326
|
def rollback
|
1286
1327
|
@context.steps << :rollback4b
|
1287
1328
|
end
|
1329
|
+
|
1330
|
+
def unexpected_error!
|
1331
|
+
raise "foo"
|
1332
|
+
end
|
1288
1333
|
end
|
1289
1334
|
}
|
1290
1335
|
|
@@ -1322,7 +1367,7 @@ describe "Integration" do
|
|
1322
1367
|
|
1323
1368
|
context "when a deeply nested before hook fails" do
|
1324
1369
|
let(:interaktor4b) {
|
1325
|
-
build_interaktor do
|
1370
|
+
FakeInteraktor.build_interaktor do
|
1326
1371
|
around do |interaktor|
|
1327
1372
|
@context.steps << :around_before4b
|
1328
1373
|
interaktor.call
|
@@ -1373,7 +1418,7 @@ describe "Integration" do
|
|
1373
1418
|
|
1374
1419
|
context "when a deeply nested before hook errors" do
|
1375
1420
|
let(:interaktor4b) {
|
1376
|
-
build_interaktor do
|
1421
|
+
FakeInteraktor.build_interaktor do
|
1377
1422
|
around do |interaktor|
|
1378
1423
|
@context.steps << :around_before4b
|
1379
1424
|
interaktor.call
|
@@ -1396,6 +1441,10 @@ describe "Integration" do
|
|
1396
1441
|
def rollback
|
1397
1442
|
@context.steps << :rollback4b
|
1398
1443
|
end
|
1444
|
+
|
1445
|
+
def unexpected_error!
|
1446
|
+
raise "foo"
|
1447
|
+
end
|
1399
1448
|
end
|
1400
1449
|
}
|
1401
1450
|
|
@@ -1434,7 +1483,7 @@ describe "Integration" do
|
|
1434
1483
|
|
1435
1484
|
context "when a deeply nested call fails" do
|
1436
1485
|
let(:interaktor4b) {
|
1437
|
-
build_interaktor do
|
1486
|
+
FakeInteraktor.build_interaktor do
|
1438
1487
|
around do |interaktor|
|
1439
1488
|
@context.steps << :around_before4b
|
1440
1489
|
interaktor.call
|
@@ -1485,7 +1534,7 @@ describe "Integration" do
|
|
1485
1534
|
|
1486
1535
|
context "when a deeply nested call errors" do
|
1487
1536
|
let(:interaktor4b) {
|
1488
|
-
build_interaktor do
|
1537
|
+
FakeInteraktor.build_interaktor do
|
1489
1538
|
around do |interaktor|
|
1490
1539
|
@context.steps << :around_before4b
|
1491
1540
|
interaktor.call
|
@@ -1508,6 +1557,10 @@ describe "Integration" do
|
|
1508
1557
|
def rollback
|
1509
1558
|
@context.steps << :rollback4b
|
1510
1559
|
end
|
1560
|
+
|
1561
|
+
def unexpected_error!
|
1562
|
+
raise "foo"
|
1563
|
+
end
|
1511
1564
|
end
|
1512
1565
|
}
|
1513
1566
|
|
@@ -1546,7 +1599,7 @@ describe "Integration" do
|
|
1546
1599
|
|
1547
1600
|
context "when a deeply nested after hook fails" do
|
1548
1601
|
let(:interaktor4b) {
|
1549
|
-
build_interaktor do
|
1602
|
+
FakeInteraktor.build_interaktor do
|
1550
1603
|
around do |interaktor|
|
1551
1604
|
@context.steps << :around_before4b
|
1552
1605
|
interaktor.call
|
@@ -1598,7 +1651,7 @@ describe "Integration" do
|
|
1598
1651
|
|
1599
1652
|
context "when a deeply nested after hook errors" do
|
1600
1653
|
let(:interaktor4b) {
|
1601
|
-
build_interaktor do
|
1654
|
+
FakeInteraktor.build_interaktor do
|
1602
1655
|
around do |interaktor|
|
1603
1656
|
@context.steps << :around_before4b
|
1604
1657
|
interaktor.call
|
@@ -1621,6 +1674,10 @@ describe "Integration" do
|
|
1621
1674
|
def rollback
|
1622
1675
|
@context.steps << :rollback4b
|
1623
1676
|
end
|
1677
|
+
|
1678
|
+
def unexpected_error!
|
1679
|
+
raise "foo"
|
1680
|
+
end
|
1624
1681
|
end
|
1625
1682
|
}
|
1626
1683
|
|
@@ -1660,7 +1717,7 @@ describe "Integration" do
|
|
1660
1717
|
|
1661
1718
|
context "when a deeply nested around hook fails late" do
|
1662
1719
|
let(:interaktor4b) {
|
1663
|
-
build_interaktor do
|
1720
|
+
FakeInteraktor.build_interaktor do
|
1664
1721
|
around do |interaktor|
|
1665
1722
|
@context.steps << :around_before4b
|
1666
1723
|
interaktor.call
|
@@ -1712,7 +1769,7 @@ describe "Integration" do
|
|
1712
1769
|
|
1713
1770
|
context "when a deeply nested around hook errors late" do
|
1714
1771
|
let(:interaktor4b) {
|
1715
|
-
build_interaktor do
|
1772
|
+
FakeInteraktor.build_interaktor do
|
1716
1773
|
around do |interaktor|
|
1717
1774
|
@context.steps << :around_before4b
|
1718
1775
|
interaktor.call
|
@@ -1735,6 +1792,10 @@ describe "Integration" do
|
|
1735
1792
|
def rollback
|
1736
1793
|
@context.steps << :rollback4b
|
1737
1794
|
end
|
1795
|
+
|
1796
|
+
def unexpected_error!
|
1797
|
+
raise "foo"
|
1798
|
+
end
|
1738
1799
|
end
|
1739
1800
|
}
|
1740
1801
|
|
@@ -1774,7 +1835,17 @@ describe "Integration" do
|
|
1774
1835
|
|
1775
1836
|
context "when there are multiple organize calls" do
|
1776
1837
|
it "runs all passed interaktors in correct order" do
|
1777
|
-
organizer = build_organizer(organize: [organizer2, interaktor3])
|
1838
|
+
# organizer = build_organizer(organize: [organizer2, interaktor3])
|
1839
|
+
interaktors = ([organizer2, interaktor3])
|
1840
|
+
|
1841
|
+
organizer = FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
|
1842
|
+
organize(interaktors)
|
1843
|
+
|
1844
|
+
def unexpected_error!
|
1845
|
+
raise "foo"
|
1846
|
+
end
|
1847
|
+
end
|
1848
|
+
|
1778
1849
|
organizer.organize(organizer4, interaktor5)
|
1779
1850
|
|
1780
1851
|
expect {
|