Sha256: 71465b7b12fd084941dd106f2678ca74e3c9dccc3cad03e6f51f90f1577576a6

Contents?: true

Size: 1.56 KB

Versions: 4

Compression:

Stored size: 1.56 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  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)   { described_class.new(header)                                  }

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

    it { should be_instance_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) { described_class.new([ relation[:id].asc, relation[:name].asc ]) }

    it { should be_instance_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) { described_class.new([ relation[:id].desc, relation[:name].asc ]) }

    it { should be_instance_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) { described_class.new([ relation[:id].desc, relation[:name].desc ]) }

    it { should be_instance_of(Array) }

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
axiom-0.1.0 spec/unit/axiom/relation/operation/order/direction_set/sort_tuples_spec.rb
veritas-0.0.7 spec/unit/veritas/relation/operation/order/direction_set/sort_tuples_spec.rb
veritas-0.0.6 spec/unit/veritas/relation/operation/order/direction_set/sort_tuples_spec.rb
veritas-0.0.5 spec/unit/veritas/relation/operation/order/direction_set/sort_tuples_spec.rb