activeinteractor 1.0.0.beta.7 → 1.0.0

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 (102) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/CHANGELOG.md +50 -158
  4. data/README.md +13 -856
  5. data/lib/active_interactor.rb +61 -4
  6. data/lib/active_interactor/base.rb +26 -20
  7. data/lib/active_interactor/config.rb +36 -18
  8. data/lib/active_interactor/configurable.rb +17 -9
  9. data/lib/active_interactor/context/attributes.rb +73 -26
  10. data/lib/active_interactor/context/base.rb +236 -65
  11. data/lib/active_interactor/context/loader.rb +20 -15
  12. data/lib/active_interactor/context/status.rb +38 -56
  13. data/lib/active_interactor/error.rb +15 -7
  14. data/lib/active_interactor/interactor/callbacks.rb +174 -160
  15. data/lib/active_interactor/interactor/context.rb +279 -87
  16. data/lib/active_interactor/interactor/perform.rb +256 -0
  17. data/lib/active_interactor/interactor/worker.rb +19 -14
  18. data/lib/active_interactor/models.rb +65 -0
  19. data/lib/active_interactor/organizer/base.rb +18 -0
  20. data/lib/active_interactor/organizer/callbacks.rb +153 -0
  21. data/lib/active_interactor/organizer/interactor_interface.rb +38 -26
  22. data/lib/active_interactor/organizer/interactor_interface_collection.rb +35 -32
  23. data/lib/active_interactor/organizer/organize.rb +67 -0
  24. data/lib/active_interactor/organizer/perform.rb +93 -0
  25. data/lib/active_interactor/rails.rb +0 -10
  26. data/lib/active_interactor/rails/orm/active_record.rb +1 -1
  27. data/lib/active_interactor/rails/railtie.rb +8 -11
  28. data/lib/active_interactor/version.rb +2 -1
  29. data/lib/rails/generators/active_interactor.rb +1 -38
  30. data/lib/rails/generators/active_interactor/application_context_generator.rb +21 -0
  31. data/lib/rails/generators/active_interactor/application_interactor_generator.rb +5 -15
  32. data/lib/rails/generators/active_interactor/application_organizer_generator.rb +21 -0
  33. data/lib/rails/generators/active_interactor/base.rb +29 -0
  34. data/lib/rails/generators/active_interactor/generator.rb +21 -0
  35. data/lib/rails/generators/active_interactor/install_generator.rb +2 -9
  36. data/lib/rails/generators/interactor/context/rspec_generator.rb +3 -10
  37. data/lib/rails/generators/interactor/context/test_unit_generator.rb +4 -11
  38. data/lib/rails/generators/interactor/context_generator.rb +7 -10
  39. data/lib/rails/generators/interactor/generates_context.rb +28 -0
  40. data/lib/rails/generators/interactor/interactor_generator.rb +8 -10
  41. data/lib/rails/generators/interactor/organizer_generator.rb +8 -12
  42. data/lib/rails/generators/interactor/rspec_generator.rb +2 -9
  43. data/lib/rails/generators/interactor/test_unit_generator.rb +3 -10
  44. data/lib/rails/generators/{active_interactor/templates/initializer.erb → templates/active_interactor.erb} +3 -11
  45. data/lib/rails/generators/{active_interactor/templates → templates}/application_context.rb +0 -0
  46. data/lib/rails/generators/{active_interactor/templates → templates}/application_interactor.rb +0 -0
  47. data/lib/rails/generators/templates/application_organizer.rb +4 -0
  48. data/lib/rails/generators/{interactor/templates → templates}/context.erb +0 -0
  49. data/lib/rails/generators/{interactor/context/templates/rspec.erb → templates/context_spec.erb} +0 -0
  50. data/lib/rails/generators/{interactor/context/templates/test_unit.erb → templates/context_test_unit.erb} +0 -0
  51. data/lib/rails/generators/{interactor/templates → templates}/interactor.erb +0 -0
  52. data/lib/rails/generators/{interactor/templates/rspec.erb → templates/interactor_spec.erb} +0 -0
  53. data/lib/rails/generators/{interactor/templates/test_unit.erb → templates/interactor_text_unit.erb} +0 -0
  54. data/lib/rails/generators/{interactor/templates → templates}/organizer.erb +0 -0
  55. data/spec/active_interactor/base_spec.rb +3 -3
  56. data/spec/active_interactor/interactor/{perform_options_spec.rb → perform/options_spec.rb} +1 -1
  57. data/spec/active_interactor/interactor/worker_spec.rb +14 -15
  58. data/spec/active_interactor/{organizer_spec.rb → organizer/base_spec.rb} +27 -17
  59. data/spec/integration/a_basic_interactor_spec.rb +106 -0
  60. data/spec/integration/a_basic_organizer_spec.rb +97 -0
  61. data/spec/integration/a_failing_interactor_spec.rb +42 -0
  62. data/spec/integration/active_record_integration_spec.rb +9 -9
  63. data/spec/integration/an_interactor_with_after_context_validation_callbacks_spec.rb +69 -0
  64. data/spec/integration/an_interactor_with_after_perform_callbacks_spec.rb +30 -0
  65. data/spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb +33 -0
  66. data/spec/integration/an_interactor_with_an_existing_context_class_spec.rb +49 -0
  67. data/spec/integration/an_interactor_with_around_perform_callbacks_spec.rb +35 -0
  68. data/spec/integration/an_interactor_with_around_rollback_callbacks_spec.rb +39 -0
  69. data/spec/integration/an_interactor_with_before_perform_callbacks_spec.rb +30 -0
  70. data/spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb +33 -0
  71. data/spec/integration/an_interactor_with_validations_on_called_spec.rb +40 -0
  72. data/spec/integration/an_interactor_with_validations_on_calling_spec.rb +36 -0
  73. data/spec/integration/an_interactor_with_validations_spec.rb +93 -0
  74. data/spec/integration/an_organizer_performing_in_parallel_spec.rb +48 -0
  75. data/spec/integration/an_organizer_with_after_each_callbacks_spec.rb +34 -0
  76. data/spec/integration/an_organizer_with_around_each_callbacks_spec.rb +39 -0
  77. data/spec/integration/an_organizer_with_before_each_callbacks_spec.rb +34 -0
  78. data/spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb +314 -0
  79. data/spec/spec_helper.rb +8 -12
  80. data/spec/support/coverage.rb +4 -0
  81. data/spec/support/coverage/reporters.rb +11 -0
  82. data/spec/support/coverage/reporters/codacy.rb +39 -0
  83. data/spec/support/coverage/reporters/simple_cov.rb +54 -0
  84. data/spec/support/coverage/runner.rb +66 -0
  85. data/spec/support/helpers/factories.rb +1 -1
  86. data/spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb +8 -8
  87. data/spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb +5 -5
  88. data/spec/support/shared_examples/a_class_with_interactor_methods_example.rb +2 -2
  89. data/spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb +3 -3
  90. metadata +83 -40
  91. data/lib/active_interactor/interactor.rb +0 -84
  92. data/lib/active_interactor/interactor/perform_options.rb +0 -29
  93. data/lib/active_interactor/organizer.rb +0 -269
  94. data/lib/active_interactor/rails/config.rb +0 -45
  95. data/lib/active_interactor/rails/models.rb +0 -58
  96. data/lib/rails/generators/active_interactor/templates/application_organizer.rb +0 -4
  97. data/spec/active_interactor/rails/config_spec.rb +0 -29
  98. data/spec/active_interactor/rails_spec.rb +0 -24
  99. data/spec/integration/basic_callback_integration_spec.rb +0 -355
  100. data/spec/integration/basic_context_integration_spec.rb +0 -73
  101. data/spec/integration/basic_integration_spec.rb +0 -570
  102. data/spec/integration/basic_validations_integration_spec.rb +0 -204
