interaktor 0.1.3 → 0.1.4

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,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "interaktor"
3
- spec.version = "0.1.3"
3
+ spec.version = "0.1.4"
4
4
 
5
5
  spec.author = "Taylor Thurlow"
6
6
  spec.email = "taylorthurlow@me.com"
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.required_ruby_version = ">= 2.5"
14
14
  spec.require_path = "lib"
15
15
 
16
- spec.add_runtime_dependency "zeitwerk", "~> 2.3.1"
16
+ spec.add_runtime_dependency "zeitwerk", "~> 2.0"
17
17
 
18
18
  spec.add_development_dependency "rake", "~> 13.0"
19
19
  end
@@ -14,9 +14,6 @@ module Interaktor
14
14
  extend ClassMethods
15
15
  include Hooks
16
16
  end
17
-
18
- # @return [Interaktor::Context] this should not be used publicly
19
- attr_accessor :context
20
17
  end
21
18
 
22
19
  module ClassMethods
@@ -44,6 +41,14 @@ module Interaktor
44
41
  @failure_attributes ||= []
45
42
  end
46
43
 
44
+ # The list of attributes which are required to be passed in when calling
45
+ # `#fail!` from within the interaktor.
46
+ #
47
+ # @return [Array<Symbol>]
48
+ def success_attributes
49
+ @success_attributes ||= []
50
+ end
51
+
47
52
  # A DSL method for documenting required interaktor attributes.
48
53
  #
49
54
  # @param attributes [Symbol, Array<Symbol>] the list of attribute names
@@ -53,9 +58,9 @@ module Interaktor
53
58
  required_attributes.concat attributes
54
59
 
55
60
  attributes.each do |attribute|
56
- define_method(attribute) { context.send(attribute) }
61
+ define_method(attribute) { @context.send(attribute) }
57
62
  define_method("#{attribute}=".to_sym) do |value|
58
- context.send("#{attribute}=".to_sym, value)
63
+ @context.send("#{attribute}=".to_sym, value)
59
64
  end
60
65
  end
61
66
  end
@@ -69,16 +74,17 @@ module Interaktor
69
74
  optional_attributes.concat attributes
70
75
 
71
76
  attributes.each do |attribute|
72
- define_method(attribute) { context.send(attribute) }
77
+ define_method(attribute) { @context.send(attribute) }
73
78
  define_method("#{attribute}=".to_sym) do |value|
74
- unless context.to_h.key?(attribute)
79
+ unless @context.to_h.key?(attribute)
75
80
  raise <<~ERROR
76
- You can't assign a value to an optional parameter if you didn't
77
- initialize the interaktor with it in the first place.
81
+ You can't assign a value to an optional parameter if you
82
+ didn't initialize the interaktor with it in the first
83
+ place.
78
84
  ERROR
79
85
  end
80
86
 
81
- context.send("#{attribute}=".to_sym, value)
87
+ @context.send("#{attribute}=".to_sym, value)
82
88
  end
83
89
  end
84
90
  end
@@ -92,6 +98,15 @@ module Interaktor
92
98
  failure_attributes.concat attributes
93
99
  end
94
100
 
101
+ # A DSL method for documenting required interaktor success attributes.
102
+ #
103
+ # @param attributes [Symbol, Array<Symbol>] the list of attribute names
104
+ #
105
+ # @return [void]
106
+ def success(*attributes)
107
+ success_attributes.concat attributes
108
+ end
109
+
95
110
  # Invoke an Interaktor. This is the primary public API method to an
96
111
  # interaktor.
97
112
  #
@@ -102,7 +117,9 @@ module Interaktor
102
117
  def call(context = {})
103
118
  verify_attribute_presence(context)
104
119
 
105
- new(context).tap(&:run).context
120
+ catch(:early_return) do
121
+ new(context).tap(&:run).instance_variable_get(:@context)
122
+ end
106
123
  end
107
124
 
108
125
  # Invoke an Interaktor. This method behaves identically to `#call`, with
@@ -118,7 +135,9 @@ module Interaktor
118
135
  def call!(context = {})
119
136
  verify_attribute_presence(context)
120
137
 
121
- new(context).tap(&:run!).context
138
+ catch(:early_return) do
139
+ new(context).tap(&:run!).instance_variable_get(:@context)
140
+ end
122
141
  end
123
142
 
124
143
  private
@@ -158,7 +177,27 @@ module Interaktor
158
177
  .reject { |failure_attr| failure_attributes.key?(failure_attr) }
159
178
  raise "Missing failure attrs: #{missing_attrs.join(", ")}" if missing_attrs.any?
160
179
 
161
- context.fail!(failure_attributes)
180
+ @context.fail!(failure_attributes)
181
+ end
182
+
183
+ # Terminate execution of the current interaktor and copy the success
184
+ # attributes into the context.
185
+ #
186
+ # @param success_attributes [Hash{Symbol=>Object}] the context attributes
187
+ #
188
+ # @return [void]
189
+ def success!(success_attributes = {})
190
+ # Make sure we have all required attributes
191
+ missing_attrs = self.class.success_attributes
192
+ .reject { |success_attr| success_attributes.key?(success_attr) }
193
+ raise "Missing success attrs: #{missing_attrs.join(", ")}" if missing_attrs.any?
194
+
195
+ # Make sure we haven't provided any unknown attributes
196
+ unknown_attrs = success_attributes.keys
197
+ .reject { |success_attr| self.class.success_attributes.include?(success_attr) }
198
+ raise "Unknown success attrs: #{unknown_attrs.join(", ")}" if unknown_attrs.any?
199
+
200
+ @context.success!(success_attributes)
162
201
  end
