Sha256: df67697830f143afbdc81c9f462d60a89e4ab0de30a2b971351ff4d651c4c50f
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require "dry-monads" require "dry/matcher/result_matcher" RSpec.describe "Dry::Matcher::ResultMatcher" do describe "external matching" do subject(:match) { Dry::Matcher::ResultMatcher.(result) do |m| m.success do |v| "Matched success: #{v}" end m.failure do |v| "Matched failure: #{v}" end end } context "successful result" do let(:result) { Dry::Monads::Success("a success") } it "matches on success" do expect(match).to eq "Matched success: a success" end end context "failed result" do let(:result) { Dry::Monads::Failure("a failure") } it "matches on failure" do expect(match).to eq "Matched failure: a failure" end end context "result convertible to result" do context "converts to success" do let(:result) { Dry::Monads::Try.lift([StandardError], -> { 'a success' }) } it "matches on success" do expect(match).to eq "Matched success: a success" end end context "converts to failure" do let(:result) { Dry::Monads::Try.lift([StandardError], -> { raise('a failure') }) } it "matches on failure" do expect(match).to eq "Matched failure: a failure" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-matcher-0.7.0 | spec/integration/result_matcher_spec.rb |