Sha256: c5cf60885ae4c1ffb4d684c2aa39bd4896e5239e0e0085243bde8b63af27914c

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

require 'spec_helper'

describe 'Veritas::Relation::Operation::Limit::Methods#last' do
  let(:klass)    { Relation                                                      }
  let(:relation) { klass.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ], [ 3 ] ].each) }
  let(:object)   { relation.order                                                }

  context 'with no arguments' do
    subject { object.last }

    it { should be_kind_of(Relation::Operation::Reverse) }

    it 'returns the expected tuples' do
      should == [ [ 3 ] ]
    end

    it 'behaves similar to Array#last' do
      should == [ object.to_a.last ]
    end
  end

  context 'with a limit' do
    subject { object.last(limit) }

    let(:limit) { 2 }

    it { should be_kind_of(Relation::Operation::Reverse) }

    it 'returns the expected tuples' do
      should == [ [ 2 ], [ 3 ] ]
    end

    it 'behaves the same as Array#last' do
      should == object.to_a.last(limit)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/relation/operation/limit/methods/last_spec.rb