Sha256: 734a0f038073e4e34b5b4c2f53015f7e5a57109564b78bbf686d13d7fe5d9ec9

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

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


describe Piglet::Relation::Union do

  before do
    @relation1 = Object.new
    @relation1.extend Piglet::Relation::Relation
    @relation2 = mock('relation2')
    @relation3 = mock('relation3')
    @relation1.stub!(:alias).and_return('relation1')
    @relation2.stub!(:alias).and_return('relation2')
    @relation3.stub!(:alias).and_return('relation3')
  end

  describe '#to_s' do    
    it 'outputs the names of all the relations (given as separate arguments)' do
      pig_latin = @relation1.union(@relation2, @relation3).to_s
      pig_latin.should include('relation1')
      pig_latin.should include('relation2')
      pig_latin.should include('relation3')
    end

    it 'outputs the names of all the relations (given as an array)' do
      pig_latin = @relation1.union([@relation2, @relation3]).to_s
      pig_latin.should include('relation1')
      pig_latin.should include('relation2')
      pig_latin.should include('relation3')
    end
    
    it 'outputs a UNION statement with the right number of relations' do
      pig_latin = @relation1.union(@relation2, @relation3).to_s
      pig_latin.should match(/UNION \w+, \w+, \w+/)
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

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