Sha256: affcac98feef8c19a9ed06fa5cb22333aa07baf3ddc5be472a69774a16f49106

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe 'Veritas::Relation::Operation::Limit::Methods#first' 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.first }

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

    its(:limit) { should == 1 }

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

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

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

    let(:limit) { 2 }

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

    its(:limit) { should == limit }

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

    it 'behaves the same as Array#first' do
      should == object.to_a.first(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/first_spec.rb