Sha256: ca6a36559e8ff974ff22faa6889b5fee9cfd4fa60374082fffb0e0294d834d93

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 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 be(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 be(object) }

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

Version data entries

2 entries across 2 versions & 1 rubygems

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