activeinteractor 1.2.0 → 1.2.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -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 +8 -128
- 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
- /data/lib/rails/generators/templates/{interactor_text_unit.erb → interactor_test_unit.erb} +0 -0
@@ -1,276 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe ActiveInteractor::Organizer::Base do
|
6
|
-
let(:interactor_class) { described_class }
|
7
|
-
|
8
|
-
include_examples 'a class with interactor methods'
|
9
|
-
include_examples 'a class with interactor callback methods'
|
10
|
-
include_examples 'a class with interactor context methods'
|
11
|
-
include_examples 'a class with organizer callback methods'
|
12
|
-
|
13
|
-
describe '.contextualize_with' do
|
14
|
-
subject { described_class.contextualize_with(klass) }
|
15
|
-
|
16
|
-
context 'with an class that does not exist' do
|
17
|
-
let(:klass) { 'SomeClassThatDoesNotExist' }
|
18
|
-
|
19
|
-
it { expect { subject }.to raise_error(ActiveInteractor::Error::InvalidContextClass) }
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'with context class TestContext' do
|
23
|
-
before { build_context }
|
24
|
-
|
25
|
-
context 'when passed as a string' do
|
26
|
-
let(:klass) { 'TestContext' }
|
27
|
-
|
28
|
-
it 'is expected to assign the appropriate context class' do
|
29
|
-
subject
|
30
|
-
expect(described_class.context_class).to eq TestContext
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when passed as a symbol' do
|
35
|
-
let(:klass) { :test_context }
|
36
|
-
|
37
|
-
it 'is expected to assign the appropriate context class' do
|
38
|
-
subject
|
39
|
-
expect(described_class.context_class).to eq TestContext
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'when passed as a constant' do
|
44
|
-
let(:klass) { TestContext }
|
45
|
-
|
46
|
-
it 'is expected to assign the appropriate context class' do
|
47
|
-
subject
|
48
|
-
expect(described_class.context_class).to eq TestContext
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '.organize' do
|
55
|
-
context 'with two existing interactors' do
|
56
|
-
let!(:interactor1) { build_interactor('TestInteractor1') }
|
57
|
-
let!(:interactor2) { build_interactor('TestInteractor2') }
|
58
|
-
|
59
|
-
context 'when interactors are passed as args' do
|
60
|
-
let(:organizer) do
|
61
|
-
build_organizer do
|
62
|
-
organize :test_interactor_1, :test_interactor_2
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '.organized' do
|
67
|
-
subject { organizer.organized }
|
68
|
-
|
69
|
-
it { expect(subject.collection).to all(be_a ActiveInteractor::Organizer::InteractorInterface) }
|
70
|
-
|
71
|
-
it 'is expected to organize the approriate interactors' do
|
72
|
-
expect(subject.collection.first.interactor_class).to eq TestInteractor1
|
73
|
-
expect(subject.collection.last.interactor_class).to eq TestInteractor2
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'when a block is passed' do
|
79
|
-
let(:organizer) do
|
80
|
-
build_organizer do
|
81
|
-
organize do
|
82
|
-
add :test_interactor_1
|
83
|
-
add :test_interactor_2
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '.organized' do
|
89
|
-
subject { organizer.organized }
|
90
|
-
|
91
|
-
it { expect(subject.collection).to all(be_a ActiveInteractor::Organizer::InteractorInterface) }
|
92
|
-
|
93
|
-
it 'is expected to organize the approriate interactors' do
|
94
|
-
expect(subject.collection.first.interactor_class).to eq TestInteractor1
|
95
|
-
expect(subject.collection.last.interactor_class).to eq TestInteractor2
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '.perform_in_parallel' do
|
103
|
-
subject do
|
104
|
-
build_organizer do
|
105
|
-
perform_in_parallel
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
it { is_expected.to have_attributes(parallel: true) }
|
110
|
-
end
|
111
|
-
|
112
|
-
describe '#perform' do
|
113
|
-
subject { interactor_class.perform }
|
114
|
-
|
115
|
-
context 'with two existing interactors' do
|
116
|
-
let!(:interactor1) { build_interactor('TestInteractor1') }
|
117
|
-
let!(:interactor2) { build_interactor('TestInteractor2') }
|
118
|
-
let(:interactor_class) do
|
119
|
-
build_organizer do
|
120
|
-
organize TestInteractor1, TestInteractor2
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
it { is_expected.to be_a interactor_class.context_class }
|
125
|
-
|
126
|
-
it 'is expected to receive #perform on both interactors' do
|
127
|
-
expect_any_instance_of(interactor1).to receive(:perform)
|
128
|
-
expect_any_instance_of(interactor2).to receive(:perform)
|
129
|
-
subject
|
130
|
-
end
|
131
|
-
|
132
|
-
context 'with options :skip_each_perform_callbacks eq to true' do
|
133
|
-
subject { interactor_class.perform({}, skip_each_perform_callbacks: true) }
|
134
|
-
|
135
|
-
it { is_expected.to be_a interactor_class.context_class }
|
136
|
-
|
137
|
-
it 'is expected to receive #perform on both interactors' do
|
138
|
-
expect_any_instance_of(interactor1).to receive(:perform)
|
139
|
-
expect_any_instance_of(interactor2).to receive(:perform)
|
140
|
-
subject
|
141
|
-
end
|
142
|
-
|
143
|
-
it 'is expected not to receive #run_callbacks with :each_perform' do
|
144
|
-
expect_any_instance_of(interactor_class).not_to receive(:run_callbacks)
|
145
|
-
.with(:each_perform)
|
146
|
-
subject
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context 'when the first interactor context fails' do
|
151
|
-
let!(:interactor1) do
|
152
|
-
build_interactor('TestInteractor1') do
|
153
|
-
def perform
|
154
|
-
context.fail!
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
it { expect { subject }.not_to raise_error }
|
160
|
-
it { is_expected.to be_failure }
|
161
|
-
it { is_expected.to be_a interactor_class.context_class }
|
162
|
-
|
163
|
-
it 'is expected to receive #perform on the first interactor' do
|
164
|
-
expect_any_instance_of(interactor1).to receive(:perform)
|
165
|
-
subject
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'is expected not to receive #perform on the second interactor' do
|
169
|
-
expect_any_instance_of(interactor2).not_to receive(:perform)
|
170
|
-
subject
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'is expected to receive #rollback on the first interactor' do
|
174
|
-
expect_any_instance_of(interactor1).to receive(:rollback)
|
175
|
-
subject
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context 'when the second interactor context fails' do
|
180
|
-
let!(:interactor2) do
|
181
|
-
build_interactor('TestInteractor2') do
|
182
|
-
def perform
|
183
|
-
context.fail!
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
it { expect { subject }.not_to raise_error }
|
189
|
-
it { is_expected.to be_failure }
|
190
|
-
it { is_expected.to be_a interactor_class.context_class }
|
191
|
-
|
192
|
-
it 'is expected to receive #perform on both interactors' do
|
193
|
-
expect_any_instance_of(interactor1).to receive(:perform)
|
194
|
-
expect_any_instance_of(interactor2).to receive(:perform)
|
195
|
-
subject
|
196
|
-
end
|
197
|
-
|
198
|
-
it 'is expected to receive #rollback on both interactors' do
|
199
|
-
expect_any_instance_of(interactor1).to receive(:rollback)
|
200
|
-
expect_any_instance_of(interactor2).to receive(:rollback)
|
201
|
-
subject
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
context 'when the organizer is set to perform in parallel' do
|
206
|
-
let(:interactor_class) do
|
207
|
-
build_organizer do
|
208
|
-
perform_in_parallel
|
209
|
-
|
210
|
-
organize TestInteractor1, TestInteractor2
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
it { is_expected.to be_a interactor_class.context_class }
|
215
|
-
|
216
|
-
it 'is expected to receive #perform on both interactors' do
|
217
|
-
expect_any_instance_of(interactor1).to receive(:perform)
|
218
|
-
expect_any_instance_of(interactor2).to receive(:perform)
|
219
|
-
subject
|
220
|
-
end
|
221
|
-
|
222
|
-
context 'when the first interactor context fails' do
|
223
|
-
let!(:interactor1) do
|
224
|
-
build_interactor('TestInteractor1') do
|
225
|
-
def perform
|
226
|
-
context.fail!
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
it { expect { subject }.not_to raise_error }
|
232
|
-
it { is_expected.to be_failure }
|
233
|
-
it { is_expected.to be_a interactor_class.context_class }
|
234
|
-
|
235
|
-
it 'is expected to receive #perform on both interactors' do
|
236
|
-
expect_any_instance_of(interactor1).to receive(:perform)
|
237
|
-
expect_any_instance_of(interactor2).to receive(:perform)
|
238
|
-
subject
|
239
|
-
end
|
240
|
-
|
241
|
-
it 'is expected to receive #rollback both interactors' do
|
242
|
-
expect_any_instance_of(interactor1).to receive(:rollback)
|
243
|
-
expect_any_instance_of(interactor2).to receive(:rollback)
|
244
|
-
subject
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
context 'when the second interactor context fails' do
|
249
|
-
let!(:interactor2) do
|
250
|
-
build_interactor('TestInteractor2') do
|
251
|
-
def perform
|
252
|
-
context.fail!
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
it { expect { subject }.not_to raise_error }
|
258
|
-
it { is_expected.to be_failure }
|
259
|
-
it { is_expected.to be_a interactor_class.context_class }
|
260
|
-
|
261
|
-
it 'is expected to receive #perform on both interactors' do
|
262
|
-
expect_any_instance_of(interactor1).to receive(:perform)
|
263
|
-
expect_any_instance_of(interactor2).to receive(:perform)
|
264
|
-
subject
|
265
|
-
end
|
266
|
-
|
267
|
-
it 'is expected to receive #rollback on both interactors' do
|
268
|
-
expect_any_instance_of(interactor1).to receive(:rollback)
|
269
|
-
expect_any_instance_of(interactor2).to receive(:rollback)
|
270
|
-
subject
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe ActiveInteractor::Organizer::InteractorInterfaceCollection do
|
6
|
-
describe '#add' do
|
7
|
-
subject { instance.add(interactor) }
|
8
|
-
|
9
|
-
let(:instance) { described_class.new }
|
10
|
-
|
11
|
-
context 'with an interactor that does not exist' do
|
12
|
-
let(:interactor) { :an_interactor_that_does_not_exist }
|
13
|
-
|
14
|
-
it { expect { subject }.not_to(change { instance.collection.count }) }
|
15
|
-
it { is_expected.to be_a described_class }
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'with an existing interactor' do
|
19
|
-
before { build_interactor }
|
20
|
-
|
21
|
-
context 'when interactors are passed as contants' do
|
22
|
-
let(:interactor) { TestInteractor }
|
23
|
-
|
24
|
-
it { expect { subject }.to change { instance.collection.count }.by(1) }
|
25
|
-
it { is_expected.to be_a described_class }
|
26
|
-
|
27
|
-
it 'is expected to add the appropriate interactor' do
|
28
|
-
subject
|
29
|
-
expect(instance.collection.first.interactor_class).to eq TestInteractor
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when interactors are passed as symbols' do
|
34
|
-
let(:interactor) { :test_interactor }
|
35
|
-
|
36
|
-
it { expect { subject }.to change { instance.collection.count }.by(1) }
|
37
|
-
it { is_expected.to be_a described_class }
|
38
|
-
|
39
|
-
it 'is expected to add the appropriate interactor' do
|
40
|
-
subject
|
41
|
-
expect(instance.collection.first.interactor_class).to eq TestInteractor
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when interactors are passed as strings' do
|
46
|
-
let(:interactor) { 'TestInteractor' }
|
47
|
-
|
48
|
-
it { expect { subject }.to change { instance.collection.count }.by(1) }
|
49
|
-
it { is_expected.to be_a described_class }
|
50
|
-
|
51
|
-
it 'is expected to add the appropriate interactor' do
|
52
|
-
subject
|
53
|
-
expect(instance.collection.first.interactor_class).to eq TestInteractor
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#concat' do
|
60
|
-
subject { instance.concat(interactors) }
|
61
|
-
|
62
|
-
let(:instance) { described_class.new }
|
63
|
-
|
64
|
-
context 'with two existing interactors' do
|
65
|
-
let!(:interactor1) { build_interactor('TestInteractor1') }
|
66
|
-
let!(:interactor2) { build_interactor('TestInteractor2') }
|
67
|
-
let(:interactors) { %i[test_interactor_1 test_interactor_2] }
|
68
|
-
|
69
|
-
it { expect { subject }.to change { instance.collection.count }.by(2) }
|
70
|
-
|
71
|
-
it 'is expected to add the appropriate interactors' do
|
72
|
-
subject
|
73
|
-
expect(instance.collection.first.interactor_class).to eq TestInteractor1
|
74
|
-
expect(instance.collection.last.interactor_class).to eq TestInteractor2
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,235 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe ActiveInteractor::Organizer::InteractorInterface do
|
6
|
-
describe '.new' do
|
7
|
-
subject(:instance) { described_class.new(interactor_class, options) }
|
8
|
-
|
9
|
-
context 'with an interactor that does not exist' do
|
10
|
-
let(:interactor_class) { :an_interactor_that_does_not_exist }
|
11
|
-
let(:options) { {} }
|
12
|
-
|
13
|
-
describe '#interactor_class' do
|
14
|
-
subject { instance.interactor_class }
|
15
|
-
|
16
|
-
it { is_expected.to be_nil }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
RSpec.shared_examples 'an instance of InteractorInterface correctly parse options' do
|
21
|
-
context 'with options {:if => :some_method }' do
|
22
|
-
let(:options) { { if: :some_method } }
|
23
|
-
|
24
|
-
describe '#filters' do
|
25
|
-
subject { instance.filters }
|
26
|
-
|
27
|
-
it { is_expected.to eq(if: :some_method) }
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#perform_options' do
|
31
|
-
subject { instance.perform_options }
|
32
|
-
|
33
|
-
it { is_expected.to be_empty }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'with options {:if => -> { context.test == true } }' do
|
38
|
-
let(:options) { { if: -> { context.test == true } } }
|
39
|
-
|
40
|
-
describe '#filters' do
|
41
|
-
subject { instance.filters }
|
42
|
-
|
43
|
-
it { expect(subject[:if]).not_to be_nil }
|
44
|
-
it { expect(subject[:if]).to be_a Proc }
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#perform_options' do
|
48
|
-
subject { instance.perform_options }
|
49
|
-
|
50
|
-
it { is_expected.to be_empty }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'with options {:unless => :some_method }' do
|
55
|
-
let(:options) { { unless: :some_method } }
|
56
|
-
|
57
|
-
describe '#filters' do
|
58
|
-
subject { instance.filters }
|
59
|
-
|
60
|
-
it { is_expected.to eq(unless: :some_method) }
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '#perform_options' do
|
64
|
-
subject { instance.perform_options }
|
65
|
-
|
66
|
-
it { is_expected.to be_empty }
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'with options {:unless => -> { context.test == true } }' do
|
71
|
-
let(:options) { { unless: -> { context.test == true } } }
|
72
|
-
|
73
|
-
describe '#filters' do
|
74
|
-
subject { instance.filters }
|
75
|
-
|
76
|
-
it { expect(subject[:unless]).not_to be_nil }
|
77
|
-
it { expect(subject[:unless]).to be_a Proc }
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#perform_options' do
|
81
|
-
subject { instance.perform_options }
|
82
|
-
|
83
|
-
it { is_expected.to be_empty }
|
84
|
-
end
|
85
|
-
end
|
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
|
-
|
153
|
-
context 'with options { :validate => false }' do
|
154
|
-
let(:options) { { validate: false } }
|
155
|
-
|
156
|
-
describe '#filters' do
|
157
|
-
subject { instance.filters }
|
158
|
-
|
159
|
-
it { is_expected.to be_empty }
|
160
|
-
end
|
161
|
-
|
162
|
-
describe '#perform_options' do
|
163
|
-
subject { instance.perform_options }
|
164
|
-
|
165
|
-
it { is_expected.to eq(validate: false) }
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
context 'with options { :if => :some_method, :validate => false, :before => :other_method }' do
|
170
|
-
let(:options) { { if: :some_method, validate: false, before: :other_method } }
|
171
|
-
|
172
|
-
describe '#filters' do
|
173
|
-
subject { instance.filters }
|
174
|
-
|
175
|
-
it { is_expected.to eq(if: :some_method) }
|
176
|
-
end
|
177
|
-
|
178
|
-
describe '#callbacks' do
|
179
|
-
subject { instance.callbacks }
|
180
|
-
|
181
|
-
it { is_expected.to eq(before: :other_method) }
|
182
|
-
end
|
183
|
-
|
184
|
-
describe '#perform_options' do
|
185
|
-
subject { instance.perform_options }
|
186
|
-
|
187
|
-
it { is_expected.to eq(validate: false) }
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
context 'with an existing interactor' do
|
193
|
-
before { build_interactor }
|
194
|
-
|
195
|
-
context 'when interactors are passed as contants' do
|
196
|
-
let(:interactor_class) { TestInteractor }
|
197
|
-
let(:options) { {} }
|
198
|
-
|
199
|
-
include_examples 'an instance of InteractorInterface correctly parse options'
|
200
|
-
|
201
|
-
describe '#interactor_class' do
|
202
|
-
subject { instance.interactor_class }
|
203
|
-
|
204
|
-
it { is_expected.to eq TestInteractor }
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
context 'when interactors are passed as symbols' do
|
209
|
-
let(:interactor_class) { :test_interactor }
|
210
|
-
let(:options) { {} }
|
211
|
-
|
212
|
-
include_examples 'an instance of InteractorInterface correctly parse options'
|
213
|
-
|
214
|
-
describe '#interactor_class' do
|
215
|
-
subject { instance.interactor_class }
|
216
|
-
|
217
|
-
it { is_expected.to eq TestInteractor }
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
context 'when interactors are passed as strings' do
|
222
|
-
let(:interactor_class) { 'TestInteractor' }
|
223
|
-
let(:options) { {} }
|
224
|
-
|
225
|
-
include_examples 'an instance of InteractorInterface correctly parse options'
|
226
|
-
|
227
|
-
describe '#interactor_class' do
|
228
|
-
subject { instance.interactor_class }
|
229
|
-
|
230
|
-
it { is_expected.to eq TestInteractor }
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
@@ -1,119 +0,0 @@
|
|
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
|