Sha256: 7facefb33d17df260d3184c3d8a2770281b46ca122b3b3cd6d5f56447f20e1ae

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8

require 'spec_helper'

[ :join, :+ ].each do |method|
  describe Algebra::Join::Methods, "##{method}" do
    let(:described_class) { Relation                                                                                                     }
    let(:object)          { described_class.new([ [ :id, Integer ], [ :name, String  ] ], [ [ 1, 'Dan Kubb' ], [ 2, 'Dan Kubb' ] ].each) }

    context 'without a block' do
      subject { object.send(method, other) }

      let(:other) { described_class.new([ [ :id, Integer ], [ :age, Integer ] ], [ [ 1, 35 ] ]) }

      it { should be_kind_of(Algebra::Join) }
    end

    context 'with a block' do
      subject { object.send(method, other, &block) }

      let(:other) { described_class.new([ Attribute::Boolean.new(:active) ], [ [ true ] ]) }
      let(:block) do
        lambda do |relation|
          relation[:id].eq(1).and(relation[:active].eq(true))
        end
      end

      it { should be_kind_of(Algebra::Restriction) }

      it 'restricts a product' do
        should == [ [ 1, 'Dan Kubb', true ] ]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.4 spec/unit/veritas/algebra/join/methods/join_spec.rb