Sha256: 53d9c3b5e9c46c1e56cc994d6e60f918f1b2ad41892b621ce8193c98b4a68fea
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
require 'spec_helper' describe 'Veritas::Relation::Operation::Order::Methods#order' do let(:klass) { Relation } let(:object) { klass.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ] ].each) } context 'with no arguments' do subject { object.order } it { should be_kind_of(Relation::Operation::Order) } its(:directions) { should == object.header } it 'behaves the same as Array#sort_by' do subject.to_a.should == object.to_a.sort_by { |tuple| tuple[:id] } end end context 'with direction arguments' do subject { object.order(directions) } let(:directions) { [ object[:id].desc ] } it { should be_kind_of(Relation::Operation::Order) } its(:directions) { should == directions } it 'behaves the same as Array#sort_by' do subject.to_a.should == object.to_a.sort_by { |tuple| tuple[:id] }.reverse end end context 'with a block' do subject { object.order(&block) } let(:block) { lambda { |relation| [ relation[:id].desc ] } } it { should be_kind_of(Relation::Operation::Order) } its(:directions) { should == block.call(object) } it 'behaves the same as Array#sort_by' do subject.to_a.should == object.to_a.sort_by { |tuple| tuple[:id] }.reverse end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
veritas-0.0.2 | spec/unit/veritas/relation/operation/order/methods/order_spec.rb |