@@ -1,22 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../active_interactor'
3
+ require 'rails/generators/active_interactor/base'
4
4
 
5
5
  module Interactor
6
6
  module Context
7
7
  module Generators
8
8
  class TestUnitGenerator < ActiveInteractor::Generators::NamedBase
9
- source_root File.expand_path('templates', __dir__)
10
- desc 'Generate an interactor unit test'
9
+ desc 'Generate an interactor context unit test'
11
10
 
12
- def create_test
13
- template 'test_unit.erb', file_path
14
- end
15
-
16
- private
17
-
18
- def file_path
19
- File.join('test', interactor_directory, File.join(class_path), "#{file_name}_context_test.rb")
11
+ def create_spec
12
+ template 'context_test_unit.erb', active_interactor_file(parent_dir: 'test', suffix: 'context_test')
20
13
  end
21
14
  end
22
15
  end
@@ -1,25 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../active_interactor'
3
+ require 'rails/generators/active_interactor/base'
4
4
 
5
5
  module Interactor
6
6
  module Generators
7
7
  class ContextGenerator < ActiveInteractor::Generators::NamedBase
8
- include ActiveInteractor::Generators::GeneratesContext
9
- source_root File.expand_path('templates', __dir__)
10
8
  desc 'Generate an interactor context'