163
202
 
164
203
  # Invoke an Interaktor instance without any hooks, tracking, or rollback. It
@@ -200,10 +239,10 @@ module Interaktor
200
239
  def run!
201
240
  with_hooks do
202
241
  call
203
- context.called!(self)
242
+ @context.called!(self)
204
243
  end
205
244
  rescue StandardError
206
- context.rollback!
245
+ @context.rollback!
207
246
  raise
208
247
  end
209
248
  end
@@ -55,6 +55,16 @@ class Interaktor::Context < OpenStruct
55
55
  raise Interaktor::Failure, self
56
56
  end
57
57
 
58
+ # @param context [Hash] data to be merged into the existing context
59
+ #
60
+ # @raises [Interaktor::Failure]
61
+ #
62
+ # @return [void]
63
+ def success!(context = {})
64
+ context.each { |key, value| self[key.to_sym] = value }
65
+ throw :early_return, self
66
+ end
67
+
58
68
  # Roll back the Interaktor::Context. Any interaktors to which this context
59
69
  # has been passed and which have been successfully called are asked to roll
60
70
  # themselves back by invoking their `#rollback` methods.
@@ -40,7 +40,7 @@ module Interaktor::Organizer
40
40
  # @return [void]
41
41
  def call
42
42
  self.class.organized.each do |interaktor|
43
- interaktor.call!(context)
43
+ catch(:early_return) { interaktor.call!(@context) }
44
44
  end
45
45
  end
46
46
 
@@ -1,3 +1,8 @@
1
+ # rubocop:disable RSpec/InstanceVariable
2
+ # rubocop:disable RSpec/MultipleMemoizedHelpers
3
+ # rubocop:disable RSpec/ScatteredSetup
4
+ # rubocop:disable Style/DocumentationMethod
5
+
1
6
  describe "Integration" do
2
7
  def build_interaktor(&block)
3
8
  interaktor = Class.new.send(:include, Interaktor)
@@ -42,17 +47,17 @@ describe "Integration" do
42
47
  interaktors = [organizer2, interaktor3, organizer4, interaktor5]
43
48
  build_organizer(organize: interaktors) do
44
49
  around do |interaktor|
45
- context.steps << :around_before
50
+ @context.steps << :around_before
46
51
  interaktor.call
47
- context.steps << :around_after
52
+ @context.steps << :around_after
48
53
  end
49
54
 
50
55
  before do
51
- context.steps << :before
56
+ @context.steps << :before
52
57
  end
53
58
 
54
59
  after do
55
- context.steps << :after
60
+ @context.steps << :after
56
61
  end
57
62
  end
58
63
  }
@@ -60,17 +65,17 @@ describe "Integration" do
60
65
  let(:organizer2) {
61
66
  build_organizer(organize: [interaktor2a, interaktor2b, interaktor2c]) do
62
67
  around do |interaktor|
63
- context.steps << :around_before2
68
+ @context.steps << :around_before2
64
69
  interaktor.call
65
- context.steps << :around_after2
70
+ @context.steps << :around_after2
66
71
  end
67
72
 
68
73
  before do
69
- context.steps << :before2
74
+ @context.steps << :before2
70
75
  end
71
76
 
72
77
  after do
73
- context.steps << :after2
78
+ @context.steps << :after2
74
79
  end
75
80
  end
76
81
  }
@@ -78,25 +83,25 @@ describe "Integration" do
78
83
  let(:interaktor2a) {
79
84
  build_interaktor do
80
85
  around do |interaktor|
81
- context.steps << :around_before2a
86
+ @context.steps << :around_before2a
82
87
  interaktor.call
83
- context.steps << :around_after2a
88
+ @context.steps << :around_after2a
84
89
  end
85
90
 
86
91
  before do
87
- context.steps << :before2a
92
+ @context.steps << :before2a
88
93
  end
89
94
 
90
95
  after do
91
- context.steps << :after2a
96
+ @context.steps << :after2a
92
97
  end
93
98
 
94
99
  def call
95
- context.steps << :call2a
100
+ @context.steps << :call2a
96
101
  end
97
102
 
98
103
  def rollback
99
- context.steps << :rollback2a
104
+ @context.steps << :rollback2a
100
105
  end
101
106
  end
102
107
  }
@@ -104,25 +109,25 @@ describe "Integration" do
104
109
  let(:interaktor2b) {
105
110
  build_interaktor do
106
111
  around do |interaktor|
107
- context.steps << :around_before2b
112
+ @context.steps << :around_before2b
108
113
  interaktor.call
109
- context.steps << :around_after2b
114
+ @context.steps << :around_after2b
110
115
  end
111
116
 
112
117
  before do
113
- context.steps << :before2b
118
+ @context.steps << :before2b
114
119
  end
115
120
 
116
121
  after do
117
- context.steps << :after2b
122
+ @context.steps << :after2b
118
123
  end
119
124
 
120
125
  def call
121
- context.steps << :call2b
126
+ @context.steps << :call2b
122
127
  end
123
128
 
124
129
  def rollback
125
- context.steps << :rollback2b
130
+ @context.steps << :rollback2b
126
131
  end
127
132
  end
128
133
  }
