activeinteractor 1.0.5 → 1.1.3

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -2
  3. data/README.md +10 -29
  4. data/lib/active_interactor/context/attributes.rb +25 -4
  5. data/lib/active_interactor/context/errors.rb +11 -1
  6. data/lib/active_interactor/organizer/interactor_interface.rb +24 -7
  7. data/lib/active_interactor/organizer/perform.rb +11 -2
  8. data/lib/active_interactor/version.rb +41 -3
  9. data/spec/active_interactor/base_spec.rb +1 -0
  10. data/spec/active_interactor/config_spec.rb +1 -0
  11. data/spec/active_interactor/context/base_spec.rb +16 -0
  12. data/spec/active_interactor/error_spec.rb +3 -1
  13. data/spec/active_interactor/interactor/worker_spec.rb +3 -0
  14. data/spec/active_interactor/organizer/base_spec.rb +18 -1
  15. data/spec/active_interactor/organizer/interactor_interface_collection_spec.rb +2 -0
  16. data/spec/active_interactor/organizer/interactor_interface_spec.rb +75 -2
  17. data/spec/active_interactor/version_spec.rb +119 -0
  18. data/spec/active_interactor_spec.rb +0 -6
  19. data/spec/integration/a_basic_organizer_spec.rb +139 -1
  20. data/spec/integration/a_failing_interactor_spec.rb +1 -0
  21. data/spec/integration/an_interactor_with_after_perform_callbacks_spec.rb +1 -0
  22. data/spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb +1 -0
  23. data/spec/integration/an_interactor_with_an_existing_context_class_spec.rb +1 -0
  24. data/spec/integration/an_interactor_with_before_perform_callbacks_spec.rb +1 -0
  25. data/spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb +1 -0
  26. data/spec/integration/an_interactor_with_validations_on_called_spec.rb +1 -0
  27. data/spec/integration/an_interactor_with_validations_on_calling_spec.rb +1 -0
  28. data/spec/integration/an_interactor_with_validations_spec.rb +2 -0
  29. data/spec/integration/an_organizer_with_after_each_callbacks_spec.rb +1 -0
  30. data/spec/integration/an_organizer_with_before_each_callbacks_spec.rb +1 -0
  31. data/spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb +14 -2
  32. data/spec/integration/an_organizer_with_failing_nested_organizer_spec.rb +47 -0
  33. data/spec/integration/an_organizer_with_options_callbacks_spec.rb +64 -0
  34. data/spec/spec_helper.rb +3 -20
  35. data/spec/support/coverage.rb +50 -0
  36. data/spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb +8 -0
  37. data/spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb +2 -0
  38. data/spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb +3 -0
  39. metadata +45 -37
@@ -5,6 +5,7 @@ require 'spec_helper'
5
5
  RSpec.describe ActiveInteractor::Organizer::InteractorInterfaceCollection do
6
6
  describe '#add' do
7
7
  subject { instance.add(interactor) }
8
+
8
9
  let(:instance) { described_class.new }
9
10
 
10
11
  context 'with an interactor that does not exist' do
@@ -57,6 +58,7 @@ RSpec.describe ActiveInteractor::Organizer::InteractorInterfaceCollection do
57
58
 
58
59
  describe '#concat' do
59
60
  subject { instance.concat(interactors) }
61
+
60
62
  let(:instance) { described_class.new }
61
63
 
62
64
  context 'with two existing interactors' do
@@ -84,6 +84,72 @@ RSpec.describe ActiveInteractor::Organizer::InteractorInterface do
84
84
  end
85
85
  end
86
86
 