9
+ argument :context_attributes, type: :array, default: [], banner: 'attribute attribute'
10
+
11
+ def generate_application_context
12
+ generate :'active_interactor:application_context'
13
+ end
11
14
 
12
15
  def create_context
13
- template 'context.erb', file_path
16
+ template 'context.erb', active_interactor_file(suffix: 'context')
14
17
  end
15
18
 
16
19
  hook_for :test_framework, in: :'interactor:context'
17
-
18
- private
19
-
20
- def file_path
21
- File.join('app', interactor_directory, File.join(class_path), "#{file_name}_context.rb")
22
- end
23
20
  end
24
21
  end
25
22
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Interactor
4
+ module Generators
5
+ module GeneratesContext
6
+ module WithArguments
7
+ def self.included(base)
8
+ base.class_eval do
9
+ include GeneratesContext
10
+ argument :context_attributes, type: :array, default: [], banner: 'attribute attribute'
11
+ end
12
+ end
13
+ end
14
+
15
+ def self.included(base)
16
+ base.class_eval do
17
+ class_option :skip_context, type: :boolean, desc: 'Whether or not to generate a context class'
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def skip_context?
24
+ options[:skip_context] == true || active_interactor_options.fetch(:generate_context, true) == false
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,14 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../active_interactor'
3
+ require 'rails/generators/active_interactor/base'
4
+ require 'rails/generators/interactor/generates_context'
4
5
 
5
6
  class InteractorGenerator < ActiveInteractor::Generators::NamedBase
6
- include ActiveInteractor::Generators::GeneratesContext
7
- source_root File.expand_path('templates', __dir__)
7
+ include Interactor::Generators::GeneratesContext::WithArguments
8
8
  desc 'Generate an interactor'
9
9
 
10
+ def generate_application_interactor
11
+ generate :'active_interactor:application_interactor'
12
+ end
13
+
10
14
  def create_interactor
11
- template 'interactor.erb', file_path
15
+ template 'interactor.erb', active_interactor_file
12
16
  end
13
17
 
14
18
  def create_context
@@ -18,10 +22,4 @@ class InteractorGenerator < ActiveInteractor::Generators::NamedBase
18
22
  end
19
23
 
20
24
  hook_for :test_framework, in: :interactor
21
-
22
- private
23
-
24
- def file_path
25
- File.join('app', interactor_directory, File.join(class_path), "#{file_name}.rb")
26
- end
27
25
  end
@@ -1,20 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../active_interactor'
3
+ require 'rails/generators/active_interactor/base'
4
+ require 'rails/generators/interactor/generates_context'
4
5
 
5
6
  module Interactor
6
7
  module Generators
7
8
  class OrganizerGenerator < ActiveInteractor::Generators::NamedBase
8
- source_root File.expand_path('templates', __dir__)
9
+ include GeneratesContext
9
10
  desc 'Generate an interactor organizer'
10
11
  argument :interactors, type: :array, default: [], banner: 'interactor interactor'
11
12
 
12
13
  class_option :context_attributes, type: :array, default: [], banner: 'attribute attribute',
13
14
  desc: 'Attributes for the context'
14
- class_option :skip_context, type: :boolean, desc: 'Whether or not to generate a context class'
15
+
16
+ def generate_application_organizer
17
+ generate :'active_interactor:application_organizer'
18
+ end
15
19
 
16
20
  def create_organizer
17
- template 'organizer.erb', file_path
21
+ template 'organizer.erb', active_interactor_file
18
22
  end
19
23
 
20
24
  def create_context
@@ -30,14 +34,6 @@ module Interactor
30
34
  def context_attributes
31
35
  options[:context_attributes]
32
36
  end
33
-
34
- def file_path
35
- File.join('app', interactor_directory, File.join(class_path), "#{file_name}.rb")
36
- end
37
-
38
- def skip_context?
39
- options[:skip_context] == true || ActiveInteractor::Rails.config.generate_context_classes == false
40
- end
41
37
  end
