interactor_with_steroids 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66961ad27a598bec0b93dc0297720eb97d0cdd5199b05e7e1490b731bc098de0
4
- data.tar.gz: 6432d13df06f22d9f30c8ad4a766b80dc5f3726be2f5a80495efc3edd6b0d444
3
+ metadata.gz: ee0822c1b5d0c7e5ec36e35a2eb7989f19587f8b64a6a784e183fc6545c2ce4b
4
+ data.tar.gz: 4759c36e11b659a8ddef357ac928c297f5383b370d0a075c1dd0eb20e2a392bf
5
5
  SHA512:
6
- metadata.gz: 23295d8872c9888924deb8f6937f3030f371a74ecb6c3ee0e5d0d79a7bf2a0419aa590c1705e18b76a731bb1f1bf5893599cd677835c8666b075fb3b86766cd4
7
- data.tar.gz: ac5eaf844aa979041a8fe09c11336f413310576d9736209083baaf27a617208f5d8cc39be9a7e2ff308d0879488171099afd4e845d4bbb6da804a61e0c62e282
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.1.2"
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/)
@@ -58,7 +58,7 @@ module Interactor
58
58
  end
59
59
  end
60
60
 
61
- attr_accessor :error
61
+ attr_accessor :error, :error_cause
62
62
  delegate :to_s, to: :to_h
63
63
 
64
64
  # Public: Whether the Interactor::Context is successful. By default, a new
data/lib/interactor.rb CHANGED
@@ -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
@@ -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.1.2
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-01-13 00:00:00.000000000 Z
11
+ date: 2022-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '2.1'
97
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ">="