87
+ context 'with options {:before => :some_method }' do
88
+ let(:options) { { before: :some_method } }
89
+
90
+ describe '#callbacks' do
91
+ subject { instance.callbacks }
92
+
93
+ it { is_expected.to eq(before: :some_method) }
94
+ end
95
+
96
+ describe '#perform_options' do
97
+ subject { instance.perform_options }
98
+
99
+ it { is_expected.to be_empty }
100
+ end
101
+ end
102
+
103
+ context 'with options {:before => -> { context.test = true } }' do
104
+ let(:options) { { before: -> { context.test = true } } }
105
+
106
+ describe '#callbacks' do
107
+ subject { instance.callbacks }
108
+
109
+ it { expect(subject[:before]).not_to be_nil }
110
+ it { expect(subject[:before]).to be_a Proc }
111
+ end
112
+
113
+ describe '#perform_options' do
114
+ subject { instance.perform_options }
115
+
116
+ it { is_expected.to be_empty }
117
+ end
118
+ end
119
+
120
+ context 'with options {:after => :some_method }' do
121
+ let(:options) { { after: :some_method } }
122
+
123
+ describe '#callbacks' do
124
+ subject { instance.callbacks }
125
+
126
+ it { is_expected.to eq(after: :some_method) }
127
+ end
128
+
129
+ describe '#perform_options' do
130
+ subject { instance.perform_options }
131
+
132
+ it { is_expected.to be_empty }
133
+ end
134
+ end
135
+
136
+ context 'with options {:after => -> { context.test = true } }' do
137
+ let(:options) { { after: -> { context.test = true } } }
138
+
139
+ describe '#callbacks' do
140
+ subject { instance.callbacks }
141
+
142
+ it { expect(subject[:after]).not_to be_nil }
143
+ it { expect(subject[:after]).to be_a Proc }
144
+ end
145
+
146
+ describe '#perform_options' do
147
+ subject { instance.perform_options }
148
+
149
+ it { is_expected.to be_empty }
150
+ end
151
+ end
152
+
87
153
  context 'with options { :validate => false }' do
88
154
  let(:options) { { validate: false } }
89
155
 
@@ -100,8 +166,8 @@ RSpec.describe ActiveInteractor::Organizer::InteractorInterface do
100
166
  end
101
167
  end
102
168
 
103
- context 'with options { :if => :some_method, :validate => false }' do
104
- let(:options) { { if: :some_method, validate: false } }
169
+ context 'with options { :if => :some_method, :validate => false, :before => :other_method }' do
170
+ let(:options) { { if: :some_method, validate: false, before: :other_method } }
105
171
 
106
172
  describe '#filters' do
107
173
  subject { instance.filters }
@@ -109,6 +175,12 @@ RSpec.describe ActiveInteractor::Organizer::InteractorInterface do
109
175
  it { is_expected.to eq(if: :some_method) }
110
176
  end
111
177
 
178
+ describe '#callbacks' do
179
+ subject { instance.callbacks }
180
+
181
+ it { is_expected.to eq(before: :other_method) }
182
+ end
183
+
112
184
  describe '#perform_options' do
113
185
  subject { instance.perform_options }
114
186
 
@@ -149,6 +221,7 @@ RSpec.describe ActiveInteractor::Organizer::InteractorInterface do
149
221
  context 'when interactors are passed as strings' do
150
222
  let(:interactor_class) { 'TestInteractor' }
151
223
  let(:options) { {} }
224
+
152
225
  include_examples 'an instance of InteractorInterface correctly parse options'
153
226
 
