Sha256: 8c6dcea4eae846b98463ccc452991d3e22555a86d3bac9f7fcf15df01b183a5a

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 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_instance_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) { [] }

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

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

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

Version data entries

4 entries across 4 versions & 2 rubygems

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