Sha256: ff17eec603bca55d8b75dcc12c503d0b94d041944eff10ef32e91a79eb4b89ad

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'
module Alf
  module Operator::Relational
    describe Intersect do
        
      let(:operator_class){ Intersect }
      it_should_behave_like("An operator class")
        
      let(:left) {[
        {:sid => 'S1', :city => 'London'},
        {:sid => 'S2', :city => 'Paris'},
        {:sid => 'S3', :city => 'Paris'}
      ]}
        
      let(:right) {[
        {:sid => 'S2', :city => 'Paris'},
        {:sid => 'S1', :city => 'London'},
      ]}
        
      let(:disjoint) {[
        {:sid => 'S4', :city => 'Oslo'},
        {:sid => 'S5', :city => 'Bruxelles'},
      ]}
  
      let(:operator){ Intersect.run([]) }
      subject{ operator.to_a }
  
      describe "when applied on the same operand twice" do
        before{ operator.datasets = [left, left] }
        it { should == left }
      end
      
      describe "when applied on operands sharing tuples" do
        before{ operator.datasets = [left, right] }
        let(:expected) {[
          {:sid => 'S1', :city => 'London'},
          {:sid => 'S2', :city => 'Paris'},
        ]}
        it { should == expected }
      end
    
      describe "when applied on disjoint operands" do
        before{ operator.datasets = [left, disjoint] }
        it { should be_empty }
      end
      
      describe "when factored with Lispy" do
        let(:operator){ Lispy.intersect(left, right) }
        let(:expected) {[
          {:sid => 'S1', :city => 'London'},
          {:sid => 'S2', :city => 'Paris'},
        ]}
        it { should == expected }
      end
  
    end 
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-0.9.3 spec/unit/operator/relational/test_intersect.rb
alf-0.9.2 spec/unit/operator/relational/test_intersect.rb
alf-0.9.1 spec/unit/operator/relational/test_intersect.rb
alf-0.9.0 spec/operator/relational/intersect_spec.rb