Sha256: fb5dd67e9b88fc6bd9298455b7f808f6491b691ccd5911947882e1b1f464af28

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe 'Veritas::Relation::Operation::Reverse.new' do
  subject { object.new(relation) }

  let(:original_relation) { Relation.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ] ]) }
  let(:object)            { Relation::Operation::Reverse                         }

  context 'with an ordered relation' do
    let(:relation) { original_relation.order { |r| r[:id] } }

    it { should be_kind_of(object) }

    it 'reverses the directions' do
      subject.directions.should == relation.directions.reverse
    end
  end

  context 'with an ordered relation having an empty header' do
    let(:relation) { original_relation.order { |r| r[:id] }.project([]) }

    it { should be_kind_of(object) }

    it 'reverses the directions' do
      subject.directions.should == relation.directions.reverse
    end
  end

  context 'without an ordered relation' do
    let(:relation) { original_relation }

    specify { expect { subject }.to raise_error(OrderedRelationRequiredError, 'can only reverse an ordered operand') }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/relation/operation/reverse/class_methods/new_spec.rb