Sha256: debec60aaf41ebe29e774d3075c35488d02877f87a1208f692e6edcfe414f212

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Relation::Operation::Order, '#delete' do
  subject { object.delete(other) }

  let(:object)     { described_class.new(relation, directions)                      }
  let(:relation)   { Relation.new([attribute], LazyEnumerable.new([[1], [2], [3]])) }
  let(:attribute)  { Attribute::Integer.new(:id)                                    }
  let(:directions) { [attribute.desc]                                               }

  context 'when other relation has matching directions' do
    let(:other)      { other_base.sort_by(directions)                       }
    let(:other_base) { Relation.new([attribute], LazyEnumerable.new([[2]])) }

    it { should be_instance_of(described_class) }

    its(:operand) { should be_kind_of(Relation::Operation::Deletion) }

    it 'passes expected relations into the deletion' do
      subject = self.subject.operand
      subject.left.should be(relation)
      subject.right.should be(other_base)
    end

    its(:directions) { should == directions }

    it 'deletes the tuples' do
      should == [[3], [1]]
    end
  end

  context 'when other relation does not have the same directions' do
    let(:other) { Relation.new([attribute], LazyEnumerable.new([[2]])).sort_by([attribute]) }

    specify { expect { subject }.to raise_error(OrderMismatchError, 'other relation must have matching directions to be deleted') }
  end

  context 'when other relation is not an order' do
    let(:other) { Relation.new([attribute], LazyEnumerable.new([[2]])) }

    specify { expect { subject }.to raise_error(OrderMismatchError, 'other relation must have matching directions to be deleted') }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.1 spec/unit/axiom/relation/operation/order/delete_spec.rb