Sha256: 67af77877f06d5afcba09982fa0f2266fb00e19ced714528a54434dc6938b316

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

require 'spec_helper'
module Alf
  describe Relation do
    
    let(:rel1){rel(
      {:sid => 'S1'},
      {:sid => 'S2'},
      {:sid => 'S3'}
    )}
    
    let(:rel2){rel(
      {:sid => 'S5'},
      {:sid => 'S2'}
    )}

    specify "allbut" do
      rel1.allbut([:sid]).should == rel({})
    end
    
    specify "extend" do
      rel1.extend(:x => lambda{ sid.downcase }).should == rel(
        {:sid => 'S1', :x => 's1'},
        {:sid => 'S2', :x => 's2'},
        {:sid => 'S3', :x => 's3'}
      )
    end
      
    specify "union" do
      (rel1 + rel1).should == rel1
      (rel1 + rel2).should == rel(
        {:sid => 'S1'},
        {:sid => 'S3'},
        {:sid => 'S2'},
        {:sid => 'S5'}
      )
    end # coerce
      
    specify "difference" do
      (rel1 - rel1).should == rel()
      (rel1 - rel2).should == rel(
        {:sid => 'S1'},
        {:sid => 'S3'}
      )
      (rel2 - rel1).should == rel(
        {:sid => 'S5'}
      )
    end # coerce
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-0.9.3 spec/unit/relation/test_relops.rb