Sha256: 2d4ae752e67792e77481d600c136843634840eee96fb9cef154f23ab5a94b358

Contents?: true

Size: 902 Bytes

Versions: 2

Compression:

Stored size: 902 Bytes

Contents

require 'spec_helper'
module Alf
  describe Ordering, "reverse" do

    subject{
      ordering.reverse
    }

    context 'on an empty ordering' do
      let(:ordering){ Ordering.new([]) }
      
      it{ should eq(ordering) }
    end

    context 'on a singleton asc ordering' do
      let(:ordering){ Ordering.new([[:name, :asc]]) }

      it{ should eq(Ordering.new([[:name, :desc]])) }
    end

    context 'on a singleton desc ordering' do
      let(:ordering){ Ordering.new([[:name, :desc]]) }

      it{ should eq(Ordering.new([[:name, :asc]])) }
    end

    #
    # name, id   => name, id
    #    b, 12         a, 13
    #    a, 10         a, 10
    #    a, 13         b, 12
    #
    context 'on a mixed ordering' do
      let(:ordering){ Ordering.new([[:name, :desc], [:id, :asc]]) }

      it{ should eq(Ordering.new([[:name, :asc], [:id, :desc]])) }
    end

  end # Ordering
end # Alf

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-types/ordering/test_reverse.rb
alf-core-0.14.0 spec/unit/alf-types/ordering/test_reverse.rb