154
227
  describe '#interactor_class' do
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ActiveInteractor::Version do
6
+ describe '::MAJOR' do
7
+ subject(:major) { described_class::MAJOR }
8
+
9
+ it { is_expected.to be_a Integer }
10
+ end
11
+
12
+ describe '::MINOR' do
13
+ subject(:minor) { described_class::MINOR }
14
+
15
+ it { is_expected.to be_a Integer }
16
+ end
17
+
18
+ describe '::PATCH' do
19
+ subject(:patch) { described_class::PATCH }
20
+
21
+ it { is_expected.to be_a Integer }
22
+ end
23
+
24
+ describe '::PRE' do
25
+ subject(:pre) { described_class::PRE }
26
+
27
+ it 'is a String or Nil' do
28
+ expect([String, NilClass]).to include pre.class
29
+ end
30
+ end
31
+
32
+ describe '::META' do
33
+ subject(:meta) { described_class::META }
34
+
35
+ it 'is a String or Nil' do
36
+ expect([String, NilClass]).to include meta.class
37
+ end
38
+ end
39
+
40
+ describe '.gem_version' do
41
+ subject(:gem_version) { described_class.gem_version }
42
+
43
+ context 'when version is 1.0.0-beta.1+test' do
44
+ before do
45
+ stub_const('ActiveInteractor::Version::MAJOR', 1)
46
+ stub_const('ActiveInteractor::Version::MINOR', 0)
47
+ stub_const('ActiveInteractor::Version::PATCH', 0)
48
+ stub_const('ActiveInteractor::Version::PRE', 'beta.1')
49
+ stub_const('ActiveInteractor::Version::META', 'test')
50
+ end
51
+
52
+ it { is_expected.to eq '1.0.0.beta.1.test' }
53
+ end
54
+
55
+ context 'when version is 1.0.0+test' do
56
+ before do
57
+ stub_const('ActiveInteractor::Version::MAJOR', 1)
58
+ stub_const('ActiveInteractor::Version::MINOR', 0)
59
+ stub_const('ActiveInteractor::Version::PATCH', 0)
60
+ stub_const('ActiveInteractor::Version::PRE', nil)
61
+ stub_const('ActiveInteractor::Version::META', 'test')
62
+ end
63
+
64
+ it { is_expected.to eq '1.0.0' }
65
+ end
66
+ end
67
+
68
+ describe '.semver' do
69
+ subject(:semver) { described_class.semver }
70
+
71
+ context 'when version is 1.0.0' do
72
+ before do
73
+ stub_const('ActiveInteractor::Version::MAJOR', 1)
74
+ stub_const('ActiveInteractor::Version::MINOR', 0)
75
+ stub_const('ActiveInteractor::Version::PATCH', 0)
76
+ stub_const('ActiveInteractor::Version::PRE', nil)
77
+ stub_const('ActiveInteractor::Version::META', nil)
78
+ end
79
+
80
+ it { is_expected.to eq '1.0.0' }
81
+ end
82
+
83
+ context 'when version is 1.0.0-beta.1' do
84
+ before do
85
+ stub_const('ActiveInteractor::Version::MAJOR', 1)
86
+ stub_const('ActiveInteractor::Version::MINOR', 0)
87
+ stub_const('ActiveInteractor::Version::PATCH', 0)
88
+ stub_const('ActiveInteractor::Version::PRE', 'beta.1')
89
+ stub_const('ActiveInteractor::Version::META', nil)
90
+ end
91
+
92
+ it { is_expected.to eq '1.0.0-beta.1' }
93
+ end
94
+
95
+ context 'when version is 1.0.0-beta.1+test' do
96
+ before do
97
+ stub_const('ActiveInteractor::Version::MAJOR', 1)
98
+ stub_const('ActiveInteractor::Version::MINOR', 0)
99
+ stub_const('ActiveInteractor::Version::PATCH', 0)
100
+ stub_const('ActiveInteractor::Version::PRE', 'beta.1')
101
+ stub_const('ActiveInteractor::Version::META', 'test')
102
+ end
103
+
104
+ it { is_expected.to eq '1.0.0-beta.1+test' }
105
+ end
106
+
107
+ context 'when version is 1.0.0+test' do
108
+ before do
109
+ stub_const('ActiveInteractor::Version::MAJOR', 1)
110
+ stub_const('ActiveInteractor::Version::MINOR', 0)
111
+ stub_const('ActiveInteractor::Version::PATCH', 0)
112
+ stub_const('ActiveInteractor::Version::PRE', nil)
113
+ stub_const('ActiveInteractor::Version::META', 'test')
114
+ end
115
+
116
+ it { is_expected.to eq '1.0.0+test' }
117
+ end
118
+ end
119
+ end
@@ -3,12 +3,6 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe ActiveInteractor do
6
- describe '::VERSION' do
7
- subject { described_class::VERSION }
8
-
9
- it { is_expected.to be_a String }
10
- end
11
-
12
6
  describe '.config' do