@@ -130,25 +135,25 @@ describe "Integration" do
130
135
  let(:interaktor2c) {
131
136
  build_interaktor do
132
137
  around do |interaktor|
133
- context.steps << :around_before2c
138
+ @context.steps << :around_before2c
134
139
  interaktor.call
135
- context.steps << :around_after2c
140
+ @context.steps << :around_after2c
136
141
  end
137
142
 
138
143
  before do
139
- context.steps << :before2c
144
+ @context.steps << :before2c
140
145
  end
141
146
 
142
147
  after do
143
- context.steps << :after2c
148
+ @context.steps << :after2c
144
149
  end
145
150
 
146
151
  def call
147
- context.steps << :call2c
152
+ @context.steps << :call2c
148
153
  end
149
154
 
150
155
  def rollback
151
- context.steps << :rollback2c
156
+ @context.steps << :rollback2c
152
157
  end
153
158
  end
154
159
  }
@@ -156,25 +161,25 @@ describe "Integration" do
156
161
  let(:interaktor3) {
157
162
  build_interaktor do
158
163
  around do |interaktor|
159
- context.steps << :around_before3
164
+ @context.steps << :around_before3
160
165
  interaktor.call
161
- context.steps << :around_after3
166
+ @context.steps << :around_after3
162
167
  end
163
168
 
164
169
  before do
165
- context.steps << :before3
170
+ @context.steps << :before3
166
171
  end
167
172
 
168
173
  after do
169
- context.steps << :after3
174
+ @context.steps << :after3
170
175
  end
171
176
 
172
177
  def call
173
- context.steps << :call3
178
+ @context.steps << :call3
174
179
  end
175
180
 
176
181
  def rollback
177
- context.steps << :rollback3
182
+ @context.steps << :rollback3
178
183
  end
179
184
  end
180
185
  }
@@ -182,17 +187,17 @@ describe "Integration" do
182
187
  let(:organizer4) {
183
188
  build_organizer(organize: [interaktor4a, interaktor4b, interaktor4c]) do
184
189
  around do |interaktor|
185
- context.steps << :around_before4
190
+ @context.steps << :around_before4
186
191
  interaktor.call
187
- context.steps << :around_after4
192
+ @context.steps << :around_after4
188
193
  end
189
194
 
190
195
  before do
191
- context.steps << :before4
196
+ @context.steps << :before4
192
197
  end
193
198
 
194
199
  after do
195
- context.steps << :after4
200
+ @context.steps << :after4
196
201
  end
197
202
  end
198
203
  }
@@ -200,25 +205,25 @@ describe "Integration" do
200
205
  let(:interaktor4a) {
201
206
  build_interaktor do
202
207
  around do |interaktor|
203
- context.steps << :around_before4a
208
+ @context.steps << :around_before4a
204
209
  interaktor.call
205
- context.steps << :around_after4a
210
+ @context.steps << :around_after4a
206
211
  end
207
212
 
208
213
  before do
209
- context.steps << :before4a
214
+ @context.steps << :before4a
210
215
  end
211
216
 
212
217
  after do
213
- context.steps << :after4a
218
+ @context.steps << :after4a
214
219
  end
215
220
 
216
221
  def call
217
- context.steps << :call4a
222
+ @context.steps << :call4a
218
223
  end
219
224
 
220
225
  def rollback
221
- context.steps << :rollback4a
226
+ @context.steps << :rollback4a
222
227
  end
223
228
  end
224
229
  }
@@ -226,25 +231,25 @@ describe "Integration" do
226
231
  let(:interaktor4b) {
227
232
  build_interaktor do
228
233
  around do |interaktor|
229
- context.steps << :around_before4b
234
+ @context.steps << :around_before4b
230
235
  interaktor.call
231
- context.steps << :around_after4b
236
+ @context.steps << :around_after4b
232
237
  end
233
238
 
234
239
  before do
235
- context.steps << :before4b
240
+ @context.steps << :before4b
236
241
  end
237
242
 
238
243
  after do
239
- context.steps << :after4b
244
+ @context.steps << :after4b
240
245
  end
241
246
 
242
247
  def call
243
- context.steps << :call4b
248
+ @context.steps << :call4b
244
249
  end
245
250
 
246
251
  def rollback
247
- context.steps << :rollback4b
252
+ @context.steps << :rollback4b
248
253
  end
249
254
  end
250
255
  }
@@ -252,25 +257,25 @@ describe "Integration" do
252
257
  let(:interaktor4c) {
253
258
  build_interaktor do
254
259
  around do |interaktor|
255
- context.steps << :around_before4c
260
+ @context.steps << :around_before4c
256
261
  interaktor.call
257
- context.steps << :around_after4c
262
+ @context.steps << :around_after4c
258
263
  end
259
264
 
260
265
  before do
261
- context.steps << :before4c
266
+ @context.steps << :before4c
262
267
  end
263
268
 
264
269
  after do
265
- context.steps << :after4c
270
+ @context.steps << :after4c
266
271
  end
267
272
 
268
273
  def call
269
- context.steps << :call4c
274
+ @context.steps << :call4c
270
275
  end
271
276
 
272
277
  def rollback
273
- context.steps << :rollback4c
278
+ @context.steps << :rollback4c
274
279
  end
275
280
  end
276
281
  }
