Sha256: faba5fd4ed57b803e031f5253b4c71c115588f68aba29bede3b47f497c6691c2

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Algebra::Difference, '#insert' do
  subject { object.insert(other) }

  let(:object)         { described_class.new(left, right) }
  let(:left)           { Relation.new(header, [ [ 1 ] ])  }
  let(:right)          { Relation.new(header, [ [ 1 ] ])  }
  let(:other_relation) { Relation.new(header, [ [ 2 ] ])  }
  let(:header)         { [ [ :id, Integer ] ]             }

  shared_examples_for 'Algebra::Difference#insert' do
    it { should be_instance_of(described_class) }

    its(:left)  { should eql(left.insert(other_relation.difference(right))) }
    its(:right) { should eql(right)                                         }

    its(:header) { should == header }

    it 'inserts the tuples' do
      should == [ [ 2 ] ]
    end
  end

  context 'with a relation' do
    let(:other) { other_relation }

    it_should_behave_like 'Algebra::Difference#insert'
  end

  context 'with an array of tuples' do
    let(:other) { other_relation.to_a }

    it_should_behave_like 'Algebra::Difference#insert'
  end

  context 'with an array of arrays' do
    let(:other) { other_relation.map(&:to_ary) }

    it_should_behave_like 'Algebra::Difference#insert'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.0 spec/unit/axiom/algebra/difference/insert_spec.rb