Sha256: f007dc365893a60a2553cff782480a0d2eb1d65b95f9c74930e7dd4568fc4f47

Contents?: true

Size: 921 Bytes

Versions: 2

Compression:

Stored size: 921 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 "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

2 entries across 2 versions & 1 rubygems

Version Path
alf-0.9.2 spec/unit/relation/test_relops.rb
alf-0.9.1 spec/unit/relation/test_relops.rb