Sha256: b7f9ebf4526d036920776d5c0f1496be0a7419f35d2355b72bf8bd0fcd44d31b

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 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.1 spec/unit/axiom/relation/operation/binary/class_methods/new_spec.rb