Sha256: cadb60bf9707728615006c50c0baeaceb1380087f10747d26d82e8ce97cdbc29

Contents?: true

Size: 623 Bytes

Versions: 3

Compression:

Stored size: 623 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Fear::Try::Mixin do
  include Fear::Try::Mixin

  describe "Try()" do
    context "success" do
      subject { Try { 4 / 2 } }

      it { is_expected.to eq(Fear::Success.new(2)) }
    end

    context "failure" do
      subject { Try { 4 / 0 } }

      it { is_expected.to be_kind_of(Fear::Failure) }
    end
  end

  describe "Success()" do
    subject { Success(42) }

    it { is_expected.to be_success_of(42) }
  end

  describe "Failure()" do
    subject { Failure(error) }

    let(:error) { StandardError.new }

    it { is_expected.to be_failure_of(error) }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fear-3.0.0 spec/fear/try/mixin_spec.rb
fear-2.0.1 spec/fear/try/mixin_spec.rb
fear-2.0.0 spec/fear/try/mixin_spec.rb