dry-transaction 0.6.0 → 0.7.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
  SHA1:
3
- metadata.gz: a1086edb5c79856eea4443feca03571381d01656
4
- data.tar.gz: 396497b3dc1c00bac2b526d5dd9b2db3b94aec86
3
+ metadata.gz: f3f3bd19cd953f553e0e0ab62bd1858d7c95be46
4
+ data.tar.gz: badf643490370178f22c9bd35dc23c9213cb7433
5
5
  SHA512:
6
- metadata.gz: 99f8334aabeda041d3d591affdde7030ddf9c227149a9f98230949adb076561fc903413bad9a51a634eeb26c6ccbe416bceb2d3a156dcf8a5d003b4d14df06e1
7
- data.tar.gz: 1157a95e3126ea8108bbea2c795f1e094bcadd4ecddb26c1e62af2c1a9ebef7c32b181d9d67b3a62df0326f681c2ab7bd3448e302dcc42c43bfaa0c6a21e0a01
6
+ metadata.gz: 67cab2a4aec90b84bf79d5ae14fff6e82244bf1d2c743adfcfde3c9e328934f72131178fcee49c70c4bdc674600dfe60092d67a57dceeba5759a66caf10341f3
7
+ data.tar.gz: c11ccbbca9e9adcc36a6b918490122f875b0d7fa97a3eebabcf5d8223d0166364b6ed0be2daa2b7574139c75560cd1978328c5190e4b7fb61aa5b8bdd6e7bd30
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dry-transaction (0.6.0)
4
+ dry-transaction (0.7.0)
5
5
  dry-container (>= 0.2.8)
6
- kleisli
6
+ dry-monads (~> 0.0.1)
7
7
  wisper (>= 1.6.0)
8
8
 
9
9
  GEM
@@ -21,8 +21,8 @@ GEM
21
21
  dry-container (0.3.1)
22
22
  concurrent-ruby (~> 1.0)
23
23
  dry-configurable (~> 0.1, >= 0.1.3)
24
+ dry-monads (0.0.1)
24
25
  json (1.8.3)
25
- kleisli (0.2.7)
26
26
  method_source (0.8.2)
27
27
  pry (0.10.3)
28
28
  coderay (~> 1.1.0)
@@ -55,7 +55,7 @@ PLATFORMS
55
55
  ruby
56
56
 
57
57
  DEPENDENCIES
58
- bundler (~> 1.11.2)
58
+ bundler (~> 1.12.2)
59
59
  byebug
60
60
  codeclimate-test-reporter
61
61
  dry-container
@@ -67,4 +67,4 @@ DEPENDENCIES
67
67
  yard
68
68
 
69
69
  BUNDLED WITH
70
- 1.11.2
70
+ 1.12.3
@@ -1,4 +1,4 @@
1
- require "kleisli"
1
+ require "dry/monads/either"
2
2
  require "dry/transaction/version"
3
3
  require "dry/transaction/dsl"
4
4
 
@@ -16,7 +16,7 @@ module Dry
16
16
  # transaction, with its output is passed as the input to the next operation.
17
17
  # Operations will only be called if the previous step was a success.
18
18
  #
19
- # A step is successful when it returns a [Kleisli](kleisli) `Right` object
19
+ # A step is successful when it returns a [dry-monads](dry-monads) `Right` object
20
20
  # wrapping its output value. A step is a failure when it returns a `Left`
21
21
  # object. If your operations already return a `Right` or `Left`, they can be
22
22
  # added to your operation as plain `step` steps.
@@ -30,7 +30,7 @@ module Dry
30
30
  # * `tee` --- ignore the output of the operation and pass through its original
31
31
  # input as a `Right`.
32
32
  #
33
- # [kleisli]: https://rubygems.org/gems/kleisli
33
+ # [dry-monads]: https://rubygems.org/gems/dry-monads
34
34
  #
35
35
  # @example
36
36
  # container = {do_first: some_obj, do_second: some_obj}
@@ -5,7 +5,7 @@ require "dry/transaction/sequence"
5
5
  module Dry
6
6
  module Transaction
7
7
  # @api private
8
- class DSL
8
+ class DSL < BasicObject
9
9
  attr_reader :container
10
10
  attr_reader :step_adapters
11
11
  attr_reader :steps
@@ -27,7 +27,7 @@ module Dry
27
27
 
28
28
  step_adapter = step_adapters[method_name]
29
29
  step_name = args.first
