dry-transaction 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +0 -2
- data/lib/dry/transaction/step.rb +5 -2
- data/lib/dry/transaction/step_failure.rb +10 -0
- data/lib/dry/transaction/version.rb +1 -1
- data/spec/examples.txt +79 -77
- data/spec/integration/around_spec.rb +41 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7411e4fbbd3d2e8d7759a51edc217763e2e0de002d42cced4ba43625d1818e8
|
4
|
+
data.tar.gz: 7fd3abc78aad520b6a980853a13727c26de21021bad9c6db824c8e287ec85ec2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2876c89f0b31df3734314c3e6ce1541cb451ae54d891296d4546ae16dcd0e7fcd8b971dab31cc779a47406847b238c4fbfe6ca76a10eadf638e0005526c63b93
|
7
|
+
data.tar.gz: 64d23944e110e9a42f43c0f1c686be199fe53ea5dcaae8a9e984fbab29eda35c9badbc85edf15c694a8bdd4669db10460edc2fab9201c9a0b194bd2dc8800efc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dry-transaction (0.12.
|
4
|
+
dry-transaction (0.12.1)
|
5
5
|
dry-container (>= 0.2.8)
|
6
6
|
dry-events (>= 0.1.0)
|
7
7
|
dry-matcher (>= 0.7.0)
|
@@ -23,9 +23,9 @@ GEM
|
|
23
23
|
dry-container (0.6.0)
|
24
24
|
concurrent-ruby (~> 1.0)
|
25
25
|
dry-configurable (~> 0.1, >= 0.1.3)
|
26
|
-
dry-core (0.4.
|
26
|
+
dry-core (0.4.6)
|
27
27
|
concurrent-ruby (~> 1.0)
|
28
|
-
dry-equalizer (0.2.
|
28
|
+
dry-equalizer (0.2.1)
|
29
29
|
dry-events (0.1.0)
|
30
30
|
concurrent-ruby (~> 1.0)
|
31
31
|
dry-core (~> 0.4)
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
[gitter]: https://gitter.im/dry-rb/chat
|
2
2
|
[gem]: https://img.shields.io/gem/v/dry-transaction.svg]
|
3
3
|
[travis]: https://travis-ci.org/dry-rb/dry-transaction
|
4
|
-
[gemnasium]: https://gemnasium.com/dry-rb/dry-transaction
|
5
4
|
[codeclimate]: https://codeclimate.com/github/dry-rb/dry-transaction
|
6
5
|
[coveralls]: https://coveralls.io/r/dry-rb/dry-transaction
|
7
6
|
[inchpages]: http://inch-ci.org/github/dry-rb/dry-transaction
|
@@ -10,7 +9,6 @@
|
|
10
9
|
|
11
10
|
[![Gem Version](https://badge.fury.io/rb/dry-transaction.svg)][gem]
|
12
11
|
[![Build Status](https://travis-ci.org/dry-rb/dry-transaction.svg?branch=master)][travis]
|
13
|
-
[![Dependency Status](https://gemnasium.com/dry-rb/dry-transaction.svg)][gemnasium]
|
14
12
|
[![Code Climate](https://codeclimate.com/github/dry-rb/dry-transaction/badges/gpa.svg)][codeclimate]
|
15
13
|
[![Test Coverage](https://codeclimate.com/github/dry-rb/dry-transaction/badges/coverage.svg)][codeclimate]
|
16
14
|
[![Inline docs](http://inch-ci.org/github/dry-rb/dry-transaction.svg?branch=master)][inchpages]
|
data/lib/dry/transaction/step.rb
CHANGED
@@ -62,8 +62,11 @@ module Dry
|
|
62
62
|
publish(:step_succeeded, step_name: step_name, args: args, value: value)
|
63
63
|
value
|
64
64
|
}.or { |value|
|
65
|
-
|
66
|
-
|
65
|
+
Failure(
|
66
|
+
StepFailure.(self, value) {
|
67
|
+
publish(:step_failed, step_name: step_name, args: args, value: value)
|
68
|
+
}
|
69
|
+
)
|
67
70
|
}
|
68
71
|
end
|
69
72
|
|
@@ -6,6 +6,16 @@ module Dry
|
|
6
6
|
attr_reader :step
|
7
7
|
attr_reader :value
|
8
8
|
|
9
|
+
# @api private
|
10
|
+
def self.call(step, value)
|
11
|
+
if self === value
|
12
|
+
value
|
13
|
+
else
|
14
|
+
yield
|
15
|
+
new(step, value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
9
19
|
def initialize(step, value)
|
10
20
|
@step = step
|
11
21
|
@value = value
|
data/spec/examples.txt
CHANGED
@@ -1,85 +1,87 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
----------------------------------------------------------- | ------ | --------------- |
|
3
|
-
./spec/integration/around_spec.rb[1:1] | passed | 0.
|
4
|
-
./spec/integration/around_spec.rb[1:2] | passed | 0.
|
3
|
+
./spec/integration/around_spec.rb[1:1] | passed | 0.00221 seconds |
|
4
|
+
./spec/integration/around_spec.rb[1:2] | passed | 0.00168 seconds |
|
5
5
|
./spec/integration/around_spec.rb[1:3] | passed | 0.00085 seconds |
|
6
|
-
./spec/integration/around_spec.rb[1:4] | passed | 0.
|
6
|
+
./spec/integration/around_spec.rb[1:4] | passed | 0.00301 seconds |
|
7
|
+
./spec/integration/around_spec.rb[1:5] | passed | 0.00093 seconds |
|
8
|
+
./spec/integration/around_spec.rb[1:6:1] | passed | 0.00078 seconds |
|
7
9
|
./spec/integration/auto_injection_spec.rb[1:1] | failed | 0.00149 seconds |
|
8
|
-
./spec/integration/custom_step_adapters_spec.rb[1:1] | passed | 0.
|
9
|
-
./spec/integration/operation_spec.rb[1:1] | passed | 0.
|
10
|
-
./spec/integration/operation_spec.rb[1:2] | passed | 0.
|
11
|
-
./spec/integration/passing_step_arguments_spec.rb[1:1:1] | passed | 0.
|
12
|
-
./spec/integration/passing_step_arguments_spec.rb[1:2:1] | passed | 0.
|
13
|
-
./spec/integration/passing_step_arguments_spec.rb[1:3:1] | passed | 0.
|
14
|
-
./spec/integration/publishing_step_events_spec.rb[1:1:1] | passed | 0.
|
15
|
-
./spec/integration/publishing_step_events_spec.rb[1:1:2] | passed | 0.
|
16
|
-
./spec/integration/publishing_step_events_spec.rb[1:2:1] | passed | 0.
|
17
|
-
./spec/integration/publishing_step_events_spec.rb[1:2:2] | passed | 0.
|
18
|
-
./spec/integration/publishing_step_events_spec.rb[1:3:1] | passed | 0.
|
19
|
-
./spec/integration/publishing_step_events_spec.rb[1:3:2] | passed | 0.
|
20
|
-
./spec/integration/transaction_spec.rb[1:1:1] | passed | 0.
|
21
|
-
./spec/integration/transaction_spec.rb[1:1:2] | passed | 0.
|
22
|
-
./spec/integration/transaction_spec.rb[1:1:3] | passed | 0.
|
23
|
-
./spec/integration/transaction_spec.rb[1:1:4] | passed | 0.
|
24
|
-
./spec/integration/transaction_spec.rb[1:1:5] | passed | 0.
|
25
|
-
./spec/integration/transaction_spec.rb[1:2:1] | passed | 0.
|
26
|
-
./spec/integration/transaction_spec.rb[1:3:1] | passed | 0.
|
27
|
-
./spec/integration/transaction_spec.rb[1:4:1] | passed | 0.
|
28
|
-
./spec/integration/transaction_spec.rb[1:5:1] | passed | 0.
|
29
|
-
./spec/integration/transaction_spec.rb[1:6:1] | passed | 0.
|
30
|
-
./spec/integration/transaction_spec.rb[1:7:1] | passed | 0.
|
31
|
-
./spec/integration/transaction_spec.rb[1:8:1] | passed | 0.
|
32
|
-
./spec/integration/transaction_spec.rb[1:9:1] | passed | 0.
|
33
|
-
./spec/integration/transaction_spec.rb[1:10:1] | passed | 0.
|
34
|
-
./spec/integration/transaction_spec.rb[1:11:1] | passed | 0.
|
35
|
-
./spec/integration/transaction_spec.rb[1:12:1] | passed | 0.
|
36
|
-
./spec/integration/transaction_spec.rb[1:12:2] | passed | 0.
|
37
|
-
./spec/integration/transaction_spec.rb[1:12:3] | passed | 0.
|
38
|
-
./spec/integration/transaction_spec.rb[1:12:4] | passed | 0.
|
39
|
-
./spec/integration/transaction_spec.rb[1:12:5] | passed | 0.
|
40
|
-
./spec/integration/transaction_spec.rb[1:12:6] | passed | 0.
|
41
|
-
./spec/integration/transaction_spec.rb[1:13:1] | passed | 0.
|
42
|
-
./spec/integration/transaction_spec.rb[1:13:2] | passed | 0.
|
43
|
-
./spec/integration/transaction_spec.rb[1:13:3] | passed | 0.
|
44
|
-
./spec/integration/transaction_spec.rb[1:13:4] | passed | 0.
|
10
|
+
./spec/integration/custom_step_adapters_spec.rb[1:1] | passed | 0.0008 seconds |
|
11
|
+
./spec/integration/operation_spec.rb[1:1] | passed | 0.00012 seconds |
|
12
|
+
./spec/integration/operation_spec.rb[1:2] | passed | 0.00015 seconds |
|
13
|
+
./spec/integration/passing_step_arguments_spec.rb[1:1:1] | passed | 0.00201 seconds |
|
14
|
+
./spec/integration/passing_step_arguments_spec.rb[1:2:1] | passed | 0.00062 seconds |
|
15
|
+
./spec/integration/passing_step_arguments_spec.rb[1:3:1] | passed | 0.00058 seconds |
|
16
|
+
./spec/integration/publishing_step_events_spec.rb[1:1:1] | passed | 0.00062 seconds |
|
17
|
+
./spec/integration/publishing_step_events_spec.rb[1:1:2] | passed | 0.00058 seconds |
|
18
|
+
./spec/integration/publishing_step_events_spec.rb[1:2:1] | passed | 0.00065 seconds |
|
19
|
+
./spec/integration/publishing_step_events_spec.rb[1:2:2] | passed | 0.00055 seconds |
|
20
|
+
./spec/integration/publishing_step_events_spec.rb[1:3:1] | passed | 0.00083 seconds |
|
21
|
+
./spec/integration/publishing_step_events_spec.rb[1:3:2] | passed | 0.00125 seconds |
|
22
|
+
./spec/integration/transaction_spec.rb[1:1:1] | passed | 0.00083 seconds |
|
23
|
+
./spec/integration/transaction_spec.rb[1:1:2] | passed | 0.0008 seconds |
|
24
|
+
./spec/integration/transaction_spec.rb[1:1:3] | passed | 0.00069 seconds |
|
25
|
+
./spec/integration/transaction_spec.rb[1:1:4] | passed | 0.00076 seconds |
|
26
|
+
./spec/integration/transaction_spec.rb[1:1:5] | passed | 0.00077 seconds |
|
27
|
+
./spec/integration/transaction_spec.rb[1:2:1] | passed | 0.00071 seconds |
|
28
|
+
./spec/integration/transaction_spec.rb[1:3:1] | passed | 0.00067 seconds |
|
29
|
+
./spec/integration/transaction_spec.rb[1:4:1] | passed | 0.00091 seconds |
|
30
|
+
./spec/integration/transaction_spec.rb[1:5:1] | passed | 0.00063 seconds |
|
31
|
+
./spec/integration/transaction_spec.rb[1:6:1] | passed | 0.0005 seconds |
|
32
|
+
./spec/integration/transaction_spec.rb[1:7:1] | passed | 0.00105 seconds |
|
33
|
+
./spec/integration/transaction_spec.rb[1:8:1] | passed | 0.00064 seconds |
|
34
|
+
./spec/integration/transaction_spec.rb[1:9:1] | passed | 0.00105 seconds |
|
35
|
+
./spec/integration/transaction_spec.rb[1:10:1] | passed | 0.001 seconds |
|
36
|
+
./spec/integration/transaction_spec.rb[1:11:1] | passed | 0.00056 seconds |
|
37
|
+
./spec/integration/transaction_spec.rb[1:12:1] | passed | 0.00081 seconds |
|
38
|
+
./spec/integration/transaction_spec.rb[1:12:2] | passed | 0.00079 seconds |
|
39
|
+
./spec/integration/transaction_spec.rb[1:12:3] | passed | 0.00069 seconds |
|
40
|
+
./spec/integration/transaction_spec.rb[1:12:4] | passed | 0.00081 seconds |
|
41
|
+
./spec/integration/transaction_spec.rb[1:12:5] | passed | 0.00083 seconds |
|
42
|
+
./spec/integration/transaction_spec.rb[1:12:6] | passed | 0.00083 seconds |
|
43
|
+
./spec/integration/transaction_spec.rb[1:13:1] | passed | 0.00068 seconds |
|
44
|
+
./spec/integration/transaction_spec.rb[1:13:2] | passed | 0.00074 seconds |
|
45
|
+
./spec/integration/transaction_spec.rb[1:13:3] | passed | 0.00067 seconds |
|
46
|
+
./spec/integration/transaction_spec.rb[1:13:4] | passed | 0.00066 seconds |
|
45
47
|
./spec/integration/transaction_spec.rb[1:13:5] | passed | 0.00073 seconds |
|
46
|
-
./spec/integration/transaction_spec.rb[1:14:1] | passed | 0.
|
47
|
-
./spec/integration/transaction_spec.rb[1:15:1] | passed | 0.
|
48
|
-
./spec/integration/transaction_spec.rb[1:16:1:1:1] | passed | 0.
|
49
|
-
./spec/integration/transaction_spec.rb[1:16:2:1:1] | passed | 0.
|
50
|
-
./spec/integration/transaction_spec.rb[1:16:2:2:1] | passed | 0.
|
51
|
-
./spec/integration/transaction_without_steps_spec.rb[1:1:1] | passed | 0.
|
52
|
-
./spec/integration/transaction_without_steps_spec.rb[1:1:2] | passed | 0.
|
53
|
-
./spec/integration/transaction_without_steps_spec.rb[1:1:3] | passed | 0.
|
54
|
-
./spec/integration/transaction_without_steps_spec.rb[1:1:4] | passed | 0.
|
55
|
-
./spec/integration/transaction_without_steps_spec.rb[1:2:1] | passed | 0.
|
56
|
-
./spec/integration/transaction_without_steps_spec.rb[1:3:1] | passed | 0.
|
57
|
-
./spec/unit/step_adapters/around_spec.rb[1:1:1:1] | passed | 0.
|
58
|
-
./spec/unit/step_adapters/around_spec.rb[1:1:2:1] | passed | 0.
|
59
|
-
./spec/unit/step_adapters/around_spec.rb[1:1:3:1] | passed | 0.
|
60
|
-
./spec/unit/step_adapters/check_spec.rb[1:1:1] | passed | 0.
|
61
|
-
./spec/unit/step_adapters/check_spec.rb[1:1:2:1] | passed | 0.
|
62
|
-
./spec/unit/step_adapters/check_spec.rb[1:1:3:1] | passed | 0.
|
48
|
+
./spec/integration/transaction_spec.rb[1:14:1] | passed | 0.00128 seconds |
|
49
|
+
./spec/integration/transaction_spec.rb[1:15:1] | passed | 0.00081 seconds |
|
50
|
+
./spec/integration/transaction_spec.rb[1:16:1:1:1] | passed | 0.00087 seconds |
|
51
|
+
./spec/integration/transaction_spec.rb[1:16:2:1:1] | passed | 0.00089 seconds |
|
52
|
+
./spec/integration/transaction_spec.rb[1:16:2:2:1] | passed | 0.00102 seconds |
|
53
|
+
./spec/integration/transaction_without_steps_spec.rb[1:1:1] | passed | 0.00232 seconds |
|
54
|
+
./spec/integration/transaction_without_steps_spec.rb[1:1:2] | passed | 0.00176 seconds |
|
55
|
+
./spec/integration/transaction_without_steps_spec.rb[1:1:3] | passed | 0.00187 seconds |
|
56
|
+
./spec/integration/transaction_without_steps_spec.rb[1:1:4] | passed | 0.00294 seconds |
|
57
|
+
./spec/integration/transaction_without_steps_spec.rb[1:2:1] | passed | 0.00107 seconds |
|
58
|
+
./spec/integration/transaction_without_steps_spec.rb[1:3:1] | passed | 0.00097 seconds |
|
59
|
+
./spec/unit/step_adapters/around_spec.rb[1:1:1:1] | passed | 0.00014 seconds |
|
60
|
+
./spec/unit/step_adapters/around_spec.rb[1:1:2:1] | passed | 0.0001 seconds |
|
61
|
+
./spec/unit/step_adapters/around_spec.rb[1:1:3:1] | passed | 0.00009 seconds |
|
62
|
+
./spec/unit/step_adapters/check_spec.rb[1:1:1] | passed | 0.00009 seconds |
|
63
|
+
./spec/unit/step_adapters/check_spec.rb[1:1:2:1] | passed | 0.00009 seconds |
|
64
|
+
./spec/unit/step_adapters/check_spec.rb[1:1:3:1] | passed | 0.00012 seconds |
|
63
65
|
./spec/unit/step_adapters/check_spec.rb[1:1:4:1] | passed | 0.00009 seconds |
|
64
|
-
./spec/unit/step_adapters/map_spec.rb[1:1:1] | passed | 0.
|
65
|
-
./spec/unit/step_adapters/raw_spec.rb[1:1:1:1] | passed | 0.
|
66
|
-
./spec/unit/step_adapters/raw_spec.rb[1:1:2:1] | passed | 0.
|
67
|
-
./spec/unit/step_adapters/tee_spec.rb[1:1:1] | passed | 0.
|
68
|
-
./spec/unit/step_adapters/try_spec.rb[1:1:1:1] | passed | 0.
|
69
|
-
./spec/unit/step_adapters/try_spec.rb[1:1:2:1:1] | passed | 0.
|
70
|
-
./spec/unit/step_adapters/try_spec.rb[1:1:2:1:2] | passed | 0.
|
71
|
-
./spec/unit/step_adapters/try_spec.rb[1:1:2:1:3:1] | passed | 0.
|
72
|
-
./spec/unit/step_adapters/try_spec.rb[1:1:2:1:3:2] | passed | 0.
|
73
|
-
./spec/unit/step_adapters/try_spec.rb[1:1:2:2:1] | passed | 0.
|
66
|
+
./spec/unit/step_adapters/map_spec.rb[1:1:1] | passed | 0.00012 seconds |
|
67
|
+
./spec/unit/step_adapters/raw_spec.rb[1:1:1:1] | passed | 0.00013 seconds |
|
68
|
+
./spec/unit/step_adapters/raw_spec.rb[1:1:2:1] | passed | 0.00013 seconds |
|
69
|
+
./spec/unit/step_adapters/tee_spec.rb[1:1:1] | passed | 0.00013 seconds |
|
70
|
+
./spec/unit/step_adapters/try_spec.rb[1:1:1:1] | passed | 0.00013 seconds |
|
71
|
+
./spec/unit/step_adapters/try_spec.rb[1:1:2:1:1] | passed | 0.00015 seconds |
|
72
|
+
./spec/unit/step_adapters/try_spec.rb[1:1:2:1:2] | passed | 0.00013 seconds |
|
73
|
+
./spec/unit/step_adapters/try_spec.rb[1:1:2:1:3:1] | passed | 0.00012 seconds |
|
74
|
+
./spec/unit/step_adapters/try_spec.rb[1:1:2:1:3:2] | passed | 0.0001 seconds |
|
75
|
+
./spec/unit/step_adapters/try_spec.rb[1:1:2:2:1] | passed | 0.00014 seconds |
|
74
76
|
./spec/unit/step_adapters/try_spec.rb[1:1:2:2:2:1] | passed | 0.0001 seconds |
|
75
|
-
./spec/unit/step_spec.rb[1:1:1:1] | passed | 0.
|
76
|
-
./spec/unit/step_spec.rb[1:1:1:2] | passed | 0.
|
77
|
-
./spec/unit/step_spec.rb[1:1:2:1] | passed | 0.
|
78
|
-
./spec/unit/step_spec.rb[1:1:3:1] | passed | 0.
|
79
|
-
./spec/unit/step_spec.rb[1:1:3:2] | passed | 0.
|
80
|
-
./spec/unit/step_spec.rb[1:1:3:3] | passed | 0.
|
81
|
-
./spec/unit/step_spec.rb[1:2:1:1] | passed | 0.
|
77
|
+
./spec/unit/step_spec.rb[1:1:1:1] | passed | 0.00254 seconds |
|
78
|
+
./spec/unit/step_spec.rb[1:1:1:2] | passed | 0.01294 seconds |
|
79
|
+
./spec/unit/step_spec.rb[1:1:2:1] | passed | 0.00045 seconds |
|
80
|
+
./spec/unit/step_spec.rb[1:1:3:1] | passed | 0.00032 seconds |
|
81
|
+
./spec/unit/step_spec.rb[1:1:3:2] | passed | 0.00224 seconds |
|
82
|
+
./spec/unit/step_spec.rb[1:1:3:3] | passed | 0.00215 seconds |
|
83
|
+
./spec/unit/step_spec.rb[1:2:1:1] | passed | 0.00014 seconds |
|
82
84
|
./spec/unit/step_spec.rb[1:2:2:1] | passed | 0.00012 seconds |
|
83
|
-
./spec/unit/step_spec.rb[1:2:3:1] | passed | 0.
|
84
|
-
./spec/unit/step_spec.rb[1:3:1:1] | passed | 0.
|
85
|
-
./spec/unit/step_spec.rb[1:3:2:1] | passed | 0.
|
85
|
+
./spec/unit/step_spec.rb[1:2:3:1] | passed | 0.00015 seconds |
|
86
|
+
./spec/unit/step_spec.rb[1:3:1:1] | passed | 0.00011 seconds |
|
87
|
+
./spec/unit/step_spec.rb[1:3:2:1] | passed | 0.00013 seconds |
|
@@ -5,7 +5,13 @@ RSpec.describe "around steps" do
|
|
5
5
|
|
6
6
|
before do
|
7
7
|
container.instance_exec do
|
8
|
-
register :validate, -> input {
|
8
|
+
register :validate, -> input {
|
9
|
+
if input[:account][:balance] >= 0
|
10
|
+
Success(input)
|
11
|
+
else
|
12
|
+
Failure(input)
|
13
|
+
end
|
14
|
+
}
|
9
15
|
|
10
16
|
register :persist_user do |user:, **other|
|
11
17
|
self[:database] << [:user, user]
|
@@ -23,8 +29,8 @@ RSpec.describe "around steps" do
|
|
23
29
|
Class.new do
|
24
30
|
include Dry::Transaction(container: Test::Container)
|
25
31
|
|
26
|
-
step :validate
|
27
32
|
around :transaction
|
33
|
+
step :validate
|
28
34
|
step :persist_user
|
29
35
|
step :persist_account
|
30
36
|
step :finalize
|
@@ -78,4 +84,37 @@ RSpec.describe "around steps" do
|
|
78
84
|
expect(database).not_to be_committed
|
79
85
|
expect(database).to be_empty
|
80
86
|
end
|
87
|
+
|
88
|
+
it "supports matching on nested failures" do
|
89
|
+
invalid_input = input.merge(account: {balance: -10})
|
90
|
+
|
91
|
+
failed_input = nil
|
92
|
+
|
93
|
+
transaction.new(finalize: -> x { Success(x) }).call(invalid_input) do |m|
|
94
|
+
m.success { |v| v }
|
95
|
+
m.failure(:validate) { |input| failed_input = input }
|
96
|
+
end
|
97
|
+
|
98
|
+
expect(failed_input).to eq invalid_input
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "subscribing to events" do
|
102
|
+
let(:subscriber) {
|
103
|
+
Class.new do
|
104
|
+
attr_reader :user_persisted
|
105
|
+
|
106
|
+
def on_step_succeeded(event)
|
107
|
+
@user_persisted = true if event[:step_name] == :persist_user
|
108
|
+
end
|
109
|
+
end.new
|
110
|
+
}
|
111
|
+
|
112
|
+
it "supports subscribing to events from nested steps" do
|
113
|
+
trans = transaction.new(finalize: -> x { Success(x) })
|
114
|
+
trans.subscribe(subscriber)
|
115
|
+
trans.call(input)
|
116
|
+
|
117
|
+
expect(subscriber.user_persisted).to be_truthy
|
118
|
+
end
|
119
|
+
end
|
81
120
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-transaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Riley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05
|
11
|
+
date: 2018-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-container
|