@@ -278,25 +283,25 @@ describe "Integration" do
278
283
  let(:interaktor5) {
279
284
  build_interaktor do
280
285
  around do |interaktor|
281
- context.steps << :around_before5
286
+ @context.steps << :around_before5
282
287
  interaktor.call
283
- context.steps << :around_after5
288
+ @context.steps << :around_after5
284
289
  end
285
290
 
286
291
  before do
287
- context.steps << :before5
292
+ @context.steps << :before5
288
293
  end
289
294
 
290
295
  after do
291
- context.steps << :after5
296
+ @context.steps << :after5
292
297
  end
293
298
 
294
299
  def call
295
- context.steps << :call5
300
+ @context.steps << :call5
296
301
  end
297
302
 
298
303
  def rollback
299
- context.steps << :rollback5
304
+ @context.steps << :rollback5
300
305
  end
301
306
  end
302
307
  }
@@ -331,19 +336,19 @@ describe "Integration" do
331
336
  interaktors = [organizer2, interaktor3, organizer4, interaktor5]
332
337
  build_organizer(organize: interaktors) do
333
338
  around do |interaktor|
334
- context.fail!
335
- context.steps << :around_before
339
+ @context.fail!
340
+ @context.steps << :around_before
336
341
  interaktor.call
337
- context.steps << :around_after
342
+ @context.steps << :around_after
338
343
  end
339
344
 
340
345
  before do
341
- context.fail!
342
- context.steps << :before
346
+ @context.fail!
347
+ @context.steps << :before
343
348
  end
344
349
 
345
350
  after do
346
- context.steps << :after
351
+ @context.steps << :after
347
352
  end
348
353
  end
349
354
  }
@@ -361,18 +366,18 @@ describe "Integration" do
361
366
  build_organizer(organize: interaktors) do
362
367
  around do |interaktor|
363
368
  unexpected_error!
364
- context.steps << :around_before
369
+ @context.steps << :around_before
365
370
  interaktor.call
366
- context.steps << :around_after
371
+ @context.steps << :around_after
367
372
  end
368
373
 
369
374
  before do
370
- context.fail!
371
- context.steps << :before
375
+ @context.fail!
376
+ @context.steps << :before
372
377
  end
373
378
 
374
379
  after do
375
- context.steps << :after
380
+ @context.steps << :after
376
381
  end
377
382
  end
378
383
  }
@@ -399,18 +404,18 @@ describe "Integration" do
399
404
  interaktors = [organizer2, interaktor3, organizer4, interaktor5]
400
405
  build_organizer(organize: interaktors) do
401
406
  around do |interaktor|
402
- context.steps << :around_before
407
+ @context.steps << :around_before
403
408
  interaktor.call
404
- context.steps << :around_after
409
+ @context.steps << :around_after
405
410
  end
406
411
 
407
412
  before do
408
- context.fail!
409
- context.steps << :before
413
+ @context.fail!
414
+ @context.steps << :before
410
415
  end
411
416
 
412
417
  after do
413
- context.steps << :after
418
+ @context.steps << :after
414
419
  end
415
420
  end
416
421
  }
@@ -429,18 +434,18 @@ describe "Integration" do
429
434
  interaktors = [organizer2, interaktor3, organizer4, interaktor5]
430
435
  build_organizer(organize: interaktors) do
431
436
  around do |interaktor|
432
- context.steps << :around_before
437
+ @context.steps << :around_before
433
438
  interaktor.call
434
- context.steps << :around_after
439
+ @context.steps << :around_after
435
440
  end
436
441
 
437
442
  before do
438
443
  unexpected_error!
439
- context.steps << :before
444
+ @context.steps << :before
440
445
  end
441
446
 
442
447
  after do
443
- context.steps << :after
448
+ @context.steps << :after
444
449
  end
445
450
  end
446
451
  }
@@ -469,18 +474,18 @@ describe "Integration" do
469
474
  interaktors = [organizer2, interaktor3, organizer4, interaktor5]
470
475
  build_organizer(organize: interaktors) do
471
476
  around do |interaktor|
472
- context.steps << :around_before
477
+ @context.steps << :around_before
473
478
  interaktor.call
474
- context.steps << :around_after
479
+ @context.steps << :around_after
475
480
  end
476
481
 
477
482
  before do
478
- context.steps << :before
483
+ @context.steps << :before
479
484
  end
480
485
 
481
486
  after do
482
- context.fail!
483
- context.steps << :after
487
+ @context.fail!
488
+ @context.steps << :after
484
489
  end
485
490
  end
486
491
  }
@@ -519,18 +524,18 @@ describe "Integration" do
519
524
  interaktors = [organizer2, interaktor3, organizer4, interaktor5]
520
525
  build_organizer(organize: interaktors) do
521
526
  around do |interaktor|
522
- context.steps << :around_before
527
+ @context.steps << :around_before
523
528
  interaktor.call
524
- context.steps << :around_after
529
+ @context.steps << :around_after
525
530
  end
526
531
 
527
532
  before do
528
- context.steps << :before
533
+ @context.steps << :before
529
534
  end
530
535
 
531
536
  after do
532
537
  unexpected_error!
533
- context.steps << :after
538
+ @context.steps << :after
534
539
  end
535
540
  end
536
541
  }
@@ -579,18 +584,18 @@ describe "Integration" do
579
584
  interaktors = [organizer2, interaktor3, organizer4, interaktor5]
580
585
  build_organizer(organize: interaktors) do
581
586
  around do |interaktor|
582
- context.steps << :around_before
587
+ @context.steps << :around_before
583
588
  interaktor.call
584
- context.fail!
585
- context.steps << :around_after
589
+ @context.fail!
590
+ @context.steps << :around_after
586
591
  end
587
592
 
588
593
  before do
589
- context.steps << :before
594
+ @context.steps << :before
590
595
  end
591
596
 
592
597
  after do