30
- options = args.last.is_a?(Hash) ? args.last : {}
30
+ options = args.last.is_a?(::Hash) ? args.last : {}
31
31
  operation_name = options.delete(:with) || step_name
32
32
  operation = container[operation_name]
33
33
 
@@ -5,17 +5,21 @@ module Dry
5
5
  attr_reader :output
6
6
 
7
7
  def initialize(result)
8
- @result = result
8
+ if result.respond_to?(:to_either)
9
+ @result = result.to_either
10
+ else
11
+ @result = result
12
+ end
9
13
  end
10
14
 
11
15
  def success(&block)
12
- return output unless result.is_a?(Kleisli::Either::Right)
16
+ return output unless result.right?
13
17
 
14
18
  @output = block.call(result.value)
15
19
  end
16
20
 
17
21
  def failure(step_name = nil, &block)
18
- return output unless result.is_a?(Kleisli::Either::Left)
22
+ return output unless result.left?
19
23
 
20
24
  if step_name.nil? || step_name == result.value.__step_name
21
25
  @output = block.call(result.value)
@@ -3,6 +3,8 @@ require "dry/transaction/result_matcher"
3
3
  module Dry
4
4
  module Transaction
5
5
  class Sequence
6
+ include Dry::Monads::Either::Mixin
7
+
6
8
  # @api private
7
9
  attr_reader :steps
8
10
 
@@ -29,10 +31,10 @@ module Dry
29
31
  # my_transaction.call(some_input, step_name: [extra_argument])
30
32
  #
31
33
  # The return value will be the output from the last operation, wrapped
32
- # in a [Kleisli](kleisli) `Either` object, a `Right` for a successful
34
+ # in a [dry-monads](dry-monads) `Either` object, a `Right` for a successful
33
35
  # transaction or a `Left` for a failed transaction.
34
36
  #
35
- # [kleisli]: https://rubygems.org/gems/kleisli
37
+ # [dry-monads]: https://rubygems.org/gems/dry-monads
36
38
  #
37
39
  # @param input
38
40
  # @param options [Hash] extra step arguments
@@ -45,7 +47,7 @@ module Dry
45
47
  assert_options_satisfy_step_arity(options)
46
48
 
47
49
  steps = steps_with_options_applied(options)
48
- result = steps.inject(Right(input), :>>)
50
+ result = steps.inject(Right(input), :bind)
49
51
 
50
52
  if block
51
53
  block.call(ResultMatcher.new(result))
@@ -6,6 +6,7 @@ module Dry
6
6
  # @api private
7
7
  class Step
8
8
  include Wisper::Publisher
9
+ include Dry::Monads::Either::Mixin
9
10
 
10
11
  attr_reader :step_adapter
11
12
  attr_reader :step_name
@@ -3,6 +3,8 @@ module Dry
3
3
  class StepAdapters
4
4
  # @api private
5
5
  class Map
6
+ include Dry::Monads::Either::Mixin
7
+
6
8
  def call(step, *args, input)
7
9
  Right(step.operation.call(*args, input))
8
10
  end
@@ -1,14 +1,16 @@
1
- require "kleisli"
1
+ require "dry/monads/either"
2
2
 
3
3
  module Dry
4
4
  module Transaction
5
5
  class StepAdapters
6
6
  # @api private
7
7
  class Raw
8
+ include Dry::Monads::Either::Mixin
9
+
8
10
  def call(step, *args, input)
9
11
  result = step.operation.call(*args, input)
10
12
 
11
- unless result.is_a?(Kleisli::Either)
13
+ unless result.is_a?(Dry::Monads::Either)
12
14
  raise ArgumentError, "step +#{step.step_name}+ must return an Either object"
13
15
  end
14
16
 
@@ -3,6 +3,8 @@ module Dry
3
3
  class StepAdapters
4
4
  # @api private
5
5
  class Tee
6
+ include Dry::Monads::Either::Mixin
7
+
6
8
  def call(step, *args, input)
7
9
  step.operation.call(*args, input)
8
10
  Right(input)
@@ -3,6 +3,8 @@ module Dry
3
3
  class StepAdapters
4
4
  # @api private
5
5
  class Try
6
+ include Dry::Monads::Either::Mixin
7
+
6
8
  def call(step, *args, input)
7
9
  unless step.options[:catch]
8
10
  raise ArgumentError, "+try+ steps require one or more exception classes provided via +catch:+"
@@ -10,6 +12,7 @@ module Dry
10
12
 
11
13
  Right(step.operation.call(*args, input))
12
14
  rescue *Array(step.options[:catch]) => e
