Sha256: 23cb5879738be849ff8411bcc94bea3e30ef6f6f01ca8f742f1d41fec8620f70

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Algebra::Extension::Methods, '#extend' do
  let(:object)          { described_class.new([ [ :id, Integer ] ], LazyEnumerable.new([ [ 1 ] ])) }
  let(:described_class) { Relation                                                                 }
  let(:extensions)      { { :test => function }                                                    }
  let(:function)        { object[:id]                                                              }

  context 'with extensions' do
    subject { object.extend(extensions) }

    it { should be_instance_of(Algebra::Extension) }

    its(:operand) { should equal(object) }

    its(:extensions) { should == { Attribute::Object.new(:test) => function } }
  end

  context 'with a block' do
    subject do
      object.extend do |context|
        context.add(:test, context[:id])
      end
    end

    it { should be_instance_of(Algebra::Extension) }

    its(:operand) { should equal(object) }

    its(:extensions) { should == { Attribute::Integer.new(:test) => function } }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.0 spec/unit/axiom/algebra/extension/methods/extend_spec.rb