Sha256: e52f87c65f1b2c5ca7b48f08b4d590e9f7c68955cb05c3d5b7014fd5e6465929
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
# frozen_string_literal: true require 'rspeckled/spec_helpers/rspeckled' require 'drillbit/resource/processors/sorting' module Drillbit module Resource module Processors describe Sorting do let(:sorting_resource) { double } it 'can return an ascending sort' do sorting = Sorting.new(sorting_resource, 'sort' => 'my_attribute') allow(sorting_resource).to receive(:order). with('my_attribute' => 'asc'). and_return('sorted') expect(sorting.processed).to eql 'sorted' expect(sorting.meta).to eql( 'sort' => { 'my_attribute' => 'asc', }, ) end it 'can return a descending sort' do sorting = Sorting.new(sorting_resource, 'sort' => '-my_attribute') allow(sorting_resource).to receive(:order). with('my_attribute' => 'desc'). and_return('sorted') expect(sorting.processed).to eql 'sorted' expect(sorting.meta).to eql( 'sort' => { 'my_attribute' => 'desc', }, ) end it 'can return multiple sorts' do sorting = Sorting.new(sorting_resource, 'sort' => '-my_attribute,my_other_attribute') allow(sorting_resource).to receive(:order). with('my_attribute' => 'desc', 'my_other_attribute' => 'asc'). and_return('sorted') expect(sorting.processed).to eql 'sorted' expect(sorting.meta).to eql( 'sort' => { 'my_attribute' => 'desc', 'my_other_attribute' => 'asc', }, ) end it 'does not do anything if sorting params are not passed in' do sorting = Sorting.new(sorting_resource) expect(sorting.processed).to eql sorting_resource end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
drillbit-2.11.0 | spec/drillbit/resource/processors/sorting_spec.rb |
drillbit-2.10.0 | spec/drillbit/resource/processors/sorting_spec.rb |