From 381c9ffec6e578dad210c013f97928b50ece809e Mon Sep 17 00:00:00 2001 From: Moritz Winter Date: Thu, 25 Apr 2019 02:24:58 +0200 Subject: [PATCH] Add a spec for nested transactions with step arguments --- .../passing_step_arguments_spec.rb | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/spec/integration/passing_step_arguments_spec.rb b/spec/integration/passing_step_arguments_spec.rb index eaa6222..520a9f3 100644 --- a/spec/integration/passing_step_arguments_spec.rb +++ b/spec/integration/passing_step_arguments_spec.rb @@ -48,4 +48,49 @@ module Test expect { call_transaction }.to raise_error(ArgumentError) end end + + context "with nested transactions" do + let(:transaction) { + Class.new do + include Dry::Transaction(container: Test::Container) + + step :root, with: :nested + end.new + } + + before do + module Test + nested_transaction = Class.new do + include Dry::Transaction + + step :process + + def process(input, *args) + Success args + end + end.new + + Container = { + nested: nested_transaction + } + end + end + + context "arguments provided" do + let(:step_options) { { root: ["doe.com"] } } + + it "passes the arguments and calls the operations successfully" do + expect(call_transaction.value!).to match /doe.com/ + end + end + + context "arguments not provided" do + let(:step_options) { {} } + + it "passes the arguments and calls the operations successfully" do + expect(call_transaction.value!).to be_empty + end + end + end end +