13
7
  subject { described_class.config }
14
8
 
@@ -60,11 +60,13 @@ RSpec.describe 'A basic organizer', type: :integration do
60
60
  it { expect { subject }.not_to raise_error }
61
61
  it { is_expected.to be_a interactor_class.context_class }
62
62
  it { is_expected.to be_failure }
63
+
63
64
  it 'is expected to receive #rollback on the first interactor' do
64
65
  expect_any_instance_of(test_interactor_1).to receive(:rollback)
65
66
  .and_call_original
66
67
  subject
67
68
  end
69
+
68
70
  it 'is expected not to receive #perform! on the second interactor' do
69
71
  expect_any_instance_of(test_interactor_2).not_to receive(:perform!)
70
72
  subject
@@ -84,6 +86,7 @@ RSpec.describe 'A basic organizer', type: :integration do
84
86
  it { is_expected.to be_a interactor_class.context_class }
85
87
  it { is_expected.to be_failure }
86
88
  it { expect(subject.errors.count).to eq 1 }
89
+
87
90
  it 'is expected to have errors "something went wrong" on :context' do
88
91
  expect(subject.errors[:context]).not_to be_empty
89
92
  expect(subject.errors[:context]).to include 'something went wrong'
@@ -107,6 +110,7 @@ RSpec.describe 'A basic organizer', type: :integration do
107
110
  it { expect { subject }.not_to raise_error }
108
111
  it { is_expected.to be_a interactor_class.context_class }
109
112
  it { is_expected.to be_failure }
113
+
110
114
  it 'is expected to receive #rollback on all interactors' do
111
115
  expect_any_instance_of(test_interactor_2).to receive(:rollback)
112
116
  expect_any_instance_of(test_interactor_1).to receive(:rollback)
@@ -127,6 +131,7 @@ RSpec.describe 'A basic organizer', type: :integration do
127
131
  it { is_expected.to be_a interactor_class.context_class }
128
132
  it { is_expected.to be_failure }
129
133
  it { expect(subject.errors.count).to eq 1 }
134
+
130
135
  it 'is expected to have errors "something went wrong" on :context' do
131
136
  expect(subject.errors[:context]).not_to be_empty
132
137
  expect(subject.errors[:context]).to include 'something went wrong'
@@ -140,6 +145,8 @@ RSpec.describe 'A basic organizer', type: :integration do
140
145
  let!(:test_context_class) do
141
146
  build_context('TestInteractor1Context') do
142
147
  attributes :foo
148
+ attributes :baz
149
+ attributes :zoo
143
150
  end
144
151
  end
145
152
 
@@ -151,6 +158,12 @@ RSpec.describe 'A basic organizer', type: :integration do
151
158
  context.has_foo_as_element = context[:foo].present?
152
159
  context.has_bar_as_method = context.bar.present?
153
160
  context.has_bar_as_element = context[:bar].present?
161
+ context.baz = 'baz'
162
+ context.has_baz_as_method = context.baz.present?
163
+ context.has_baz_as_element = context[:baz].present?
164
+ context[:zoo] = 'zoo'
165
+ context.has_zoo_as_method = context.zoo.present?
166
+ context.has_zoo_as_element = context[:zoo].present?
154
167
  end
155
168
  end
156
169
  end
@@ -167,13 +180,18 @@ RSpec.describe 'A basic organizer', type: :integration do
167
180
 
168
181
  describe '.perform' do
169
182
  subject(:result) { interactor_class.perform(context_attributes) }
170
- it { is_expected.to have_attributes(foo: 'foo', bar: 'bar') }
183
+
184
+ it { is_expected.to have_attributes(foo: 'foo', bar: 'bar', baz: 'baz', zoo: 'zoo') }
171
185
 
172
186
  it 'is expected to copy all attributes in the contexts to each interactor' do
173
187
  expect(subject.has_foo_as_method).to be true
174
188
  expect(subject.has_foo_as_element).to be true
175
189
  expect(subject.has_bar_as_method).to be true