42
38
  end
43
39
  end
@@ -1,21 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../active_interactor'
3
+ require 'rails/generators/active_interactor/base'
4
4
 
5
5
  module Interactor
6
6
  module Generators
7
7
  class RspecGenerator < ActiveInteractor::Generators::NamedBase
8
- source_root File.expand_path('templates', __dir__)
9
8
  desc 'Generate an interactor spec'
10
9
 
11
10
  def create_spec
12
- template 'rspec.erb', file_path
13
- end
14
-
15
- private
16
-
17
- def file_path
18
- File.join('spec', interactor_directory, File.join(class_path), "#{file_name}_spec.rb")
11
+ template 'interactor_spec.erb', active_interactor_file(parent_dir: 'spec', suffix: 'spec')
19
12
  end
20
13
  end
21
14
  end
@@ -1,21 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../active_interactor'
3
+ require 'rails/generators/active_interactor/base'
4
4
 
5
5
  module Interactor
6
6
  module Generators
7
7
  class TestUnitGenerator < ActiveInteractor::Generators::NamedBase
8
- source_root File.expand_path('templates', __dir__)
9
8
  desc 'Generate an interactor unit test'
10
9
 
11
- def create_test
12
- template 'test_unit.erb', file_path
13
- end
14
-
15
- private
16
-
17
- def file_path
18
- File.join('test', interactor_directory, File.join(class_path), "#{file_name}_test.rb")
10
+ def create_spec
11
+ template 'interactor_test_unit.erb', active_interactor_file(parent_dir: 'test', suffix: 'test')
19
12
  end
20
13
  end
21
14
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'active_interactor'
4
4
 
5
- ActiveInteractor::Rails.configure do |config|
5
+ ActiveInteractor.configure do |config|
6
6
  # ORM configuration
7
7
  # Load and configure the ORM. Supports :active_record (default)
8
8
  # Other ORMs may be available as additional gems.
@@ -12,14 +12,6 @@ ActiveInteractor::Rails.configure do |config|
12
12
  # require 'active_interactor/rails/orm/<MY_ORM>'
13
13
  <%- end -%>
14
14
 
15
- # set the default directory for interactors
16
- <%- if directory != 'interactors' -%>
17
- config.directory = '<%= directory %>'
18
- <%- else -%>
19
- # config.directory = 'interactors'
20
- <%- end -%>
21
-
22
- # do not automatically generate context classes
23
- # when interactors are generated
24
- # config.generate_context_classes = false
15
+ # Set the ActiveInteractor.logger
16
+ config.logger = ::Rails.logger
25
17
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationOrganizer < ActiveInteractor::Organizer::Base
4
+ end
@@ -23,7 +23,7 @@ RSpec.describe ActiveInteractor::Base do
23
23
  context 'when passed as a string' do
24
24
  let(:klass) { 'TestContext' }
25
25
 
26
- it 'assigns the context class' do
26
+ it 'is expected to assign the appropriate context class' do
27
27
  subject
28
28
  expect(described_class.context_class).to eq TestContext
29
29
  end
@@ -32,7 +32,7 @@ RSpec.describe ActiveInteractor::Base do
32
32
  context 'when passed as a symbol' do
33
33
  let(:klass) { :test_context }
34
34
 
35
- it 'assigns the context class' do
35
+ it 'is expected to assign the appropriate context class' do
36
36
  subject
37
37
  expect(described_class.context_class).to eq TestContext
38
38
  end
@@ -41,7 +41,7 @@ RSpec.describe ActiveInteractor::Base do
41
41
  context 'when passed as a constant' do
42
42
  let(:klass) { TestContext }
43
43
 
44
- it 'assigns the context class' do
44
+ it 'is expected to assign the appropriate context class' do
45
45
  subject
46
46
  expect(described_class.context_class).to eq TestContext
47
47
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe ActiveInteractor::Interactor::PerformOptions do
5
+ RSpec.describe ActiveInteractor::Interactor::Perform::Options do
6
6
  subject { described_class.new }
7
7
 
8
8
  it { is_expected.to respond_to :skip_each_perform_callbacks }
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
- require 'active_interactor/interactor/worker'
5
4
 
6
5
  RSpec.describe ActiveInteractor::Interactor::Worker do
7
6
  context 'with interactor class TestInteractor' do
@@ -12,7 +11,7 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
12
11
  context 'when interactor has options :skip_perform_callbacks eq to true' do
