Sha256: a2dcbdd2193b0bfd3471040119c795c6b1a347e9d642d9de8edd443b6563ab48

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Aggregate, '#call' do
  subject { object.call(nil, tuple) }

  let(:described_class) { Class.new(Aggregate)                }
  let(:object)          { described_class.new(attribute)      }
  let(:attribute)       { Attribute::Integer.new(:id)         }
  let(:header)          { Relation::Header.new([ attribute ]) }
  let(:tuple)           { Tuple.new(header, [ 1 ])            }

  context 'when operand is an attribute' do
    before do
      described_class.class_eval do
        def self.call(accumulator, value)
          value
        end
      end
    end

    it { should eql(1) }
  end

  context 'when operand is a literal value' do
    let(:object) { described_class.new(2) }

    before do
      described_class.class_eval do
        def self.call(accumulator, value)
          value
        end
      end
    end

    it { should eql(2) }
  end

  context 'when .call is not defined' do
    specify { expect { subject }.to raise_error(NotImplementedError, "#{described_class.name}.call must be implemented") }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-0.0.7 spec/unit/veritas/aggregate/call_spec.rb
veritas-0.0.6 spec/unit/veritas/aggregate/call_spec.rb
veritas-0.0.5 spec/unit/veritas/aggregate/call_spec.rb
veritas-0.0.4 spec/unit/veritas/aggregate/call_spec.rb