activeinteractor 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -3
- data/lib/active_interactor/interactor/worker.rb +7 -1
- data/lib/active_interactor/organizer/perform.rb +8 -9
- data/lib/active_interactor/version.rb +1 -1
- metadata +7 -127
- data/spec/active_interactor/base_spec.rb +0 -85
- data/spec/active_interactor/config_spec.rb +0 -17
- data/spec/active_interactor/context/base_spec.rb +0 -443
- data/spec/active_interactor/error_spec.rb +0 -45
- data/spec/active_interactor/interactor/perform/options_spec.rb +0 -25
- data/spec/active_interactor/interactor/worker_spec.rb +0 -189
- data/spec/active_interactor/organizer/base_spec.rb +0 -276
- data/spec/active_interactor/organizer/interactor_interface_collection_spec.rb +0 -78
- data/spec/active_interactor/organizer/interactor_interface_spec.rb +0 -235
- data/spec/active_interactor/version_spec.rb +0 -119
- data/spec/active_interactor_spec.rb +0 -23
- data/spec/integration/a_basic_interactor_spec.rb +0 -154
- data/spec/integration/a_basic_organizer_spec.rb +0 -354
- data/spec/integration/a_failing_interactor_spec.rb +0 -43
- data/spec/integration/active_record_integration_spec.rb +0 -32
- data/spec/integration/an_interactor_with_after_context_validation_callbacks_spec.rb +0 -69
- data/spec/integration/an_interactor_with_after_perform_callbacks_spec.rb +0 -31
- data/spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb +0 -34
- data/spec/integration/an_interactor_with_an_existing_context_class_spec.rb +0 -50
- data/spec/integration/an_interactor_with_around_perform_callbacks_spec.rb +0 -35
- data/spec/integration/an_interactor_with_around_rollback_callbacks_spec.rb +0 -39
- data/spec/integration/an_interactor_with_before_perform_callbacks_spec.rb +0 -31
- data/spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb +0 -34
- data/spec/integration/an_interactor_with_deferred_after_callbacks.rb +0 -32
- data/spec/integration/an_interactor_with_validations_on_called_spec.rb +0 -41
- data/spec/integration/an_interactor_with_validations_on_calling_spec.rb +0 -37
- data/spec/integration/an_interactor_with_validations_spec.rb +0 -95
- data/spec/integration/an_organizer_containing_organizer_with_after_callbacks_deferred_spec.rb +0 -125
- data/spec/integration/an_organizer_performing_in_parallel_spec.rb +0 -48
- data/spec/integration/an_organizer_with_after_callbacks_deferred_spec.rb +0 -154
- data/spec/integration/an_organizer_with_after_each_callbacks_spec.rb +0 -35
- data/spec/integration/an_organizer_with_all_perform_callbacks.rb +0 -112
- data/spec/integration/an_organizer_with_around_each_callbacks_spec.rb +0 -39
- data/spec/integration/an_organizer_with_before_each_callbacks_spec.rb +0 -35
- data/spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb +0 -326
- data/spec/integration/an_organizer_with_failing_nested_organizer_spec.rb +0 -47
- data/spec/integration/an_organizer_with_options_callbacks_spec.rb +0 -64
- data/spec/spec_helper.rb +0 -33
- data/spec/support/coverage.rb +0 -50
- data/spec/support/helpers/factories.rb +0 -49
- data/spec/support/shared_examples/a_class_that_extends_active_interactor_models_example.rb +0 -81
- data/spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb +0 -107
- data/spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb +0 -60
- data/spec/support/shared_examples/a_class_with_interactor_methods_example.rb +0 -21
- data/spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb +0 -42
- data/spec/support/spec_helpers.rb +0 -7
@@ -1,154 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'An organizer with after callbacks deferred', type: :integration do
|
6
|
-
let!(:test_interactor_1) do
|
7
|
-
build_interactor('TestInteractor1') do
|
8
|
-
defer_after_callbacks_when_organized
|
9
|
-
|
10
|
-
after_perform do
|
11
|
-
context.after_perform_1a = context.after_perform_1b + 1
|
12
|
-
end
|
13
|
-
|
14
|
-
after_perform do
|
15
|
-
context.after_perform_1b = context.after_perform_3a + 1
|
16
|
-
end
|
17
|
-
|
18
|
-
def perform
|
19
|
-
context.perform_1 = 1
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
let!(:test_interactor_2) do
|
25
|
-
build_interactor('TestInteractor2') do
|
26
|
-
defer_after_callbacks_when_organized
|
27
|
-
|
28
|
-
after_perform do
|
29
|
-
context.after_perform_2 = context.after_perform_1a + 1
|
30
|
-
end
|
31
|
-
|
32
|
-
def perform
|
33
|
-
context.perform_2 = context.perform_1 + 1
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
let!(:test_interactor_3) do
|
39
|
-
build_interactor('TestInteractor3') do
|
40
|
-
after_perform do
|
41
|
-
context.after_perform_3a = context.after_perform_3b + 1
|
42
|
-
end
|
43
|
-
|
44
|
-
after_perform do
|
45
|
-
context.after_perform_3b = context.perform_3 + 1
|
46
|
-
end
|
47
|
-
|
48
|
-
def perform
|
49
|
-
context.perform_3 = context.perform_2 + 1
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
let(:interactor_class) do
|
55
|
-
build_organizer do
|
56
|
-
organize TestInteractor1, TestInteractor2, TestInteractor3
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
include_examples 'a class with interactor methods'
|
61
|
-
include_examples 'a class with interactor callback methods'
|
62
|
-
include_examples 'a class with interactor context methods'
|
63
|
-
include_examples 'a class with organizer callback methods'
|
64
|
-
|
65
|
-
describe '.context_class' do
|
66
|
-
subject { interactor_class.context_class }
|
67
|
-
|
68
|
-
it { is_expected.to eq TestOrganizer::Context }
|
69
|
-
it { is_expected.to be < ActiveInteractor::Context::Base }
|
70
|
-
end
|
71
|
-
|
72
|
-
describe '.perform' do
|
73
|
-
subject { interactor_class.perform }
|
74
|
-
|
75
|
-
it { is_expected.to be_a interactor_class.context_class }
|
76
|
-
it { is_expected.to be_successful }
|
77
|
-
it { is_expected.to have_attributes(
|
78
|
-
perform_1: 1,
|
79
|
-
perform_2: 2,
|
80
|
-
perform_3: 3,
|
81
|
-
after_perform_3b: 4,
|
82
|
-
after_perform_3a: 5,
|
83
|
-
after_perform_1b: 6,
|
84
|
-
after_perform_1a: 7,
|
85
|
-
after_perform_2: 8,
|
86
|
-
) }
|
87
|
-
|
88
|
-
context 'when last interactor fails' do
|
89
|
-
let!(:failing_interactor) do
|
90
|
-
build_interactor('FailingInteractor') do
|
91
|
-
def perform
|
92
|
-
context.fail!
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
let(:interactor_class) do
|
98
|
-
build_organizer do
|
99
|
-
organize TestInteractor1, TestInteractor2, FailingInteractor
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
subject { interactor_class.perform}
|
104
|
-
|
105
|
-
it { is_expected.to have_attributes(
|
106
|
-
perform_1: 1,
|
107
|
-
perform_2: 2,
|
108
|
-
)}
|
109
|
-
|
110
|
-
it { is_expected.to_not respond_to(
|
111
|
-
:after_perform_1a,
|
112
|
-
:after_perform_1b,
|
113
|
-
)}
|
114
|
-
end
|
115
|
-
|
116
|
-
context 'when after_perform in first interactor fails' do
|
117
|
-
let!(:failing_interactor) do
|
118
|
-
build_interactor('FailingInteractor') do
|
119
|
-
defer_after_callbacks_when_organized
|
120
|
-
|
121
|
-
after_perform do
|
122
|
-
context.fail!
|
123
|
-
end
|
124
|
-
|
125
|
-
def perform
|
126
|
-
context.perform_1 = 1
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
let(:interactor_class) do
|
132
|
-
build_organizer do
|
133
|
-
organize FailingInteractor, TestInteractor2, TestInteractor3
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
subject { interactor_class.perform}
|
138
|
-
|
139
|
-
it { is_expected.to have_attributes(
|
140
|
-
perform_1: 1,
|
141
|
-
perform_2: 2,
|
142
|
-
perform_3: 3,
|
143
|
-
after_perform_3b: 4,
|
144
|
-
after_perform_3a: 5,
|
145
|
-
)}
|
146
|
-
|
147
|
-
it { is_expected.to_not respond_to(
|
148
|
-
:after_perform_1a,
|
149
|
-
:after_perform_1b,
|
150
|
-
:after_perform_2,
|
151
|
-
)}
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'An organizer with .after_each callbacks', type: :integration do
|
6
|
-
let!(:interactor1) { build_interactor('TestInteractor1') }
|
7
|
-
let!(:interactor2) { build_interactor('TestInteractor2') }
|
8
|
-
let(:interactor_class) do
|
9
|
-
build_organizer do
|
10
|
-
after_each_perform :test_after_each_perform
|
11
|
-
organize TestInteractor1, TestInteractor2
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def test_after_each_perform; end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
include_examples 'a class with interactor methods'
|
20
|
-
include_examples 'a class with interactor callback methods'
|
21
|
-
include_examples 'a class with interactor context methods'
|
22
|
-
include_examples 'a class with organizer callback methods'
|
23
|
-
|
24
|
-
describe '.perform' do
|
25
|
-
subject { interactor_class.perform }
|
26
|
-
|
27
|
-
it { is_expected.to be_a interactor_class.context_class }
|
28
|
-
|
29
|
-
it 'is expected to receive #test_after_each_perform twice' do
|
30
|
-
expect_any_instance_of(interactor_class).to receive(:test_after_each_perform)
|
31
|
-
.exactly(:twice)
|
32
|
-
subject
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'An organizer with around all callbacks', type: :integration do
|
6
|
-
let!(:test_interactor_1) do
|
7
|
-
build_interactor('TestInteractor1') do
|
8
|
-
before_perform do
|
9
|
-
context.before_perform_1 = context.around_all_perform_start + 1
|
10
|
-
end
|
11
|
-
|
12
|
-
after_perform do
|
13
|
-
context.after_perform_1 = context.around_perform_1_end + 1
|
14
|
-
end
|
15
|
-
|
16
|
-
around_perform :around
|
17
|
-
def around
|
18
|
-
context.around_perform_1_start = context.before_perform_1 + 1
|
19
|
-
yield
|
20
|
-
context.around_perform_1_end = context.perform_1 + 1
|
21
|
-
end
|
22
|
-
|
23
|
-
def perform
|
24
|
-
context.perform_1 = context.around_perform_1_start + 1
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
let!(:test_interactor_2) do
|
30
|
-
build_interactor('TestInteractor2') do
|
31
|
-
defer_after_callbacks_when_organized
|
32
|
-
|
33
|
-
before_perform do
|
34
|
-
context.before_perform_2 = context.after_perform_1 + 1
|
35
|
-
end
|
36
|
-
|
37
|
-
after_perform do
|
38
|
-
context.after_perform_2 = context.after_all_perform + 1
|
39
|
-
end
|
40
|
-
|
41
|
-
around_perform :around
|
42
|
-
def around
|
43
|
-
context.around_perform_2_start = context.before_perform_2 + 1
|
44
|
-
yield
|
45
|
-
context.around_perform_2_end = context.perform_2 + 1
|
46
|
-
end
|
47
|
-
|
48
|
-
def perform
|
49
|
-
context.perform_2 = context.around_perform_2_start + 1
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
let(:interactor_class) do
|
55
|
-
build_organizer do
|
56
|
-
before_all_perform do
|
57
|
-
context.before_all_perform = 1
|
58
|
-
end
|
59
|
-
|
60
|
-
after_all_perform do
|
61
|
-
context.after_all_perform = context.around_all_perform_end + 1
|
62
|
-
end
|
63
|
-
|
64
|
-
around_all_perform :around_all
|
65
|
-
def around_all
|
66
|
-
context.around_all_perform_start = context.before_all_perform + 1
|
67
|
-
yield
|
68
|
-
context.around_all_perform_end = context.around_perform_2_end + 1
|
69
|
-
end
|
70
|
-
|
71
|
-
organize TestInteractor1, TestInteractor2
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
include_examples 'a class with interactor methods'
|
76
|
-
include_examples 'a class with interactor callback methods'
|
77
|
-
include_examples 'a class with interactor context methods'
|
78
|
-
include_examples 'a class with organizer callback methods'
|
79
|
-
|
80
|
-
describe '.context_class' do
|
81
|
-
subject { interactor_class.context_class }
|
82
|
-
|
83
|
-
it { is_expected.to eq TestOrganizer::Context }
|
84
|
-
it { is_expected.to be < ActiveInteractor::Context::Base }
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '.perform' do
|
88
|
-
subject { interactor_class.perform }
|
89
|
-
|
90
|
-
it { is_expected.to be_a interactor_class.context_class }
|
91
|
-
it { is_expected.to be_successful }
|
92
|
-
it { is_expected.to have_attributes(
|
93
|
-
before_all_perform: 1,
|
94
|
-
around_all_perform_start: 2,
|
95
|
-
|
96
|
-
before_perform_1: 3,
|
97
|
-
around_perform_1_start: 4,
|
98
|
-
perform_1: 5,
|
99
|
-
around_perform_1_end: 6,
|
100
|
-
after_perform_1: 7,
|
101
|
-
|
102
|
-
before_perform_2: 8,
|
103
|
-
around_perform_2_start: 9,
|
104
|
-
perform_2: 10,
|
105
|
-
around_perform_2_end: 11,
|
106
|
-
|
107
|
-
around_all_perform_end: 12,
|
108
|
-
after_all_perform: 13,
|
109
|
-
after_perform_2: 14,
|
110
|
-
) }
|
111
|
-
end
|
112
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'An organizer with .around_each callbacks', type: :integration do
|
6
|
-
let!(:interactor1) { build_interactor('TestInteractor1') }
|
7
|
-
let!(:interactor2) { build_interactor('TestInteractor2') }
|
8
|
-
let(:interactor_class) do
|
9
|
-
build_organizer do
|
10
|
-
around_each_perform :test_around_each_perform
|
11
|
-
organize TestInteractor1, TestInteractor2
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def find_index
|
16
|
-
(context.around_each_step.last || 0) + 1
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_around_each_perform
|
20
|
-
context.around_each_step ||= []
|
21
|
-
context.around_each_step << find_index
|
22
|
-
yield
|
23
|
-
context.around_each_step << find_index
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
include_examples 'a class with interactor methods'
|
29
|
-
include_examples 'a class with interactor callback methods'
|
30
|
-
include_examples 'a class with interactor context methods'
|
31
|
-
include_examples 'a class with organizer callback methods'
|
32
|
-
|
33
|
-
describe '.perform' do
|
34
|
-
subject { interactor_class.perform }
|
35
|
-
|
36
|
-
it { is_expected.to be_a interactor_class.context_class }
|
37
|
-
it { is_expected.to have_attributes(around_each_step: [1, 2, 3, 4]) }
|
38
|
-
end
|
39
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'An organizer with .before_each callbacks', type: :integration do
|
6
|
-
let!(:interactor1) { build_interactor('TestInteractor1') }
|
7
|
-
let!(:interactor2) { build_interactor('TestInteractor2') }
|
8
|
-
let(:interactor_class) do
|
9
|
-
build_organizer do
|
10
|
-
before_each_perform :test_before_each_perform
|
11
|
-
organize TestInteractor1, TestInteractor2
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def test_before_each_perform; end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
include_examples 'a class with interactor methods'
|
20
|
-
include_examples 'a class with interactor callback methods'
|
21
|
-
include_examples 'a class with interactor context methods'
|
22
|
-
include_examples 'a class with organizer callback methods'
|
23
|
-
|
24
|
-
describe '.perform' do
|
25
|
-
subject { interactor_class.perform }
|
26
|
-
|
27
|
-
it { is_expected.to be_a interactor_class.context_class }
|
28
|
-
|
29
|
-
it 'is expected to receive #test_before_each_perform twice' do
|
30
|
-
expect_any_instance_of(interactor_class).to receive(:test_before_each_perform)
|
31
|
-
.exactly(:twice)
|
32
|
-
subject
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,326 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'An organizer with conditionally organized interactors', type: :integration do
|
6
|
-
let!(:test_interactor_1) { build_interactor('TestInteractor1') }
|
7
|
-
let!(:test_interactor_2) { build_interactor('TestInteractor2') }
|
8
|
-
|
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
|
11
|
-
let(:interactor_class) do
|
12
|
-
build_organizer do
|
13
|
-
organize do
|
14
|
-
add :test_interactor_1, if: -> { context.test_1 }
|
15
|
-
add :test_interactor_2, if: -> { context.test_2 }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
include_examples 'a class with interactor methods'
|
21
|
-
include_examples 'a class with interactor callback methods'
|
22
|
-
include_examples 'a class with interactor context methods'
|
23
|
-
include_examples 'a class with organizer callback methods'
|
24
|
-
|
25
|
-
describe '.perform' do
|
26
|
-
subject { interactor_class.perform(context_attributes) }
|
27
|
-
|
28
|
-
context 'with context_attributes test_1 and test_2 both eq to true' do
|
29
|
-
let(:context_attributes) { { test_1: true, test_2: true } }
|
30
|
-
|
31
|
-
it { is_expected.to be_a interactor_class.context_class }
|
32
|
-
it { is_expected.to be_successful }
|
33
|
-
|
34
|
-
it 'is expected to receive #perform on both interactors' do
|
35
|
-
expect_any_instance_of(test_interactor_1).to receive(:perform)
|
36
|
-
expect_any_instance_of(test_interactor_2).to receive(:perform)
|
37
|
-
subject
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'with context_attributes test_1 eq to true and test_2 eq to false' do
|
42
|
-
let(:context_attributes) { { test_1: true, test_2: false } }
|
43
|
-
|
44
|
-
it { is_expected.to be_a interactor_class.context_class }
|
45
|
-
it { is_expected.to be_successful }
|
46
|
-
|
47
|
-
it 'is expected to receive #perform on the first interactor' do
|
48
|
-
expect_any_instance_of(test_interactor_1).to receive(:perform)
|
49
|
-
subject
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'is expected not to receive #perform on the first interactor' do
|
53
|
-
expect_any_instance_of(test_interactor_2).not_to receive(:perform)
|
54
|
-
subject
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with context_attributes test_1 eq to false and test_2 eq to true' do
|
59
|
-
let(:context_attributes) { { test_1: false, test_2: true } }
|
60
|
-
|
61
|
-
it { is_expected.to be_a interactor_class.context_class }
|
62
|
-
it { is_expected.to be_successful }
|
63
|
-
|
64
|
-
it 'is expected not to receive #perform on the first interactor' do
|
65
|
-
expect_any_instance_of(test_interactor_1).not_to receive(:perform)
|
66
|
-
subject
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'is expected to receive #perform on the first interactor' do
|
70
|
-
expect_any_instance_of(test_interactor_2).to receive(:perform)
|
71
|
-
subject
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'with context_attributes test_1 and test_2 both eq to false' do
|
76
|
-
let(:context_attributes) { { test_1: false, test_2: false } }
|
77
|
-
|
78
|
-
it { is_expected.to be_a interactor_class.context_class }
|
79
|
-
it { is_expected.to be_successful }
|
80
|
-
|
81
|
-
it 'is expected not to receive #perform on the first interactor' do
|
82
|
-
expect_any_instance_of(test_interactor_1).not_to receive(:perform)
|
83
|
-
subject
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'is expected not to receive #perform on the first interactor' do
|
87
|
-
expect_any_instance_of(test_interactor_2).not_to receive(:perform)
|
88
|
-
subject
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context 'with a condition on the first interactor { :unless => -> { context.test_1 } } ' \
|
95
|
-
'and a condition on the second interactor { :unless => -> { context.test_2 } }' do
|
96
|
-
let(:interactor_class) do
|
97
|
-
build_organizer do
|
98
|
-
organize do
|
99
|
-
add :test_interactor_1, unless: -> { context.test_1 }
|
100
|
-
add :test_interactor_2, unless: -> { context.test_2 }
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
include_examples 'a class with interactor methods'
|
106
|
-
include_examples 'a class with interactor callback methods'
|
107
|
-
include_examples 'a class with interactor context methods'
|
108
|
-
include_examples 'a class with organizer callback methods'
|
109
|
-
|
110
|
-
describe '.perform' do
|
111
|
-
subject { interactor_class.perform(context_attributes) }
|
112
|
-
|
113
|
-
context 'with context_attributes test_1 and test_2 both eq to true' do
|
114
|
-
let(:context_attributes) { { test_1: true, test_2: true } }
|
115
|
-
|
116
|
-
it { is_expected.to be_a interactor_class.context_class }
|
117
|
-
it { is_expected.to be_successful }
|
118
|
-
|
119
|
-
it 'is expected not to receive #perform on the first interactor' do
|
120
|
-
expect_any_instance_of(test_interactor_1).not_to receive(:perform)
|
121
|
-
subject
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'is expected not to receive #perform on the second interactor' do
|
125
|
-
expect_any_instance_of(test_interactor_2).not_to receive(:perform)
|
126
|
-
subject
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context 'with context_attributes test_1 eq to true and test_2 eq to false' do
|
131
|
-
let(:context_attributes) { { test_1: true, test_2: false } }
|
132
|
-
|
133
|
-
it { is_expected.to be_a interactor_class.context_class }
|
134
|
-
it { is_expected.to be_successful }
|
135
|
-
|
136
|
-
it 'is expected not to receive #perform on the first interactor' do
|
137
|
-
expect_any_instance_of(test_interactor_1).not_to receive(:perform)
|
138
|
-
subject
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'is expected to receive #perform on the second interactor' do
|
142
|
-
expect_any_instance_of(test_interactor_2).to receive(:perform)
|
143
|
-
subject
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'with context_attributes test_1 eq to false and test_2 eq to true' do
|
148
|
-
let(:context_attributes) { { test_1: false, test_2: true } }
|
149
|
-
|
150
|
-
it { is_expected.to be_a interactor_class.context_class }
|
151
|
-
it { is_expected.to be_successful }
|
152
|
-
|
153
|
-
it 'is expected to receive #perform on the first interactor' do
|
154
|
-
expect_any_instance_of(test_interactor_1).to receive(:perform)
|
155
|
-
subject
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'is expected not to receive #perform on the second interactor' do
|
159
|
-
expect_any_instance_of(test_interactor_2).not_to receive(:perform)
|
160
|
-
subject
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
context 'with context_attributes test_1 and test_2 both eq to false' do
|
165
|
-
let(:context_attributes) { { test_1: false, test_2: false } }
|
166
|
-
|
167
|
-
it { is_expected.to be_a interactor_class.context_class }
|
168
|
-
it { is_expected.to be_successful }
|
169
|
-
|
170
|
-
it 'is expected to receive #perform on both interactors' do
|
171
|
-
expect_any_instance_of(test_interactor_1).to receive(:perform)
|
172
|
-
expect_any_instance_of(test_interactor_2).to receive(:perform)
|
173
|
-
subject
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context 'with a condition on the first interactor { :if => :test_method } and :test_method returning true' do
|
180
|
-
let(:interactor_class) do
|
181
|
-
build_organizer do
|
182
|
-
organize do
|
183
|
-
add :test_interactor_1, if: :test_method
|
184
|
-
add :test_interactor_2
|
185
|
-
end
|
186
|
-
|
187
|
-
private
|
188
|
-
|
189
|
-
def test_method
|
190
|
-
true
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
include_examples 'a class with interactor methods'
|
196
|
-
include_examples 'a class with interactor callback methods'
|
197
|
-
include_examples 'a class with interactor context methods'
|
198
|
-
include_examples 'a class with organizer callback methods'
|
199
|
-
|
200
|
-
describe '.perform' do
|
201
|
-
subject { interactor_class.perform }
|
202
|
-
|
203
|
-
it { is_expected.to be_a interactor_class.context_class }
|
204
|
-
it { is_expected.to be_successful }
|
205
|
-
|
206
|
-
it 'is expected to receive #perform on both interactors' do
|
207
|
-
expect_any_instance_of(test_interactor_1).to receive(:perform)
|
208
|
-
expect_any_instance_of(test_interactor_2).to receive(:perform)
|
209
|
-
subject
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
context 'with a condition on the first interactor { :if => :test_method } and :test_method returning false' do
|
215
|
-
let(:interactor_class) do
|
216
|
-
build_organizer do
|
217
|
-
organize do
|
218
|
-
add :test_interactor_1, if: :test_method
|
219
|
-
add :test_interactor_2
|
220
|
-
end
|
221
|
-
|
222
|
-
private
|
223
|
-
|
224
|
-
def test_method
|
225
|
-
false
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
include_examples 'a class with interactor methods'
|
231
|
-
include_examples 'a class with interactor callback methods'
|
232
|
-
include_examples 'a class with interactor context methods'
|
233
|
-
include_examples 'a class with organizer callback methods'
|
234
|
-
|
235
|
-
describe '.perform' do
|
236
|
-
subject { interactor_class.perform }
|
237
|
-
|
238
|
-
it { is_expected.to be_a interactor_class.context_class }
|
239
|
-
it { is_expected.to be_successful }
|
240
|
-
|
241
|
-
it 'is expected not to receive #perform on the first interactor' do
|
242
|
-
expect_any_instance_of(test_interactor_1).not_to receive(:perform)
|
243
|
-
subject
|
244
|
-
end
|
245
|
-
|
246
|
-
it 'is expected to receive #perform on the second interactor' do
|
247
|
-
expect_any_instance_of(test_interactor_2).to receive(:perform)
|
248
|
-
subject
|
249
|
-
end
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
context 'with a condition on the first interactor { :unless => :test_method } and :test_method returning true' do
|
254
|
-
let(:interactor_class) do
|
255
|
-
build_organizer do
|
256
|
-
organize do
|
257
|
-
add :test_interactor_1, unless: :test_method
|
258
|
-
add :test_interactor_2
|
259
|
-
end
|
260
|
-
|
261
|
-
private
|
262
|
-
|
263
|
-
def test_method
|
264
|
-
true
|
265
|
-
end
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
include_examples 'a class with interactor methods'
|
270
|
-
include_examples 'a class with interactor callback methods'
|
271
|
-
include_examples 'a class with interactor context methods'
|
272
|
-
include_examples 'a class with organizer callback methods'
|
273
|
-
|
274
|
-
describe '.perform' do
|
275
|
-
subject { interactor_class.perform }
|
276
|
-
|
277
|
-
it { is_expected.to be_a interactor_class.context_class }
|
278
|
-
it { is_expected.to be_successful }
|
279
|
-
|
280
|
-
it 'is expected not to receive #perform on the first interactor' do
|
281
|
-
expect_any_instance_of(test_interactor_1).not_to receive(:perform)
|
282
|
-
subject
|
283
|
-
end
|
284
|
-
|
285
|
-
it 'is expected to receive #perform on the second interactor' do
|
286
|
-
expect_any_instance_of(test_interactor_2).to receive(:perform)
|
287
|
-
subject
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
context 'with a condition on the first interactor { :unless => :test_method } and :test_method returning false' do
|
293
|
-
let(:interactor_class) do
|
294
|
-
build_organizer do
|
295
|
-
organize do
|
296
|
-
add :test_interactor_1, unless: :test_method
|
297
|
-
add :test_interactor_2
|
298
|
-
end
|
299
|
-
|
300
|
-
private
|
301
|
-
|
302
|
-
def test_method
|
303
|
-
false
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
include_examples 'a class with interactor methods'
|
309
|
-
include_examples 'a class with interactor callback methods'
|
310
|
-
include_examples 'a class with interactor context methods'
|
311
|
-
include_examples 'a class with organizer callback methods'
|
312
|
-
|
313
|
-
describe '.perform' do
|
314
|
-
subject { interactor_class.perform }
|
315
|
-
|
316
|
-
it { is_expected.to be_a interactor_class.context_class }
|
317
|
-
it { is_expected.to be_successful }
|
318
|
-
|
319
|
-
it 'is expected to receive #perform on both interactors' do
|
320
|
-
expect_any_instance_of(test_interactor_1).to receive(:perform)
|
321
|
-
expect_any_instance_of(test_interactor_2).to receive(:perform)
|
322
|
-
subject
|
323
|
-
end
|
324
|
-
end
|
325
|
-
end
|
326
|
-
end
|