Sha256: 061019688ab3e231d3b60105371ae4d296d714e854b78ff6b2e2684ba1f1575e

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 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

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.1 spec/unit/axiom/relation/operation/order/direction_set/sort_tuples_spec.rb