593
- context.steps << :after
598
+ @context.steps << :after
594
599
  end
595
600
  end
596
601
  }
@@ -630,18 +635,18 @@ describe "Integration" do
630
635
  interaktors = [organizer2, interaktor3, organizer4, interaktor5]
631
636
  build_organizer(organize: interaktors) do
632
637
  around do |interaktor|
633
- context.steps << :around_before
638
+ @context.steps << :around_before
634
639
  interaktor.call
635
640
  unexpected_error!
636
- context.steps << :around_after
641
+ @context.steps << :around_after
637
642
  end
638
643
 
639
644
  before do
640
- context.steps << :before
645
+ @context.steps << :before
641
646
  end
642
647
 
643
648
  after do
644
- context.steps << :after
649
+ @context.steps << :after
645
650
  end
646
651
  end
647
652
  }
@@ -690,26 +695,26 @@ describe "Integration" do
690
695
  let(:interaktor3) {
691
696
  build_interaktor do
692
697
  around do |interaktor|
693
- context.fail!
694
- context.steps << :around_before3
698
+ @context.fail!
699
+ @context.steps << :around_before3
695
700
  interaktor.call
696
- context.steps << :around_after3
701
+ @context.steps << :around_after3
697
702
  end
698
703
 
699
704
  before do
700
- context.steps << :before3
705
+ @context.steps << :before3
701
706
  end
702
707
 
703
708
  after do
704
- context.steps << :after3
709
+ @context.steps << :after3
705
710
  end
706
711
 
707
712
  def call
708
- context.steps << :call3
713
+ @context.steps << :call3
709
714
  end
710
715
 
711
716
  def rollback
712
- context.steps << :rollback3
717
+ @context.steps << :rollback3
713
718
  end
714
719
  end
715
720
  }
@@ -736,25 +741,25 @@ describe "Integration" do
736
741
  build_interaktor do
737
742
  around do |interaktor|
738
743
  unexpected_error!
739
- context.steps << :around_before3
744
+ @context.steps << :around_before3
740
745
  interaktor.call
741
- context.steps << :around_after3
746
+ @context.steps << :around_after3
742
747
  end
743
748
 
744
749
  before do
745
- context.steps << :before3
750
+ @context.steps << :before3
746
751
  end
747
752
 
748
753
  after do
749
- context.steps << :after3
754
+ @context.steps << :after3
750
755
  end
751
756
 
752
757
  def call
753
- context.steps << :call3
758
+ @context.steps << :call3
754
759
  end
755
760
 
756
761
  def rollback
757
- context.steps << :rollback3
762
+ @context.steps << :rollback3
758
763
  end
759
764
  end
760
765
  }
@@ -790,26 +795,26 @@ describe "Integration" do
790
795
  let(:interaktor3) {
791
796
  build_interaktor do
792
797
  around do |interaktor|
793
- context.steps << :around_before3
798
+ @context.steps << :around_before3
794
799
  interaktor.call
795
- context.steps << :around_after3
800
+ @context.steps << :around_after3
796
801
  end
797
802
 
798
803
  before do
799
- context.fail!
800
- context.steps << :before3
804
+ @context.fail!
805
+ @context.steps << :before3
801
806
  end
802
807
 
803
808
  after do
804
- context.steps << :after3
809
+ @context.steps << :after3
805
810
  end
806
811
 
807
812
  def call
808
- context.steps << :call3
813
+ @context.steps << :call3
809
814
  end
810
815
 
811
816
  def rollback
812
- context.steps << :rollback3
817
+ @context.steps << :rollback3
813
818
  end
814
819
  end
815
820
  }
@@ -836,26 +841,26 @@ describe "Integration" do
836
841
  let(:interaktor3) {
837
842
  build_interaktor do
838
843
  around do |interaktor|
839
- context.steps << :around_before3
844
+ @context.steps << :around_before3
840
845
  interaktor.call
841
- context.steps << :around_after3
846
+ @context.steps << :around_after3
842
847
  end
843
848
 
844
849
  before do
845
850
  unexpected_error!
846
- context.steps << :before3
851
+ @context.steps << :before3
847
852
  end
848
853
 
849
854
  after do
850
- context.steps << :after3
855
+ @context.steps << :after3
851
856
  end
852
857
 
853
858
  def call
854
- context.steps << :call3
859
+ @context.steps << :call3
855
860
  end
856
861
 
857
862
  def rollback
858
- context.steps << :rollback3
863
+ @context.steps << :rollback3
859
864
  end
860
865
  end
861
866
  }
@@ -892,26 +897,26 @@ describe "Integration" do
892
897
  let(:interaktor3) {
893
898
  build_interaktor do
894
899
  around do |interaktor|
895
- context.steps << :around_before3
900
+ @context.steps << :around_before3
896
901
  interaktor.call
897
- context.steps << :around_after3
902
+ @context.steps << :around_after3
898
903
  end
899
904
 
900
905
  before do
901
- context.steps << :before3
906
+ @context.steps << :before3
902
907
  end
903
908
 
904
909
  after do
905
- context.steps << :after3
910
+ @context.steps << :after3
906
911
  end
907
912
 
908
913
  def call
909
- context.fail!
910
- context.steps << :call3
914
+ @context.fail!
915
+ @context.steps << :call3
911
916
  end
912
917
 
913
918
  def rollback
914
- context.steps << :rollback3
919
+ @context.steps << :rollback3
915
920
  end
916
921
  end
917
922
  }