176
190
  expect(subject.has_bar_as_element).to be true
191
+ expect(subject.has_baz_as_method).to be true
192
+ expect(subject.has_baz_as_element).to be true
193
+ expect(subject.has_zoo_as_method).to be true
194
+ expect(subject.has_zoo_as_element).to be true
177
195
  end
178
196
 
179
197
  describe '#attributes' do
@@ -194,6 +212,7 @@ RSpec.describe 'A basic organizer', type: :integration do
194
212
 
195
213
  describe '.perform' do
196
214
  subject(:result) { interactor_class.perform(context_attributes) }
215
+
197
216
  it { is_expected.to have_attributes(foo: 'foo', bar: 'bar') }
198
217
 
199
218
  it 'is expected to copy all attributes in the contexts to each interactor' do
@@ -212,5 +231,124 @@ RSpec.describe 'A basic organizer', type: :integration do
212
231
  end
213
232
  end
214
233
  end
234
+
235
+ context 'when passing default attributes on the organizer and its interactors' do
236
+ let!(:test_organizer_context_class) do
237
+ build_context('TestOrganizerContext') do
238
+ attribute :foo
239
+ attribute :baz
240
+ attribute :zoo, default: 'zoo'
241
+ attribute :taz, default: 'taz0'
242
+ end
243
+ end
244
+
245
+ let!(:test_interactor_3_context_class) do
246
+ build_context('TestInteractor3Context') do
247
+ attribute :foo
248
+ attribute :bar, default: 'bar'
249
+ attribute :baz, default: 'baz'
250
+ attribute :zoo
251
+ attribute :taz, default: 'taz3'
252
+ end
253
+ end
254
+
255
+ let!(:test_interactor_4_context_class) do
256
+ build_context('TestInteractor4Context') do
257
+ attribute :foo
258
+ attribute :bar, default: 'bar'
259
+ attribute :baz
260
+ end
261
+ end
262
+
263
+ let!(:test_interactor_3) do
264
+ build_interactor('TestInteractor3') do
265
+ def perform
266
+ context.bar = 'bar'
267
+ context.taz_is_set_at_3 = (context.taz == 'taz')
268
+ context.baz_is_set_at_3 = (context.baz == 'baz')
269
+ context.zoo_is_set_at_3 = (context.zoo == 'zoo')
270
+ end
271
+ end
272
+ end
273
+
274
+ let!(:test_interactor_4) do
275
+ build_interactor('TestInteractor4') do
276
+ def perform
277
+ context.taz_is_set_at_4 = (context.taz == 'taz')
278
+ context.baz_is_set_at_4 = (context.baz == 'baz')
279
+ context.zoo_is_set_at_4 = (context.zoo == 'zoo')
280
+ end
281
+ end
282
+ end
283
+
284
+ let!(:interactor_class) do
285
+ build_organizer('TestOrganizer') do
286
+ organize TestInteractor3, TestInteractor4
287
+ end
288
+ end
289
+
290
+ describe '.context_class' do
291
+ describe 'TestOrganizer' do
292
+ subject { interactor_class.context_class }
293
+
294
+ it { is_expected.to eq TestOrganizerContext }
295
+ it { is_expected.to be < ActiveInteractor::Context::Base }
296
+ end
297
+
298
+ describe 'TestInteractor3' do
299
+ subject { test_interactor_3.context_class }
300
+
301
+ it { is_expected.to eq TestInteractor3Context }
302
+ it { is_expected.to be < ActiveInteractor::Context::Base }
303
+ end
304
+
305
+ describe 'TestInteractor4' do
306
+ subject { test_interactor_4.context_class }
307
+
308
+ it { is_expected.to eq TestInteractor4Context }
309
+ it { is_expected.to be < ActiveInteractor::Context::Base }
310
+ end
311
+ end
312
+
313
+ describe '.perform' do
314
+ subject(:result) { interactor_class.perform(context_attributes) }
315
+
316
+ context 'when inputs are not defined' do
317
+ let(:context_attributes) { {} }
318
+
319
+ it { is_expected.to have_attributes(foo: nil, bar: 'bar', baz: 'baz') }
320
+ end
321
+
322
+ context 'when [:foo] is defined' do
323
+ let(:context_attributes) { { foo: 'foo' } }
324
+
325
+ it { is_expected.to have_attributes(foo: 'foo', bar: 'bar', baz: 'baz') }
326
+ end
327
+
328
+ context 'when [:taz] is defined' do
329
+ let(:context_attributes) { { taz: 'taz' } }
330
+
331
+ it { is_expected.to have_attributes(taz: 'taz', taz_is_set_at_3: true, taz_is_set_at_4: true) }
332
+ end
333
+
334
+ context 'when [:bar] is nil' do
335
+ let(:context_attributes) { { bar: nil } }
336
+
337
+ it { is_expected.to have_attributes(foo: nil, bar: 'bar', baz: 'baz') }
338
+ end
339
+
340
+ context 'when [:baz] is nil' do
341
+ let(:context_attributes) { {} }
342
+
343
+ it { is_expected.to have_attributes(baz: 'baz', baz_is_set_at_3: true, baz_is_set_at_4: true) }
344
+ end
345
+
346
+ context 'when [:zoo] is nil' do
347
+ let(:context_attributes) { {} }
348
+
349
+ it { is_expected.to have_attributes(zoo: 'zoo', zoo_is_set_at_3: true, zoo_is_set_at_4: true) }
350
+ end
351
+ end
352
+ end
215
353
  end