13
12
  let(:interactor) { TestInteractor.new.with_options(skip_perform_callbacks: true) }
14
13
 
15
- it 'is expected not to invoke #run_callbacks with :perform' do
14
+ it 'is expected not to receive #run_callbacks with :perform' do
16
15
  allow_any_instance_of(TestInteractor).to receive(:run_callbacks)
17
16
  .with(:validation).and_call_original
18
17
  expect_any_instance_of(TestInteractor).not_to receive(:run_callbacks)
@@ -24,7 +23,7 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
24
23
  context 'when interactor has options :validate eq to false' do
25
24
  let(:interactor) { TestInteractor.new.with_options(validate: false) }
26
25
 
27
- it 'is expected not to invoke #run_callbacks with :validation' do
26
+ it 'is expected not to receive #run_callbacks with :validation' do
28
27
  expect_any_instance_of(TestInteractor).not_to receive(:run_callbacks)
29
28
  .with(:validation)
30
29
  subject
@@ -39,13 +38,13 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
39
38
  .with(:called).and_return(true)
40
39
  end
41
40
 
42
- it 'is expected not to invoke #context_valid? with :calling' do
41
+ it 'is expected not to receive #context_valid? with :calling' do
43
42
  expect_any_instance_of(TestInteractor).not_to receive(:context_valid?)
44
43
  .with(:calling)
45
44
  subject
46
45
  end
47
46
 
48
- it 'is expected to invoke #context_valid? with :called' do
47
+ it 'is expected to receive #context_valid? with :called' do
49
48
  expect_any_instance_of(TestInteractor).to receive(:context_valid?)
50
49
  .with(:called)
51
50
  subject
@@ -60,13 +59,13 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
60
59
  .with(:calling).and_return(true)
61
60
  end
62
61
 
63
- it 'is expected to invoke #context_valid? with :calling' do
62
+ it 'is expected to receive #context_valid? with :calling' do
64
63
  expect_any_instance_of(TestInteractor).to receive(:context_valid?)
65
64
  .with(:calling)
66
65
  subject
67
66
  end
68
67
 
69
- it 'is expected not to invoke #context_valid? with :called' do
68
+ it 'is expected not to receive #context_valid? with :called' do
70
69
  expect_any_instance_of(TestInteractor).not_to receive(:context_valid?)
71
70
  .with(:called)
72
71
  subject
@@ -103,7 +102,7 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
103
102
  subject
104
103
  end
105
104
 
106
- it 'calls #perform on interactor instance' do
105
+ it 'is expected to receive #perform on interactor instance' do
107
106
  expect_any_instance_of(TestInteractor).to receive(:perform)
108
107
  subject
109
108
  end
@@ -119,7 +118,7 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
119
118
  end
120
119
 
121
120
  it { expect { subject }.to raise_error(ActiveInteractor::Error::ContextFailure) }
122
- it 'rollsback the interactor context' do
121
+ it 'is expected to rollback the interactor context' do
123
122
  expect_any_instance_of(TestInteractor).to receive(:context_rollback!)
124
123
  expect { subject }.to raise_error(ActiveInteractor::Error::ContextFailure)
125
124
  end
@@ -136,7 +135,7 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
136
135
  end
137
136
 
138
137
  it { expect { subject }.to raise_error(ActiveInteractor::Error::ContextFailure) }
139
- it 'rollsback the interactor context' do
138
+ it 'is expected to rollback the interactor context' do
140
139
  expect_any_instance_of(TestInteractor).to receive(:context_rollback!)
141
140
  expect { subject }.to raise_error(ActiveInteractor::Error::ContextFailure)
142
141
  end
@@ -148,13 +147,13 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
148
147
  describe '#execute_rollback' do
149
148
  subject { described_class.new(interactor).execute_rollback }
150
149
 
151
- it 'is expected to run rollback callbacks on interactor' do
150
+ it 'is expected to receive #run_callbacks on interactor with :rollback' do
152
151
  expect_any_instance_of(TestInteractor).to receive(:run_callbacks)
153
152
  .with(:rollback)
154
153
  subject
155
154
  end
156
155
 
157
- it 'is expected to invoke #context_rollback on interactor instance' do
156
+ it 'is expected to receive #context_rollback on interactor instance' do
158
157
  expect_any_instance_of(TestInteractor).to receive(:context_rollback!)
159
158
  subject
