Sha256: f74d2d6d8944f384a3284d5fdfbb155d963daff3bfb73f38b12d2d4f4df85ddd

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 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.pipe [left, left] }
        it { should == left }
      end
      
      describe "when applied on operands sharing tuples" do
        before{ operator.pipe [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.pipe [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

2 entries across 2 versions & 1 rubygems

Version Path
alf-0.10.1 spec/unit/operator/relational/test_intersect.rb
alf-0.10.0 spec/unit/operator/relational/test_intersect.rb