# frozen_string_literal: true require 'dry/matcher' module Dry module Transaction ResultMatcher = Dry::Matcher.new( success: Dry::Matcher::Case.new( match: -> result { result.success? }, resolve: -> result { result.value! } ), failure: Dry::Matcher::Case.new( match: -> result, step_name = nil { if step_name result.failure? && result.failure.step.name == step_name else result.failure? end }, resolve: -> result { result.failure.value } ) ) end end