Sha256: 4bc2ab3873abd3a49134ec7e382f9b78a458ff557920832360e9f955f92fd0da

Contents?: true

Size: 879 Bytes

Versions: 4

Compression:

Stored size: 879 Bytes

Contents

require "spec_helper"
include Ribimaybe::Maybe

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

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

  describe "#apply" do
    context "when i have nothing" do
      it "should give me back nothing" do
        result = Nothing.apply Just(42)
        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 do |x|
          x + x
        end.apply Just(21)
        expect(result).to eq Just(42)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ribimaybe-0.0.4 spec/applicative_functor_spec.rb
ribimaybe-0.0.3 spec/applicative_functor_spec.rb
ribimaybe-0.0.2 spec/applicative_functor_spec.rb
ribimaybe-0.0.1 spec/applicative_functor_spec.rb