Sha256: 767c6ebc701456d9746428c49ff6f383aa9f358001bc3079fe4d3faa404fbd41

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

describe 'Veritas::Relation::Operation::Order::DirectionSet#sort_tuples' do
  subject { object.sort_tuples(relation) }

  let(:klass)    { Relation::Operation::Order::DirectionSet                     }
  let(:header)   { [ [ :id, Integer ], [ :name, String ] ]                      }
  let(:body)     { [ [ 1, 'Dan Kubb' ], [ 2, 'Alex Kubb' ], [ 2, 'Dan Kubb' ] ] }
  let(:relation) { Relation.new(header, body)                                   }
  let(:object)   { klass.new(header)                                            }

  context 'sorted with ascending id and descending name' do
    let(:object) { klass.new([ relation[:id].asc, relation[:name].desc ]) }

    it { should be_kind_of(Array) }

    it { should == [ [ 1, 'Dan Kubb' ], [ 2, 'Dan Kubb' ], [ 2, 'Alex Kubb' ] ] }
  end

  context 'sorted with ascending id and ascending name' do
    let(:object) { klass.new([ relation[:id].asc, relation[:name].asc ]) }

    it { should be_kind_of(Array) }

    it { should == [ [ 1, 'Dan Kubb' ], [ 2, 'Alex Kubb' ], [ 2, 'Dan Kubb' ] ] }
  end

  context 'sorted with descending id and ascending name' do
    let(:object) { klass.new([ relation[:id].desc, relation[:name].asc ]) }

    it { should be_kind_of(Array) }

    it { should == [ [ 2, 'Alex Kubb' ], [ 2, 'Dan Kubb' ], [ 1, 'Dan Kubb' ] ] }
  end

  context 'sorted with descending id and descending name' do
    let(:object) { klass.new([ relation[:id].desc, relation[:name].desc ]) }

    it { should be_kind_of(Array) }

    it { should == [ [ 2, 'Dan Kubb' ], [ 2, 'Alex Kubb' ], [ 1, 'Dan Kubb' ] ] }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/relation/operation/order/direction_set/sort_tuples_spec.rb