Sha256: c10be04aeb219c2304e2b44a0610542cdebbae45c5cd496d01475d8893ac496a

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

# encoding: utf-8

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

 context 'Veritas::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.order  { |r| r[:id]   } }
     let(:right) { original_right.order { |r| r[:name] } }

     it { should be_kind_of(object) }
   end

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

     it { should be_kind_of(object) }
   end

   context 'with left ordered, and right unordered' do
     let(:left)  { original_left.order { |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.order { |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
veritas-0.0.4 spec/unit/veritas/relation/operation/binary/class_methods/new_spec.rb