216
354
  end
@@ -28,6 +28,7 @@ RSpec.describe 'A failing interactor', type: :integration do
28
28
  it { expect { subject }.not_to raise_error }
29
29
  it { is_expected.to be_a interactor_class.context_class }
30
30
  it { is_expected.to be_failure }
31
+
31
32
  it 'is expected to receive #rollback' do
32
33
  expect_any_instance_of(interactor_class).to receive(:rollback)
33
34
  subject
@@ -22,6 +22,7 @@ RSpec.describe 'An interactor with .after_perform callbacks', type: :integration
22
22
 
23
23
  it { is_expected.to be_a interactor_class.context_class }
24
24
  it { is_expected.to be_successful }
25
+
25
26
  it 'is expected to receive #test_after_perform' do
26
27
  expect_any_instance_of(interactor_class).to receive(:test_after_perform)
27
28
  subject
@@ -25,6 +25,7 @@ RSpec.describe 'An interactor with .after_rollback callbacks', type: :integratio
25
25
  subject { interactor_class.perform }
26
26
 
27
27
  it { is_expected.to be_a interactor_class.context_class }
28
+
28
29
  it 'is expected to receive #test_after_rollback' do
29
30
  expect_any_instance_of(interactor_class).to receive(:test_after_rollback)
30
31
  subject
@@ -39,6 +39,7 @@ RSpec.describe 'An interactor with an existing .context_class', type: :integrati
39
39
 
40
40
  it { is_expected.to be_an AnInteractorContext }
41
41
  it { is_expected.to be_failure }
42
+
42
43
  it 'is expected to have errors on :some_field' do
43
44
  expect(subject.errors[:test_field]).not_to be_nil
44
45
  end
@@ -22,6 +22,7 @@ RSpec.describe 'An interactor with .before_perform callbacks', type: :integratio
22
22
 
23
23
  it { is_expected.to be_a interactor_class.context_class }
24
24
  it { is_expected.to be_successful }
25
+
25
26
  it 'is expected to receive #test_before_perform' do
26
27
  expect_any_instance_of(interactor_class).to receive(:test_before_perform)
27
28
  subject
@@ -25,6 +25,7 @@ RSpec.describe 'An interactor with .before_rollback callbacks', type: :integrati
25
25
  subject { interactor_class.perform }
26
26
 
27
27
  it { is_expected.to be_a interactor_class.context_class }
28
+
28
29
  it 'is expected to receive #test_before_rollback' do