160
159
  end
@@ -162,7 +161,7 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
162
161
  context 'when interactor has options :skip_rollback eq to true' do
163
162
  let(:interactor) { TestInteractor.new.with_options(skip_rollback: true) }
164
163
 
165
- it 'is expected not to invoke #context_rollback on interactor instance' do
164
+ it 'is expected not to receive #context_rollback on interactor instance' do
166
165
  expect_any_instance_of(TestInteractor).not_to receive(:context_rollback!)
167
166
  subject
168
167
  end
@@ -171,12 +170,12 @@ RSpec.describe ActiveInteractor::Interactor::Worker do
171
170
  context 'when interactor has options :skip_rollback_callbacks eq to true' do
172
171
  let(:interactor) { TestInteractor.new.with_options(skip_rollback_callbacks: true) }
173
172
 
174
- it 'is expected to invoke #context_rollback on interactor instance' do
173
+ it 'is expected to receive #context_rollback on interactor instance' do
175
174
  expect_any_instance_of(TestInteractor).to receive(:context_rollback!)
176
175
  subject
177
176
  end
178
177
 
179
- it 'is expected not to run rollback callbacks on interactor' do
178
+ it 'is expected not to receive #run_callbacks on interactor with :rollback' do
180
179
  expect_any_instance_of(TestInteractor).not_to receive(:run_callbacks)
181
180
  .with(:rollback)
182
181
  subject
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe ActiveInteractor::Organizer do
5
+ RSpec.describe ActiveInteractor::Organizer::Base do
6
6
  let(:interactor_class) { described_class }
7
7
  include_examples 'a class with interactor methods'
8
8
  include_examples 'a class with interactor callback methods'
@@ -24,7 +24,7 @@ RSpec.describe ActiveInteractor::Organizer do
24
24
  context 'when passed as a string' do
25
25
  let(:klass) { 'TestContext' }
26
26
 
27
- it 'assigns the context class' do
27
+ it 'is expected to assign the appropriate context class' do
28
28
  subject
29
29
  expect(described_class.context_class).to eq TestContext
30
30
  end
@@ -33,7 +33,7 @@ RSpec.describe ActiveInteractor::Organizer do
33
33
  context 'when passed as a symbol' do
34
34
  let(:klass) { :test_context }
35
35
 
36
- it 'assigns the context class' do
36
+ it 'is expected to assign the appropriate context class' do
37
37
  subject
38
38
  expect(described_class.context_class).to eq TestContext
39
39
  end
@@ -42,7 +42,7 @@ RSpec.describe ActiveInteractor::Organizer do
42
42
  context 'when passed as a constant' do
43
43
  let(:klass) { TestContext }
44
44
 
45
- it 'assigns the context class' do
45
+ it 'is expected to assign the appropriate context class' do
46
46
  subject
47
47
  expect(described_class.context_class).to eq TestContext
48
48
  end
@@ -96,6 +96,16 @@ RSpec.describe ActiveInteractor::Organizer do
96
96
  end
97
97
  end
98
98
 
99
+ describe '.perform_in_parallel' do
100
+ subject do
101
+ build_organizer do
102
+ perform_in_parallel
103
+ end
104
+ end
105
+
106
+ it { should have_attributes(parallel: true) }
107
+ end
108
+
99
109
  describe '#perform' do
100
110
  subject { interactor_class.perform }
101
111
  context 'with two existing interactors' do
@@ -108,7 +118,7 @@ RSpec.describe ActiveInteractor::Organizer do
108
118
  end
109
119
 
110
120
  it { is_expected.to be_a interactor_class.context_class }
111
- it 'is expected to call #perform on both interactors' do
121
+ it 'is expected to receive #perform on both interactors' do
112
122
  expect_any_instance_of(interactor1).to receive(:perform)
113
123
  expect_any_instance_of(interactor2).to receive(:perform)
114
124
  subject
@@ -118,12 +128,12 @@ RSpec.describe ActiveInteractor::Organizer do
118
128
  subject { interactor_class.perform({}, skip_each_perform_callbacks: true) }
119
129
 
120
130
  it { is_expected.to be_a interactor_class.context_class }
121
- it 'is expected to invoke #perform on both interactors' do
131
+ it 'is expected to receive #perform on both interactors' do
122
132
  expect_any_instance_of(interactor1).to receive(:perform)
123
133
  expect_any_instance_of(interactor2).to receive(:perform)
