Sha256: b507a23b6039c661b718256cf4b915e53802dc885e2395781f45d39821e09c09
Contents?: true
Size: 1006 Bytes
Versions: 2
Compression:
Stored size: 1006 Bytes
Contents
RSpec.describe "Custom step adapters" do let(:transaction) { Dry.Transaction(container: container, step_adapters: Test::CustomStepAdapters) do map :process tee :persist enqueue :deliver end } let(:container) { { process: -> input { {name: input["name"], email: input["email"]} }, persist: -> input { Test::DB << input and true }, deliver: -> input { "Delivered email to #{input[:email]}" }, } } before do Test::DB = [] Test::QUEUE = [] module Test class CustomStepAdapters < Dry::Transaction::StepAdapters extend Dry::Monads::Either::Mixin register :enqueue, -> step, *args, input { Test::QUEUE << step.operation.call(*args, input) Right(input) } end end end it "supports custom step adapters" do input = {"name" => "Jane", "email" => "jane@doe.com"} transaction.call(input) expect(Test::QUEUE).to include("Delivered email to jane@doe.com") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-transaction-0.8.0 | spec/integration/custom_step_adapters_spec.rb |
dry-transaction-0.7.0 | spec/integration/custom_step_adapters_spec.rb |