Sha256: a6a037c77810295f4ad4a75fe71f6df9163401a10feefc12c28a80cc0a569ae1

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 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.datasets = [left, left] }
        it { should be_empty }
      end
      
      describe "when applied on operands sharing tuples" do
        before{ operator.datasets = [left, right] }
        let(:expected) {[
          {:sid => 'S3', :city => 'Paris'}
        ]}
        it { should == expected }
      end
    
      describe "when applied on disjoint operands" do
        before{ operator.datasets = [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

4 entries across 4 versions & 1 rubygems

Version Path
alf-0.9.3 spec/unit/operator/relational/test_minus.rb
alf-0.9.2 spec/unit/operator/relational/test_minus.rb
alf-0.9.1 spec/unit/operator/relational/test_minus.rb
alf-0.9.0 spec/operator/relational/minus_spec.rb