Sha256: 18e3f86aafd9aa520e5cf6480283929f878095720c5e0ffbda9ee7fa23712611

Contents?: true

Size: 906 Bytes

Versions: 7

Compression:

Stored size: 906 Bytes

Contents

require "spec_helper"
include Ribimaybe::Maybe

describe "Monad Instance" do
  describe "#rturn" do
    context "when i provide a nil" do
      it "should give me back nothing" do
        result = rturn(nil)
        expect(result).to eq Nothing
      end
    end

    context "when i provide a value" do
      it "should wrap the value" do
        result = rturn(42)
        expect(result).to eq Just(42)
      end
    end
  end

  describe "#bind" do
    context "when i have nothing" do
      it "should give me back nothing" do
        result = Nothing.bind do |x|
          rturn x + x
        end
        expect(result).to eq Nothing
      end
    end

    context "when i something containing a fn" do
      it "should be apply to apply that fn to something" do
        result = Just(21).bind do |x|
          rturn x + x
        end
        expect(result).to eq Just(42)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ribimaybe-0.0.8 spec/monad_instance_spec.rb
ribimaybe-0.0.6 spec/monad_instance_spec.rb
ribimaybe-0.0.5 spec/monad_instance_spec.rb
ribimaybe-0.0.4 spec/monad_instance_spec.rb
ribimaybe-0.0.3 spec/monad_instance_spec.rb
ribimaybe-0.0.2 spec/monad_instance_spec.rb
ribimaybe-0.0.1 spec/monad_instance_spec.rb