Skip to content

Commit

Permalink
another mock_step doc test.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Jan 1, 2025
1 parent fded4d4 commit ed4ae19
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/docs/assertion_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Validate < Trailblazer::Operation

class Create < Trailblazer::Operation
step :model
step Subprocess(Validate)
step Subprocess(Validate), id: :validate
step :save

include Testing.def_steps(:model, :save)
Expand All @@ -149,6 +149,26 @@ class Create < Trailblazer::Operation
assert_equal result[:saved], true
end

it "allows mocking steps any level" do
create_operation = mock_step(Memo::Operation::Create, path: [:validate, :verify_content]) do |ctx, **|
# new logic for {Validate#verify_content}.
ctx[:is_verified] = true
end

result = create_operation.(seq: [])
assert_equal result[:seq].inspect, %([:model, :check_params, :save])
assert_equal result[:is_verified], true

result =
assert_pass create_operation, {
#~skip
seq: []
#~skip end
}

assert_equal result[:is_verified], true
end

end
# run (???)
end

0 comments on commit ed4ae19

Please sign in to comment.