Sha256: 1e5a6d7f0e6b90d789ede1f7f2ab2635d99c20b3cdacbab128ea8cad840b61e0

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'
module Alf
  module Operator::Relational
    describe Project do

      let(:operator_class){ Project }
      it_should_behave_like("An operator class")

      let(:input) {[
        {:a => "a", :b => "b"},
        {:a => "a", :b => "b"},
      ]}

      subject{ operator.to_a }

      context "--no-allbut" do
        let(:expected){[{:a => "a"}]}

        context "with Lispy" do
          let(:operator){ Lispy.project(input, [:a]) }
          it { should eq(expected) } 
        end
      end # --no-allbut

      context "--allbut" do
        let(:expected){[{:b => "b"}]}

        context "and factored with Lispy#project" do
          let(:operator){ Lispy.project(input, [:a], :allbut => true) }
          it { should eq(expected) } 
        end

        context "and factored with Lispy#allbut" do
          let(:operator){ Lispy.allbut(input, [:a]) }
          it { should eq(expected) } 
        end

      end # --allbut

      context "when all is projected" do
        let(:expected){[{}]}

        context "with empty attributes" do
          let(:operator){ Lispy.project(input, []) }
          it { should eq(expected) } 
        end

        context "when empty attributes and input" do
          let(:operator){ Lispy.project([], []) }
          it { should == [] } 
        end

        context "--allbut" do
          let(:operator){ Lispy.project(input, [:a, :b], :allbut => true) }
          it { should eq(expected) } 
        end

      end # all attributes projected

    end 
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-core/operator/relational/test_project.rb
alf-0.12.1 spec/unit/alf-core/operator/relational/test_project.rb
alf-0.12.0 spec/unit/alf-core/operator/relational/test_project.rb
alf-0.11.1 spec/unit/alf-core/operator/relational/test_project.rb
alf-0.11.0 spec/unit/alf-core/operator/relational/test_project.rb