activeinteractor 1.1.1 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -1
  3. data/README.md +10 -29
  4. data/lib/active_interactor/context/errors.rb +11 -1
  5. data/lib/active_interactor/version.rb +41 -3
  6. data/spec/active_interactor/base_spec.rb +1 -0
  7. data/spec/active_interactor/config_spec.rb +1 -0
  8. data/spec/active_interactor/context/base_spec.rb +16 -0
  9. data/spec/active_interactor/error_spec.rb +3 -1
  10. data/spec/active_interactor/interactor/worker_spec.rb +3 -0
  11. data/spec/active_interactor/organizer/base_spec.rb +18 -1
  12. data/spec/active_interactor/organizer/interactor_interface_collection_spec.rb +2 -0
  13. data/spec/active_interactor/organizer/interactor_interface_spec.rb +1 -0
  14. data/spec/active_interactor/version_spec.rb +119 -0
  15. data/spec/active_interactor_spec.rb +0 -6
  16. data/spec/integration/a_basic_organizer_spec.rb +7 -0
  17. data/spec/integration/a_failing_interactor_spec.rb +1 -0
  18. data/spec/integration/an_interactor_with_after_perform_callbacks_spec.rb +1 -0
  19. data/spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb +1 -0
  20. data/spec/integration/an_interactor_with_an_existing_context_class_spec.rb +1 -0
  21. data/spec/integration/an_interactor_with_before_perform_callbacks_spec.rb +1 -0
  22. data/spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb +1 -0
  23. data/spec/integration/an_interactor_with_validations_on_called_spec.rb +1 -0
  24. data/spec/integration/an_interactor_with_validations_on_calling_spec.rb +1 -0
  25. data/spec/integration/an_interactor_with_validations_spec.rb +2 -0
  26. data/spec/integration/an_organizer_with_after_each_callbacks_spec.rb +1 -0
  27. data/spec/integration/an_organizer_with_before_each_callbacks_spec.rb +1 -0
  28. data/spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb +14 -2
  29. data/spec/integration/an_organizer_with_options_callbacks_spec.rb +1 -0
  30. data/spec/spec_helper.rb +3 -20
  31. data/spec/support/coverage.rb +50 -0
  32. data/spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb +8 -0
  33. data/spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb +2 -0
  34. data/spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb +3 -0
  35. metadata +45 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18cf10a86ec48171ff40670464a016626fed857a9f429f39a66cecd5e5d89ce8
4
- data.tar.gz: f53205376b409a3c4a589b73c3f45dd5f56264c077d96e8af64d28918da0ea91
3
+ metadata.gz: db44b925fee62b19ed7c6ce4fcdd34f47df0ec40c6092a64e1c7f8b0c68c6319
4
+ data.tar.gz: cecf7423c0e19bdfac2ccf1da81847702091dd94e5565e04d9cc4a704f1dc6b2
5
5
  SHA512:
6
- metadata.gz: 52ae6e7c4a6a595ee8ef7bdecf5b496cd399f60ab79b0b7806b690661b1a8a82ce05438026a2a6a1e6177688077057209a2aad546f36bb57fb16ba87948fe3c8
7
- data.tar.gz: d6510e42ddb2bb1b639fe36b7ec4a9df936519be1cce3d6c7000ecc05578f9609118b50131a82e19b725ff5dfa21597f00b23cabe16bbb5a153dc60bded0f716
6
+ metadata.gz: 965b0ace916447617faf9a1d41ba8cb7e4842bd02933df39ae962b8415f928d6623c5e728b7cd64137ba85ab2a2ed25903a5024429138e5f733025059fe04572
7
+ data.tar.gz: fe9ca1ef603aaeacd57a3ff7b2cb39905e4311525f16edeb26954a9fbeb1bca57f2bb5fa31107db4a296d22c457664f095511104676ba9e26fa107afbb59c600
data/CHANGELOG.md CHANGED
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [v1.1.4] - 2022-03-07
11
+
12
+ ### Changed
13
+
14
+ - [\#340] Bump activemodel and activesupport to 6.1.4.6
15
+
16
+ ## [v1.1.3] - 2022-02-16
17
+
18
+ ### Changed
19
+
20
+ - [\#338] Bump activemodel and activesupport to 6.1.4.4
21
+
22
+ ## [v1.1.2] - 2020-11-10
23
+
24
+ ### Changed
25
+
26
+ - [\#300](https://github.com/aaronmallen/activeinteractor/pull/300) `ActiveModel` and `ActiveSupport` v6.1 will be the
27
+ highest supported version for `ActiveInteractor` v1.1.x
28
+
29
+ ### Fixed
30
+
31
+ - [\#300](https://github.com/aaronmallen/activeinteractor/pull/300) `ActiveInteractor::Context::Error` compatibility
32
+ with `ActiveModel` v6.1
33
+
10
34
  ## [v1.1.1] - 2020-10-21
11
35
 
12
36
  ### Fixed
@@ -219,7 +243,10 @@ and this project adheres to [Semantic Versioning].
219
243
 
220
244
  <!-- versions -->
221
245
 
222
- [Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.1...HEAD
246
+ [Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.4...HEAD
247
+ [v1.1.4]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.3...v1.1.4
248
+ [v1.1.3]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.2...v1.1.3
249
+ [v1.1.2]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.1...v1.1.2
223
250
  [v1.1.1]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.0...v1.1.1
224
251
  [v1.1.0]: https://github.com/aaronmallen/activeinteractor/compare/v1.0.5...v1.1.0
225
252
  [v1.0.5]: https://github.com/aaronmallen/activeinteractor/compare/v1.0.4...v1.0.5
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
- ## Getting Started
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
- ```bash
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
- * Special thanks to [@collectiveidea] for their amazing foundational work on
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
@@ -18,6 +18,16 @@ module ActiveInteractor
18
18
 
19
19
  private
20
20
 
21
+ def add_errors(errors)
22
+ errors.each do |error|
23
+ if self.errors.respond_to?(:import)
24
+ self.errors.import(error)
25
+ else
26
+ self.errors.add(error[0], error[1])
27
+ end
28
+ end
29
+ end
30
+
21
31
  def clear_all_errors
22
32
  errors.clear
23
33
  failure_errors.clear
@@ -40,7 +50,7 @@ module ActiveInteractor
40
50
  def resolve_errors
41
51
  all_errors = (failure_errors.uniq + errors.uniq).compact.uniq
42
52
  clear_all_errors
43
- all_errors.each { |error| errors.add(error[0], error[1]) }
53
+ add_errors(all_errors)
44
54
  end
45
55
  end
46
56
  end
@@ -1,7 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveInteractor
4
- # The ActiveInteractor version
5
- # @return [String] the ActiveInteractor version
6
- VERSION = '1.1.1'
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 = 4
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'
@@ -4,6 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  RSpec.describe ActiveInteractor::Config do
6
6
  subject { described_class.new }
7
+
7
8
  it { is_expected.to respond_to :logger }
8
9
 
9
10
  describe '.defaults' do
@@ -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 { should have_attributes(parallel: true) }
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
@@ -3,12 +3,6 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe ActiveInteractor do
6
- describe '::VERSION' do
7
- subject { described_class::VERSION }
8
-
9
- it { is_expected.to be_a String }
10
- end
11
-
12
6
  describe '.config' do
13
7
  subject { described_class.config }
14
8