Sha256: b96a568c0475aa81ffb51be43aa6f11cfa3c6e22a13c6c788aa2d9c814b79cc6

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

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

  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.4 spec/unit/veritas/relation/operation/reverse/class_methods/new_spec.rb