Sha256: 82f8203d1bc33fdeb771552740c5ac54f112b75518318dac040f660d896be30d

Contents?: true

Size: 1021 Bytes

Versions: 1

Compression:

Stored size: 1021 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Relation::Operation::Limit::Methods, '#last' do
  let(:described_class) { Relation                                                                }
  let(:relation)        { described_class.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.4 spec/unit/veritas/relation/operation/limit/methods/last_spec.rb