Sha256: eaccbc077cf6469614dd2ba3bd5fdaec5e1be22db5be16d5863ed91d3de4e4ea

Contents?: true

Size: 964 Bytes

Versions: 5

Compression:

Stored size: 964 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')


describe Piglet::Relation::Split do

  before do
    @relation = mock('source')
    @expr1 = mock('expr1')
    @expr2 = mock('expr2')
    @relation.stub!(:alias).and_return('rel')
    @expr1.stub!(:to_s).and_return('expr1')
    @expr2.stub!(:to_s).and_return('expr2')
    @split = Piglet::Relation::Split.new(@relation, [@expr1, @expr2])
  end

  describe '#to_s' do
    it 'outputs all x IF y expressions' do
      @split.to_s.should match(/SPLIT rel INTO \w+ IF expr[12], \w+ IF expr[12]/)
    end
    
    it 'contains the names of all the shard relations' do
      @shards = @split.shards
      @split.to_s.should include("#{@shards[0].alias} IF expr1")
      @split.to_s.should include("#{@shards[1].alias} IF expr2")
    end
  end
  
  describe '#shards' do
    it 'returns the same number of shards as there are expressions' do
      @split.shards.size.should == 2
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
piglet-0.2.4 spec/piglet/relation/split_spec.rb
piglet-0.2.3 spec/piglet/relation/split_spec.rb
piglet-0.2.2 spec/piglet/relation/split_spec.rb
piglet-0.2.0 spec/piglet/relation/split_spec.rb
piglet-0.1.2 spec/piglet/relation/split_spec.rb