Result matcher

dry-matcher provides a ready-to-use ResultMatcher for working with Result or Try monads from dry-monads or any other compatible gems.

require "dry-monads"
require "dry/matcher/result_matcher"

value = Dry::Monads::Result::Success.new("success!")

result = Dry::Matcher::ResultMatcher.(value) do |m|
  m.success do |v|
    "Yay: #{v}"
  end

  m.failure do |v|
    "Boo: #{v}"
  end
end

result # => "Yay: success!"