Sha256: ab6423cfc524b2007bed6c83c464f9f0204ba7ad73095386329cf67ccd15608a

Contents?: true

Size: 826 Bytes

Versions: 8

Compression:

Stored size: 826 Bytes

Contents

require 'spec_helper'
module Alf
  describe "Relation#to_a" do
    
    let(:rel){Alf::Relation[
      {:sid => 'S2'},
      {:sid => 'S1'},
      {:sid => 'S3'}
    ]}
    
    specify "without an ordering key" do
      rel.to_a.sort{|k1,k2| k1[:sid] <=> k2[:sid]}.should eq([
        {:sid => 'S1'},
        {:sid => 'S2'},
        {:sid => 'S3'}
      ])
    end
      
    specify "with an ordering key" do
      rel.to_a([:sid]).should eq([
        {:sid => 'S1'},
        {:sid => 'S2'},
        {:sid => 'S3'}
      ])
      rel.to_a([[:sid, :desc]]).should eq([
        {:sid => 'S3'},
        {:sid => 'S2'},
        {:sid => 'S1'}
      ])
    end
    
    specify "ON DUM" do
      Relation::DUM.to_a.should eq([])
    end
    
    specify "ON DEE" do
      Relation::DEE.to_a.should eq([{}])
    end
    
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-core/relation/test_to_a.rb
alf-0.12.1 spec/unit/alf-core/relation/test_to_a.rb
alf-0.12.0 spec/unit/alf-core/relation/test_to_a.rb
alf-0.11.1 spec/unit/alf-core/relation/test_to_a.rb
alf-0.11.0 spec/unit/alf-core/relation/test_to_a.rb
alf-0.10.1 spec/unit/relation/test_to_a.rb
alf-0.10.0 spec/unit/relation/test_to_a.rb
alf-0.9.3 spec/unit/relation/test_to_a.rb