Sha256: 3c50c1f2df62189220b2386ab06513dff443db010d042ee13eb7f13bc44ab873
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
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 = pure do |x| x + x end.apply Just(21) expect(result).to eq Just(42) end it "should be curried by default" do result = pure do |x, y| x + y end.apply(Just(21)).apply(Just(21)) expect(result).to eq Just(42) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ribimaybe-0.0.8 | spec/applicative_functor_spec.rb |
ribimaybe-0.0.6 | spec/applicative_functor_spec.rb |
ribimaybe-0.0.5 | spec/applicative_functor_spec.rb |