@@ -938,26 +943,26 @@ describe "Integration" do
938
943
  let(:interaktor3) {
939
944
  build_interaktor do
940
945
  around do |interaktor|
941
- context.steps << :around_before3
946
+ @context.steps << :around_before3
942
947
  interaktor.call
943
- context.steps << :around_after3
948
+ @context.steps << :around_after3
944
949
  end
945
950
 
946
951
  before do
947
- context.steps << :before3
952
+ @context.steps << :before3
948
953
  end
949
954
 
950
955
  after do
951
- context.steps << :after3
956
+ @context.steps << :after3
952
957
  end
953
958
 
954
959
  def call
955
960
  unexpected_error!
956
- context.steps << :call3
961
+ @context.steps << :call3
957
962
  end
958
963
 
959
964
  def rollback
960
- context.steps << :rollback3
965
+ @context.steps << :rollback3
961
966
  end
962
967
  end
963
968
  }
@@ -994,26 +999,26 @@ describe "Integration" do
994
999
  let(:interaktor3) {
995
1000
  build_interaktor do
996
1001
  around do |interaktor|
997
- context.steps << :around_before3
1002
+ @context.steps << :around_before3
998
1003
  interaktor.call
999
- context.steps << :around_after3
1004
+ @context.steps << :around_after3
1000
1005
  end
1001
1006
 
1002
1007
  before do
1003
- context.steps << :before3
1008
+ @context.steps << :before3
1004
1009
  end
1005
1010
 
1006
1011
  after do
1007
- context.fail!
1008
- context.steps << :after3
1012
+ @context.fail!
1013
+ @context.steps << :after3
1009
1014
  end
1010
1015
 
1011
1016
  def call
1012
- context.steps << :call3
1017
+ @context.steps << :call3
1013
1018
  end
1014
1019
 
1015
1020
  def rollback
1016
- context.steps << :rollback3
1021
+ @context.steps << :rollback3
1017
1022
  end
1018
1023
  end
1019
1024
  }
@@ -1041,26 +1046,26 @@ describe "Integration" do
1041
1046
  let(:interaktor3) {
1042
1047
  build_interaktor do
1043
1048
  around do |interaktor|
1044
- context.steps << :around_before3
1049
+ @context.steps << :around_before3
1045
1050
  interaktor.call
1046
- context.steps << :around_after3
1051
+ @context.steps << :around_after3
1047
1052
  end
1048
1053
 
1049
1054
  before do
1050
- context.steps << :before3
1055
+ @context.steps << :before3
1051
1056
  end
1052
1057
 
1053
1058
  after do
1054
1059
  unexpected_error!
1055
- context.steps << :after3
1060
+ @context.steps << :after3
1056
1061
  end
1057
1062
 
1058
1063
  def call
1059
- context.steps << :call3
1064
+ @context.steps << :call3
1060
1065
  end
1061
1066
 
1062
1067
  def rollback
1063
- context.steps << :rollback3
1068
+ @context.steps << :rollback3
1064
1069
  end
1065
1070
  end
1066
1071
  }
@@ -1098,26 +1103,26 @@ describe "Integration" do
1098
1103
  let(:interaktor3) {
1099
1104
  build_interaktor do
1100
1105
  around do |interaktor|
1101
- context.steps << :around_before3
1106
+ @context.steps << :around_before3
1102
1107
  interaktor.call
1103
- context.fail!
1104
- context.steps << :around_after3
1108
+ @context.fail!
1109
+ @context.steps << :around_after3
1105
1110
  end
1106
1111
 
1107
1112
  before do
1108
- context.steps << :before3
1113
+ @context.steps << :before3
1109
1114
  end
1110
1115
 
1111
1116
  after do
1112
- context.steps << :after3
1117
+ @context.steps << :after3
1113
1118
  end
1114
1119
 
1115
1120
  def call
1116
- context.steps << :call3
1121
+ @context.steps << :call3
1117
1122
  end
1118
1123
 
1119
1124
  def rollback
1120
- context.steps << :rollback3
1125
+ @context.steps << :rollback3
1121
1126
  end
1122
1127
  end
1123
1128
  }
@@ -1145,26 +1150,26 @@ describe "Integration" do
1145
1150
  let(:interaktor3) {
1146
1151
  build_interaktor do
1147
1152
  around do |interaktor|
1148
- context.steps << :around_before3
1153
+ @context.steps << :around_before3
1149
1154
  interaktor.call
1150
1155
  unexpected_error!
1151
- context.steps << :around_after3
1156
+ @context.steps << :around_after3
1152
1157
  end
1153
1158
 
1154
1159
  before do
1155
- context.steps << :before3
1160
+ @context.steps << :before3
1156
1161
  end
1157
1162
 
1158
1163
  after do
1159
- context.steps << :after3
1164
+ @context.steps << :after3
1160
1165
  end
1161
1166
 
1162
1167
  def call
1163
- context.steps << :call3
1168
+ @context.steps << :call3
1164
1169
  end
1165
1170
 
1166
1171
  def rollback
1167
- context.steps << :rollback3
1172
+ @context.steps << :rollback3
1168
1173
  end
1169
1174
  end
1170
1175
  }
