Sha256: dd623683434e6c16689523752faf093ec06c9e0bf3b38d29ff935856a168c64e

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 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.0 spec/unit/axiom/aggregate/call_spec.rb