29
30
  expect_any_instance_of(interactor_class).to receive(:test_before_rollback)
30
31
  subject
@@ -32,6 +32,7 @@ RSpec.describe 'An interactor with validations on :called', type: :integration d
32
32
 
33
33
  it { is_expected.to be_an TestInteractor::Context }
34
34
  it { is_expected.to be_failure }
35
+
35
36
  it 'is expected to have errors on :some_field' do
36
37
  expect(subject.errors[:test_field]).not_to be_nil
37
38
  end
@@ -28,6 +28,7 @@ RSpec.describe 'An interactor with validations on :calling', type: :integration
28
28
 
29
29
  it { is_expected.to be_an TestInteractor::Context }
30
30
  it { is_expected.to be_failure }
31
+
31
32
  it 'is expected to have errors on :some_field' do
32
33
  expect(subject.errors[:test_field]).not_to be_nil
33
34
  end
@@ -38,6 +38,7 @@ RSpec.describe 'An interactor with validations', type: :integration do
38
38
  it { is_expected.to be_a interactor_class.context_class }
39
39
  it { is_expected.to be_failure }
40
40
  it { is_expected.to have_attributes(other_field: 'failed') }
41
+
41
42
  it 'is expected to have errors on :test_field' do
42
43
  expect(subject.errors[:test_field]).not_to be_nil
43
44
  end
@@ -84,6 +85,7 @@ RSpec.describe 'An interactor with validations', type: :integration do
84
85
  it { is_expected.to be_a interactor_class.context_class }
85
86
  it { is_expected.to be_failure }
86
87
  it { is_expected.to have_attributes(test_condition: true, other_field: 'failed') }
88
+
87
89
  it 'is expected to have errors on :test_field' do
88
90
  expect(subject.errors[:test_field]).not_to be_nil
89
91
  end
@@ -25,6 +25,7 @@ RSpec.describe 'An organizer with .after_each callbacks', type: :integration do
25
25
  subject { interactor_class.perform }
26
26
 
27
27
  it { is_expected.to be_a interactor_class.context_class }
28
+
28
29
  it 'is expected to receive #test_after_each_perform twice' do
29
30
  expect_any_instance_of(interactor_class).to receive(:test_after_each_perform)
30
31
  .exactly(:twice)
@@ -25,6 +25,7 @@ RSpec.describe 'An organizer with .before_each callbacks', type: :integration do
25
25
  subject { interactor_class.perform }
26
26
 
27
27
  it { is_expected.to be_a interactor_class.context_class }
28
+
28
29
  it 'is expected to receive #test_before_each_perform twice' do
29
30
  expect_any_instance_of(interactor_class).to receive(:test_before_each_perform)
30
31
  .exactly(:twice)
@@ -7,7 +7,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
7
7
  let!(:test_interactor_2) { build_interactor('TestInteractor2') }
8
8
 
9
9
  context 'with a condition on the first interactor { :if => -> { context.test_1 } } ' \
10
- 'and a condition on the second interactor { :if => -> { context.test_2 } }' do
10
+ 'and a condition on the second interactor { :if => -> { context.test_2 } }' do
11
11
  let(:interactor_class) do
12
12
  build_organizer do
13
13
  organize do
@@ -30,6 +30,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
30
30
 
31
31
  it { is_expected.to be_a interactor_class.context_class }
32
32
  it { is_expected.to be_successful }
33
+
33
34
  it 'is expected to receive #perform on both interactors' do
34
35
  expect_any_instance_of(test_interactor_1).to receive(:perform)
35
36
  expect_any_instance_of(test_interactor_2).to receive(:perform)
@@ -42,6 +43,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
42
43
 
43
44
  it { is_expected.to be_a interactor_class.context_class }
44
45
  it { is_expected.to be_successful }
46
+
45
47
  it 'is expected to receive #perform on the first interactor' do
46
48
  expect_any_instance_of(test_interactor_1).to receive(:perform)
47
49
  subject
@@ -58,6 +60,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
58
60
 
59
61
  it { is_expected.to be_a interactor_class.context_class }
