Sha256: 439e40896b59a9ed8e874735d680dd1b8ba4ce671794f5ea68ef0b3acfd16f27

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 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}.call is not implemented") }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.1 spec/unit/axiom/aggregate/call_spec.rb