Sha256: 5f1225afa01b8e1422b233a183e82bed9d5933488755887851ffb1f5a327e0bb

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Algebra::Summarization, '.new' do
  subject { object.new(operand, summarize_per, summarizers) }

  let(:header)      { [ [ :id, Integer ], [ :name, String ] ]                        }
  let(:operand)     { Relation.new(header, [ [ 1, 'John Doe' ], [ 2, 'Jane Doe' ] ]) }
  let(:summarizers) { {}                                                             }
  let(:object)      { described_class                                                }

  context 'with a summarize_per that has a subset of the headers in the operand' do
    let(:summarize_per) { Relation.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ] ]) }

    it { should be_instance_of(object) }
  end

  context 'with a summarize_per that has equivalent headers to the headers in the operand' do
    let(:summarize_per) { operand }

    specify { expect { subject }.to raise_error(InvalidHeaderError, 'the summarize_per header must be a proper subset of the operand header') }
  end

  context 'with a summarize_per that has a superset of the headers in the operand' do
    let(:summarize_per) { Relation.new([ [ :id, Integer ], [ :name, String ] ], [ [ 1, 'Dan Kubb' ] ]) }

    specify { expect { subject }.to raise_error(InvalidHeaderError, 'the summarize_per header must be a proper subset of the operand header') }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.0 spec/unit/axiom/algebra/summarization/class_methods/new_spec.rb