interaktor 0.6.0.pre → 0.6.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/.ruby-version +1 -1
- data/interaktor.gemspec +1 -1
- data/lib/interaktor/attributes.rb +0 -4
- data/lib/interaktor/failure.rb +17 -1
- data/spec/interaktor/failure_spec.rb +36 -0
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe8bfb895d5be7950b49cde31d318c904d33ac57e4db772d79834061d5f561fd
|
|
4
|
+
data.tar.gz: ef77d7af2851d7c3de8db7632b1e2fbc38528981f42e7da500c7f1b21c3836ed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6fe6cee6bdd970cd8572c7b7874a4eb60b17d21911d23a1b9d529dee3398e690d3ac0d3290c85ce9e78b080af3e58f82a6c051bbdf432c54c0a2ecab16b24cfb
|
|
7
|
+
data.tar.gz: f1fe97ca9a55ee29c6fec80b5681acf722b7baea437a28a69f7a73aaf9583373aad9ec43086ad46dbb3a894782526d6b81f925d12a91ce5436f3f45b32c02f23
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.4.
|
|
1
|
+
3.4.9
|
data/interaktor.gemspec
CHANGED
|
@@ -6,10 +6,6 @@ module Interaktor
|
|
|
6
6
|
include ::ActiveModel::Serialization
|
|
7
7
|
include ::ActiveModel::Validations
|
|
8
8
|
|
|
9
|
-
if defined?(::ActiveModel::Attributes::Normalization)
|
|
10
|
-
include ::ActiveModel::Attributes::Normalization
|
|
11
|
-
end
|
|
12
|
-
|
|
13
9
|
DISALLOWED_ATTRIBUTE_NAMES = instance_methods
|
|
14
10
|
.map { |m| m.to_s.freeze }
|
|
15
11
|
.freeze
|
data/lib/interaktor/failure.rb
CHANGED
|
@@ -8,6 +8,22 @@ class Interaktor::Failure < StandardError
|
|
|
8
8
|
# error was raised
|
|
9
9
|
def initialize(interaction = nil)
|
|
10
10
|
@interaction = interaction
|
|
11
|
-
super
|
|
11
|
+
super(build_message)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
# Build a human-readable message from the failure attributes, if any were
|
|
17
|
+
# provided to `fail!`. When there are none, returns nil so that
|
|
18
|
+
# StandardError falls back to its default (the exception class name).
|
|
19
|
+
#
|
|
20
|
+
# @return [String, nil]
|
|
21
|
+
def build_message
|
|
22
|
+
attributes = interaction&.failure_object&.attributes
|
|
23
|
+
return if attributes.nil? || attributes.empty?
|
|
24
|
+
|
|
25
|
+
attributes
|
|
26
|
+
.map { |name, value| "#{name}: #{value.inspect}" }
|
|
27
|
+
.join(", ")
|
|
12
28
|
end
|
|
13
29
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
RSpec.describe Interaktor::Failure do
|
|
2
|
+
describe "#message" do
|
|
3
|
+
it "builds a message from the failure attributes" do
|
|
4
|
+
interaktor = FakeInteraktor.build_interaktor do
|
|
5
|
+
failure do
|
|
6
|
+
attribute :error
|
|
7
|
+
attribute :code
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def call
|
|
11
|
+
fail!(error: "not found", code: 404)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
expect {
|
|
16
|
+
interaktor.call!
|
|
17
|
+
}.to raise_error(described_class, 'error: "not found", code: 404')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "falls back to the default message when there are no failure attributes" do
|
|
21
|
+
interaktor = FakeInteraktor.build_interaktor do
|
|
22
|
+
def call
|
|
23
|
+
fail!
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
expect {
|
|
28
|
+
interaktor.call!
|
|
29
|
+
}.to raise_error(described_class, described_class.name)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "falls back to the default message when the interaction is absent" do
|
|
33
|
+
expect(described_class.new.message).to eq described_class.name
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: interaktor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.0
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Taylor Thurlow
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-06-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|
|
@@ -90,6 +90,7 @@ files:
|
|
|
90
90
|
- lib/interaktor/interaction.rb
|
|
91
91
|
- lib/interaktor/organizer.rb
|
|
92
92
|
- spec/integration_spec.rb
|
|
93
|
+
- spec/interaktor/failure_spec.rb
|
|
93
94
|
- spec/interaktor/hooks_spec.rb
|
|
94
95
|
- spec/interaktor/organizer_spec.rb
|
|
95
96
|
- spec/interaktor_spec.rb
|
|
@@ -111,9 +112,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
111
112
|
version: '3.0'
|
|
112
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
114
|
requirements:
|
|
114
|
-
- - "
|
|
115
|
+
- - ">="
|
|
115
116
|
- !ruby/object:Gem::Version
|
|
116
|
-
version:
|
|
117
|
+
version: '0'
|
|
117
118
|
requirements: []
|
|
118
119
|
rubygems_version: 3.4.19
|
|
119
120
|
signing_key:
|