60
62
  it { is_expected.to be_successful }
63
+
61
64
  it 'is expected not to receive #perform on the first interactor' do
62
65
  expect_any_instance_of(test_interactor_1).not_to receive(:perform)
63
66
  subject
@@ -74,6 +77,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
74
77
 
75
78
  it { is_expected.to be_a interactor_class.context_class }
76
79
  it { is_expected.to be_successful }
80
+
77
81
  it 'is expected not to receive #perform on the first interactor' do
78
82
  expect_any_instance_of(test_interactor_1).not_to receive(:perform)
79
83
  subject
@@ -88,7 +92,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
88
92
  end
89
93
 
90
94
  context 'with a condition on the first interactor { :unless => -> { context.test_1 } } ' \
91
- 'and a condition on the second interactor { :unless => -> { context.test_2 } }' do
95
+ 'and a condition on the second interactor { :unless => -> { context.test_2 } }' do
92
96
  let(:interactor_class) do
93
97
  build_organizer do
94
98
  organize do
@@ -111,6 +115,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
111
115
 
112
116
  it { is_expected.to be_a interactor_class.context_class }
113
117
  it { is_expected.to be_successful }
118
+
114
119
  it 'is expected not to receive #perform on the first interactor' do
115
120
  expect_any_instance_of(test_interactor_1).not_to receive(:perform)
116
121
  subject
@@ -127,6 +132,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
127
132
 
128
133
  it { is_expected.to be_a interactor_class.context_class }
129
134
  it { is_expected.to be_successful }
135
+
130
136
  it 'is expected not to receive #perform on the first interactor' do
131
137
  expect_any_instance_of(test_interactor_1).not_to receive(:perform)
132
138
  subject
@@ -143,6 +149,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
143
149
 
144
150
  it { is_expected.to be_a interactor_class.context_class }
145
151
  it { is_expected.to be_successful }
152
+
146
153
  it 'is expected to receive #perform on the first interactor' do
147
154
  expect_any_instance_of(test_interactor_1).to receive(:perform)
148
155
  subject
@@ -159,6 +166,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
159
166
 
160
167
  it { is_expected.to be_a interactor_class.context_class }
161
168
  it { is_expected.to be_successful }
169
+
162
170
  it 'is expected to receive #perform on both interactors' do
163
171
  expect_any_instance_of(test_interactor_1).to receive(:perform)
164
172
  expect_any_instance_of(test_interactor_2).to receive(:perform)
@@ -194,6 +202,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
194
202
 
195
203
  it { is_expected.to be_a interactor_class.context_class }
196
204
  it { is_expected.to be_successful }
205
+
197
206
  it 'is expected to receive #perform on both interactors' do
198
207
  expect_any_instance_of(test_interactor_1).to receive(:perform)
199
208
  expect_any_instance_of(test_interactor_2).to receive(:perform)
@@ -228,6 +237,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
228
237
 
229
238
  it { is_expected.to be_a interactor_class.context_class }
230
239
  it { is_expected.to be_successful }
240
+
231
241
  it 'is expected not to receive #perform on the first interactor' do
232
242
  expect_any_instance_of(test_interactor_1).not_to receive(:perform)
233
243
  subject
@@ -266,6 +276,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
266
276
 
267
277
  it { is_expected.to be_a interactor_class.context_class }
268
278
  it { is_expected.to be_successful }
279
+
269
280
  it 'is expected not to receive #perform on the first interactor' do
270
281
  expect_any_instance_of(test_interactor_1).not_to receive(:perform)
271
282
  subject
@@ -304,6 +315,7 @@ RSpec.describe 'An organizer with conditionally organized interactors', type: :i
304
315
 
305
316
  it { is_expected.to be_a interactor_class.context_class }
306
317
  it { is_expected.to be_successful }
318
+
307
319
  it 'is expected to receive #perform on both interactors' do
308
320
  expect_any_instance_of(test_interactor_1).to receive(:perform)
309
321
  expect_any_instance_of(test_interactor_2).to receive(:perform)