Sha256: 406da18cc4d92ff3f7ae9cda35adf8e37848bd285ebb11d1b59fb38117d01037

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:header)   { [ [ :id, Integer ], [ :name, String ] ]   }
  let(:body)     { [ [ 1, 'Dan Kubb' ], [ 2, 'Alex Kubb' ] ] }
  let(:relation) { Relation.new(header, body)                }
  let(:object)   { described_class                           }

  context 'with all attributes specified in the directions' do
    let(:directions) { [ relation[:id], relation[:name] ] }

    it { should be_kind_of(object) }

    its(:operand) { should equal(relation) }

    its(:directions) { should == [ relation[:id].asc, relation[:name].asc ] }
  end

  context 'without no attributes specified in the directions' do
    let(:directions) { [] }

    it { should be_kind_of(object) }

    its(:operand) { should equal(relation) }

    its(:directions) { should == [ relation[:id].asc, relation[:name].asc ] }
  end

  context 'without all attributes specified in the directions' do
    let(:directions) { [ :id ] }

    specify { expect { subject }.to raise_error(InvalidDirectionsError, 'directions must include every attribute in the header') }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.4 spec/unit/veritas/relation/operation/order/class_methods/new_spec.rb