@@ -1202,26 +1207,26 @@ describe "Integration" do
1202
1207
  let(:interaktor4b) {
1203
1208
  build_interaktor do
1204
1209
  around do |interaktor|
1205
- context.fail!
1206
- context.steps << :around_before4b
1210
+ @context.fail!
1211
+ @context.steps << :around_before4b
1207
1212
  interaktor.call
1208
- context.steps << :around_after4b
1213
+ @context.steps << :around_after4b
1209
1214
  end
1210
1215
 
1211
1216
  before do
1212
- context.steps << :before4b
1217
+ @context.steps << :before4b
1213
1218
  end
1214
1219
 
1215
1220
  after do
1216
- context.steps << :after4b
1221
+ @context.steps << :after4b
1217
1222
  end
1218
1223
 
1219
1224
  def call
1220
- context.steps << :call4b
1225
+ @context.steps << :call4b
1221
1226
  end
1222
1227
 
1223
1228
  def rollback
1224
- context.steps << :rollback4b
1229
+ @context.steps << :rollback4b
1225
1230
  end
1226
1231
  end
1227
1232
  }
@@ -1253,25 +1258,25 @@ describe "Integration" do
1253
1258
  build_interaktor do
1254
1259
  around do |interaktor|
1255
1260
  unexpected_error!
1256
- context.steps << :around_before4b
1261
+ @context.steps << :around_before4b
1257
1262
  interaktor.call
1258
- context.steps << :around_after4b
1263
+ @context.steps << :around_after4b
1259
1264
  end
1260
1265
 
1261
1266
  before do
1262
- context.steps << :before4b
1267
+ @context.steps << :before4b
1263
1268
  end
1264
1269
 
1265
1270
  after do
1266
- context.steps << :after4b
1271
+ @context.steps << :after4b
1267
1272
  end
1268
1273
 
1269
1274
  def call
1270
- context.steps << :call4b
1275
+ @context.steps << :call4b
1271
1276
  end
1272
1277
 
1273
1278
  def rollback
1274
- context.steps << :rollback4b
1279
+ @context.steps << :rollback4b
1275
1280
  end
1276
1281
  end
1277
1282
  }
@@ -1312,26 +1317,26 @@ describe "Integration" do
1312
1317
  let(:interaktor4b) {
1313
1318
  build_interaktor do
1314
1319
  around do |interaktor|
1315
- context.steps << :around_before4b
1320
+ @context.steps << :around_before4b
1316
1321
  interaktor.call
1317
- context.steps << :around_after4b
1322
+ @context.steps << :around_after4b
1318
1323
  end
1319
1324
 
1320
1325
  before do
1321
- context.fail!
1322
- context.steps << :before4b
1326
+ @context.fail!
1327
+ @context.steps << :before4b
1323
1328
  end
1324
1329
 
1325
1330
  after do
1326
- context.steps << :after4b
1331
+ @context.steps << :after4b
1327
1332
  end
1328
1333
 
1329
1334
  def call
1330
- context.steps << :call4b
1335
+ @context.steps << :call4b
1331
1336
  end
1332
1337
 
1333
1338
  def rollback
1334
- context.steps << :rollback4b
1339
+ @context.steps << :rollback4b
1335
1340
  end
1336
1341
  end
1337
1342
  }
@@ -1363,26 +1368,26 @@ describe "Integration" do
1363
1368
  let(:interaktor4b) {
1364
1369
  build_interaktor do
1365
1370
  around do |interaktor|
1366
- context.steps << :around_before4b
1371
+ @context.steps << :around_before4b
1367
1372
  interaktor.call
1368
- context.steps << :around_after4b
1373
+ @context.steps << :around_after4b
1369
1374
  end
1370
1375
 
1371
1376
  before do
1372
1377
  unexpected_error!
1373
- context.steps << :before4b
1378
+ @context.steps << :before4b
1374
1379
  end
1375
1380
 
1376
1381
  after do
1377
- context.steps << :after4b
1382
+ @context.steps << :after4b
1378
1383
  end
1379
1384
 
1380
1385
  def call
1381
- context.steps << :call4b
1386
+ @context.steps << :call4b
1382
1387
  end
1383
1388
 
1384
1389
  def rollback
1385
- context.steps << :rollback4b
1390
+ @context.steps << :rollback4b
1386
1391
  end
1387
1392
  end
1388
1393
  }
@@ -1424,26 +1429,26 @@ describe "Integration" do
1424
1429
  let(:interaktor4b) {
1425
1430
  build_interaktor do
1426
1431
  around do |interaktor|
1427
- context.steps << :around_before4b
1432
+ @context.steps << :around_before4b
1428
1433
  interaktor.call
1429
- context.steps << :around_after4b
1434
+ @context.steps << :around_after4b
1430
1435
  end
1431
1436
 
1432
1437
  before do
1433
- context.steps << :before4b
1438
+ @context.steps << :before4b
1434
1439
  end
1435
1440
 
1436
1441
  after do
1437
- context.steps << :after4b
1442
+ @context.steps << :after4b
1438
1443
  end
1439
1444
 
1440
1445
  def call
1441
- context.fail!
1442
- context.steps << :call4b
1446
+ @context.fail!
1447
+ @context.steps << :call4b
1443
1448
  end
1444
1449
 
1445
1450
  def rollback
1446
- context.steps << :rollback4b
1451
+ @context.steps << :rollback4b
1447
1452
  end
1448
1453
  end
1449
1454
  }
