Sha256: f529890a8dcbc62900687453b9385ff8c7b1c2506e79dd342c94e99990f2b999

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:object)         { described_class.new(operand, aliases)                          }
  let(:operand)        { Relation.new([[:id, Integer]], LazyEnumerable.new([[1], [2]])) }
  let(:other_relation) { Relation.new(header,               LazyEnumerable.new([[2]]))  }
  let(:aliases)        { described_class::Aliases.coerce(operand.header, id: :other_id) }
  let(:header)         { [[:other_id, Integer]]                                         }

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

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

    its(:header) { should == header }

    its(:aliases) { should eql(aliases) }

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

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

    it_should_behave_like 'Algebra::Rename#delete'
  end

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

    it_should_behave_like 'Algebra::Rename#delete'
  end

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

    it_should_behave_like 'Algebra::Rename#delete'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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