Sha256: c250baac083392de690aeaa891155a0384580702c4eba17eaecae47b2e4d72c8

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 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.sort_by { |r| r.id } }

    it { should be_instance_of(object) }

    it 'reverses the directions' do
      subject.directions.should eql(relation.directions.reverse)
    end
  end

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

    it { should be_instance_of(object) }

    it 'reverses the directions' do
      subject.directions.should eql(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

4 entries across 4 versions & 2 rubygems

Version Path
axiom-0.1.0 spec/unit/axiom/relation/operation/reverse/class_methods/new_spec.rb
veritas-0.0.7 spec/unit/veritas/relation/operation/reverse/class_methods/new_spec.rb
veritas-0.0.6 spec/unit/veritas/relation/operation/reverse/class_methods/new_spec.rb
veritas-0.0.5 spec/unit/veritas/relation/operation/reverse/class_methods/new_spec.rb