interaktor 0.3.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.
@@ -1,1874 +1,1874 @@
1
- # rubocop:disable RSpec/InstanceVariable
2
- # rubocop:disable RSpec/MultipleMemoizedHelpers
3
- # rubocop:disable RSpec/ScatteredSetup
4
- # rubocop:disable Style/DocumentationMethod
5
-
6
- RSpec.describe "Integration" do
7
- # rubocop:disable Style/AsciiComments
8
- #
9
- # organizer
10
- # ├─ organizer2
11
- # │ ├─ interaktor2a
12
- # │ ├─ interaktor2b
13
- # │ └─ interaktor2c
14
- # ├─ interaktor3
15
- # ├─ organizer4
16
- # │ ├─ interaktor4a
17
- # │ ├─ interaktor4b
18
- # │ └─ interaktor4c
19
- # └─ interaktor5
20
- #
21
- # rubocop:enable Style/AsciiComments
22
-
23
- let(:organizer) {
24
- interaktors = [organizer2, interaktor3, organizer4, interaktor5]
25
-
26
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
27
- organize(interaktors)
28
-
29
- around do |interaktor|
30
- @context.steps << :around_before
31
- interaktor.call
32
- @context.steps << :around_after
33
- end
34
-
35
- before do
36
- @context.steps << :before
37
- end
38
-
39
- after do
40
- @context.steps << :after
41
- end
42
- end
43
- }
44
-
45
- let(:organizer2) {
46
- interaktors = [interaktor2a, interaktor2b, interaktor2c]
47
-
48
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
49
- organize(interaktors)
50
-
51
- around do |interaktor|
52
- @context.steps << :around_before2
53
- interaktor.call
54
- @context.steps << :around_after2
55
- end
56
-
57
- before do
58
- @context.steps << :before2
59
- end
60
-
61
- after do
62
- @context.steps << :after2
63
- end
64
- end
65
- }
66
-
67
- let(:interaktor2a) {
68
- FakeInteraktor.build_interaktor do
69
- around do |interaktor|
70
- @context.steps << :around_before2a
71
- interaktor.call
72
- @context.steps << :around_after2a
73
- end
74
-
75
- before do
76
- @context.steps << :before2a
77
- end
78
-
79
- after do
80
- @context.steps << :after2a
81
- end
82
-
83
- def call
84
- @context.steps << :call2a
85
- end
86
-
87
- def rollback
88
- @context.steps << :rollback2a
89
- end
90
- end
91
- }
92
-
93
- let(:interaktor2b) {
94
- FakeInteraktor.build_interaktor do
95
- around do |interaktor|
96
- @context.steps << :around_before2b
97
- interaktor.call
98
- @context.steps << :around_after2b
99
- end
100
-
101
- before do
102
- @context.steps << :before2b
103
- end
104
-
105
- after do
106
- @context.steps << :after2b
107
- end
108
-
109
- def call
110
- @context.steps << :call2b
111
- end
112
-
113
- def rollback
114
- @context.steps << :rollback2b
115
- end
116
- end
117
- }
118
-
119
- let(:interaktor2c) {
120
- FakeInteraktor.build_interaktor do
121
- around do |interaktor|
122
- @context.steps << :around_before2c
123
- interaktor.call
124
- @context.steps << :around_after2c
125
- end
126
-
127
- before do
128
- @context.steps << :before2c
129
- end
130
-
131
- after do
132
- @context.steps << :after2c
133
- end
134
-
135
- def call
136
- @context.steps << :call2c
137
- end
138
-
139
- def rollback
140
- @context.steps << :rollback2c
141
- end
142
- end
143
- }
144
-
145
- let(:interaktor3) {
146
- FakeInteraktor.build_interaktor do
147
- around do |interaktor|
148
- @context.steps << :around_before3
149
- interaktor.call
150
- @context.steps << :around_after3
151
- end
152
-
153
- before do
154
- @context.steps << :before3
155
- end
156
-
157
- after do
158
- @context.steps << :after3
159
- end
160
-
161
- def call
162
- @context.steps << :call3
163
- end
164
-
165
- def rollback
166
- @context.steps << :rollback3
167
- end
168
- end
169
- }
170
-
171
- let(:organizer4) {
172
- interaktors = [interaktor4a, interaktor4b, interaktor4c]
173
-
174
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
175
- organize(interaktors)
176
-
177
- around do |interaktor|
178
- @context.steps << :around_before4
179
- interaktor.call
180
- @context.steps << :around_after4
181
- end
182
-
183
- before do
184
- @context.steps << :before4
185
- end
186
-
187
- after do
188
- @context.steps << :after4
189
- end
190
- end
191
- }
192
-
193
- let(:interaktor4a) {
194
- FakeInteraktor.build_interaktor do
195
- around do |interaktor|
196
- @context.steps << :around_before4a
197
- interaktor.call
198
- @context.steps << :around_after4a
199
- end
200
-
201
- before do
202
- @context.steps << :before4a
203
- end
204
-
205
- after do
206
- @context.steps << :after4a
207
- end
208
-
209
- def call
210
- @context.steps << :call4a
211
- end
212
-
213
- def rollback
214
- @context.steps << :rollback4a
215
- end
216
- end
217
- }
218
-
219
- let(:interaktor4b) {
220
- FakeInteraktor.build_interaktor do
221
- around do |interaktor|
222
- @context.steps << :around_before4b
223
- interaktor.call
224
- @context.steps << :around_after4b
225
- end
226
-
227
- before do
228
- @context.steps << :before4b
229
- end
230
-
231
- after do
232
- @context.steps << :after4b
233
- end
234
-
235
- def call
236
- @context.steps << :call4b
237
- end
238
-
239
- def rollback
240
- @context.steps << :rollback4b
241
- end
242
- end
243
- }
244
-
245
- let(:interaktor4c) {
246
- FakeInteraktor.build_interaktor do
247
- around do |interaktor|
248
- @context.steps << :around_before4c
249
- interaktor.call
250
- @context.steps << :around_after4c
251
- end
252
-
253
- before do
254
- @context.steps << :before4c
255
- end
256
-
257
- after do
258
- @context.steps << :after4c
259
- end
260
-
261
- def call
262
- @context.steps << :call4c
263
- end
264
-
265
- def rollback
266
- @context.steps << :rollback4c
267
- end
268
- end
269
- }
270
-
271
- let(:interaktor5) {
272
- FakeInteraktor.build_interaktor do
273
- around do |interaktor|
274
- @context.steps << :around_before5
275
- interaktor.call
276
- @context.steps << :around_after5
277
- end
278
-
279
- before do
280
- @context.steps << :before5
281
- end
282
-
283
- after do
284
- @context.steps << :after5
285
- end
286
-
287
- def call
288
- @context.steps << :call5
289
- end
290
-
291
- def rollback
292
- @context.steps << :rollback5
293
- end
294
- end
295
- }
296
-
297
- let(:context) { Interaktor::Context.new(steps: []) }
298
-
299
- context "when successful" do
300
- it "calls and runs hooks in the proper sequence" do
301
- expect {
302
- organizer.call(context)
303
- }.to change(context, :steps).from([]).to([
304
- :around_before, :before,
305
- :around_before2, :before2,
306
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
307
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
308
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
309
- :after2, :around_after2,
310
- :around_before3, :before3, :call3, :after3, :around_after3,
311
- :around_before4, :before4,
312
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
313
- :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
314
- :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
315
- :after4, :around_after4,
316
- :around_before5, :before5, :call5, :after5, :around_after5,
317
- :after, :around_after,
318
- ])
319
- end
320
- end
321
-
322
- context "when an around hook fails early" do
323
- let(:organizer) {
324
- interaktors = [organizer2, interaktor3, organizer4, interaktor5]
325
-
326
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
327
- organize(interaktors)
328
-
329
- around do |interaktor|
330
- @context.fail!
331
- @context.steps << :around_before
332
- interaktor.call
333
- @context.steps << :around_after
334
- end
335
-
336
- before do
337
- @context.fail!
338
- @context.steps << :before
339
- end
340
-
341
- after do
342
- @context.steps << :after
343
- end
344
- end
345
- }
346
-
347
- it "aborts" do
348
- expect {
349
- organizer.call(context)
350
- }.not_to change(context, :steps)
351
- end
352
- end
353
-
354
- context "when an around hook errors early" do
355
- let(:organizer) {
356
- interaktors = [organizer2, interaktor3, organizer4, interaktor5]
357
-
358
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
359
- organize(interaktors)
360
-
361
- around do |interaktor|
362
- unexpected_error!
363
- @context.steps << :around_before
364
- interaktor.call
365
- @context.steps << :around_after
366
- end
367
-
368
- before do
369
- @context.fail!
370
- @context.steps << :before
371
- end
372
-
373
- after do
374
- @context.steps << :after
375
- end
376
-
377
- def unexpected_error!
378
- raise "foo"
379
- end
380
- end
381
- }
382
-
383
- it "aborts" do
384
- expect {
385
- begin
386
- organizer.call(context)
387
- rescue StandardError
388
- nil
389
- end
390
- }.not_to change(context, :steps)
391
- end
392
-
393
- it "raises the error" do
394
- expect {
395
- organizer.call(context)
396
- }.to raise_error("foo")
397
- end
398
- end
399
-
400
- context "when a before hook fails" do
401
- let(:organizer) {
402
- interaktors = [organizer2, interaktor3, organizer4, interaktor5]
403
-
404
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
405
- organize(interaktors)
406
-
407
- around do |interaktor|
408
- @context.steps << :around_before
409
- interaktor.call
410
- @context.steps << :around_after
411
- end
412
-
413
- before do
414
- @context.fail!
415
- @context.steps << :before
416
- end
417
-
418
- after do
419
- @context.steps << :after
420
- end
421
- end
422
- }
423
-
424
- it "aborts" do
425
- expect {
426
- organizer.call(context)
427
- }.to change(context, :steps).from([]).to([
428
- :around_before,
429
- ])
430
- end
431
- end
432
-
433
- context "when a before hook errors" do
434
- let(:organizer) {
435
- interaktors = [organizer2, interaktor3, organizer4, interaktor5]
436
-
437
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
438
- organize(interaktors)
439
-
440
- around do |interaktor|
441
- @context.steps << :around_before
442
- interaktor.call
443
- @context.steps << :around_after
444
- end
445
-
446
- before do
447
- unexpected_error!
448
- @context.steps << :before
449
- end
450
-
451
- after do
452
- @context.steps << :after
453
- end
454
-
455
- def unexpected_error!
456
- raise "foo"
457
- end
458
- end
459
- }
460
-
461
- it "aborts" do
462
- expect {
463
- begin
464
- organizer.call(context)
465
- rescue StandardError
466
- nil
467
- end
468
- }.to change(context, :steps).from([]).to([
469
- :around_before,
470
- ])
471
- end
472
-
473
- it "raises the error" do
474
- expect {
475
- organizer.call(context)
476
- }.to raise_error("foo")
477
- end
478
- end
479
-
480
- context "when an after hook fails" do
481
- let(:organizer) {
482
- interaktors = [organizer2, interaktor3, organizer4, interaktor5]
483
-
484
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
485
- organize(interaktors)
486
-
487
- around do |interaktor|
488
- @context.steps << :around_before
489
- interaktor.call
490
- @context.steps << :around_after
491
- end
492
-
493
- before do
494
- @context.steps << :before
495
- end
496
-
497
- after do
498
- @context.fail!
499
- @context.steps << :after
500
- end
501
- end
502
- }
503
-
504
- it "rolls back successfully called interaktors and the failed interaktor" do
505
- expect {
506
- organizer.call(context)
507
- }.to change(context, :steps).from([]).to([
508
- :around_before, :before,
509
- :around_before2, :before2,
510
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
511
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
512
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
513
- :after2, :around_after2,
514
- :around_before3, :before3, :call3, :after3, :around_after3,
515
- :around_before4, :before4,
516
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
517
- :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
518
- :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
519
- :after4, :around_after4,
520
- :around_before5, :before5, :call5, :after5, :around_after5,
521
- :rollback5,
522
- :rollback4c,
523
- :rollback4b,
524
- :rollback4a,
525
- :rollback3,
526
- :rollback2c,
527
- :rollback2b,
528
- :rollback2a,
529
- ])
530
- end
531
- end
532
-
533
- context "when an after hook errors" do
534
- let(:organizer) {
535
- interaktors = [organizer2, interaktor3, organizer4, interaktor5]
536
-
537
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
538
- organize(interaktors)
539
-
540
- around do |interaktor|
541
- @context.steps << :around_before
542
- interaktor.call
543
- @context.steps << :around_after
544
- end
545
-
546
- before do
547
- @context.steps << :before
548
- end
549
-
550
- after do
551
- unexpected_error!
552
- @context.steps << :after
553
- end
554
-
555
- def unexpected_error!
556
- raise "foo"
557
- end
558
- end
559
- }
560
-
561
- it "rolls back successfully called interaktors and the failed interaktor" do
562
- expect {
563
- begin
564
- organizer.call(context)
565
- rescue StandardError
566
- nil
567
- end
568
- }.to change(context, :steps).from([]).to([
569
- :around_before, :before,
570
- :around_before2, :before2,
571
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
572
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
573
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
574
- :after2, :around_after2,
575
- :around_before3, :before3, :call3, :after3, :around_after3,
576
- :around_before4, :before4,
577
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
578
- :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
579
- :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
580
- :after4, :around_after4,
581
- :around_before5, :before5, :call5, :after5, :around_after5,
582
- :rollback5,
583
- :rollback4c,
584
- :rollback4b,
585
- :rollback4a,
586
- :rollback3,
587
- :rollback2c,
588
- :rollback2b,
589
- :rollback2a,
590
- ])
591
- end
592
-
593
- it "raises the error" do
594
- expect {
595
- organizer.call(context)
596
- }.to raise_error("foo")
597
- end
598
- end
599
-
600
- context "when an around hook fails late" do
601
- let(:organizer) {
602
- interaktors = [organizer2, interaktor3, organizer4, interaktor5]
603
-
604
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
605
- organize(interaktors)
606
-
607
- around do |interaktor|
608
- @context.steps << :around_before
609
- interaktor.call
610
- @context.fail!
611
- @context.steps << :around_after
612
- end
613
-
614
- before do
615
- @context.steps << :before
616
- end
617
-
618
- after do
619
- @context.steps << :after
620
- end
621
- end
622
- }
623
-
624
- it "rolls back successfully called interaktors and the failed interaktor" do
625
- expect {
626
- organizer.call(context)
627
- }.to change(context, :steps).from([]).to([
628
- :around_before, :before,
629
- :around_before2, :before2,
630
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
631
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
632
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
633
- :after2, :around_after2,
634
- :around_before3, :before3, :call3, :after3, :around_after3,
635
- :around_before4, :before4,
636
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
637
- :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
638
- :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
639
- :after4, :around_after4,
640
- :around_before5, :before5, :call5, :after5, :around_after5,
641
- :after,
642
- :rollback5,
643
- :rollback4c,
644
- :rollback4b,
645
- :rollback4a,
646
- :rollback3,
647
- :rollback2c,
648
- :rollback2b,
649
- :rollback2a,
650
- ])
651
- end
652
- end
653
-
654
- context "when an around hook errors late" do
655
- let(:organizer) {
656
- interaktors = [organizer2, interaktor3, organizer4, interaktor5]
657
-
658
- FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
659
- organize(interaktors)
660
-
661
- around do |interaktor|
662
- @context.steps << :around_before
663
- interaktor.call
664
- unexpected_error!
665
- @context.steps << :around_after
666
- end
667
-
668
- before do
669
- @context.steps << :before
670
- end
671
-
672
- after do
673
- @context.steps << :after
674
- end
675
-
676
- def unexpected_error!
677
- raise "foo"
678
- end
679
- end
680
- }
681
-
682
- it "rolls back successfully called interaktors and the failed interaktor" do
683
- expect {
684
- begin
685
- organizer.call(context)
686
- rescue StandardError
687
- nil
688
- end
689
- }.to change(context, :steps).from([]).to([
690
- :around_before, :before,
691
- :around_before2, :before2,
692
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
693
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
694
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
695
- :after2, :around_after2,
696
- :around_before3, :before3, :call3, :after3, :around_after3,
697
- :around_before4, :before4,
698
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
699
- :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
700
- :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
701
- :after4, :around_after4,
702
- :around_before5, :before5, :call5, :after5, :around_after5,
703
- :after,
704
- :rollback5,
705
- :rollback4c,
706
- :rollback4b,
707
- :rollback4a,
708
- :rollback3,
709
- :rollback2c,
710
- :rollback2b,
711
- :rollback2a,
712
- ])
713
- end
714
-
715
- it "raises the error" do
716
- expect {
717
- organizer.call(context)
718
- }.to raise_error("foo")
719
- end
720
- end
721
-
722
- context "when a nested around hook fails early" do
723
- let(:interaktor3) {
724
- FakeInteraktor.build_interaktor do
725
- around do |interaktor|
726
- @context.fail!
727
- @context.steps << :around_before3
728
- interaktor.call
729
- @context.steps << :around_after3
730
- end
731
-
732
- before do
733
- @context.steps << :before3
734
- end
735
-
736
- after do
737
- @context.steps << :after3
738
- end
739
-
740
- def call
741
- @context.steps << :call3
742
- end
743
-
744
- def rollback
745
- @context.steps << :rollback3
746
- end
747
- end
748
- }
749
-
750
- it "rolls back successfully called interaktors" do
751
- expect {
752
- organizer.call(context)
753
- }.to change(context, :steps).from([]).to([
754
- :around_before, :before,
755
- :around_before2, :before2,
756
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
757
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
758
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
759
- :after2, :around_after2,
760
- :rollback2c,
761
- :rollback2b,
762
- :rollback2a,
763
- ])
764
- end
765
- end
766
-
767
- context "when a nested around hook errors early" do
768
- let(:interaktor3) {
769
- FakeInteraktor.build_interaktor do
770
- around do |interaktor|
771
- unexpected_error!
772
- @context.steps << :around_before3
773
- interaktor.call
774
- @context.steps << :around_after3
775
- end
776
-
777
- before do
778
- @context.steps << :before3
779
- end
780
-
781
- after do
782
- @context.steps << :after3
783
- end
784
-
785
- def call
786
- @context.steps << :call3
787
- end
788
-
789
- def rollback
790
- @context.steps << :rollback3
791
- end
792
-
793
- def unexpected_error!
794
- raise "foo"
795
- end
796
- end
797
- }
798
-
799
- it "rolls back successfully called interaktors" do
800
- expect {
801
- begin
802
- organizer.call(context)
803
- rescue StandardError
804
- nil
805
- end
806
- }.to change(context, :steps).from([]).to([
807
- :around_before, :before,
808
- :around_before2, :before2,
809
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
810
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
811
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
812
- :after2, :around_after2,
813
- :rollback2c,
814
- :rollback2b,
815
- :rollback2a,
816
- ])
817
- end
818
-
819
- it "raises the error" do
820
- expect {
821
- organizer.call(context)
822
- }.to raise_error("foo")
823
- end
824
- end
825
-
826
- context "when a nested before hook fails" do
827
- let(:interaktor3) {
828
- FakeInteraktor.build_interaktor do
829
- around do |interaktor|
830
- @context.steps << :around_before3
831
- interaktor.call
832
- @context.steps << :around_after3
833
- end
834
-
835
- before do
836
- @context.fail!
837
- @context.steps << :before3
838
- end
839
-
840
- after do
841
- @context.steps << :after3
842
- end
843
-
844
- def call
845
- @context.steps << :call3
846
- end
847
-
848
- def rollback
849
- @context.steps << :rollback3
850
- end
851
- end
852
- }
853
-
854
- it "rolls back successfully called interaktors" do
855
- expect {
856
- organizer.call(context)
857
- }.to change(context, :steps).from([]).to([
858
- :around_before, :before,
859
- :around_before2, :before2,
860
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
861
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
862
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
863
- :after2, :around_after2,
864
- :around_before3,
865
- :rollback2c,
866
- :rollback2b,
867
- :rollback2a,
868
- ])
869
- end
870
- end
871
-
872
- context "when a nested before hook errors" do
873
- let(:interaktor3) {
874
- FakeInteraktor.build_interaktor do
875
- around do |interaktor|
876
- @context.steps << :around_before3
877
- interaktor.call
878
- @context.steps << :around_after3
879
- end
880
-
881
- before do
882
- unexpected_error!
883
- @context.steps << :before3
884
- end
885
-
886
- after do
887
- @context.steps << :after3
888
- end
889
-
890
- def call
891
- @context.steps << :call3
892
- end
893
-
894
- def rollback
895
- @context.steps << :rollback3
896
- end
897
-
898
- def unexpected_error!
899
- raise "foo"
900
- end
901
- end
902
- }
903
-
904
- it "rolls back successfully called interaktors" do
905
- expect {
906
- begin
907
- organizer.call(context)
908
- rescue StandardError
909
- nil
910
- end
911
- }.to change(context, :steps).from([]).to([
912
- :around_before, :before,
913
- :around_before2, :before2,
914
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
915
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
916
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
917
- :after2, :around_after2,
918
- :around_before3,
919
- :rollback2c,
920
- :rollback2b,
921
- :rollback2a,
922
- ])
923
- end
924
-
925
- it "raises the error" do
926
- expect {
927
- organizer.call(context)
928
- }.to raise_error("foo")
929
- end
930
- end
931
-
932
- context "when a nested call fails" do
933
- let(:interaktor3) {
934
- FakeInteraktor.build_interaktor do
935
- around do |interaktor|
936
- @context.steps << :around_before3
937
- interaktor.call
938
- @context.steps << :around_after3
939
- end
940
-
941
- before do
942
- @context.steps << :before3
943
- end
944
-
945
- after do
946
- @context.steps << :after3
947
- end
948
-
949
- def call
950
- @context.fail!
951
- @context.steps << :call3
952
- end
953
-
954
- def rollback
955
- @context.steps << :rollback3
956
- end
957
- end
958
- }
959
-
960
- it "rolls back successfully called interaktors" do
961
- expect {
962
- organizer.call(context)
963
- }.to change(context, :steps).from([]).to([
964
- :around_before, :before,
965
- :around_before2, :before2,
966
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
967
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
968
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
969
- :after2, :around_after2,
970
- :around_before3, :before3,
971
- :rollback2c,
972
- :rollback2b,
973
- :rollback2a,
974
- ])
975
- end
976
- end
977
-
978
- context "when a nested call errors" do
979
- let(:interaktor3) {
980
- FakeInteraktor.build_interaktor do
981
- around do |interaktor|
982
- @context.steps << :around_before3
983
- interaktor.call
984
- @context.steps << :around_after3
985
- end
986
-
987
- before do
988
- @context.steps << :before3
989
- end
990
-
991
- after do
992
- @context.steps << :after3
993
- end
994
-
995
- def call
996
- unexpected_error!
997
- @context.steps << :call3
998
- end
999
-
1000
- def rollback
1001
- @context.steps << :rollback3
1002
- end
1003
-
1004
- def unexpected_error!
1005
- raise "foo"
1006
- end
1007
- end
1008
- }
1009
-
1010
- it "rolls back successfully called interaktors" do
1011
- expect {
1012
- begin
1013
- organizer.call(context)
1014
- rescue StandardError
1015
- nil
1016
- end
1017
- }.to change(context, :steps).from([]).to([
1018
- :around_before, :before,
1019
- :around_before2, :before2,
1020
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1021
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1022
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1023
- :after2, :around_after2,
1024
- :around_before3, :before3,
1025
- :rollback2c,
1026
- :rollback2b,
1027
- :rollback2a,
1028
- ])
1029
- end
1030
-
1031
- it "raises the error" do
1032
- expect {
1033
- organizer.call(context)
1034
- }.to raise_error("foo")
1035
- end
1036
- end
1037
-
1038
- context "when a nested after hook fails" do
1039
- let(:interaktor3) {
1040
- FakeInteraktor.build_interaktor do
1041
- around do |interaktor|
1042
- @context.steps << :around_before3
1043
- interaktor.call
1044
- @context.steps << :around_after3
1045
- end
1046
-
1047
- before do
1048
- @context.steps << :before3
1049
- end
1050
-
1051
- after do
1052
- @context.fail!
1053
- @context.steps << :after3
1054
- end
1055
-
1056
- def call
1057
- @context.steps << :call3
1058
- end
1059
-
1060
- def rollback
1061
- @context.steps << :rollback3
1062
- end
1063
- end
1064
- }
1065
-
1066
- it "rolls back successfully called interaktors and the failed interaktor" do
1067
- expect {
1068
- organizer.call(context)
1069
- }.to change(context, :steps).from([]).to([
1070
- :around_before, :before,
1071
- :around_before2, :before2,
1072
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1073
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1074
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1075
- :after2, :around_after2,
1076
- :around_before3, :before3, :call3,
1077
- :rollback3,
1078
- :rollback2c,
1079
- :rollback2b,
1080
- :rollback2a,
1081
- ])
1082
- end
1083
- end
1084
-
1085
- context "when a nested after hook errors" do
1086
- let(:interaktor3) {
1087
- FakeInteraktor.build_interaktor do
1088
- around do |interaktor|
1089
- @context.steps << :around_before3
1090
- interaktor.call
1091
- @context.steps << :around_after3
1092
- end
1093
-
1094
- before do
1095
- @context.steps << :before3
1096
- end
1097
-
1098
- after do
1099
- unexpected_error!
1100
- @context.steps << :after3
1101
- end
1102
-
1103
- def call
1104
- @context.steps << :call3
1105
- end
1106
-
1107
- def rollback
1108
- @context.steps << :rollback3
1109
- end
1110
-
1111
- def unexpected_error!
1112
- raise "foo"
1113
- end
1114
- end
1115
- }
1116
-
1117
- it "rolls back successfully called interaktors and the failed interaktor" do
1118
- expect {
1119
- begin
1120
- organizer.call(context)
1121
- rescue StandardError
1122
- nil
1123
- end
1124
- }.to change(context, :steps).from([]).to([
1125
- :around_before, :before,
1126
- :around_before2, :before2,
1127
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1128
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1129
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1130
- :after2, :around_after2,
1131
- :around_before3, :before3, :call3,
1132
- :rollback3,
1133
- :rollback2c,
1134
- :rollback2b,
1135
- :rollback2a,
1136
- ])
1137
- end
1138
-
1139
- it "raises the error" do
1140
- expect {
1141
- organizer.call(context)
1142
- }.to raise_error("foo")
1143
- end
1144
- end
1145
-
1146
- context "when a nested around hook fails late" do
1147
- let(:interaktor3) {
1148
- FakeInteraktor.build_interaktor do
1149
- around do |interaktor|
1150
- @context.steps << :around_before3
1151
- interaktor.call
1152
- @context.fail!
1153
- @context.steps << :around_after3
1154
- end
1155
-
1156
- before do
1157
- @context.steps << :before3
1158
- end
1159
-
1160
- after do
1161
- @context.steps << :after3
1162
- end
1163
-
1164
- def call
1165
- @context.steps << :call3
1166
- end
1167
-
1168
- def rollback
1169
- @context.steps << :rollback3
1170
- end
1171
- end
1172
- }
1173
-
1174
- it "rolls back successfully called interaktors and the failed interaktor" do
1175
- expect {
1176
- organizer.call(context)
1177
- }.to change(context, :steps).from([]).to([
1178
- :around_before, :before,
1179
- :around_before2, :before2,
1180
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1181
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1182
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1183
- :after2, :around_after2,
1184
- :around_before3, :before3, :call3, :after3,
1185
- :rollback3,
1186
- :rollback2c,
1187
- :rollback2b,
1188
- :rollback2a,
1189
- ])
1190
- end
1191
- end
1192
-
1193
- context "when a nested around hook errors late" do
1194
- let(:interaktor3) {
1195
- FakeInteraktor.build_interaktor do
1196
- around do |interaktor|
1197
- @context.steps << :around_before3
1198
- interaktor.call
1199
- unexpected_error!
1200
- @context.steps << :around_after3
1201
- end
1202
-
1203
- before do
1204
- @context.steps << :before3
1205
- end
1206
-
1207
- after do
1208
- @context.steps << :after3
1209
- end
1210
-
1211
- def call
1212
- @context.steps << :call3
1213
- end
1214
-
1215
- def rollback
1216
- @context.steps << :rollback3
1217
- end
1218
-
1219
- def unexpected_error!
1220
- raise "foo"
1221
- end
1222
- end
1223
- }
1224
-
1225
- it "rolls back successfully called interaktors and the failed interaktor" do
1226
- expect {
1227
- begin
1228
- organizer.call(context)
1229
- rescue StandardError
1230
- nil
1231
- end
1232
- }.to change(context, :steps).from([]).to([
1233
- :around_before, :before,
1234
- :around_before2, :before2,
1235
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1236
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1237
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1238
- :after2, :around_after2,
1239
- :around_before3, :before3, :call3, :after3,
1240
- :rollback3,
1241
- :rollback2c,
1242
- :rollback2b,
1243
- :rollback2a,
1244
- ])
1245
- end
1246
-
1247
- it "raises the error" do
1248
- expect {
1249
- organizer.call(context)
1250
- }.to raise_error("foo")
1251
- end
1252
- end
1253
-
1254
- context "when a deeply nested around hook fails early" do
1255
- let(:interaktor4b) {
1256
- FakeInteraktor.build_interaktor do
1257
- around do |interaktor|
1258
- @context.fail!
1259
- @context.steps << :around_before4b
1260
- interaktor.call
1261
- @context.steps << :around_after4b
1262
- end
1263
-
1264
- before do
1265
- @context.steps << :before4b
1266
- end
1267
-
1268
- after do
1269
- @context.steps << :after4b
1270
- end
1271
-
1272
- def call
1273
- @context.steps << :call4b
1274
- end
1275
-
1276
- def rollback
1277
- @context.steps << :rollback4b
1278
- end
1279
- end
1280
- }
1281
-
1282
- it "rolls back successfully called interaktors" do
1283
- expect {
1284
- organizer.call(context)
1285
- }.to change(context, :steps).from([]).to([
1286
- :around_before, :before,
1287
- :around_before2, :before2,
1288
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1289
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1290
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1291
- :after2, :around_after2,
1292
- :around_before3, :before3, :call3, :after3, :around_after3,
1293
- :around_before4, :before4,
1294
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1295
- :rollback4a,
1296
- :rollback3,
1297
- :rollback2c,
1298
- :rollback2b,
1299
- :rollback2a,
1300
- ])
1301
- end
1302
- end
1303
-
1304
- context "when a deeply nested around hook errors early" do
1305
- let(:interaktor4b) {
1306
- FakeInteraktor.build_interaktor do
1307
- around do |interaktor|
1308
- unexpected_error!
1309
- @context.steps << :around_before4b
1310
- interaktor.call
1311
- @context.steps << :around_after4b
1312
- end
1313
-
1314
- before do
1315
- @context.steps << :before4b
1316
- end
1317
-
1318
- after do
1319
- @context.steps << :after4b
1320
- end
1321
-
1322
- def call
1323
- @context.steps << :call4b
1324
- end
1325
-
1326
- def rollback
1327
- @context.steps << :rollback4b
1328
- end
1329
-
1330
- def unexpected_error!
1331
- raise "foo"
1332
- end
1333
- end
1334
- }
1335
-
1336
- it "rolls back successfully called interaktors" do
1337
- expect {
1338
- begin
1339
- organizer.call(context)
1340
- rescue StandardError
1341
- nil
1342
- end
1343
- }.to change(context, :steps).from([]).to([
1344
- :around_before, :before,
1345
- :around_before2, :before2,
1346
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1347
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1348
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1349
- :after2, :around_after2,
1350
- :around_before3, :before3, :call3, :after3, :around_after3,
1351
- :around_before4, :before4,
1352
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1353
- :rollback4a,
1354
- :rollback3,
1355
- :rollback2c,
1356
- :rollback2b,
1357
- :rollback2a,
1358
- ])
1359
- end
1360
-
1361
- it "raises the error" do
1362
- expect {
1363
- organizer.call(context)
1364
- }.to raise_error("foo")
1365
- end
1366
- end
1367
-
1368
- context "when a deeply nested before hook fails" do
1369
- let(:interaktor4b) {
1370
- FakeInteraktor.build_interaktor do
1371
- around do |interaktor|
1372
- @context.steps << :around_before4b
1373
- interaktor.call
1374
- @context.steps << :around_after4b
1375
- end
1376
-
1377
- before do
1378
- @context.fail!
1379
- @context.steps << :before4b
1380
- end
1381
-
1382
- after do
1383
- @context.steps << :after4b
1384
- end
1385
-
1386
- def call
1387
- @context.steps << :call4b
1388
- end
1389
-
1390
- def rollback
1391
- @context.steps << :rollback4b
1392
- end
1393
- end
1394
- }
1395
-
1396
- it "rolls back successfully called interaktors" do
1397
- expect {
1398
- organizer.call(context)
1399
- }.to change(context, :steps).from([]).to([
1400
- :around_before, :before,
1401
- :around_before2, :before2,
1402
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1403
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1404
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1405
- :after2, :around_after2,
1406
- :around_before3, :before3, :call3, :after3, :around_after3,
1407
- :around_before4, :before4,
1408
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1409
- :around_before4b,
1410
- :rollback4a,
1411
- :rollback3,
1412
- :rollback2c,
1413
- :rollback2b,
1414
- :rollback2a,
1415
- ])
1416
- end
1417
- end
1418
-
1419
- context "when a deeply nested before hook errors" do
1420
- let(:interaktor4b) {
1421
- FakeInteraktor.build_interaktor do
1422
- around do |interaktor|
1423
- @context.steps << :around_before4b
1424
- interaktor.call
1425
- @context.steps << :around_after4b
1426
- end
1427
-
1428
- before do
1429
- unexpected_error!
1430
- @context.steps << :before4b
1431
- end
1432
-
1433
- after do
1434
- @context.steps << :after4b
1435
- end
1436
-
1437
- def call
1438
- @context.steps << :call4b
1439
- end
1440
-
1441
- def rollback
1442
- @context.steps << :rollback4b
1443
- end
1444
-
1445
- def unexpected_error!
1446
- raise "foo"
1447
- end
1448
- end
1449
- }
1450
-
1451
- it "rolls back successfully called interaktors" do
1452
- expect {
1453
- begin
1454
- organizer.call(context)
1455
- rescue StandardError
1456
- nil
1457
- end
1458
- }.to change(context, :steps).from([]).to([
1459
- :around_before, :before,
1460
- :around_before2, :before2,
1461
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1462
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1463
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1464
- :after2, :around_after2,
1465
- :around_before3, :before3, :call3, :after3, :around_after3,
1466
- :around_before4, :before4,
1467
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1468
- :around_before4b,
1469
- :rollback4a,
1470
- :rollback3,
1471
- :rollback2c,
1472
- :rollback2b,
1473
- :rollback2a,
1474
- ])
1475
- end
1476
-
1477
- it "raises the error" do
1478
- expect {
1479
- organizer.call(context)
1480
- }.to raise_error("foo")
1481
- end
1482
- end
1483
-
1484
- context "when a deeply nested call fails" do
1485
- let(:interaktor4b) {
1486
- FakeInteraktor.build_interaktor do
1487
- around do |interaktor|
1488
- @context.steps << :around_before4b
1489
- interaktor.call
1490
- @context.steps << :around_after4b
1491
- end
1492
-
1493
- before do
1494
- @context.steps << :before4b
1495
- end
1496
-
1497
- after do
1498
- @context.steps << :after4b
1499
- end
1500
-
1501
- def call
1502
- @context.fail!
1503
- @context.steps << :call4b
1504
- end
1505
-
1506
- def rollback
1507
- @context.steps << :rollback4b
1508
- end
1509
- end
1510
- }
1511
-
1512
- it "rolls back successfully called interaktors" do
1513
- expect {
1514
- organizer.call(context)
1515
- }.to change(context, :steps).from([]).to([
1516
- :around_before, :before,
1517
- :around_before2, :before2,
1518
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1519
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1520
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1521
- :after2, :around_after2,
1522
- :around_before3, :before3, :call3, :after3, :around_after3,
1523
- :around_before4, :before4,
1524
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1525
- :around_before4b, :before4b,
1526
- :rollback4a,
1527
- :rollback3,
1528
- :rollback2c,
1529
- :rollback2b,
1530
- :rollback2a,
1531
- ])
1532
- end
1533
- end
1534
-
1535
- context "when a deeply nested call errors" do
1536
- let(:interaktor4b) {
1537
- FakeInteraktor.build_interaktor do
1538
- around do |interaktor|
1539
- @context.steps << :around_before4b
1540
- interaktor.call
1541
- @context.steps << :around_after4b
1542
- end
1543
-
1544
- before do
1545
- @context.steps << :before4b
1546
- end
1547
-
1548
- after do
1549
- @context.steps << :after4b
1550
- end
1551
-
1552
- def call
1553
- unexpected_error!
1554
- @context.steps << :call4b
1555
- end
1556
-
1557
- def rollback
1558
- @context.steps << :rollback4b
1559
- end
1560
-
1561
- def unexpected_error!
1562
- raise "foo"
1563
- end
1564
- end
1565
- }
1566
-
1567
- it "rolls back successfully called interaktors" do
1568
- expect {
1569
- begin
1570
- organizer.call(context)
1571
- rescue StandardError
1572
- nil
1573
- end
1574
- }.to change(context, :steps).from([]).to([
1575
- :around_before, :before,
1576
- :around_before2, :before2,
1577
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1578
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1579
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1580
- :after2, :around_after2,
1581
- :around_before3, :before3, :call3, :after3, :around_after3,
1582
- :around_before4, :before4,
1583
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1584
- :around_before4b, :before4b,
1585
- :rollback4a,
1586
- :rollback3,
1587
- :rollback2c,
1588
- :rollback2b,
1589
- :rollback2a,
1590
- ])
1591
- end
1592
-
1593
- it "raises the error" do
1594
- expect {
1595
- organizer.call(context)
1596
- }.to raise_error("foo")
1597
- end
1598
- end
1599
-
1600
- context "when a deeply nested after hook fails" do
1601
- let(:interaktor4b) {
1602
- FakeInteraktor.build_interaktor do
1603
- around do |interaktor|
1604
- @context.steps << :around_before4b
1605
- interaktor.call
1606
- @context.steps << :around_after4b
1607
- end
1608
-
1609
- before do
1610
- @context.steps << :before4b
1611
- end
1612
-
1613
- after do
1614
- @context.fail!
1615
- @context.steps << :after4b
1616
- end
1617
-
1618
- def call
1619
- @context.steps << :call4b
1620
- end
1621
-
1622
- def rollback
1623
- @context.steps << :rollback4b
1624
- end
1625
- end
1626
- }
1627
-
1628
- it "rolls back successfully called interaktors and the failed interaktor" do
1629
- expect {
1630
- organizer.call(context)
1631
- }.to change(context, :steps).from([]).to([
1632
- :around_before, :before,
1633
- :around_before2, :before2,
1634
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1635
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1636
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1637
- :after2, :around_after2,
1638
- :around_before3, :before3, :call3, :after3, :around_after3,
1639
- :around_before4, :before4,
1640
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1641
- :around_before4b, :before4b, :call4b,
1642
- :rollback4b,
1643
- :rollback4a,
1644
- :rollback3,
1645
- :rollback2c,
1646
- :rollback2b,
1647
- :rollback2a,
1648
- ])
1649
- end
1650
- end
1651
-
1652
- context "when a deeply nested after hook errors" do
1653
- let(:interaktor4b) {
1654
- FakeInteraktor.build_interaktor do
1655
- around do |interaktor|
1656
- @context.steps << :around_before4b
1657
- interaktor.call
1658
- @context.steps << :around_after4b
1659
- end
1660
-
1661
- before do
1662
- @context.steps << :before4b
1663
- end
1664
-
1665
- after do
1666
- unexpected_error!
1667
- @context.steps << :after4b
1668
- end
1669
-
1670
- def call
1671
- @context.steps << :call4b
1672
- end
1673
-
1674
- def rollback
1675
- @context.steps << :rollback4b
1676
- end
1677
-
1678
- def unexpected_error!
1679
- raise "foo"
1680
- end
1681
- end
1682
- }
1683
-
1684
- it "rolls back successfully called interaktors and the failed interaktor" do
1685
- expect {
1686
- begin
1687
- organizer.call(context)
1688
- rescue StandardError
1689
- nil
1690
- end
1691
- }.to change(context, :steps).from([]).to([
1692
- :around_before, :before,
1693
- :around_before2, :before2,
1694
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1695
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1696
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1697
- :after2, :around_after2,
1698
- :around_before3, :before3, :call3, :after3, :around_after3,
1699
- :around_before4, :before4,
1700
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1701
- :around_before4b, :before4b, :call4b,
1702
- :rollback4b,
1703
- :rollback4a,
1704
- :rollback3,
1705
- :rollback2c,
1706
- :rollback2b,
1707
- :rollback2a,
1708
- ])
1709
- end
1710
-
1711
- it "raises the error" do
1712
- expect {
1713
- organizer.call(context)
1714
- }.to raise_error("foo")
1715
- end
1716
- end
1717
-
1718
- context "when a deeply nested around hook fails late" do
1719
- let(:interaktor4b) {
1720
- FakeInteraktor.build_interaktor do
1721
- around do |interaktor|
1722
- @context.steps << :around_before4b
1723
- interaktor.call
1724
- @context.fail!
1725
- @context.steps << :around_after4b
1726
- end
1727
-
1728
- before do
1729
- @context.steps << :before4b
1730
- end
1731
-
1732
- after do
1733
- @context.steps << :after4b
1734
- end
1735
-
1736
- def call
1737
- @context.steps << :call4b
1738
- end
1739
-
1740
- def rollback
1741
- @context.steps << :rollback4b
1742
- end
1743
- end
1744
- }
1745
-
1746
- it "rolls back successfully called interaktors and the failed interaktor" do
1747
- expect {
1748
- organizer.call(context)
1749
- }.to change(context, :steps).from([]).to([
1750
- :around_before, :before,
1751
- :around_before2, :before2,
1752
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1753
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1754
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1755
- :after2, :around_after2,
1756
- :around_before3, :before3, :call3, :after3, :around_after3,
1757
- :around_before4, :before4,
1758
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1759
- :around_before4b, :before4b, :call4b, :after4b,
1760
- :rollback4b,
1761
- :rollback4a,
1762
- :rollback3,
1763
- :rollback2c,
1764
- :rollback2b,
1765
- :rollback2a,
1766
- ])
1767
- end
1768
- end
1769
-
1770
- context "when a deeply nested around hook errors late" do
1771
- let(:interaktor4b) {
1772
- FakeInteraktor.build_interaktor do
1773
- around do |interaktor|
1774
- @context.steps << :around_before4b
1775
- interaktor.call
1776
- unexpected_error!
1777
- @context.steps << :around_after4b
1778
- end
1779
-
1780
- before do
1781
- @context.steps << :before4b
1782
- end
1783
-
1784
- after do
1785
- @context.steps << :after4b
1786
- end
1787
-
1788
- def call
1789
- @context.steps << :call4b
1790
- end
1791
-
1792
- def rollback
1793
- @context.steps << :rollback4b
1794
- end
1795
-
1796
- def unexpected_error!
1797
- raise "foo"
1798
- end
1799
- end
1800
- }
1801
-
1802
- it "rolls back successfully called interaktors and the failed interaktor" do
1803
- expect {
1804
- begin
1805
- organizer.call(context)
1806
- rescue StandardError
1807
- nil
1808
- end
1809
- }.to change(context, :steps).from([]).to([
1810
- :around_before, :before,
1811
- :around_before2, :before2,
1812
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1813
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1814
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1815
- :after2, :around_after2,
1816
- :around_before3, :before3, :call3, :after3, :around_after3,
1817
- :around_before4, :before4,
1818
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1819
- :around_before4b, :before4b, :call4b, :after4b,
1820
- :rollback4b,
1821
- :rollback4a,
1822
- :rollback3,
1823
- :rollback2c,
1824
- :rollback2b,
1825
- :rollback2a,
1826
- ])
1827
- end
1828
-
1829
- it "raises the error" do
1830
- expect {
1831
- organizer.call(context)
1832
- }.to raise_error("foo")
1833
- end
1834
- end
1835
-
1836
- context "when there are multiple organize calls" do
1837
- it "runs all passed interaktors in correct order" do
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
-
1849
- organizer.organize(organizer4, interaktor5)
1850
-
1851
- expect {
1852
- organizer.call(context)
1853
- }.to change(context, :steps).from([]).to([
1854
- :around_before2, :before2,
1855
- :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1856
- :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1857
- :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1858
- :after2, :around_after2,
1859
- :around_before3, :before3, :call3, :after3, :around_after3,
1860
- :around_before4, :before4,
1861
- :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1862
- :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
1863
- :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
1864
- :after4, :around_after4,
1865
- :around_before5, :before5, :call5, :after5, :around_after5,
1866
- ])
1867
- end
1868
- end
1869
- end
1870
-
1871
- # rubocop:enable RSpec/InstanceVariable
1872
- # rubocop:enable RSpec/MultipleMemoizedHelpers
1873
- # rubocop:enable RSpec/ScatteredSetup
1874
- # rubocop:enable Style/DocumentationMethod
1
+ # # rubocop:disable RSpec/InstanceVariable
2
+ # # rubocop:disable RSpec/MultipleMemoizedHelpers
3
+ # # rubocop:disable RSpec/ScatteredSetup
4
+ # # rubocop:disable Style/DocumentationMethod
5
+
6
+ # RSpec.describe "Integration" do
7
+ # # rubocop:disable Style/AsciiComments
8
+ # #
9
+ # # organizer
10
+ # # ├─ organizer2
11
+ # # │ ├─ interaktor2a
12
+ # # │ ├─ interaktor2b
13
+ # # │ └─ interaktor2c
14
+ # # ├─ interaktor3
15
+ # # ├─ organizer4
16
+ # # │ ├─ interaktor4a
17
+ # # │ ├─ interaktor4b
18
+ # # │ └─ interaktor4c
19
+ # # └─ interaktor5
20
+ # #
21
+ # # rubocop:enable Style/AsciiComments
22
+
23
+ # let(:organizer) {
24
+ # interaktors = [organizer2, interaktor3, organizer4, interaktor5]
25
+
26
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
27
+ # organize(interaktors)
28
+
29
+ # around do |interaktor|
30
+ # @context.steps << :around_before
31
+ # interaktor.call
32
+ # @context.steps << :around_after
33
+ # end
34
+
35
+ # before do
36
+ # @context.steps << :before
37
+ # end
38
+
39
+ # after do
40
+ # @context.steps << :after
41
+ # end
42
+ # end
43
+ # }
44
+
45
+ # let(:organizer2) {
46
+ # interaktors = [interaktor2a, interaktor2b, interaktor2c]
47
+
48
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
49
+ # organize(interaktors)
50
+
51
+ # around do |interaktor|
52
+ # @context.steps << :around_before2
53
+ # interaktor.call
54
+ # @context.steps << :around_after2
55
+ # end
56
+
57
+ # before do
58
+ # @context.steps << :before2
59
+ # end
60
+
61
+ # after do
62
+ # @context.steps << :after2
63
+ # end
64
+ # end
65
+ # }
66
+
67
+ # let(:interaktor2a) {
68
+ # FakeInteraktor.build_interaktor do
69
+ # around do |interaktor|
70
+ # @context.steps << :around_before2a
71
+ # interaktor.call
72
+ # @context.steps << :around_after2a
73
+ # end
74
+
75
+ # before do
76
+ # @context.steps << :before2a
77
+ # end
78
+
79
+ # after do
80
+ # @context.steps << :after2a
81
+ # end
82
+
83
+ # def call
84
+ # @context.steps << :call2a
85
+ # end
86
+
87
+ # def rollback
88
+ # @context.steps << :rollback2a
89
+ # end
90
+ # end
91
+ # }
92
+
93
+ # let(:interaktor2b) {
94
+ # FakeInteraktor.build_interaktor do
95
+ # around do |interaktor|
96
+ # @context.steps << :around_before2b
97
+ # interaktor.call
98
+ # @context.steps << :around_after2b
99
+ # end
100
+
101
+ # before do
102
+ # @context.steps << :before2b
103
+ # end
104
+
105
+ # after do
106
+ # @context.steps << :after2b
107
+ # end
108
+
109
+ # def call
110
+ # @context.steps << :call2b
111
+ # end
112
+
113
+ # def rollback
114
+ # @context.steps << :rollback2b
115
+ # end
116
+ # end
117
+ # }
118
+
119
+ # let(:interaktor2c) {
120
+ # FakeInteraktor.build_interaktor do
121
+ # around do |interaktor|
122
+ # @context.steps << :around_before2c
123
+ # interaktor.call
124
+ # @context.steps << :around_after2c
125
+ # end
126
+
127
+ # before do
128
+ # @context.steps << :before2c
129
+ # end
130
+
131
+ # after do
132
+ # @context.steps << :after2c
133
+ # end
134
+
135
+ # def call
136
+ # @context.steps << :call2c
137
+ # end
138
+
139
+ # def rollback
140
+ # @context.steps << :rollback2c
141
+ # end
142
+ # end
143
+ # }
144
+
145
+ # let(:interaktor3) {
146
+ # FakeInteraktor.build_interaktor do
147
+ # around do |interaktor|
148
+ # @context.steps << :around_before3
149
+ # interaktor.call
150
+ # @context.steps << :around_after3
151
+ # end
152
+
153
+ # before do
154
+ # @context.steps << :before3
155
+ # end
156
+
157
+ # after do
158
+ # @context.steps << :after3
159
+ # end
160
+
161
+ # def call
162
+ # @context.steps << :call3
163
+ # end
164
+
165
+ # def rollback
166
+ # @context.steps << :rollback3
167
+ # end
168
+ # end
169
+ # }
170
+
171
+ # let(:organizer4) {
172
+ # interaktors = [interaktor4a, interaktor4b, interaktor4c]
173
+
174
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
175
+ # organize(interaktors)
176
+
177
+ # around do |interaktor|
178
+ # @context.steps << :around_before4
179
+ # interaktor.call
180
+ # @context.steps << :around_after4
181
+ # end
182
+
183
+ # before do
184
+ # @context.steps << :before4
185
+ # end
186
+
187
+ # after do
188
+ # @context.steps << :after4
189
+ # end
190
+ # end
191
+ # }
192
+
193
+ # let(:interaktor4a) {
194
+ # FakeInteraktor.build_interaktor do
195
+ # around do |interaktor|
196
+ # @context.steps << :around_before4a
197
+ # interaktor.call
198
+ # @context.steps << :around_after4a
199
+ # end
200
+
201
+ # before do
202
+ # @context.steps << :before4a
203
+ # end
204
+
205
+ # after do
206
+ # @context.steps << :after4a
207
+ # end
208
+
209
+ # def call
210
+ # @context.steps << :call4a
211
+ # end
212
+
213
+ # def rollback
214
+ # @context.steps << :rollback4a
215
+ # end
216
+ # end
217
+ # }
218
+
219
+ # let(:interaktor4b) {
220
+ # FakeInteraktor.build_interaktor do
221
+ # around do |interaktor|
222
+ # @context.steps << :around_before4b
223
+ # interaktor.call
224
+ # @context.steps << :around_after4b
225
+ # end
226
+
227
+ # before do
228
+ # @context.steps << :before4b
229
+ # end
230
+
231
+ # after do
232
+ # @context.steps << :after4b
233
+ # end
234
+
235
+ # def call
236
+ # @context.steps << :call4b
237
+ # end
238
+
239
+ # def rollback
240
+ # @context.steps << :rollback4b
241
+ # end
242
+ # end
243
+ # }
244
+
245
+ # let(:interaktor4c) {
246
+ # FakeInteraktor.build_interaktor do
247
+ # around do |interaktor|
248
+ # @context.steps << :around_before4c
249
+ # interaktor.call
250
+ # @context.steps << :around_after4c
251
+ # end
252
+
253
+ # before do
254
+ # @context.steps << :before4c
255
+ # end
256
+
257
+ # after do
258
+ # @context.steps << :after4c
259
+ # end
260
+
261
+ # def call
262
+ # @context.steps << :call4c
263
+ # end
264
+
265
+ # def rollback
266
+ # @context.steps << :rollback4c
267
+ # end
268
+ # end
269
+ # }
270
+
271
+ # let(:interaktor5) {
272
+ # FakeInteraktor.build_interaktor do
273
+ # around do |interaktor|
274
+ # @context.steps << :around_before5
275
+ # interaktor.call
276
+ # @context.steps << :around_after5
277
+ # end
278
+
279
+ # before do
280
+ # @context.steps << :before5
281
+ # end
282
+
283
+ # after do
284
+ # @context.steps << :after5
285
+ # end
286
+
287
+ # def call
288
+ # @context.steps << :call5
289
+ # end
290
+
291
+ # def rollback
292
+ # @context.steps << :rollback5
293
+ # end
294
+ # end
295
+ # }
296
+
297
+ # let(:context) { Interaktor::Context.new(steps: []) }
298
+
299
+ # context "when successful" do
300
+ # it "calls and runs hooks in the proper sequence" do
301
+ # expect {
302
+ # organizer.call(context)
303
+ # }.to change(context, :steps).from([]).to([
304
+ # :around_before, :before,
305
+ # :around_before2, :before2,
306
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
307
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
308
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
309
+ # :after2, :around_after2,
310
+ # :around_before3, :before3, :call3, :after3, :around_after3,
311
+ # :around_before4, :before4,
312
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
313
+ # :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
314
+ # :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
315
+ # :after4, :around_after4,
316
+ # :around_before5, :before5, :call5, :after5, :around_after5,
317
+ # :after, :around_after
318
+ # ])
319
+ # end
320
+ # end
321
+
322
+ # context "when an around hook fails early" do
323
+ # let(:organizer) {
324
+ # interaktors = [organizer2, interaktor3, organizer4, interaktor5]
325
+
326
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
327
+ # organize(interaktors)
328
+
329
+ # around do |interaktor|
330
+ # @context.fail!
331
+ # @context.steps << :around_before
332
+ # interaktor.call
333
+ # @context.steps << :around_after
334
+ # end
335
+
336
+ # before do
337
+ # @context.fail!
338
+ # @context.steps << :before
339
+ # end
340
+
341
+ # after do
342
+ # @context.steps << :after
343
+ # end
344
+ # end
345
+ # }
346
+
347
+ # it "aborts" do
348
+ # expect {
349
+ # organizer.call(context)
350
+ # }.not_to change(context, :steps)
351
+ # end
352
+ # end
353
+
354
+ # context "when an around hook errors early" do
355
+ # let(:organizer) {
356
+ # interaktors = [organizer2, interaktor3, organizer4, interaktor5]
357
+
358
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
359
+ # organize(interaktors)
360
+
361
+ # around do |interaktor|
362
+ # unexpected_error!
363
+ # @context.steps << :around_before
364
+ # interaktor.call
365
+ # @context.steps << :around_after
366
+ # end
367
+
368
+ # before do
369
+ # @context.fail!
370
+ # @context.steps << :before
371
+ # end
372
+
373
+ # after do
374
+ # @context.steps << :after
375
+ # end
376
+
377
+ # def unexpected_error!
378
+ # raise "foo"
379
+ # end
380
+ # end
381
+ # }
382
+
383
+ # it "aborts" do
384
+ # expect {
385
+ # begin
386
+ # organizer.call(context)
387
+ # rescue
388
+ # nil
389
+ # end
390
+ # }.not_to change(context, :steps)
391
+ # end
392
+
393
+ # it "raises the error" do
394
+ # expect {
395
+ # organizer.call(context)
396
+ # }.to raise_error("foo")
397
+ # end
398
+ # end
399
+
400
+ # context "when a before hook fails" do
401
+ # let(:organizer) {
402
+ # interaktors = [organizer2, interaktor3, organizer4, interaktor5]
403
+
404
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
405
+ # organize(interaktors)
406
+
407
+ # around do |interaktor|
408
+ # @context.steps << :around_before
409
+ # interaktor.call
410
+ # @context.steps << :around_after
411
+ # end
412
+
413
+ # before do
414
+ # @context.fail!
415
+ # @context.steps << :before
416
+ # end
417
+
418
+ # after do
419
+ # @context.steps << :after
420
+ # end
421
+ # end
422
+ # }
423
+
424
+ # it "aborts" do
425
+ # expect {
426
+ # organizer.call(context)
427
+ # }.to change(context, :steps).from([]).to([
428
+ # :around_before
429
+ # ])
430
+ # end
431
+ # end
432
+
433
+ # context "when a before hook errors" do
434
+ # let(:organizer) {
435
+ # interaktors = [organizer2, interaktor3, organizer4, interaktor5]
436
+
437
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
438
+ # organize(interaktors)
439
+
440
+ # around do |interaktor|
441
+ # @context.steps << :around_before
442
+ # interaktor.call
443
+ # @context.steps << :around_after
444
+ # end
445
+
446
+ # before do
447
+ # unexpected_error!
448
+ # @context.steps << :before
449
+ # end
450
+
451
+ # after do
452
+ # @context.steps << :after
453
+ # end
454
+
455
+ # def unexpected_error!
456
+ # raise "foo"
457
+ # end
458
+ # end
459
+ # }
460
+
461
+ # it "aborts" do
462
+ # expect {
463
+ # begin
464
+ # organizer.call(context)
465
+ # rescue
466
+ # nil
467
+ # end
468
+ # }.to change(context, :steps).from([]).to([
469
+ # :around_before
470
+ # ])
471
+ # end
472
+
473
+ # it "raises the error" do
474
+ # expect {
475
+ # organizer.call(context)
476
+ # }.to raise_error("foo")
477
+ # end
478
+ # end
479
+
480
+ # context "when an after hook fails" do
481
+ # let(:organizer) {
482
+ # interaktors = [organizer2, interaktor3, organizer4, interaktor5]
483
+
484
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
485
+ # organize(interaktors)
486
+
487
+ # around do |interaktor|
488
+ # @context.steps << :around_before
489
+ # interaktor.call
490
+ # @context.steps << :around_after
491
+ # end
492
+
493
+ # before do
494
+ # @context.steps << :before
495
+ # end
496
+
497
+ # after do
498
+ # @context.fail!
499
+ # @context.steps << :after
500
+ # end
501
+ # end
502
+ # }
503
+
504
+ # it "rolls back successfully called interaktors and the failed interaktor" do
505
+ # expect {
506
+ # organizer.call(context)
507
+ # }.to change(context, :steps).from([]).to([
508
+ # :around_before, :before,
509
+ # :around_before2, :before2,
510
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
511
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
512
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
513
+ # :after2, :around_after2,
514
+ # :around_before3, :before3, :call3, :after3, :around_after3,
515
+ # :around_before4, :before4,
516
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
517
+ # :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
518
+ # :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
519
+ # :after4, :around_after4,
520
+ # :around_before5, :before5, :call5, :after5, :around_after5,
521
+ # :rollback5,
522
+ # :rollback4c,
523
+ # :rollback4b,
524
+ # :rollback4a,
525
+ # :rollback3,
526
+ # :rollback2c,
527
+ # :rollback2b,
528
+ # :rollback2a
529
+ # ])
530
+ # end
531
+ # end
532
+
533
+ # context "when an after hook errors" do
534
+ # let(:organizer) {
535
+ # interaktors = [organizer2, interaktor3, organizer4, interaktor5]
536
+
537
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
538
+ # organize(interaktors)
539
+
540
+ # around do |interaktor|
541
+ # @context.steps << :around_before
542
+ # interaktor.call
543
+ # @context.steps << :around_after
544
+ # end
545
+
546
+ # before do
547
+ # @context.steps << :before
548
+ # end
549
+
550
+ # after do
551
+ # unexpected_error!
552
+ # @context.steps << :after
553
+ # end
554
+
555
+ # def unexpected_error!
556
+ # raise "foo"
557
+ # end
558
+ # end
559
+ # }
560
+
561
+ # it "rolls back successfully called interaktors and the failed interaktor" do
562
+ # expect {
563
+ # begin
564
+ # organizer.call(context)
565
+ # rescue
566
+ # nil
567
+ # end
568
+ # }.to change(context, :steps).from([]).to([
569
+ # :around_before, :before,
570
+ # :around_before2, :before2,
571
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
572
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
573
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
574
+ # :after2, :around_after2,
575
+ # :around_before3, :before3, :call3, :after3, :around_after3,
576
+ # :around_before4, :before4,
577
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
578
+ # :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
579
+ # :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
580
+ # :after4, :around_after4,
581
+ # :around_before5, :before5, :call5, :after5, :around_after5,
582
+ # :rollback5,
583
+ # :rollback4c,
584
+ # :rollback4b,
585
+ # :rollback4a,
586
+ # :rollback3,
587
+ # :rollback2c,
588
+ # :rollback2b,
589
+ # :rollback2a
590
+ # ])
591
+ # end
592
+
593
+ # it "raises the error" do
594
+ # expect {
595
+ # organizer.call(context)
596
+ # }.to raise_error("foo")
597
+ # end
598
+ # end
599
+
600
+ # context "when an around hook fails late" do
601
+ # let(:organizer) {
602
+ # interaktors = [organizer2, interaktor3, organizer4, interaktor5]
603
+
604
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
605
+ # organize(interaktors)
606
+
607
+ # around do |interaktor|
608
+ # @context.steps << :around_before
609
+ # interaktor.call
610
+ # @context.fail!
611
+ # @context.steps << :around_after
612
+ # end
613
+
614
+ # before do
615
+ # @context.steps << :before
616
+ # end
617
+
618
+ # after do
619
+ # @context.steps << :after
620
+ # end
621
+ # end
622
+ # }
623
+
624
+ # it "rolls back successfully called interaktors and the failed interaktor" do
625
+ # expect {
626
+ # organizer.call(context)
627
+ # }.to change(context, :steps).from([]).to([
628
+ # :around_before, :before,
629
+ # :around_before2, :before2,
630
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
631
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
632
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
633
+ # :after2, :around_after2,
634
+ # :around_before3, :before3, :call3, :after3, :around_after3,
635
+ # :around_before4, :before4,
636
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
637
+ # :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
638
+ # :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
639
+ # :after4, :around_after4,
640
+ # :around_before5, :before5, :call5, :after5, :around_after5,
641
+ # :after,
642
+ # :rollback5,
643
+ # :rollback4c,
644
+ # :rollback4b,
645
+ # :rollback4a,
646
+ # :rollback3,
647
+ # :rollback2c,
648
+ # :rollback2b,
649
+ # :rollback2a
650
+ # ])
651
+ # end
652
+ # end
653
+
654
+ # context "when an around hook errors late" do
655
+ # let(:organizer) {
656
+ # interaktors = [organizer2, interaktor3, organizer4, interaktor5]
657
+
658
+ # FakeInteraktor.build_interaktor(type: Interaktor::Organizer) do
659
+ # organize(interaktors)
660
+
661
+ # around do |interaktor|
662
+ # @context.steps << :around_before
663
+ # interaktor.call
664
+ # unexpected_error!
665
+ # @context.steps << :around_after
666
+ # end
667
+
668
+ # before do
669
+ # @context.steps << :before
670
+ # end
671
+
672
+ # after do
673
+ # @context.steps << :after
674
+ # end
675
+
676
+ # def unexpected_error!
677
+ # raise "foo"
678
+ # end
679
+ # end
680
+ # }
681
+
682
+ # it "rolls back successfully called interaktors and the failed interaktor" do
683
+ # expect {
684
+ # begin
685
+ # organizer.call(context)
686
+ # rescue
687
+ # nil
688
+ # end
689
+ # }.to change(context, :steps).from([]).to([
690
+ # :around_before, :before,
691
+ # :around_before2, :before2,
692
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
693
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
694
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
695
+ # :after2, :around_after2,
696
+ # :around_before3, :before3, :call3, :after3, :around_after3,
697
+ # :around_before4, :before4,
698
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
699
+ # :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
700
+ # :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
701
+ # :after4, :around_after4,
702
+ # :around_before5, :before5, :call5, :after5, :around_after5,
703
+ # :after,
704
+ # :rollback5,
705
+ # :rollback4c,
706
+ # :rollback4b,
707
+ # :rollback4a,
708
+ # :rollback3,
709
+ # :rollback2c,
710
+ # :rollback2b,
711
+ # :rollback2a
712
+ # ])
713
+ # end
714
+
715
+ # it "raises the error" do
716
+ # expect {
717
+ # organizer.call(context)
718
+ # }.to raise_error("foo")
719
+ # end
720
+ # end
721
+
722
+ # context "when a nested around hook fails early" do
723
+ # let(:interaktor3) {
724
+ # FakeInteraktor.build_interaktor do
725
+ # around do |interaktor|
726
+ # @context.fail!
727
+ # @context.steps << :around_before3
728
+ # interaktor.call
729
+ # @context.steps << :around_after3
730
+ # end
731
+
732
+ # before do
733
+ # @context.steps << :before3
734
+ # end
735
+
736
+ # after do
737
+ # @context.steps << :after3
738
+ # end
739
+
740
+ # def call
741
+ # @context.steps << :call3
742
+ # end
743
+
744
+ # def rollback
745
+ # @context.steps << :rollback3
746
+ # end
747
+ # end
748
+ # }
749
+
750
+ # it "rolls back successfully called interaktors" do
751
+ # expect {
752
+ # organizer.call(context)
753
+ # }.to change(context, :steps).from([]).to([
754
+ # :around_before, :before,
755
+ # :around_before2, :before2,
756
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
757
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
758
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
759
+ # :after2, :around_after2,
760
+ # :rollback2c,
761
+ # :rollback2b,
762
+ # :rollback2a
763
+ # ])
764
+ # end
765
+ # end
766
+
767
+ # context "when a nested around hook errors early" do
768
+ # let(:interaktor3) {
769
+ # FakeInteraktor.build_interaktor do
770
+ # around do |interaktor|
771
+ # unexpected_error!
772
+ # @context.steps << :around_before3
773
+ # interaktor.call
774
+ # @context.steps << :around_after3
775
+ # end
776
+
777
+ # before do
778
+ # @context.steps << :before3
779
+ # end
780
+
781
+ # after do
782
+ # @context.steps << :after3
783
+ # end
784
+
785
+ # def call
786
+ # @context.steps << :call3
787
+ # end
788
+
789
+ # def rollback
790
+ # @context.steps << :rollback3
791
+ # end
792
+
793
+ # def unexpected_error!
794
+ # raise "foo"
795
+ # end
796
+ # end
797
+ # }
798
+
799
+ # it "rolls back successfully called interaktors" do
800
+ # expect {
801
+ # begin
802
+ # organizer.call(context)
803
+ # rescue
804
+ # nil
805
+ # end
806
+ # }.to change(context, :steps).from([]).to([
807
+ # :around_before, :before,
808
+ # :around_before2, :before2,
809
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
810
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
811
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
812
+ # :after2, :around_after2,
813
+ # :rollback2c,
814
+ # :rollback2b,
815
+ # :rollback2a
816
+ # ])
817
+ # end
818
+
819
+ # it "raises the error" do
820
+ # expect {
821
+ # organizer.call(context)
822
+ # }.to raise_error("foo")
823
+ # end
824
+ # end
825
+
826
+ # context "when a nested before hook fails" do
827
+ # let(:interaktor3) {
828
+ # FakeInteraktor.build_interaktor do
829
+ # around do |interaktor|
830
+ # @context.steps << :around_before3
831
+ # interaktor.call
832
+ # @context.steps << :around_after3
833
+ # end
834
+
835
+ # before do
836
+ # @context.fail!
837
+ # @context.steps << :before3
838
+ # end
839
+
840
+ # after do
841
+ # @context.steps << :after3
842
+ # end
843
+
844
+ # def call
845
+ # @context.steps << :call3
846
+ # end
847
+
848
+ # def rollback
849
+ # @context.steps << :rollback3
850
+ # end
851
+ # end
852
+ # }
853
+
854
+ # it "rolls back successfully called interaktors" do
855
+ # expect {
856
+ # organizer.call(context)
857
+ # }.to change(context, :steps).from([]).to([
858
+ # :around_before, :before,
859
+ # :around_before2, :before2,
860
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
861
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
862
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
863
+ # :after2, :around_after2,
864
+ # :around_before3,
865
+ # :rollback2c,
866
+ # :rollback2b,
867
+ # :rollback2a
868
+ # ])
869
+ # end
870
+ # end
871
+
872
+ # context "when a nested before hook errors" do
873
+ # let(:interaktor3) {
874
+ # FakeInteraktor.build_interaktor do
875
+ # around do |interaktor|
876
+ # @context.steps << :around_before3
877
+ # interaktor.call
878
+ # @context.steps << :around_after3
879
+ # end
880
+
881
+ # before do
882
+ # unexpected_error!
883
+ # @context.steps << :before3
884
+ # end
885
+
886
+ # after do
887
+ # @context.steps << :after3
888
+ # end
889
+
890
+ # def call
891
+ # @context.steps << :call3
892
+ # end
893
+
894
+ # def rollback
895
+ # @context.steps << :rollback3
896
+ # end
897
+
898
+ # def unexpected_error!
899
+ # raise "foo"
900
+ # end
901
+ # end
902
+ # }
903
+
904
+ # it "rolls back successfully called interaktors" do
905
+ # expect {
906
+ # begin
907
+ # organizer.call(context)
908
+ # rescue
909
+ # nil
910
+ # end
911
+ # }.to change(context, :steps).from([]).to([
912
+ # :around_before, :before,
913
+ # :around_before2, :before2,
914
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
915
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
916
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
917
+ # :after2, :around_after2,
918
+ # :around_before3,
919
+ # :rollback2c,
920
+ # :rollback2b,
921
+ # :rollback2a
922
+ # ])
923
+ # end
924
+
925
+ # it "raises the error" do
926
+ # expect {
927
+ # organizer.call(context)
928
+ # }.to raise_error("foo")
929
+ # end
930
+ # end
931
+
932
+ # context "when a nested call fails" do
933
+ # let(:interaktor3) {
934
+ # FakeInteraktor.build_interaktor do
935
+ # around do |interaktor|
936
+ # @context.steps << :around_before3
937
+ # interaktor.call
938
+ # @context.steps << :around_after3
939
+ # end
940
+
941
+ # before do
942
+ # @context.steps << :before3
943
+ # end
944
+
945
+ # after do
946
+ # @context.steps << :after3
947
+ # end
948
+
949
+ # def call
950
+ # @context.fail!
951
+ # @context.steps << :call3
952
+ # end
953
+
954
+ # def rollback
955
+ # @context.steps << :rollback3
956
+ # end
957
+ # end
958
+ # }
959
+
960
+ # it "rolls back successfully called interaktors" do
961
+ # expect {
962
+ # organizer.call(context)
963
+ # }.to change(context, :steps).from([]).to([
964
+ # :around_before, :before,
965
+ # :around_before2, :before2,
966
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
967
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
968
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
969
+ # :after2, :around_after2,
970
+ # :around_before3, :before3,
971
+ # :rollback2c,
972
+ # :rollback2b,
973
+ # :rollback2a
974
+ # ])
975
+ # end
976
+ # end
977
+
978
+ # context "when a nested call errors" do
979
+ # let(:interaktor3) {
980
+ # FakeInteraktor.build_interaktor do
981
+ # around do |interaktor|
982
+ # @context.steps << :around_before3
983
+ # interaktor.call
984
+ # @context.steps << :around_after3
985
+ # end
986
+
987
+ # before do
988
+ # @context.steps << :before3
989
+ # end
990
+
991
+ # after do
992
+ # @context.steps << :after3
993
+ # end
994
+
995
+ # def call
996
+ # unexpected_error!
997
+ # @context.steps << :call3
998
+ # end
999
+
1000
+ # def rollback
1001
+ # @context.steps << :rollback3
1002
+ # end
1003
+
1004
+ # def unexpected_error!
1005
+ # raise "foo"
1006
+ # end
1007
+ # end
1008
+ # }
1009
+
1010
+ # it "rolls back successfully called interaktors" do
1011
+ # expect {
1012
+ # begin
1013
+ # organizer.call(context)
1014
+ # rescue
1015
+ # nil
1016
+ # end
1017
+ # }.to change(context, :steps).from([]).to([
1018
+ # :around_before, :before,
1019
+ # :around_before2, :before2,
1020
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1021
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1022
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1023
+ # :after2, :around_after2,
1024
+ # :around_before3, :before3,
1025
+ # :rollback2c,
1026
+ # :rollback2b,
1027
+ # :rollback2a
1028
+ # ])
1029
+ # end
1030
+
1031
+ # it "raises the error" do
1032
+ # expect {
1033
+ # organizer.call(context)
1034
+ # }.to raise_error("foo")
1035
+ # end
1036
+ # end
1037
+
1038
+ # context "when a nested after hook fails" do
1039
+ # let(:interaktor3) {
1040
+ # FakeInteraktor.build_interaktor do
1041
+ # around do |interaktor|
1042
+ # @context.steps << :around_before3
1043
+ # interaktor.call
1044
+ # @context.steps << :around_after3
1045
+ # end
1046
+
1047
+ # before do
1048
+ # @context.steps << :before3
1049
+ # end
1050
+
1051
+ # after do
1052
+ # @context.fail!
1053
+ # @context.steps << :after3
1054
+ # end
1055
+
1056
+ # def call
1057
+ # @context.steps << :call3
1058
+ # end
1059
+
1060
+ # def rollback
1061
+ # @context.steps << :rollback3
1062
+ # end
1063
+ # end
1064
+ # }
1065
+
1066
+ # it "rolls back successfully called interaktors and the failed interaktor" do
1067
+ # expect {
1068
+ # organizer.call(context)
1069
+ # }.to change(context, :steps).from([]).to([
1070
+ # :around_before, :before,
1071
+ # :around_before2, :before2,
1072
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1073
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1074
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1075
+ # :after2, :around_after2,
1076
+ # :around_before3, :before3, :call3,
1077
+ # :rollback3,
1078
+ # :rollback2c,
1079
+ # :rollback2b,
1080
+ # :rollback2a
1081
+ # ])
1082
+ # end
1083
+ # end
1084
+
1085
+ # context "when a nested after hook errors" do
1086
+ # let(:interaktor3) {
1087
+ # FakeInteraktor.build_interaktor do
1088
+ # around do |interaktor|
1089
+ # @context.steps << :around_before3
1090
+ # interaktor.call
1091
+ # @context.steps << :around_after3
1092
+ # end
1093
+
1094
+ # before do
1095
+ # @context.steps << :before3
1096
+ # end
1097
+
1098
+ # after do
1099
+ # unexpected_error!
1100
+ # @context.steps << :after3
1101
+ # end
1102
+
1103
+ # def call
1104
+ # @context.steps << :call3
1105
+ # end
1106
+
1107
+ # def rollback
1108
+ # @context.steps << :rollback3
1109
+ # end
1110
+
1111
+ # def unexpected_error!
1112
+ # raise "foo"
1113
+ # end
1114
+ # end
1115
+ # }
1116
+
1117
+ # it "rolls back successfully called interaktors and the failed interaktor" do
1118
+ # expect {
1119
+ # begin
1120
+ # organizer.call(context)
1121
+ # rescue
1122
+ # nil
1123
+ # end
1124
+ # }.to change(context, :steps).from([]).to([
1125
+ # :around_before, :before,
1126
+ # :around_before2, :before2,
1127
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1128
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1129
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1130
+ # :after2, :around_after2,
1131
+ # :around_before3, :before3, :call3,
1132
+ # :rollback3,
1133
+ # :rollback2c,
1134
+ # :rollback2b,
1135
+ # :rollback2a
1136
+ # ])
1137
+ # end
1138
+
1139
+ # it "raises the error" do
1140
+ # expect {
1141
+ # organizer.call(context)
1142
+ # }.to raise_error("foo")
1143
+ # end
1144
+ # end
1145
+
1146
+ # context "when a nested around hook fails late" do
1147
+ # let(:interaktor3) {
1148
+ # FakeInteraktor.build_interaktor do
1149
+ # around do |interaktor|
1150
+ # @context.steps << :around_before3
1151
+ # interaktor.call
1152
+ # @context.fail!
1153
+ # @context.steps << :around_after3
1154
+ # end
1155
+
1156
+ # before do
1157
+ # @context.steps << :before3
1158
+ # end
1159
+
1160
+ # after do
1161
+ # @context.steps << :after3
1162
+ # end
1163
+
1164
+ # def call
1165
+ # @context.steps << :call3
1166
+ # end
1167
+
1168
+ # def rollback
1169
+ # @context.steps << :rollback3
1170
+ # end
1171
+ # end
1172
+ # }
1173
+
1174
+ # it "rolls back successfully called interaktors and the failed interaktor" do
1175
+ # expect {
1176
+ # organizer.call(context)
1177
+ # }.to change(context, :steps).from([]).to([
1178
+ # :around_before, :before,
1179
+ # :around_before2, :before2,
1180
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1181
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1182
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1183
+ # :after2, :around_after2,
1184
+ # :around_before3, :before3, :call3, :after3,
1185
+ # :rollback3,
1186
+ # :rollback2c,
1187
+ # :rollback2b,
1188
+ # :rollback2a
1189
+ # ])
1190
+ # end
1191
+ # end
1192
+
1193
+ # context "when a nested around hook errors late" do
1194
+ # let(:interaktor3) {
1195
+ # FakeInteraktor.build_interaktor do
1196
+ # around do |interaktor|
1197
+ # @context.steps << :around_before3
1198
+ # interaktor.call
1199
+ # unexpected_error!
1200
+ # @context.steps << :around_after3
1201
+ # end
1202
+
1203
+ # before do
1204
+ # @context.steps << :before3
1205
+ # end
1206
+
1207
+ # after do
1208
+ # @context.steps << :after3
1209
+ # end
1210
+
1211
+ # def call
1212
+ # @context.steps << :call3
1213
+ # end
1214
+
1215
+ # def rollback
1216
+ # @context.steps << :rollback3
1217
+ # end
1218
+
1219
+ # def unexpected_error!
1220
+ # raise "foo"
1221
+ # end
1222
+ # end
1223
+ # }
1224
+
1225
+ # it "rolls back successfully called interaktors and the failed interaktor" do
1226
+ # expect {
1227
+ # begin
1228
+ # organizer.call(context)
1229
+ # rescue
1230
+ # nil
1231
+ # end
1232
+ # }.to change(context, :steps).from([]).to([
1233
+ # :around_before, :before,
1234
+ # :around_before2, :before2,
1235
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1236
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1237
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1238
+ # :after2, :around_after2,
1239
+ # :around_before3, :before3, :call3, :after3,
1240
+ # :rollback3,
1241
+ # :rollback2c,
1242
+ # :rollback2b,
1243
+ # :rollback2a
1244
+ # ])
1245
+ # end
1246
+
1247
+ # it "raises the error" do
1248
+ # expect {
1249
+ # organizer.call(context)
1250
+ # }.to raise_error("foo")
1251
+ # end
1252
+ # end
1253
+
1254
+ # context "when a deeply nested around hook fails early" do
1255
+ # let(:interaktor4b) {
1256
+ # FakeInteraktor.build_interaktor do
1257
+ # around do |interaktor|
1258
+ # @context.fail!
1259
+ # @context.steps << :around_before4b
1260
+ # interaktor.call
1261
+ # @context.steps << :around_after4b
1262
+ # end
1263
+
1264
+ # before do
1265
+ # @context.steps << :before4b
1266
+ # end
1267
+
1268
+ # after do
1269
+ # @context.steps << :after4b
1270
+ # end
1271
+
1272
+ # def call
1273
+ # @context.steps << :call4b
1274
+ # end
1275
+
1276
+ # def rollback
1277
+ # @context.steps << :rollback4b
1278
+ # end
1279
+ # end
1280
+ # }
1281
+
1282
+ # it "rolls back successfully called interaktors" do
1283
+ # expect {
1284
+ # organizer.call(context)
1285
+ # }.to change(context, :steps).from([]).to([
1286
+ # :around_before, :before,
1287
+ # :around_before2, :before2,
1288
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1289
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1290
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1291
+ # :after2, :around_after2,
1292
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1293
+ # :around_before4, :before4,
1294
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1295
+ # :rollback4a,
1296
+ # :rollback3,
1297
+ # :rollback2c,
1298
+ # :rollback2b,
1299
+ # :rollback2a
1300
+ # ])
1301
+ # end
1302
+ # end
1303
+
1304
+ # context "when a deeply nested around hook errors early" do
1305
+ # let(:interaktor4b) {
1306
+ # FakeInteraktor.build_interaktor do
1307
+ # around do |interaktor|
1308
+ # unexpected_error!
1309
+ # @context.steps << :around_before4b
1310
+ # interaktor.call
1311
+ # @context.steps << :around_after4b
1312
+ # end
1313
+
1314
+ # before do
1315
+ # @context.steps << :before4b
1316
+ # end
1317
+
1318
+ # after do
1319
+ # @context.steps << :after4b
1320
+ # end
1321
+
1322
+ # def call
1323
+ # @context.steps << :call4b
1324
+ # end
1325
+
1326
+ # def rollback
1327
+ # @context.steps << :rollback4b
1328
+ # end
1329
+
1330
+ # def unexpected_error!
1331
+ # raise "foo"
1332
+ # end
1333
+ # end
1334
+ # }
1335
+
1336
+ # it "rolls back successfully called interaktors" do
1337
+ # expect {
1338
+ # begin
1339
+ # organizer.call(context)
1340
+ # rescue
1341
+ # nil
1342
+ # end
1343
+ # }.to change(context, :steps).from([]).to([
1344
+ # :around_before, :before,
1345
+ # :around_before2, :before2,
1346
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1347
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1348
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1349
+ # :after2, :around_after2,
1350
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1351
+ # :around_before4, :before4,
1352
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1353
+ # :rollback4a,
1354
+ # :rollback3,
1355
+ # :rollback2c,
1356
+ # :rollback2b,
1357
+ # :rollback2a
1358
+ # ])
1359
+ # end
1360
+
1361
+ # it "raises the error" do
1362
+ # expect {
1363
+ # organizer.call(context)
1364
+ # }.to raise_error("foo")
1365
+ # end
1366
+ # end
1367
+
1368
+ # context "when a deeply nested before hook fails" do
1369
+ # let(:interaktor4b) {
1370
+ # FakeInteraktor.build_interaktor do
1371
+ # around do |interaktor|
1372
+ # @context.steps << :around_before4b
1373
+ # interaktor.call
1374
+ # @context.steps << :around_after4b
1375
+ # end
1376
+
1377
+ # before do
1378
+ # @context.fail!
1379
+ # @context.steps << :before4b
1380
+ # end
1381
+
1382
+ # after do
1383
+ # @context.steps << :after4b
1384
+ # end
1385
+
1386
+ # def call
1387
+ # @context.steps << :call4b
1388
+ # end
1389
+
1390
+ # def rollback
1391
+ # @context.steps << :rollback4b
1392
+ # end
1393
+ # end
1394
+ # }
1395
+
1396
+ # it "rolls back successfully called interaktors" do
1397
+ # expect {
1398
+ # organizer.call(context)
1399
+ # }.to change(context, :steps).from([]).to([
1400
+ # :around_before, :before,
1401
+ # :around_before2, :before2,
1402
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1403
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1404
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1405
+ # :after2, :around_after2,
1406
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1407
+ # :around_before4, :before4,
1408
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1409
+ # :around_before4b,
1410
+ # :rollback4a,
1411
+ # :rollback3,
1412
+ # :rollback2c,
1413
+ # :rollback2b,
1414
+ # :rollback2a
1415
+ # ])
1416
+ # end
1417
+ # end
1418
+
1419
+ # context "when a deeply nested before hook errors" do
1420
+ # let(:interaktor4b) {
1421
+ # FakeInteraktor.build_interaktor do
1422
+ # around do |interaktor|
1423
+ # @context.steps << :around_before4b
1424
+ # interaktor.call
1425
+ # @context.steps << :around_after4b
1426
+ # end
1427
+
1428
+ # before do
1429
+ # unexpected_error!
1430
+ # @context.steps << :before4b
1431
+ # end
1432
+
1433
+ # after do
1434
+ # @context.steps << :after4b
1435
+ # end
1436
+
1437
+ # def call
1438
+ # @context.steps << :call4b
1439
+ # end
1440
+
1441
+ # def rollback
1442
+ # @context.steps << :rollback4b
1443
+ # end
1444
+
1445
+ # def unexpected_error!
1446
+ # raise "foo"
1447
+ # end
1448
+ # end
1449
+ # }
1450
+
1451
+ # it "rolls back successfully called interaktors" do
1452
+ # expect {
1453
+ # begin
1454
+ # organizer.call(context)
1455
+ # rescue
1456
+ # nil
1457
+ # end
1458
+ # }.to change(context, :steps).from([]).to([
1459
+ # :around_before, :before,
1460
+ # :around_before2, :before2,
1461
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1462
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1463
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1464
+ # :after2, :around_after2,
1465
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1466
+ # :around_before4, :before4,
1467
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1468
+ # :around_before4b,
1469
+ # :rollback4a,
1470
+ # :rollback3,
1471
+ # :rollback2c,
1472
+ # :rollback2b,
1473
+ # :rollback2a
1474
+ # ])
1475
+ # end
1476
+
1477
+ # it "raises the error" do
1478
+ # expect {
1479
+ # organizer.call(context)
1480
+ # }.to raise_error("foo")
1481
+ # end
1482
+ # end
1483
+
1484
+ # context "when a deeply nested call fails" do
1485
+ # let(:interaktor4b) {
1486
+ # FakeInteraktor.build_interaktor do
1487
+ # around do |interaktor|
1488
+ # @context.steps << :around_before4b
1489
+ # interaktor.call
1490
+ # @context.steps << :around_after4b
1491
+ # end
1492
+
1493
+ # before do
1494
+ # @context.steps << :before4b
1495
+ # end
1496
+
1497
+ # after do
1498
+ # @context.steps << :after4b
1499
+ # end
1500
+
1501
+ # def call
1502
+ # @context.fail!
1503
+ # @context.steps << :call4b
1504
+ # end
1505
+
1506
+ # def rollback
1507
+ # @context.steps << :rollback4b
1508
+ # end
1509
+ # end
1510
+ # }
1511
+
1512
+ # it "rolls back successfully called interaktors" do
1513
+ # expect {
1514
+ # organizer.call(context)
1515
+ # }.to change(context, :steps).from([]).to([
1516
+ # :around_before, :before,
1517
+ # :around_before2, :before2,
1518
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1519
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1520
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1521
+ # :after2, :around_after2,
1522
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1523
+ # :around_before4, :before4,
1524
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1525
+ # :around_before4b, :before4b,
1526
+ # :rollback4a,
1527
+ # :rollback3,
1528
+ # :rollback2c,
1529
+ # :rollback2b,
1530
+ # :rollback2a
1531
+ # ])
1532
+ # end
1533
+ # end
1534
+
1535
+ # context "when a deeply nested call errors" do
1536
+ # let(:interaktor4b) {
1537
+ # FakeInteraktor.build_interaktor do
1538
+ # around do |interaktor|
1539
+ # @context.steps << :around_before4b
1540
+ # interaktor.call
1541
+ # @context.steps << :around_after4b
1542
+ # end
1543
+
1544
+ # before do
1545
+ # @context.steps << :before4b
1546
+ # end
1547
+
1548
+ # after do
1549
+ # @context.steps << :after4b
1550
+ # end
1551
+
1552
+ # def call
1553
+ # unexpected_error!
1554
+ # @context.steps << :call4b
1555
+ # end
1556
+
1557
+ # def rollback
1558
+ # @context.steps << :rollback4b
1559
+ # end
1560
+
1561
+ # def unexpected_error!
1562
+ # raise "foo"
1563
+ # end
1564
+ # end
1565
+ # }
1566
+
1567
+ # it "rolls back successfully called interaktors" do
1568
+ # expect {
1569
+ # begin
1570
+ # organizer.call(context)
1571
+ # rescue
1572
+ # nil
1573
+ # end
1574
+ # }.to change(context, :steps).from([]).to([
1575
+ # :around_before, :before,
1576
+ # :around_before2, :before2,
1577
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1578
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1579
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1580
+ # :after2, :around_after2,
1581
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1582
+ # :around_before4, :before4,
1583
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1584
+ # :around_before4b, :before4b,
1585
+ # :rollback4a,
1586
+ # :rollback3,
1587
+ # :rollback2c,
1588
+ # :rollback2b,
1589
+ # :rollback2a
1590
+ # ])
1591
+ # end
1592
+
1593
+ # it "raises the error" do
1594
+ # expect {
1595
+ # organizer.call(context)
1596
+ # }.to raise_error("foo")
1597
+ # end
1598
+ # end
1599
+
1600
+ # context "when a deeply nested after hook fails" do
1601
+ # let(:interaktor4b) {
1602
+ # FakeInteraktor.build_interaktor do
1603
+ # around do |interaktor|
1604
+ # @context.steps << :around_before4b
1605
+ # interaktor.call
1606
+ # @context.steps << :around_after4b
1607
+ # end
1608
+
1609
+ # before do
1610
+ # @context.steps << :before4b
1611
+ # end
1612
+
1613
+ # after do
1614
+ # @context.fail!
1615
+ # @context.steps << :after4b
1616
+ # end
1617
+
1618
+ # def call
1619
+ # @context.steps << :call4b
1620
+ # end
1621
+
1622
+ # def rollback
1623
+ # @context.steps << :rollback4b
1624
+ # end
1625
+ # end
1626
+ # }
1627
+
1628
+ # it "rolls back successfully called interaktors and the failed interaktor" do
1629
+ # expect {
1630
+ # organizer.call(context)
1631
+ # }.to change(context, :steps).from([]).to([
1632
+ # :around_before, :before,
1633
+ # :around_before2, :before2,
1634
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1635
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1636
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1637
+ # :after2, :around_after2,
1638
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1639
+ # :around_before4, :before4,
1640
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1641
+ # :around_before4b, :before4b, :call4b,
1642
+ # :rollback4b,
1643
+ # :rollback4a,
1644
+ # :rollback3,
1645
+ # :rollback2c,
1646
+ # :rollback2b,
1647
+ # :rollback2a
1648
+ # ])
1649
+ # end
1650
+ # end
1651
+
1652
+ # context "when a deeply nested after hook errors" do
1653
+ # let(:interaktor4b) {
1654
+ # FakeInteraktor.build_interaktor do
1655
+ # around do |interaktor|
1656
+ # @context.steps << :around_before4b
1657
+ # interaktor.call
1658
+ # @context.steps << :around_after4b
1659
+ # end
1660
+
1661
+ # before do
1662
+ # @context.steps << :before4b
1663
+ # end
1664
+
1665
+ # after do
1666
+ # unexpected_error!
1667
+ # @context.steps << :after4b
1668
+ # end
1669
+
1670
+ # def call
1671
+ # @context.steps << :call4b
1672
+ # end
1673
+
1674
+ # def rollback
1675
+ # @context.steps << :rollback4b
1676
+ # end
1677
+
1678
+ # def unexpected_error!
1679
+ # raise "foo"
1680
+ # end
1681
+ # end
1682
+ # }
1683
+
1684
+ # it "rolls back successfully called interaktors and the failed interaktor" do
1685
+ # expect {
1686
+ # begin
1687
+ # organizer.call(context)
1688
+ # rescue
1689
+ # nil
1690
+ # end
1691
+ # }.to change(context, :steps).from([]).to([
1692
+ # :around_before, :before,
1693
+ # :around_before2, :before2,
1694
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1695
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1696
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1697
+ # :after2, :around_after2,
1698
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1699
+ # :around_before4, :before4,
1700
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1701
+ # :around_before4b, :before4b, :call4b,
1702
+ # :rollback4b,
1703
+ # :rollback4a,
1704
+ # :rollback3,
1705
+ # :rollback2c,
1706
+ # :rollback2b,
1707
+ # :rollback2a
1708
+ # ])
1709
+ # end
1710
+
1711
+ # it "raises the error" do
1712
+ # expect {
1713
+ # organizer.call(context)
1714
+ # }.to raise_error("foo")
1715
+ # end
1716
+ # end
1717
+
1718
+ # context "when a deeply nested around hook fails late" do
1719
+ # let(:interaktor4b) {
1720
+ # FakeInteraktor.build_interaktor do
1721
+ # around do |interaktor|
1722
+ # @context.steps << :around_before4b
1723
+ # interaktor.call
1724
+ # @context.fail!
1725
+ # @context.steps << :around_after4b
1726
+ # end
1727
+
1728
+ # before do
1729
+ # @context.steps << :before4b
1730
+ # end
1731
+
1732
+ # after do
1733
+ # @context.steps << :after4b
1734
+ # end
1735
+
1736
+ # def call
1737
+ # @context.steps << :call4b
1738
+ # end
1739
+
1740
+ # def rollback
1741
+ # @context.steps << :rollback4b
1742
+ # end
1743
+ # end
1744
+ # }
1745
+
1746
+ # it "rolls back successfully called interaktors and the failed interaktor" do
1747
+ # expect {
1748
+ # organizer.call(context)
1749
+ # }.to change(context, :steps).from([]).to([
1750
+ # :around_before, :before,
1751
+ # :around_before2, :before2,
1752
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1753
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1754
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1755
+ # :after2, :around_after2,
1756
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1757
+ # :around_before4, :before4,
1758
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1759
+ # :around_before4b, :before4b, :call4b, :after4b,
1760
+ # :rollback4b,
1761
+ # :rollback4a,
1762
+ # :rollback3,
1763
+ # :rollback2c,
1764
+ # :rollback2b,
1765
+ # :rollback2a
1766
+ # ])
1767
+ # end
1768
+ # end
1769
+
1770
+ # context "when a deeply nested around hook errors late" do
1771
+ # let(:interaktor4b) {
1772
+ # FakeInteraktor.build_interaktor do
1773
+ # around do |interaktor|
1774
+ # @context.steps << :around_before4b
1775
+ # interaktor.call
1776
+ # unexpected_error!
1777
+ # @context.steps << :around_after4b
1778
+ # end
1779
+
1780
+ # before do
1781
+ # @context.steps << :before4b
1782
+ # end
1783
+
1784
+ # after do
1785
+ # @context.steps << :after4b
1786
+ # end
1787
+
1788
+ # def call
1789
+ # @context.steps << :call4b
1790
+ # end
1791
+
1792
+ # def rollback
1793
+ # @context.steps << :rollback4b
1794
+ # end
1795
+
1796
+ # def unexpected_error!
1797
+ # raise "foo"
1798
+ # end
1799
+ # end
1800
+ # }
1801
+
1802
+ # it "rolls back successfully called interaktors and the failed interaktor" do
1803
+ # expect {
1804
+ # begin
1805
+ # organizer.call(context)
1806
+ # rescue
1807
+ # nil
1808
+ # end
1809
+ # }.to change(context, :steps).from([]).to([
1810
+ # :around_before, :before,
1811
+ # :around_before2, :before2,
1812
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1813
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1814
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1815
+ # :after2, :around_after2,
1816
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1817
+ # :around_before4, :before4,
1818
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1819
+ # :around_before4b, :before4b, :call4b, :after4b,
1820
+ # :rollback4b,
1821
+ # :rollback4a,
1822
+ # :rollback3,
1823
+ # :rollback2c,
1824
+ # :rollback2b,
1825
+ # :rollback2a
1826
+ # ])
1827
+ # end
1828
+
1829
+ # it "raises the error" do
1830
+ # expect {
1831
+ # organizer.call(context)
1832
+ # }.to raise_error("foo")
1833
+ # end
1834
+ # end
1835
+
1836
+ # context "when there are multiple organize calls" do
1837
+ # it "runs all passed interaktors in correct order" do
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
+
1849
+ # organizer.organize(organizer4, interaktor5)
1850
+
1851
+ # expect {
1852
+ # organizer.call(context)
1853
+ # }.to change(context, :steps).from([]).to([
1854
+ # :around_before2, :before2,
1855
+ # :around_before2a, :before2a, :call2a, :after2a, :around_after2a,
1856
+ # :around_before2b, :before2b, :call2b, :after2b, :around_after2b,
1857
+ # :around_before2c, :before2c, :call2c, :after2c, :around_after2c,
1858
+ # :after2, :around_after2,
1859
+ # :around_before3, :before3, :call3, :after3, :around_after3,
1860
+ # :around_before4, :before4,
1861
+ # :around_before4a, :before4a, :call4a, :after4a, :around_after4a,
1862
+ # :around_before4b, :before4b, :call4b, :after4b, :around_after4b,
1863
+ # :around_before4c, :before4c, :call4c, :after4c, :around_after4c,
1864
+ # :after4, :around_after4,
1865
+ # :around_before5, :before5, :call5, :after5, :around_after5
1866
+ # ])
1867
+ # end
1868
+ # end
1869
+ # end
1870
+
1871
+ # # rubocop:enable RSpec/InstanceVariable
1872
+ # # rubocop:enable RSpec/MultipleMemoizedHelpers
1873
+ # # rubocop:enable RSpec/ScatteredSetup
1874
+ # # rubocop:enable Style/DocumentationMethod