15
+ e = step.options[:raise].new(e.message) if step.options[:raise]
13
16
  Left(e)
14
17
  end
15
18
  end
@@ -9,7 +9,11 @@ module Dry
9
9
  end
10
10
 
11
11
  def method_missing(name, *args, &block)
12
- @__object.send(name, *args, &block)
12
+ @__object.public_send(name, *args, &block)
13
+ end
14
+
15
+ def respond_to_missing?(name, include_private = false)
16
+ @__object.respond_to?(name, include_private)
13
17
  end
14
18
 
15
19
  def ==(other)
@@ -1,6 +1,6 @@
1
1
  module Dry
2
2
  # Business transaction DSL.
3
3
  module Transaction
4
- VERSION = "0.6.0".freeze
4
+ VERSION = "0.7.0".freeze
5
5
  end
6
6
  end
data/spec/examples.txt CHANGED
@@ -1,43 +1,45 @@
1
1
  example_id | status | run_time |
2
2
  -------------------------------------------------------- | ------ | --------------- |
3
- ./spec/integration/custom_step_adapters_spec.rb[1:1] | passed | 0.00032 seconds |
4
- ./spec/integration/passing_step_arguments_spec.rb[1:1:1] | passed | 0.001 seconds |
5
- ./spec/integration/passing_step_arguments_spec.rb[1:2:1] | passed | 0.00021 seconds |
6
- ./spec/integration/passing_step_arguments_spec.rb[1:3:1] | passed | 0.0002 seconds |
7
- ./spec/integration/publishing_step_events_spec.rb[1:1:1] | passed | 0.00089 seconds |
8
- ./spec/integration/publishing_step_events_spec.rb[1:1:2] | passed | 0.00323 seconds |
9
- ./spec/integration/publishing_step_events_spec.rb[1:2:1] | passed | 0.00071 seconds |
10
- ./spec/integration/publishing_step_events_spec.rb[1:2:2] | passed | 0.00032 seconds |
11
- ./spec/integration/transaction_spec.rb[1:1:1] | passed | 0.00166 seconds |
12
- ./spec/integration/transaction_spec.rb[1:1:2] | passed | 0.00031 seconds |
13
- ./spec/integration/transaction_spec.rb[1:1:3] | passed | 0.00024 seconds |
14
- ./spec/integration/transaction_spec.rb[1:1:4] | passed | 0.00033 seconds |
15
- ./spec/integration/transaction_spec.rb[1:1:5] | passed | 0.00036 seconds |
16
- ./spec/integration/transaction_spec.rb[1:2:1] | passed | 0.00029 seconds |
17
- ./spec/integration/transaction_spec.rb[1:2:2] | passed | 0.00023 seconds |
18
- ./spec/integration/transaction_spec.rb[1:2:3] | passed | 0.00025 seconds |
19
- ./spec/integration/transaction_spec.rb[1:2:4] | passed | 0.00025 seconds |
20
- ./spec/integration/transaction_spec.rb[1:2:5] | passed | 0.00026 seconds |
21
- ./spec/integration/transaction_spec.rb[1:2:6] | passed | 0.00024 seconds |
22
- ./spec/integration/transaction_spec.rb[1:3:1] | passed | 0.00242 seconds |
23
- ./spec/integration/transaction_spec.rb[1:3:2] | passed | 0.00023 seconds |
24
- ./spec/integration/transaction_spec.rb[1:3:3] | passed | 0.00022 seconds |
25
- ./spec/integration/transaction_spec.rb[1:4:1] | passed | 0.00026 seconds |
26
- ./spec/unit/sequence_spec.rb[1:1:1] | passed | 0.00028 seconds |
27
- ./spec/unit/sequence_spec.rb[1:1:2] | passed | 0.00017 seconds |
28
- ./spec/unit/sequence_spec.rb[1:1:3] | passed | 0.00015 seconds |
29
- ./spec/unit/sequence_spec.rb[1:1:4] | passed | 0.00017 seconds |
30
- ./spec/unit/sequence_spec.rb[1:2:1] | passed | 0.0003 seconds |
31
- ./spec/unit/sequence_spec.rb[1:2:2] | passed | 0.00021 seconds |
32
- ./spec/unit/sequence_spec.rb[1:2:3] | passed | 0.0023 seconds |
33
- ./spec/unit/sequence_spec.rb[1:2:4] | passed | 0.00161 seconds |
34
- ./spec/unit/sequence_spec.rb[1:3:1] | passed | 0.00018 seconds |
35
- ./spec/unit/sequence_spec.rb[1:3:2] | passed | 0.00018 seconds |
36
- ./spec/unit/sequence_spec.rb[1:4:1] | passed | 0.00027 seconds |
37
- ./spec/unit/sequence_spec.rb[1:4:2] | passed | 0.0003 seconds |
38
- ./spec/unit/sequence_spec.rb[1:4:3] | passed | 0.00017 seconds |
39
- ./spec/unit/sequence_spec.rb[1:4:4] | passed | 0.00014 seconds |
40
- ./spec/unit/sequence_spec.rb[1:4:5:1] | passed | 0.0002 seconds |
3
+ ./spec/integration/custom_step_adapters_spec.rb[1:1] | passed | 0.00027 seconds |
4
+ ./spec/integration/passing_step_arguments_spec.rb[1:1:1] | passed | 0.00022 seconds |
5
+ ./spec/integration/passing_step_arguments_spec.rb[1:2:1] | passed | 0.00017 seconds |
6
+ ./spec/integration/passing_step_arguments_spec.rb[1:3:1] | passed | 0.00021 seconds |
7
+ ./spec/integration/publishing_step_events_spec.rb[1:1:1] | passed | 0.00084 seconds |
8
+ ./spec/integration/publishing_step_events_spec.rb[1:1:2] | passed | 0.00356 seconds |
9
+ ./spec/integration/publishing_step_events_spec.rb[1:2:1] | passed | 0.00057 seconds |
10
+ ./spec/integration/publishing_step_events_spec.rb[1:2:2] | passed | 0.0007 seconds |
11
+ ./spec/integration/transaction_spec.rb[1:1:1] | passed | 0.00435 seconds |
12
+ ./spec/integration/transaction_spec.rb[1:1:2] | passed | 0.00039 seconds |
13
+ ./spec/integration/transaction_spec.rb[1:1:3] | passed | 0.0002 seconds |
14
+ ./spec/integration/transaction_spec.rb[1:1:4] | passed | 0.00036 seconds |
15
+ ./spec/integration/transaction_spec.rb[1:1:5] | passed | 0.00034 seconds |
16
+ ./spec/integration/transaction_spec.rb[1:2:1] | passed | 0.00022 seconds |
17
+ ./spec/integration/transaction_spec.rb[1:2:2] | passed | 0.00021 seconds |
18
+ ./spec/integration/transaction_spec.rb[1:2:3] | passed | 0.0002 seconds |
19
+ ./spec/integration/transaction_spec.rb[1:2:4] | passed | 0.0002 seconds |
20
+ ./spec/integration/transaction_spec.rb[1:2:5] | passed | 0.00024 seconds |
21
+ ./spec/integration/transaction_spec.rb[1:2:6] | passed | 0.00021 seconds |
22
+ ./spec/integration/transaction_spec.rb[1:3:1] | passed | 0.00295 seconds |
23
+ ./spec/integration/transaction_spec.rb[1:3:2] | passed | 0.00111 seconds |
24
+ ./spec/integration/transaction_spec.rb[1:3:3] | passed | 0.00032 seconds |
25
+ ./spec/integration/transaction_spec.rb[1:3:4] | passed | 0.00166 seconds |
26
+ ./spec/integration/transaction_spec.rb[1:3:5] | passed | 0.00049 seconds |
27
+ ./spec/integration/transaction_spec.rb[1:4:1] | passed | 0.00293 seconds |
28
+ ./spec/unit/sequence_spec.rb[1:1:1] | passed | 0.00018 seconds |
29
+ ./spec/unit/sequence_spec.rb[1:1:2] | passed | 0.0002 seconds |
30
+ ./spec/unit/sequence_spec.rb[1:1:3] | passed | 0.00012 seconds |
31
+ ./spec/unit/sequence_spec.rb[1:1:4] | passed | 0.00015 seconds |
32
+ ./spec/unit/sequence_spec.rb[1:2:1] | passed | 0.00016 seconds |
33
+ ./spec/unit/sequence_spec.rb[1:2:2] | passed | 0.0002 seconds |
34
+ ./spec/unit/sequence_spec.rb[1:2:3] | passed | 0.00013 seconds |
35
+ ./spec/unit/sequence_spec.rb[1:2:4] | passed | 0.00015 seconds |
36
+ ./spec/unit/sequence_spec.rb[1:3:1] | passed | 0.00014 seconds |
37
+ ./spec/unit/sequence_spec.rb[1:3:2] | passed | 0.00017 seconds |
38
+ ./spec/unit/sequence_spec.rb[1:4:1] | passed | 0.0002 seconds |
39
+ ./spec/unit/sequence_spec.rb[1:4:2] | passed | 0.00021 seconds |
40
+ ./spec/unit/sequence_spec.rb[1:4:3] | passed | 0.00015 seconds |
41
+ ./spec/unit/sequence_spec.rb[1:4:4] | passed | 0.00013 seconds |
42
+ ./spec/unit/sequence_spec.rb[1:4:5:1] | passed | 0.00022 seconds |
41
43
  ./spec/unit/sequence_spec.rb[1:4:5:2] | passed | 0.00018 seconds |