124
134
  subject
125
135
  end
126
- it 'is expected not to invoke #run_callbacks with :each_perform' do
136
+ it 'is expected not to receive #run_callbacks with :each_perform' do
127
137
  expect_any_instance_of(interactor_class).not_to receive(:run_callbacks)
128
138
  .with(:each_perform)
129
139
  subject
@@ -142,15 +152,15 @@ RSpec.describe ActiveInteractor::Organizer do
142
152
  it { expect { subject }.not_to raise_error }
143
153
  it { is_expected.to be_failure }
144
154
  it { is_expected.to be_a interactor_class.context_class }
145
- it 'is expected to call #perform on the first interactor' do
155
+ it 'is expected to receive #perform on the first interactor' do
146
156
  expect_any_instance_of(interactor1).to receive(:perform)
147
157
  subject
148
158
  end
149
- it 'is expected to not call #perform on the second interactor' do
159
+ it 'is expected not to receive #perform on the second interactor' do
150
160
  expect_any_instance_of(interactor2).not_to receive(:perform)
151
161
  subject
152
162
  end
153
- it 'is expected to call #rollback on the first interactor' do
163
+ it 'is expected to receive #rollback on the first interactor' do
154
164
  expect_any_instance_of(interactor1).to receive(:rollback)
155
165
  subject
156
166
  end
@@ -168,12 +178,12 @@ RSpec.describe ActiveInteractor::Organizer do
168
178
  it { expect { subject }.not_to raise_error }
169
179
  it { is_expected.to be_failure }
170
180
  it { is_expected.to be_a interactor_class.context_class }
171
- it 'is expected to call #perform on both interactors' do
181
+ it 'is expected to receive #perform on both interactors' do
172
182
  expect_any_instance_of(interactor1).to receive(:perform)
173
183
  expect_any_instance_of(interactor2).to receive(:perform)
174
184
  subject
175
185
  end
176
- it 'is expected to call #rollback on both interactors' do
186
+ it 'is expected to receive #rollback on both interactors' do
177
187
  expect_any_instance_of(interactor1).to receive(:rollback)
178
188
  expect_any_instance_of(interactor2).to receive(:rollback)
179
189
  subject
@@ -190,7 +200,7 @@ RSpec.describe ActiveInteractor::Organizer do
190
200
  end
191
201
 
192
202
  it { is_expected.to be_a interactor_class.context_class }
193
- it 'is expected to call #perform on both interactors' do
203
+ it 'is expected to receive #perform on both interactors' do
194
204
  expect_any_instance_of(interactor1).to receive(:perform)
195
205
  expect_any_instance_of(interactor2).to receive(:perform)
196
206
  subject
@@ -208,12 +218,12 @@ RSpec.describe ActiveInteractor::Organizer do
208
218
  it { expect { subject }.not_to raise_error }
209
219
  it { is_expected.to be_failure }
210
220
  it { is_expected.to be_a interactor_class.context_class }
211
- it 'is expected to call #perform on both interactors' do
221
+ it 'is expected to receive #perform on both interactors' do
212
222
  expect_any_instance_of(interactor1).to receive(:perform)
213
223
  expect_any_instance_of(interactor2).to receive(:perform)
214
224
  subject
215
225
  end
216
- it 'is expected to call #rollback both interactors' do
226
+ it 'is expected to receive #rollback both interactors' do
217
227
  expect_any_instance_of(interactor1).to receive(:rollback)
218
228
  expect_any_instance_of(interactor2).to receive(:rollback)
219
229
  subject
@@ -232,12 +242,12 @@ RSpec.describe ActiveInteractor::Organizer do
232
242
  it { expect { subject }.not_to raise_error }
233
243
  it { is_expected.to be_failure }
234
244
  it { is_expected.to be_a interactor_class.context_class }
235
- it 'is expected to call #perform on both interactors' do
245
+ it 'is expected to receive #perform on both interactors' do
236
246
  expect_any_instance_of(interactor1).to receive(:perform)
237
247
  expect_any_instance_of(interactor2).to receive(:perform)
238
248
  subject
239
249
  end
240
- it 'is expected to call #rollback on both interactors' do
250
+ it 'is expected to receive #rollback on both interactors' do
241
251
  expect_any_instance_of(interactor1).to receive(:rollback)
242
252
  expect_any_instance_of(interactor2).to receive(:rollback)
243
253
  subject