Sha256: 3805fd50a7f9d867297ba35a36c22527ed7621e171c61fbb58467335046031e5

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

# encoding: utf-8

require 'spec_helper'
require File.expand_path('../../fixtures/classes', __FILE__)

describe Relation::Operation::Binary::ClassMethods, '#new' do
  subject { object.new(left, right) }

  let(:original_left)  { Relation.new([ [ :id,   Integer ] ], [ [ 1 ] ])          }
  let(:original_right) { Relation.new([ [ :name, String  ] ], [ [ 'Dan Kubb' ] ]) }
  let(:object)         { BinaryRelationOperationSpecs::Object                     }

  context 'with left and right ordered' do
    let(:left)  { original_left.sort_by  { |r| r.id   } }
    let(:right) { original_right.sort_by { |r| r.name } }

    it { should be_instance_of(object) }
  end

  context 'with left and right unordered' do
    let(:left)  { original_left  }
    let(:right) { original_right }

    it { should be_instance_of(object) }
  end

  context 'with left ordered, and right unordered' do
    let(:left)  { original_left.sort_by { |r| r.id } }
    let(:right) { original_right                     }

    specify { expect { subject }.to raise_error(RelationMismatchError, 'both relations must be ordered or neither may be ordered') }
  end

  context 'with right ordered, and left unordered' do
    let(:left)  { original_left                         }
    let(:right) { original_right.sort_by { |r| r.name } }

    specify { expect { subject }.to raise_error(RelationMismatchError, 'both relations must be ordered or neither may be ordered') }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.0 spec/unit/axiom/relation/operation/binary/class_methods/new_spec.rb