interactor_with_steroids 1.1.1 → 1.2.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.
- checksums.yaml +4 -4
- data/interactor.gemspec +2 -1
- data/lib/interactor/context.rb +1 -1
- data/lib/interactor.rb +2 -2
- data/spec/interactor/context_spec.rb +2 -2
- data/spec/interactor_spec.rb +12 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee0822c1b5d0c7e5ec36e35a2eb7989f19587f8b64a6a784e183fc6545c2ce4b
|
4
|
+
data.tar.gz: 4759c36e11b659a8ddef357ac928c297f5383b370d0a075c1dd0eb20e2a392bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce654d725ec8ebec129d6667612d2bf74e309457589c05592c6ec6402fc69f5756ce05f392a132177c3b351ca362374ea1b75ce217c26c73a6a0313ee4e08bff
|
7
|
+
data.tar.gz: b562c0b40d1d4d95e16726b0aeb115b89ada4606d3371ebababda23be7ae74ca984138182c2790ee1fd9c837d614bcaf741c47dfe19f7083fd0d9d5f742f38bb
|
data/interactor.gemspec
CHANGED
@@ -2,7 +2,7 @@ require "English"
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "interactor_with_steroids"
|
5
|
-
spec.version = "1.
|
5
|
+
spec.version = "1.2.0"
|
6
6
|
|
7
7
|
spec.author = "Collective Idea/Sorare Team"
|
8
8
|
spec.email = "hello@sorare.com"
|
@@ -10,6 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.summary = "Simple interactor implementation"
|
11
11
|
spec.homepage = "https://github.com/sorare/interactor"
|
12
12
|
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = '>= 2.1'
|
13
14
|
|
14
15
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
15
16
|
spec.test_files = spec.files.grep(/^spec/)
|
data/lib/interactor/context.rb
CHANGED
data/lib/interactor.rb
CHANGED
@@ -92,7 +92,7 @@ module Interactor
|
|
92
92
|
# MyInteractor.new
|
93
93
|
# # => #<MyInteractor @context=#<Interactor::Context>>
|
94
94
|
def initialize(context = {})
|
95
|
-
@context = self.context_class.build(context)
|
95
|
+
@context = self.context_class.build(**context.to_h)
|
96
96
|
end
|
97
97
|
|
98
98
|
# Internal: Invoke an interactor instance along with all defined hooks. The
|
@@ -145,7 +145,7 @@ module Interactor
|
|
145
145
|
end
|
146
146
|
rescue Failure => e
|
147
147
|
# Make sure we fail the current context when a call! to another interactor fails
|
148
|
-
context.fail!(error: e.context&.error)
|
148
|
+
context.fail!(error: e.context&.error, error_cause: e.cause)
|
149
149
|
end
|
150
150
|
|
151
151
|
# Public: Invoke an Interactor instance without any hooks, tracking, or
|
@@ -27,7 +27,7 @@ module Interactor
|
|
27
27
|
|
28
28
|
it "doesn't affect the original hash" do
|
29
29
|
hash = { foo: "bar" }
|
30
|
-
context = interactor.context_class.build(hash)
|
30
|
+
context = interactor.context_class.build(**hash)
|
31
31
|
|
32
32
|
expect(context).to be_a(interactor.context_class)
|
33
33
|
expect {
|
@@ -39,7 +39,7 @@ module Interactor
|
|
39
39
|
|
40
40
|
it "ignores any additional argument" do
|
41
41
|
hash = { foo: 'bar', bar: "baz" }
|
42
|
-
expect { interactor.context_class.build(hash) }.not_to raise_error
|
42
|
+
expect { interactor.context_class.build(**hash) }.not_to raise_error
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
data/spec/interactor_spec.rb
CHANGED
@@ -52,7 +52,7 @@ describe Interactor do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "initializes a blank context if none is given" do
|
55
|
-
expect(Interactor::Context).to receive(:build).once.with(
|
55
|
+
expect(Interactor::Context).to receive(:build).once.with(no_args) { context }
|
56
56
|
|
57
57
|
instance = interactor.new
|
58
58
|
|
@@ -63,6 +63,8 @@ describe Interactor do
|
|
63
63
|
|
64
64
|
describe "#run" do
|
65
65
|
let(:instance) { interactor.new }
|
66
|
+
let(:exception_klass) { Class.new(Exception) }
|
67
|
+
let(:failure_cause) { exception_klass.new }
|
66
68
|
|
67
69
|
it "runs the interactor" do
|
68
70
|
expect(instance).to receive(:run!).once.with(no_args)
|
@@ -78,6 +80,15 @@ describe Interactor do
|
|
78
80
|
}.not_to raise_error
|
79
81
|
end
|
80
82
|
|
83
|
+
it "persists failure cause" do
|
84
|
+
expect(instance).to receive(:call).and_raise(
|
85
|
+
Interactor::Failure.new(instance.context), cause: failure_cause
|
86
|
+
)
|
87
|
+
|
88
|
+
instance.run
|
89
|
+
expect(instance.context.error_cause).to eq(failure_cause)
|
90
|
+
end
|
91
|
+
|
81
92
|
it "raises other errors" do
|
82
93
|
expect(instance).to receive(:run!).and_raise("foo")
|
83
94
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interactor_with_steroids
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Collective Idea/Sorare Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -93,14 +93,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.1'
|
97
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
99
|
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
103
|
+
rubygems_version: 3.3.3
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Simple interactor implementation
|