Sha256: 738b7b9fb4b7bd97bac6f90dfc2508eacc4a92402f65997c43e4b9f0371262e0

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'
module Alf
  module Operator::Relational
    describe Minus do
        
      let(:operator_class){ Minus }
      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){ Minus.run([]) }
      subject{ operator.to_a }
  
      describe "when applied on the same operand twice" do
        before{ operator.pipe [left, left] }
        it { should be_empty }
      end
      
      describe "when applied on operands sharing tuples" do
        before{ operator.pipe [left, right] }
        let(:expected) {[
          {:sid => 'S3', :city => 'Paris'}
        ]}
        it { should == expected }
      end
    
      describe "when applied on disjoint operands" do
        before{ operator.pipe [left, disjoint] }
        it { should == left }
      end
      
      describe "when factored with Lispy" do
        let(:operator){ Lispy.minus(left, right) }
        let(:expected) {[
          {:sid => 'S3', :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_minus.rb
alf-0.10.0 spec/unit/operator/relational/test_minus.rb