@@ -1475,26 +1480,26 @@ describe "Integration" do
1475
1480
  let(:interaktor4b) {
1476
1481
  build_interaktor do
1477
1482
  around do |interaktor|
1478
- context.steps << :around_before4b
1483
+ @context.steps << :around_before4b
1479
1484
  interaktor.call
1480
- context.steps << :around_after4b
1485
+ @context.steps << :around_after4b
1481
1486
  end
1482
1487
 
1483
1488
  before do
1484
- context.steps << :before4b
1489
+ @context.steps << :before4b
1485
1490
  end
1486
1491
 
1487
1492
  after do
1488
- context.steps << :after4b
1493
+ @context.steps << :after4b
1489
1494
  end
1490
1495
 
1491
1496
  def call
1492
1497
  unexpected_error!
1493
- context.steps << :call4b
1498
+ @context.steps << :call4b
1494
1499
  end
1495
1500
 
1496
1501
  def rollback
1497
- context.steps << :rollback4b
1502
+ @context.steps << :rollback4b
1498
1503
  end
1499
1504
  end
1500
1505
  }
@@ -1536,26 +1541,26 @@ describe "Integration" do
1536
1541
  let(:interaktor4b) {
1537
1542
  build_interaktor do
1538
1543
  around do |interaktor|
1539
- context.steps << :around_before4b
1544
+ @context.steps << :around_before4b
1540
1545
  interaktor.call
1541
- context.steps << :around_after4b
1546
+ @context.steps << :around_after4b
1542
1547
  end
1543
1548
 
1544
1549
  before do
1545
- context.steps << :before4b
1550
+ @context.steps << :before4b
1546
1551
  end
1547
1552
 
1548
1553
  after do
1549
- context.fail!
1550
- context.steps << :after4b
1554
+ @context.fail!
1555
+ @context.steps << :after4b
1551
1556
  end
1552
1557
 
1553
1558
  def call
1554
- context.steps << :call4b
1559
+ @context.steps << :call4b
1555
1560
  end
1556
1561
 
1557
1562
  def rollback
1558
- context.steps << :rollback4b
1563
+ @context.steps << :rollback4b
1559
1564
  end
1560
1565
  end
1561
1566
  }
@@ -1588,26 +1593,26 @@ describe "Integration" do
1588
1593
  let(:interaktor4b) {
1589
1594
  build_interaktor do
1590
1595
  around do |interaktor|
1591
- context.steps << :around_before4b
1596
+ @context.steps << :around_before4b
1592
1597
  interaktor.call
1593
- context.steps << :around_after4b
1598
+ @context.steps << :around_after4b
1594
1599
  end
1595
1600
 
1596
1601
  before do
1597
- context.steps << :before4b
1602
+ @context.steps << :before4b
1598
1603
  end
1599
1604
 
1600
1605
  after do
1601
1606
  unexpected_error!
1602
- context.steps << :after4b
1607
+ @context.steps << :after4b
1603
1608
  end
1604
1609
 
1605
1610
  def call
1606
- context.steps << :call4b
1611
+ @context.steps << :call4b
1607
1612
  end
1608
1613
 
1609
1614
  def rollback
1610
- context.steps << :rollback4b
1615
+ @context.steps << :rollback4b
1611
1616
  end
1612
1617
  end
1613
1618
  }
@@ -1650,26 +1655,26 @@ describe "Integration" do
1650
1655
  let(:interaktor4b) {
1651
1656
  build_interaktor do
1652
1657
  around do |interaktor|
1653
- context.steps << :around_before4b
1658
+ @context.steps << :around_before4b
1654
1659
  interaktor.call
1655
- context.fail!
1656
- context.steps << :around_after4b
1660
+ @context.fail!
1661
+ @context.steps << :around_after4b
1657
1662
  end
1658
1663
 
1659
1664
  before do
1660
- context.steps << :before4b
1665
+ @context.steps << :before4b
1661
1666
  end
1662
1667
 
1663
1668
  after do
1664
- context.steps << :after4b
1669
+ @context.steps << :after4b
1665
1670
  end
1666
1671
 
1667
1672
  def call
1668
- context.steps << :call4b
1673
+ @context.steps << :call4b
1669
1674
  end
1670
1675
 
1671
1676
  def rollback
1672
- context.steps << :rollback4b
1677
+ @context.steps << :rollback4b
1673
1678
  end
1674
1679
  end
1675
1680
  }
@@ -1702,26 +1707,26 @@ describe "Integration" do
1702
1707
  let(:interaktor4b) {
1703
1708
  build_interaktor do
1704
1709
  around do |interaktor|
1705
- context.steps << :around_before4b
1710
+ @context.steps << :around_before4b
1706
1711
  interaktor.call
1707
1712
  unexpected_error!
1708
- context.steps << :around_after4b
1713
+ @context.steps << :around_after4b
1709
1714
  end
1710
1715
 
1711
1716
  before do
1712
- context.steps << :before4b
1717
+ @context.steps << :before4b
1713
1718
  end
1714
1719
 
1715
1720
  after do
1716
- context.steps << :after4b
1721
+ @context.steps << :after4b
1717
1722
  end
1718
1723
 
1719
1724
  def call
1720
- context.steps << :call4b
1725
+ @context.steps << :call4b
1721
1726
  end
1722
1727
 
1723
1728
  def rollback
1724
- context.steps << :rollback4b
1729
+ @context.steps << :rollback4b
1725
1730
  end
1726
1731
  end
1727
1732
  }
@@ -1784,3 +1789,8 @@ describe "Integration" do
1784
1789
  end
1785
1790
  end
1786
1791
  end
1792
+
1793
+ # rubocop:enable RSpec/InstanceVariable
1794
+ # rubocop:enable RSpec/MultipleMemoizedHelpers
1795
+ # rubocop:enable RSpec/ScatteredSetup
1796
+ # rubocop:enable Style/DocumentationMethod