Sha256: 6547ca4cb22cb084b5369d6070b815ba62faf4b5b0ce82d14253235d3019c4f1

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

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

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

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

    its(:header) { should == header }

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

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

    it_should_behave_like 'Algebra::Difference#delete'
  end

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

    it_should_behave_like 'Algebra::Difference#delete'
  end

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

    it_should_behave_like 'Algebra::Difference#delete'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-0.2.0 spec/unit/axiom/algebra/difference/delete_spec.rb
axiom-0.1.1 spec/unit/axiom/algebra/difference/delete_spec.rb