Sha256: ac995a73ec6f7e19a65d8ea830bf6b1a0f8548d77d769c298c3897972c84b52f

Contents?: true

Size: 754 Bytes

Versions: 1

Compression:

Stored size: 754 Bytes

Contents

require 'spec_helper'
module Alf
  describe "Relation#to_a" do

    let(:rel){Alf::Relation(sid: ['S2', 'S1', '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

1 entries across 1 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-relation/relation/test_to_a.rb