Sha256: 7f5f5c3314ebcf46553b028f635e3f3d513228dc867dfb1541d399d5ad8e2e78

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'
module Alf
  describe TupleComputation, "project" do
    big = TupleExpression.coerce(->(t){ t.status > 10 })
    who = TupleExpression.coerce(->(t){ t.name })

    let(:comp){
      TupleComputation[big?: big, who: who]
    }

    subject{ comp.project(list, allbut) }

    context 'when not allbut' do
      let(:allbut){ false }

      [
        [ [:big?, :who],  TupleComputation[big?: big, who: who] ],
        [ [:big?],        TupleComputation[big?: big] ],
        [ [:none],        TupleComputation[{}] ],
      ].each do |(attrs,expected)|
        context "on #{attrs}" do
          let(:list){ attrs }

          it{ should eq(expected) }
        end
      end
    end

    context 'when allbut' do
      let(:allbut){ true }

      [
        [ [:big?, :who], TupleComputation[{}] ],
        [ [:big?],       TupleComputation[who: who] ],
        [ [:none],       TupleComputation[big?: big, who: who] ],
      ].each do |(attrs,expected)|
        context "on #{attrs}" do
          let(:list){ attrs }

          it{ should eq(expected) }
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-types/tuple_computation/test_project.rb