activeinteractor 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +10 -29
- data/lib/active_interactor/version.rb +41 -3
- data/spec/active_interactor/base_spec.rb +1 -0
- data/spec/active_interactor/config_spec.rb +1 -0
- data/spec/active_interactor/context/base_spec.rb +16 -0
- data/spec/active_interactor/error_spec.rb +3 -1
- data/spec/active_interactor/interactor/worker_spec.rb +3 -0
- data/spec/active_interactor/organizer/base_spec.rb +18 -1
- data/spec/active_interactor/organizer/interactor_interface_collection_spec.rb +2 -0
- data/spec/active_interactor/organizer/interactor_interface_spec.rb +1 -0
- data/spec/active_interactor/version_spec.rb +119 -0
- data/spec/active_interactor_spec.rb +0 -6
- data/spec/integration/a_basic_organizer_spec.rb +7 -0
- data/spec/integration/a_failing_interactor_spec.rb +1 -0
- data/spec/integration/an_interactor_with_after_perform_callbacks_spec.rb +1 -0
- data/spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb +1 -0
- data/spec/integration/an_interactor_with_an_existing_context_class_spec.rb +1 -0
- data/spec/integration/an_interactor_with_before_perform_callbacks_spec.rb +1 -0
- data/spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb +1 -0
- data/spec/integration/an_interactor_with_validations_on_called_spec.rb +1 -0
- data/spec/integration/an_interactor_with_validations_on_calling_spec.rb +1 -0
- data/spec/integration/an_interactor_with_validations_spec.rb +2 -0
- data/spec/integration/an_organizer_with_after_each_callbacks_spec.rb +1 -0
- data/spec/integration/an_organizer_with_before_each_callbacks_spec.rb +1 -0
- data/spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb +14 -2
- data/spec/integration/an_organizer_with_options_callbacks_spec.rb +1 -0
- data/spec/spec_helper.rb +3 -20
- data/spec/support/coverage.rb +50 -0
- data/spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb +8 -0
- data/spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb +2 -0
- data/spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb +3 -0
- metadata +41 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6326a8924b24caa906991b69c80eebeb735183386bf0914b6efb04881910ff03
|
4
|
+
data.tar.gz: aa2c69acce205ff007a54ec141b7eef0a917d9af68805ce7bd68b91686882139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 145052b08089c27b93ef87cfe7a9e29a6ffca822d3a190e8b9925117331a262a2179c2275365fe14c6e4d6997f81fbd96a4a581d8412797743c941a34caed8ec
|
7
|
+
data.tar.gz: 8eafb80d3c0fab16fe28a9b5669b237f00ca738e37729869488c4a32ebe36b0afd39b82384a9c66e758e1c8f10159f68a71e38914154361484fedc8c9407a910
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning].
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [v1.1.3] - 2022-02-16
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- [\#338] Bump activemodel and activesupport to 6.1.4.4
|
15
|
+
|
10
16
|
## [v1.1.2] - 2020-11-10
|
11
17
|
|
12
18
|
### Changed
|
@@ -231,7 +237,8 @@ and this project adheres to [Semantic Versioning].
|
|
231
237
|
|
232
238
|
<!-- versions -->
|
233
239
|
|
234
|
-
[Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.
|
240
|
+
[Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.3...HEAD
|
241
|
+
[v1.1.3]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.2...v1.1.3
|
235
242
|
[v1.1.2]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.1...v1.1.2
|
236
243
|
[v1.1.1]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.0...v1.1.1
|
237
244
|
[v1.1.0]: https://github.com/aaronmallen/activeinteractor/compare/v1.0.5...v1.1.0
|
data/README.md
CHANGED
@@ -22,7 +22,13 @@ course on how to use ActiveInteractors. Read the [wiki] for detailed usage infor
|
|
22
22
|
* Thread safe performance calls
|
23
23
|
* Organize multiple interactors [conditionally][wiki_organizers_conditionally] or in [parallel][wiki_organizers_parallel]
|
24
24
|
|
25
|
-
##
|
25
|
+
## Documentation
|
26
|
+
|
27
|
+
Be sure to read the [wiki] for detailed information on how to use ActiveInteractor.
|
28
|
+
|
29
|
+
For technical documentation please see the gem's [ruby docs].
|
30
|
+
|
31
|
+
## Install
|
26
32
|
|
27
33
|
Add this line to your application's Gemfile:
|
28
34
|
|
@@ -30,54 +36,29 @@ Add this line to your application's Gemfile:
|
|
30
36
|
gem 'activeinteractor', require: 'active_interactor'
|
31
37
|
```
|
32
38
|
|
33
|
-
And then execute:
|
34
|
-
|
35
|
-
```bash
|
36
|
-
bundle
|
37
|
-
```
|
38
|
-
|
39
39
|
Or install it yourself as:
|
40
40
|
|
41
|
-
```
|
41
|
+
```sh
|
42
42
|
gem install activeinteractor
|
43
43
|
```
|
44
44
|
|
45
|
-
## Usage
|
46
|
-
|
47
|
-
Be sure to read the [wiki] for detailed information on how to use ActiveInteractor.
|
48
|
-
|
49
|
-
For technical documentation please see the gem's [ruby docs].
|
50
|
-
|
51
|
-
## Development
|
52
|
-
|
53
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
54
|
-
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
-
|
56
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
57
|
-
|
58
45
|
## Contributing
|
59
46
|
|
60
47
|
Read our guidelines for [Contributing](CONTRIBUTING.md).
|
61
48
|
|
62
49
|
## Acknowledgements
|
63
50
|
|
64
|
-
|
65
|
-
the [interactor][collective_idea_interactors] gem.
|
66
|
-
* Special thanks to the [@rails] team for their work on [ActiveModel][active_model_git]
|
67
|
-
and [ActiveSupport][active_support_git] gems.
|
51
|
+
ActiveInteractor is made possible by wonderful [humans].
|
68
52
|
|
69
53
|
## License
|
70
54
|
|
71
55
|
The gem is available as open source under the terms of the [MIT License][mit_license].
|
72
56
|
|
73
|
-
[@collectiveidea]: https://github.com/collectiveidea
|
74
|
-
[@rails]: https://github.com/rails
|
75
|
-
[active_model_git]: https://github.com/rails/rails/tree/master/activemodel
|
76
|
-
[active_support_git]: https://github.com/rails/rails/tree/master/activesupport
|
77
57
|
[ActiveModel::Validations]: https://api.rubyonrails.org/classes/ActiveModel/Validations.html
|
78
58
|
[business_logic_wikipedia]: https://en.wikipedia.org/wiki/Business_logic
|
79
59
|
[collective_idea_interactors]: https://github.com/collectiveidea/interactor
|
80
60
|
[command pattern]: https://en.wikipedia.org/wiki/Command_pattern
|
61
|
+
[humans]: https://github.com/aaronmallen/activeinteractor/tree/main/HUMANS.md
|
81
62
|
[Medium article]: https://medium.com/@aaronmallen/activeinteractor-8557c0dc78db
|
82
63
|
[mit_license]: https://opensource.org/licenses/MIT
|
83
64
|
[ruby docs]: https://www.rubydoc.info/gems/activeinteractor
|
@@ -1,7 +1,45 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveInteractor
|
4
|
-
# The ActiveInteractor version
|
5
|
-
#
|
6
|
-
|
4
|
+
# The ActiveInteractor version info
|
5
|
+
#
|
6
|
+
# @author Aaron Allen <hello@aaronmallen.me>
|
7
|
+
# @since unreleased
|
8
|
+
module Version
|
9
|
+
# The ActiveInterctor major version number
|
10
|
+
# @return [Integer] The ActiveInteractor major version number
|
11
|
+
MAJOR = 1
|
12
|
+
|
13
|
+
# The ActiveInterctor minor version number
|
14
|
+
# @return [Integer] The ActiveInteractor minor version number
|
15
|
+
MINOR = 1
|
16
|
+
|
17
|
+
# The ActiveInterctor patch version number
|
18
|
+
# @return [Integer] The ActiveInteractor patch version number
|
19
|
+
PATCH = 3
|
20
|
+
|
21
|
+
# The ActiveInterctor pre-release version
|
22
|
+
# @return [String | nil] The ActiveInteractor pre-release version
|
23
|
+
PRE = nil
|
24
|
+
|
25
|
+
# The ActiveInterctor meta version
|
26
|
+
# @return [String | nil] The ActiveInteractor meta version
|
27
|
+
META = nil
|
28
|
+
|
29
|
+
# The ActiveInterctor rubygems version
|
30
|
+
# @return [String] The ActiveInteractor rubygems version
|
31
|
+
def self.gem_version
|
32
|
+
pre_meta = PRE.nil? ? nil : [PRE, META].compact.join('.').freeze
|
33
|
+
[MAJOR, MINOR, PATCH, pre_meta].compact.join('.').freeze
|
34
|
+
end
|
35
|
+
|
36
|
+
# The ActiveInterctor semver version
|
37
|
+
# @return [String] The ActiveInteractor semver version
|
38
|
+
def self.semver
|
39
|
+
version = [MAJOR, MINOR, PATCH].join('.')
|
40
|
+
version = "#{version}-#{PRE}" if PRE
|
41
|
+
version = "#{version}+#{META}" if META
|
42
|
+
version.freeze
|
43
|
+
end
|
44
|
+
end
|
7
45
|
end
|
@@ -4,6 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe ActiveInteractor::Base do
|
6
6
|
let(:interactor_class) { described_class }
|
7
|
+
|
7
8
|
include_examples 'a class with interactor methods'
|
8
9
|
include_examples 'a class with interactor callback methods'
|
9
10
|
include_examples 'a class with interactor context methods'
|
@@ -6,7 +6,9 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
6
6
|
describe '.attributes' do
|
7
7
|
context 'when no arguments are passed' do
|
8
8
|
subject { context_class.attributes }
|
9
|
+
|
9
10
|
let!(:context_class) { build_context }
|
11
|
+
|
10
12
|
it { is_expected.to eq [] }
|
11
13
|
|
12
14
|
context 'when an attribute :foo was previously defined' do
|
@@ -22,6 +24,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
22
24
|
|
23
25
|
context 'when given arguments :foo and :bar' do
|
24
26
|
subject { context_class.attributes(:foo, :bar) }
|
27
|
+
|
25
28
|
let!(:context_class) { build_context }
|
26
29
|
|
27
30
|
it { is_expected.to eq %i[bar foo] }
|
@@ -48,6 +51,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
48
51
|
|
49
52
|
context 'with attribute equal to "foo"' do
|
50
53
|
let(:attribute) { :foo }
|
54
|
+
|
51
55
|
before { instance.foo = 'foo' }
|
52
56
|
|
53
57
|
it { is_expected.to eq 'foo' }
|
@@ -70,6 +74,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
70
74
|
|
71
75
|
context 'with attribute equal to "foo"' do
|
72
76
|
let(:attribute) { :foo }
|
77
|
+
|
73
78
|
before { instance.foo = 'foo' }
|
74
79
|
|
75
80
|
it { is_expected.to eq 'foo' }
|
@@ -136,6 +141,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
136
141
|
|
137
142
|
it { is_expected.to be_a Hash }
|
138
143
|
it { is_expected.to eq(bar: 'bar', foo: 'foo') }
|
144
|
+
|
139
145
|
it 'is expected to assign :baz' do
|
140
146
|
expect(instance.baz).to eq 'baz'
|
141
147
|
end
|
@@ -162,6 +168,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
162
168
|
|
163
169
|
describe '#fail!' do
|
164
170
|
subject { instance.fail!(errors) }
|
171
|
+
|
165
172
|
let(:instance) { described_class.new }
|
166
173
|
|
167
174
|
context 'with errors equal to nil' do
|
@@ -224,6 +231,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
224
231
|
|
225
232
|
describe '#failure?' do
|
226
233
|
subject { instance.failure? }
|
234
|
+
|
227
235
|
let(:instance) { described_class.new }
|
228
236
|
|
229
237
|
it { is_expected.to eq false }
|
@@ -275,6 +283,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
275
283
|
|
276
284
|
it { is_expected.to be_a described_class }
|
277
285
|
it { is_expected.to have_attributes(foo: 'foo') }
|
286
|
+
|
278
287
|
it 'is expected to preserve @_failed instance variable' do
|
279
288
|
expect(subject.instance_variable_get('@_failed')).to eq true
|
280
289
|
end
|
@@ -285,6 +294,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
285
294
|
|
286
295
|
it { is_expected.to be_a described_class }
|
287
296
|
it { is_expected.to have_attributes(foo: 'foo') }
|
297
|
+
|
288
298
|
it 'is expected to preserve @_rolled_back instance variable' do
|
289
299
|
expect(subject.instance_variable_get('@_rolled_back')).to eq true
|
290
300
|
end
|
@@ -347,6 +357,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
347
357
|
before { attributes.errors.add(:foo, 'invalid') }
|
348
358
|
|
349
359
|
it { is_expected.to be_a described_class }
|
360
|
+
|
350
361
|
it 'is expected to have errors on :foo' do
|
351
362
|
expect(subject.errors[:foo]).not_to be_nil
|
352
363
|
expect(subject.errors[:foo]).to include 'invalid'
|
@@ -358,6 +369,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
358
369
|
|
359
370
|
it { is_expected.to be_a described_class }
|
360
371
|
it { is_expected.to have_attributes(foo: 'foo') }
|
372
|
+
|
361
373
|
it 'is expected to preserve @_called instance variable' do
|
362
374
|
expect(subject.instance_variable_get('@_called')).to eq %w[foo]
|
363
375
|
end
|
@@ -368,6 +380,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
368
380
|
|
369
381
|
it { is_expected.to be_a described_class }
|
370
382
|
it { is_expected.to have_attributes(foo: 'foo') }
|
383
|
+
|
371
384
|
it 'is expected to preserve @_failed instance variable' do
|
372
385
|
expect(subject.instance_variable_get('@_failed')).to eq true
|
373
386
|
end
|
@@ -378,6 +391,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
378
391
|
|
379
392
|
it { is_expected.to be_a described_class }
|
380
393
|
it { is_expected.to have_attributes(foo: 'foo') }
|
394
|
+
|
381
395
|
it 'is expected to preserve @_rolled_back instance variable' do
|
382
396
|
expect(subject.instance_variable_get('@_rolled_back')).to eq true
|
383
397
|
end
|
@@ -387,6 +401,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
387
401
|
|
388
402
|
describe '#rollback!' do
|
389
403
|
subject { instance.rollback! }
|
404
|
+
|
390
405
|
let(:instance) { described_class.new }
|
391
406
|
|
392
407
|
context 'with #called! interactors' do
|
@@ -414,6 +429,7 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
414
429
|
|
415
430
|
describe '#success?' do
|
416
431
|
subject { instance.success? }
|
432
|
+
|
417
433
|
let(:instance) { described_class.new }
|
418
434
|
|
419
435
|
it { is_expected.to eq true }
|
@@ -14,10 +14,12 @@ RSpec.describe ActiveInteractor::Error::ContextFailure do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
context 'when context is an instance of "TestContext"' do
|
17
|
-
before { build_context }
|
18
17
|
subject { described_class.new(TestContext.new) }
|
19
18
|
|
19
|
+
before { build_context }
|
20
|
+
|
20
21
|
it { is_expected.to have_attributes(message: 'TestContext failed!') }
|
22
|
+
|
21
23
|
it 'is expected to have an instance of TestContext' do
|
22
24
|
expect(subject.context).to be_a TestContext
|
23
25
|
end
|
@@ -5,6 +5,7 @@ require 'spec_helper'
|
|
5
5
|
RSpec.describe ActiveInteractor::Interactor::Worker do
|
6
6
|
context 'with interactor class TestInteractor' do
|
7
7
|
before { build_interactor }
|
8
|
+
|
8
9
|
let(:interactor) { TestInteractor.new }
|
9
10
|
|
10
11
|
RSpec.shared_examples 'an interactor with options' do
|
@@ -118,6 +119,7 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
|
|
118
119
|
end
|
119
120
|
|
120
121
|
it { expect { subject }.to raise_error(ActiveInteractor::Error::ContextFailure) }
|
122
|
+
|
121
123
|
it 'is expected to rollback the interactor context' do
|
122
124
|
expect_any_instance_of(TestInteractor).to receive(:context_rollback!)
|
123
125
|
expect { subject }.to raise_error(ActiveInteractor::Error::ContextFailure)
|
@@ -135,6 +137,7 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
|
|
135
137
|
end
|
136
138
|
|
137
139
|
it { expect { subject }.to raise_error(ActiveInteractor::Error::ContextFailure) }
|
140
|
+
|
138
141
|
it 'is expected to rollback the interactor context' do
|
139
142
|
expect_any_instance_of(TestInteractor).to receive(:context_rollback!)
|
140
143
|
expect { subject }.to raise_error(ActiveInteractor::Error::ContextFailure)
|
@@ -4,6 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe ActiveInteractor::Organizer::Base do
|
6
6
|
let(:interactor_class) { described_class }
|
7
|
+
|
7
8
|
include_examples 'a class with interactor methods'
|
8
9
|
include_examples 'a class with interactor callback methods'
|
9
10
|
include_examples 'a class with interactor context methods'
|
@@ -66,6 +67,7 @@ RSpec.describe ActiveInteractor::Organizer::Base do
|
|
66
67
|
subject { organizer.organized }
|
67
68
|
|
68
69
|
it { expect(subject.collection).to all(be_a ActiveInteractor::Organizer::InteractorInterface) }
|
70
|
+
|
69
71
|
it 'is expected to organize the approriate interactors' do
|
70
72
|
expect(subject.collection.first.interactor_class).to eq TestInteractor1
|
71
73
|
expect(subject.collection.last.interactor_class).to eq TestInteractor2
|
@@ -87,6 +89,7 @@ RSpec.describe ActiveInteractor::Organizer::Base do
|
|
87
89
|
subject { organizer.organized }
|
88
90
|
|
89
91
|
it { expect(subject.collection).to all(be_a ActiveInteractor::Organizer::InteractorInterface) }
|
92
|
+
|
90
93
|
it 'is expected to organize the approriate interactors' do
|
91
94
|
expect(subject.collection.first.interactor_class).to eq TestInteractor1
|
92
95
|
expect(subject.collection.last.interactor_class).to eq TestInteractor2
|
@@ -103,11 +106,12 @@ RSpec.describe ActiveInteractor::Organizer::Base do
|
|
103
106
|
end
|
104
107
|
end
|
105
108
|
|
106
|
-
it {
|
109
|
+
it { is_expected.to have_attributes(parallel: true) }
|
107
110
|
end
|
108
111
|
|
109
112
|
describe '#perform' do
|
110
113
|
subject { interactor_class.perform }
|
114
|
+
|
111
115
|
context 'with two existing interactors' do
|
112
116
|
let!(:interactor1) { build_interactor('TestInteractor1') }
|
113
117
|
let!(:interactor2) { build_interactor('TestInteractor2') }
|
@@ -118,6 +122,7 @@ RSpec.describe ActiveInteractor::Organizer::Base do
|
|
118
122
|
end
|
119
123
|
|
120
124
|
it { is_expected.to be_a interactor_class.context_class }
|
125
|
+
|
121
126
|
it 'is expected to receive #perform on both interactors' do
|
122
127
|
expect_any_instance_of(interactor1).to receive(:perform)
|
123
128
|
expect_any_instance_of(interactor2).to receive(:perform)
|
@@ -128,11 +133,13 @@ RSpec.describe ActiveInteractor::Organizer::Base do
|
|
128
133
|
subject { interactor_class.perform({}, skip_each_perform_callbacks: true) }
|
129
134
|
|
130
135
|
it { is_expected.to be_a interactor_class.context_class }
|
136
|
+
|
131
137
|
it 'is expected to receive #perform on both interactors' do
|
132
138
|
expect_any_instance_of(interactor1).to receive(:perform)
|
133
139
|
expect_any_instance_of(interactor2).to receive(:perform)
|
134
140
|
subject
|
135
141
|
end
|
142
|
+
|
136
143
|
it 'is expected not to receive #run_callbacks with :each_perform' do
|
137
144
|
expect_any_instance_of(interactor_class).not_to receive(:run_callbacks)
|
138
145
|
.with(:each_perform)
|
@@ -152,14 +159,17 @@ RSpec.describe ActiveInteractor::Organizer::Base do
|
|
152
159
|
it { expect { subject }.not_to raise_error }
|
153
160
|
it { is_expected.to be_failure }
|
154
161
|
it { is_expected.to be_a interactor_class.context_class }
|
162
|
+
|
155
163
|
it 'is expected to receive #perform on the first interactor' do
|
156
164
|
expect_any_instance_of(interactor1).to receive(:perform)
|
157
165
|
subject
|
158
166
|
end
|
167
|
+
|
159
168
|
it 'is expected not to receive #perform on the second interactor' do
|
160
169
|
expect_any_instance_of(interactor2).not_to receive(:perform)
|
161
170
|
subject
|
162
171
|
end
|
172
|
+
|
163
173
|
it 'is expected to receive #rollback on the first interactor' do
|
164
174
|
expect_any_instance_of(interactor1).to receive(:rollback)
|
165
175
|
subject
|
@@ -178,11 +188,13 @@ RSpec.describe ActiveInteractor::Organizer::Base do
|
|
178
188
|
it { expect { subject }.not_to raise_error }
|
179
189
|
it { is_expected.to be_failure }
|
180
190
|
it { is_expected.to be_a interactor_class.context_class }
|
191
|
+
|
181
192
|
it 'is expected to receive #perform on both interactors' do
|
182
193
|
expect_any_instance_of(interactor1).to receive(:perform)
|
183
194
|
expect_any_instance_of(interactor2).to receive(:perform)
|
184
195
|
subject
|
185
196
|
end
|
197
|
+
|
186
198
|
it 'is expected to receive #rollback on both interactors' do
|
187
199
|
expect_any_instance_of(interactor1).to receive(:rollback)
|
188
200
|
expect_any_instance_of(interactor2).to receive(:rollback)
|
@@ -200,6 +212,7 @@ RSpec.describe ActiveInteractor::Organizer::Base do
|
|
200
212
|
end
|
201
213
|
|
202
214
|
it { is_expected.to be_a interactor_class.context_class }
|
215
|
+
|
203
216
|
it 'is expected to receive #perform on both interactors' do
|
204
217
|
expect_any_instance_of(interactor1).to receive(:perform)
|
205
218
|
expect_any_instance_of(interactor2).to receive(:perform)
|
@@ -218,11 +231,13 @@ RSpec.describe ActiveInteractor::Organizer::Base do
|
|
218
231
|
it { expect { subject }.not_to raise_error }
|
219
232
|
it { is_expected.to be_failure }
|
220
233
|
it { is_expected.to be_a interactor_class.context_class }
|
234
|
+
|
221
235
|
it 'is expected to receive #perform on both interactors' do
|
222
236
|
expect_any_instance_of(interactor1).to receive(:perform)
|
223
237
|
expect_any_instance_of(interactor2).to receive(:perform)
|
224
238
|
subject
|
225
239
|
end
|
240
|
+
|
226
241
|
it 'is expected to receive #rollback both interactors' do
|
227
242
|
expect_any_instance_of(interactor1).to receive(:rollback)
|
228
243
|
expect_any_instance_of(interactor2).to receive(:rollback)
|
@@ -242,11 +257,13 @@ RSpec.describe ActiveInteractor::Organizer::Base do
|
|
242
257
|
it { expect { subject }.not_to raise_error }
|
243
258
|
it { is_expected.to be_failure }
|
244
259
|
it { is_expected.to be_a interactor_class.context_class }
|
260
|
+
|
245
261
|
it 'is expected to receive #perform on both interactors' do
|
246
262
|
expect_any_instance_of(interactor1).to receive(:perform)
|
247
263
|
expect_any_instance_of(interactor2).to receive(:perform)
|
248
264
|
subject
|
249
265
|
end
|
266
|
+
|
250
267
|
it 'is expected to receive #rollback on both interactors' do
|
251
268
|
expect_any_instance_of(interactor1).to receive(:rollback)
|
252
269
|
expect_any_instance_of(interactor2).to receive(:rollback)
|
@@ -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
|
@@ -221,6 +221,7 @@ RSpec.describe ActiveInteractor::Organizer::InteractorInterface do
|
|
221
221
|
context 'when interactors are passed as strings' do
|
222
222
|
let(:interactor_class) { 'TestInteractor' }
|
223
223
|
let(:options) { {} }
|
224
|
+
|
224
225
|
include_examples 'an instance of InteractorInterface correctly parse options'
|
225
226
|
|
226
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
|
@@ -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'
|
@@ -175,6 +180,7 @@ RSpec.describe 'A basic organizer', type: :integration do
|
|
175
180
|
|
176
181
|
describe '.perform' do
|
177
182
|
subject(:result) { interactor_class.perform(context_attributes) }
|
183
|
+
|
178
184
|
it { is_expected.to have_attributes(foo: 'foo', bar: 'bar', baz: 'baz', zoo: 'zoo') }
|
179
185
|
|
180
186
|
it 'is expected to copy all attributes in the contexts to each interactor' do
|
@@ -206,6 +212,7 @@ RSpec.describe 'A basic organizer', type: :integration do
|
|
206
212
|
|
207
213
|
describe '.perform' do
|
208
214
|
subject(:result) { interactor_class.perform(context_attributes) }
|
215
|
+
|
209
216
|
it { is_expected.to have_attributes(foo: 'foo', bar: 'bar') }
|
210
217
|
|
211
218
|
it 'is expected to copy all attributes in the contexts to each interactor' do
|
@@ -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
|
-
|
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
|
-
|
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)
|
@@ -44,6 +44,7 @@ RSpec.describe 'An organizer with options callbacks', type: :integration do
|
|
44
44
|
subject { interactor_class.perform(step: 1) }
|
45
45
|
|
46
46
|
it { is_expected.to be_a interactor_class.context_class }
|
47
|
+
|
47
48
|
it 'is expected to receive #test_before_method once' do
|
48
49
|
expect_any_instance_of(interactor_class).to receive(:test_before_method)
|
49
50
|
.exactly(:once)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require 'simplecov-lcov'
|
6
|
-
|
7
|
-
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
|
8
|
-
|
9
|
-
SimpleCov.start do
|
10
|
-
enable_coverage :branch
|
11
|
-
add_filter '/spec/'
|
12
|
-
add_filter '/lib/rails/**/*.rb'
|
13
|
-
track_files '/lib/**/*.rb'
|
14
|
-
formatter SimpleCov::Formatter::MultiFormatter.new([
|
15
|
-
SimpleCov::Formatter::HTMLFormatter,
|
16
|
-
SimpleCov::Formatter::LcovFormatter
|
17
|
-
])
|
18
|
-
end
|
19
|
-
rescue LoadError
|
20
|
-
puts 'Skipping coverage...'
|
21
|
-
end
|
3
|
+
require_relative 'support/coverage'
|
4
|
+
ActiveInteractor::Spec::Coverage.start
|
22
5
|
|
23
6
|
require 'bundler/setup'
|
24
7
|
require 'active_interactor'
|
@@ -32,7 +15,7 @@ RSpec.configure do |config|
|
|
32
15
|
allow(ActiveInteractor.logger).to receive(:error).and_return(true)
|
33
16
|
end
|
34
17
|
|
35
|
-
config.after
|
18
|
+
config.after do
|
36
19
|
clean_factories!
|
37
20
|
end
|
38
21
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
require 'simplecov-lcov'
|
5
|
+
|
6
|
+
module ActiveInteractor
|
7
|
+
module Spec
|
8
|
+
class Coverage
|
9
|
+
DEFAULT_COVERAGE_TYPE = 'unit'
|
10
|
+
EXCLUDED_FILES_PATTERN = '/spec/'
|
11
|
+
TRACKED_FILES_PATTERN = 'lib/**/*.rb'
|
12
|
+
|
13
|
+
FORMATTERS = [
|
14
|
+
SimpleCov::Formatter::HTMLFormatter,
|
15
|
+
SimpleCov::Formatter::LcovFormatter
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def start
|
20
|
+
setup_lcov_formatter
|
21
|
+
start_simplecov
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def simplecov_formatter
|
27
|
+
@simplecov_formatter ||= SimpleCov::Formatter::MultiFormatter.new(FORMATTERS)
|
28
|
+
end
|
29
|
+
|
30
|
+
def setup_lcov_formatter
|
31
|
+
coverage_type = ENV.fetch('COVERAGE_TYPE', DEFAULT_COVERAGE_TYPE)
|
32
|
+
|
33
|
+
SimpleCov::Formatter::LcovFormatter.config do |config|
|
34
|
+
config.report_with_single_file = true
|
35
|
+
config.single_report_path = "coverage/#{coverage_type}_lcov.info"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def start_simplecov
|
40
|
+
SimpleCov.start do
|
41
|
+
add_filter EXCLUDED_FILES_PATTERN
|
42
|
+
enable_coverage :branch
|
43
|
+
track_files TRACKED_FILES_PATTERN
|
44
|
+
formatter simplecov_formatter
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
RSpec.shared_examples 'a class with interactor callback methods' do
|
4
4
|
describe '.after_context_validation' do
|
5
5
|
subject { interactor_class.after_context_validation(*args) }
|
6
|
+
|
6
7
|
let(:args) { :some_method }
|
7
8
|
|
8
9
|
it 'is expected to receive #set_callback with :validation, :after, :some_method, { :prepend => true }' do
|
@@ -15,6 +16,7 @@ RSpec.shared_examples 'a class with interactor callback methods' do
|
|
15
16
|
|
16
17
|
describe '.after_perform' do
|
17
18
|
subject { interactor_class.after_perform(*args) }
|
19
|
+
|
18
20
|
let(:args) { :some_method }
|
19
21
|
|
20
22
|
it 'is expected to receive #set_callback with :perform, :after, :some_method' do
|
@@ -27,6 +29,7 @@ RSpec.shared_examples 'a class with interactor callback methods' do
|
|
27
29
|
|
28
30
|
describe '.after_rollback' do
|
29
31
|
subject { interactor_class.after_rollback(*args) }
|
32
|
+
|
30
33
|
let(:args) { :some_method }
|
31
34
|
|
32
35
|
it 'is expected to receive #set_callback with :rollback, :after, :some_method' do
|
@@ -39,6 +42,7 @@ RSpec.shared_examples 'a class with interactor callback methods' do
|
|
39
42
|
|
40
43
|
describe '.around_perform' do
|
41
44
|
subject { interactor_class.around_perform(*args) }
|
45
|
+
|
42
46
|
let(:args) { :some_method }
|
43
47
|
|
44
48
|
it 'is expected to receive #set_callback with :perform, :around, :some_method' do
|
@@ -51,6 +55,7 @@ RSpec.shared_examples 'a class with interactor callback methods' do
|
|
51
55
|
|
52
56
|
describe '.around_rollback' do
|
53
57
|
subject { interactor_class.around_rollback(*args) }
|
58
|
+
|
54
59
|
let(:args) { :some_method }
|
55
60
|
|
56
61
|
it 'is expected to receive #set_callback with :rollback, :around, :some_method' do
|
@@ -63,6 +68,7 @@ RSpec.shared_examples 'a class with interactor callback methods' do
|
|
63
68
|
|
64
69
|
describe '.before_context_validation' do
|
65
70
|
subject { interactor_class.before_context_validation(*args) }
|
71
|
+
|
66
72
|
let(:args) { :some_method }
|
67
73
|
|
68
74
|
it 'is expected to receive #set_callback with :validation, :before, :some_method' do
|
@@ -75,6 +81,7 @@ RSpec.shared_examples 'a class with interactor callback methods' do
|
|
75
81
|
|
76
82
|
describe '.before_perform' do
|
77
83
|
subject { interactor_class.before_perform(*args) }
|
84
|
+
|
78
85
|
let(:args) { :some_method }
|
79
86
|
|
80
87
|
it 'is expected to receive #set_callback with :perform, :before, :some_method' do
|
@@ -87,6 +94,7 @@ RSpec.shared_examples 'a class with interactor callback methods' do
|
|
87
94
|
|
88
95
|
describe '.before_rollback' do
|
89
96
|
subject { interactor_class.before_rollback(*args) }
|
97
|
+
|
90
98
|
let(:args) { :some_method }
|
91
99
|
|
92
100
|
it 'is expected to receive #set_callback with :rollback, :before, :some_method' do
|
@@ -3,6 +3,7 @@
|
|
3
3
|
RSpec.shared_examples 'a class with interactor context methods' do
|
4
4
|
describe '.context_attributes' do
|
5
5
|
subject { interactor_class.context_attributes(attributes) }
|
6
|
+
|
6
7
|
let(:attributes) { :some_attribute }
|
7
8
|
|
8
9
|
it 'is expected to receive #attributes on .context_class with :some_attribute' do
|
@@ -45,6 +46,7 @@ RSpec.shared_examples 'a class with interactor context methods' do
|
|
45
46
|
|
46
47
|
describe '#finalize_context!' do
|
47
48
|
subject { instance.finalize_context! }
|
49
|
+
|
48
50
|
let(:instance) { interactor_class.new }
|
49
51
|
|
50
52
|
it 'is expected to receive #called! on instance of .context_class' do
|
@@ -3,6 +3,7 @@
|
|
3
3
|
RSpec.shared_examples 'a class with organizer callback methods' do
|
4
4
|
describe '.after_each_perform' do
|
5
5
|
subject { interactor_class.after_each_perform(*args) }
|
6
|
+
|
6
7
|
let(:args) { :some_method }
|
7
8
|
|
8
9
|
it 'is expected to receive #set_callback with :each_perform, :after, :some_method' do
|
@@ -15,6 +16,7 @@ RSpec.shared_examples 'a class with organizer callback methods' do
|
|
15
16
|
|
16
17
|
describe '.around_each_perform' do
|
17
18
|
subject { interactor_class.around_each_perform(*args) }
|
19
|
+
|
18
20
|
let(:args) { :some_method }
|
19
21
|
|
20
22
|
it 'is expected to receive #set_callback with :each_perform, :around, :some_method' do
|
@@ -27,6 +29,7 @@ RSpec.shared_examples 'a class with organizer callback methods' do
|
|
27
29
|
|
28
30
|
describe '.before_each_perform' do
|
29
31
|
subject { interactor_class.before_each_perform(*args) }
|
32
|
+
|
30
33
|
let(:args) { :some_method }
|
31
34
|
|
32
35
|
it 'is expected to receive #set_callback with :each_perform, :before, :some_method' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeinteractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '4.2'
|
20
20
|
- - "<="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 6.1.4.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '4.2'
|
30
30
|
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 6.1.4.4
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '4.2'
|
40
40
|
- - "<="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 6.1.4.4
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '4.2'
|
50
50
|
- - "<="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
52
|
+
version: 6.1.4.4
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- spec/active_interactor/organizer/base_spec.rb
|
168
168
|
- spec/active_interactor/organizer/interactor_interface_collection_spec.rb
|
169
169
|
- spec/active_interactor/organizer/interactor_interface_spec.rb
|
170
|
+
- spec/active_interactor/version_spec.rb
|
170
171
|
- spec/active_interactor_spec.rb
|
171
172
|
- spec/integration/a_basic_interactor_spec.rb
|
172
173
|
- spec/integration/a_basic_organizer_spec.rb
|
@@ -191,6 +192,7 @@ files:
|
|
191
192
|
- spec/integration/an_organizer_with_failing_nested_organizer_spec.rb
|
192
193
|
- spec/integration/an_organizer_with_options_callbacks_spec.rb
|
193
194
|
- spec/spec_helper.rb
|
195
|
+
- spec/support/coverage.rb
|
194
196
|
- spec/support/helpers/factories.rb
|
195
197
|
- spec/support/shared_examples/a_class_that_extends_active_interactor_models_example.rb
|
196
198
|
- spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb
|
@@ -203,10 +205,10 @@ licenses:
|
|
203
205
|
- MIT
|
204
206
|
metadata:
|
205
207
|
bug_tracker_uri: https://github.com/aaronmallen/activeinteractor/issues
|
206
|
-
changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v1.1.
|
207
|
-
documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.1.
|
208
|
+
changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v1.1.3/CHANGELOG.md
|
209
|
+
documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.1.3
|
208
210
|
hompage_uri: https://github.com/aaronmallen/activeinteractor
|
209
|
-
source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v1.1.
|
211
|
+
source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v1.1.3
|
210
212
|
wiki_uri: https://github.com/aaronmallen/activeinteractor/wiki
|
211
213
|
post_install_message:
|
212
214
|
rdoc_options: []
|
@@ -223,48 +225,50 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
225
|
- !ruby/object:Gem::Version
|
224
226
|
version: '0'
|
225
227
|
requirements: []
|
226
|
-
rubygems_version: 3.0.3
|
228
|
+
rubygems_version: 3.0.3.1
|
227
229
|
signing_key:
|
228
230
|
specification_version: 4
|
229
231
|
summary: Ruby interactors with ActiveModel::Validations
|
230
232
|
test_files:
|
233
|
+
- spec/support/coverage.rb
|
234
|
+
- spec/support/spec_helpers.rb
|
231
235
|
- spec/support/shared_examples/a_class_that_extends_active_interactor_models_example.rb
|
232
|
-
- spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb
|
233
|
-
- spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb
|
234
236
|
- spec/support/shared_examples/a_class_with_interactor_methods_example.rb
|
235
237
|
- spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb
|
236
|
-
- spec/support/
|
238
|
+
- spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb
|
239
|
+
- spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb
|
237
240
|
- spec/support/helpers/factories.rb
|
238
|
-
- spec/
|
239
|
-
- spec/
|
240
|
-
- spec/
|
241
|
-
- spec/active_interactor/config_spec.rb
|
242
|
-
- spec/active_interactor/interactor/perform/options_spec.rb
|
243
|
-
- spec/active_interactor/interactor/worker_spec.rb
|
244
|
-
- spec/active_interactor/error_spec.rb
|
245
|
-
- spec/active_interactor/base_spec.rb
|
246
|
-
- spec/active_interactor/context/base_spec.rb
|
247
|
-
- spec/integration/an_interactor_with_validations_spec.rb
|
241
|
+
- spec/active_interactor_spec.rb
|
242
|
+
- spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb
|
243
|
+
- spec/integration/an_interactor_with_around_rollback_callbacks_spec.rb
|
248
244
|
- spec/integration/a_basic_interactor_spec.rb
|
249
|
-
- spec/integration/
|
250
|
-
- spec/integration/an_organizer_performing_in_parallel_spec.rb
|
251
|
-
- spec/integration/an_organizer_with_failing_nested_organizer_spec.rb
|
245
|
+
- spec/integration/an_interactor_with_validations_spec.rb
|
252
246
|
- spec/integration/an_interactor_with_after_context_validation_callbacks_spec.rb
|
247
|
+
- spec/integration/an_organizer_with_failing_nested_organizer_spec.rb
|
248
|
+
- spec/integration/a_basic_organizer_spec.rb
|
249
|
+
- spec/integration/an_organizer_with_options_callbacks_spec.rb
|
253
250
|
- spec/integration/an_interactor_with_an_existing_context_class_spec.rb
|
254
|
-
- spec/integration/
|
255
|
-
- spec/integration/an_organizer_with_before_each_callbacks_spec.rb
|
251
|
+
- spec/integration/active_record_integration_spec.rb
|
256
252
|
- spec/integration/an_interactor_with_validations_on_calling_spec.rb
|
257
|
-
- spec/integration/an_organizer_with_options_callbacks_spec.rb
|
258
|
-
- spec/integration/an_interactor_with_around_rollback_callbacks_spec.rb
|
259
|
-
- spec/integration/an_interactor_with_validations_on_called_spec.rb
|
260
253
|
- spec/integration/an_interactor_with_after_perform_callbacks_spec.rb
|
254
|
+
- spec/integration/an_organizer_performing_in_parallel_spec.rb
|
255
|
+
- spec/integration/an_organizer_with_after_each_callbacks_spec.rb
|
261
256
|
- spec/integration/a_failing_interactor_spec.rb
|
262
|
-
- spec/integration/
|
257
|
+
- spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb
|
263
258
|
- spec/integration/an_interactor_with_around_perform_callbacks_spec.rb
|
264
|
-
- spec/integration/an_organizer_with_around_each_callbacks_spec.rb
|
265
|
-
- spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb
|
266
|
-
- spec/integration/an_organizer_with_after_each_callbacks_spec.rb
|
267
259
|
- spec/integration/an_interactor_with_before_perform_callbacks_spec.rb
|
268
|
-
- spec/integration/
|
260
|
+
- spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb
|
261
|
+
- spec/integration/an_organizer_with_before_each_callbacks_spec.rb
|
262
|
+
- spec/integration/an_interactor_with_validations_on_called_spec.rb
|
263
|
+
- spec/integration/an_organizer_with_around_each_callbacks_spec.rb
|
269
264
|
- spec/spec_helper.rb
|
270
|
-
- spec/
|
265
|
+
- spec/active_interactor/error_spec.rb
|
266
|
+
- spec/active_interactor/organizer/interactor_interface_spec.rb
|
267
|
+
- spec/active_interactor/organizer/interactor_interface_collection_spec.rb
|
268
|
+
- spec/active_interactor/organizer/base_spec.rb
|
269
|
+
- spec/active_interactor/config_spec.rb
|
270
|
+
- spec/active_interactor/context/base_spec.rb
|
271
|
+
- spec/active_interactor/interactor/perform/options_spec.rb
|
272
|
+
- spec/active_interactor/interactor/worker_spec.rb
|
273
|
+
- spec/active_interactor/version_spec.rb
|
274
|
+
- spec/active_interactor/base_spec.rb
|