Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested transactions with step arguments fail with ArgumentError #125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions spec/integration/passing_step_arguments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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