42
- ./spec/unit/sequence_spec.rb[1:4:6:1] | passed | 0.00021 seconds |
43
- ./spec/unit/sequence_spec.rb[1:4:6:2] | passed | 0.00021 seconds |
44
+ ./spec/unit/sequence_spec.rb[1:4:6:1] | passed | 0.0002 seconds |
45
+ ./spec/unit/sequence_spec.rb[1:4:6:2] | passed | 0.00017 seconds |
@@ -21,6 +21,8 @@ RSpec.describe "Custom step adapters" do
21
21
 
22
22
  module Test
23
23
  class CustomStepAdapters < Dry::Transaction::StepAdapters
24
+ extend Dry::Monads::Either::Mixin
25
+
24
26
  register :enqueue, -> step, *args, input {
25
27
  Test::QUEUE << step.operation.call(*args, input)
26
28
  Right(input)
@@ -28,7 +28,7 @@ RSpec.describe "Passing additional arguments to step operations" do
28
28
  let(:step_options) { {validate: ["doe.com"]} }
29
29
 
30
30
  it "passes the arguments and calls the operations successfully" do
31
- expect(call_transaction).to be_a Kleisli::Either::Right
31
+ expect(call_transaction).to be_a Dry::Monads::Either::Right
32
32
  end
33
33
  end
34
34
 
@@ -31,7 +31,7 @@ RSpec.describe "Transactions" do
31
31
  end
32
32
 
33
33
  it "returns a success" do
34
- expect(transaction.call(input)).to be_a Kleisli::Either::Right
34
+ expect(transaction.call(input)).to be_a Dry::Monads::Either::Right
35
35
  end
36
36
 
37
37
  it "wraps the result of the final operation" do
@@ -68,7 +68,7 @@ RSpec.describe "Transactions" do
68
68
  end
69
69
 
70
70
  it "returns a failure" do
71
- expect(transaction.call(input)).to be_a Kleisli::Either::Left
71
+ expect(transaction.call(input)).to be_a Dry::Monads::Either::Left
72
72
  end
73
73
 
74
74
  it "wraps the result of the failing operation" do
@@ -129,12 +129,24 @@ RSpec.describe "Transactions" do
129
129
  end
130
130
 
131
131
  it "returns a failure" do
132
- expect(transaction.call(input)).to be_a Kleisli::Either::Left
132
+ expect(transaction.call(input)).to be_a Dry::Monads::Either::Left
133
133
  end
134
134
 
135
135
  it "returns the failing value from the operation" do
136
136
  expect(transaction.call(input).value).to eq "raw failure"
137
137
  end
138
+
139
+ it "returns an object that quacks like expected" do
140
+ result = transaction.call(input).value
141
+
142
+ expect(Array(result)).to eq(['raw failure'])
143
+ end
144
+
145
+ it "does not allow to call private methods on the result accidently" do
146
+ result = transaction.call(input).value
147
+
148
+ expect { result.print('') }.to raise_error(NoMethodError)
149
+ end
138
150
  end
139
151
 
140
152
  context "non-confirming raw step result" do
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include Dry::Monads::Either::Mixin
3
+ end
@@ -36,7 +36,7 @@ RSpec.describe Dry::Transaction::Sequence do
36
36
  end
37
37
 
38
38
  it "leaves the original transaction unmodified" do
39
- new_transaction = initial_transaction.prepend(container: container) do
39
+ _new_transaction = initial_transaction.prepend(container: container) do
40
40
  map :reverse
41
41
  end
42
42
 
@@ -73,7 +73,7 @@ RSpec.describe Dry::Transaction::Sequence do
73
73
  end
74
74
 
75
75
  it "leaves the original transaction unmodified" do
76
- new_transaction = initial_transaction.append(container: container) do
76
+ _new_transaction = initial_transaction.append(container: container) do
77
77
  map :reverse
78
78
  end
79
79
 
@@ -96,7 +96,7 @@ RSpec.describe Dry::Transaction::Sequence do
96
96
  end
97
97
 
98
98
  it "leaves the original transaction unmodified" do
99
- new_transaction = initial_transaction.remove(:exclaim_all, :reverse)
99
+ _new_transaction = initial_transaction.remove(:exclaim_all, :reverse)
100
100
  expect(initial_transaction.call("hello world").right).to eq "!DLROW !OLLEH"
101
101
  end
102
102
  end
@@ -0,0 +1,98 @@
1
+ RSpec.describe Dry::Transaction::StepAdapters::Try do
2
+
3
+ subject { described_class.new }
4
+
5
+ let(:operation) {
6
+ -> (input) {
7
+ raise(Test::NotValidError, 'not a string') unless input.is_a? String
8
+ input.upcase
9
+ }
10
+ }
11
+
12
+ let(:step) {
13
+ Dry::Transaction::Step.new(subject, :step, :step, operation, options)
14
+ }
15
+
16
+ let(:options) { { catch: Test::NotValidError } }
17
+
18
+ before do
19
+ Test::NotValidError = Class.new(StandardError)
20
+ Test::BetterNamingError = Class.new(StandardError)
21
+ end
22
+
23
+ describe "#call" do
24
+
25
+ context "without the :catch option" do
26
+ let(:options) { { } }
27
+
28
+ it "raises an ArgumentError" do
29
+ expect do
30
+ subject.call(step, {})
31
+ end.to raise_error(ArgumentError)
32
+ end
33
+ end
34
+
35
+ context "with the :catch option" do
36
+
37
+ context "when the error was raised" do
38
+
39
+ it "return a Left Monad" do
40
+ expect(subject.call(step, 1234)).to be_a Dry::Monads::Either::Left
41
+ end
42
+
43
+ it "return the raised error as output" do
44
+ result = subject.call(step, 1234)
45
+ expect(result.value).to be_a Test::NotValidError
46
+ expect(result.value.message).to eql 'not a string'
47
+ end
48
+
49
+ context "when using the :raise option" do
50
+ let(:options) {
51
+ {
52
+ catch: Test::NotValidError,
53
+ raise: Test::BetterNamingError
54
+ }
55
+ }
56
+
57
+ it "return a Left Monad" do
58
+ expect(subject.call(step, 1234)).to be_a Dry::Monads::Either::Left
59
+ end
60
+
61
+ it "return the error specified by :raise as output" do
62
+ result = subject.call(step, 1234)
63
+ expect(result.value).to be_a Test::BetterNamingError
64
+ expect(result.value.message).to eql 'not a string'
65
+ end
66
+ end
67
+ end
68
+
69
+ context "when the error was NOT raised" do
70
+
71
+ it "return a Right Monad" do
72
+ expect(subject.call(step, 'input')).to be_a Dry::Monads::Either::Right
73
+ end
74
+
75
+ it "return the result of the operation as output" do
76
+ expect(subject.call(step, 'input').value).to eql 'INPUT'
77
+ end
78
+
79
+ context "when using the :raise option" do
80
+ let(:options) {
81
+ {
82
+ catch: Test::NotValidError,
83
+ raise: Test::BetterNamingError
84
+ }
85
+ }
86
+
87
+ it "return a Right Monad" do
88
+ expect(subject.call(step, 'input')).to be_a Dry::Monads::Either::Right
89
+ end
90
+
91
+ it "return the result of the operation as output" do
92
+ expect(subject.call(step, 'input').value).to eql 'INPUT'
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ 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.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-05 00:00:00.000000000 Z
11
+ date: 2016-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.2.8
27
27
  - !ruby/object:Gem::Dependency
28
- name: kleisli
28
+ name: dry-monads
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.0.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.0.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: wisper
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.11.2
61
+ version: 1.12.2
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.11.2
68
+ version: 1.12.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -153,8 +153,10 @@ files:
153
153
  - spec/integration/publishing_step_events_spec.rb
154
154
  - spec/integration/transaction_spec.rb
155
155
  - spec/spec_helper.rb
156
+ - spec/support/either_mixin.rb
156
157
  - spec/support/test_module_constants.rb
157
158
  - spec/unit/sequence_spec.rb
159
+ - spec/unit/step_adapters/try_spec.rb
158
160
  homepage: https://github.com/dry-rb/dry-transaction
159
161
  licenses:
160
162
  - MIT