Sha256: f09233b16ed3f570e8b75223dccbe0a78170ba15d1f6275301c5e361c5e5e422

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Axiom::Adapter::Arango::Gateway, '#join' do
  subject { object.join(other) }

  let(:adapter)         { mock('Adapter')                        }
  let(:relation)        { mock('Relation')                       }
  let(:object)          { described_class.new(adapter, relation) }
  let(:operation)       { :join                                  }
  let(:factory)         { Axiom::Algebra::Join                 }
  let(:binary_relation) { mock(factory)                          }

  it_should_behave_like 'a binary relation method'

  context 'when passed a block' do
    subject { object.join(other) { |context| yields << context } }

    let(:other_relation) { mock('Other Relation')                       }
    let(:other)          { described_class.new(adapter, other_relation) }
    let(:gateway)        { mock('Other Gateway')                        }
    let(:join)           { mock('Join', :restrict => gateway)           }
    let(:yields)         { []                                           }

    before do
      Axiom::Algebra::Join.stub!(:new).with(relation, other_relation).and_return(join)
    end

    it { should equal(gateway) }

    it 'passes the relations to the join constructor' do
      Axiom::Algebra::Join.should_receive(:new).with(relation, other_relation)
      subject
    end

    it 'passes the block to the join relation' do
      context = mock('Context')
      join.should_receive(:restrict).and_yield(context)
      expect { subject }.to change { yields.dup }.from([]).to([ context ])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-arango-adapter-0.0.2 spec/unit/axiom/adapter/arango/gateway/join_spec.rb
axiom-arango-adapter-0.0.1 spec/unit/axiom/adapter/arango/gateway/join_spec.rb