Sha256: 7efcbb677df2fcf96b4f419ab716aba63faf92911c8f41e299d0a79030b774a8

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

# encoding: utf-8

shared_examples_for 'a binary relation method' do
  describe 'when other has the same adapter' do
    let(:other_relation) { mock('Other Relation')                       }
    let(:other)          { described_class.new(adapter, other_relation) }
    let(:gateway)        { mock('Other Gateway')                        }

    before do
      relation.stub(operation).and_return(gateway)
    end

    it { should be(gateway) }

    it 'passes the other relation to the binary operation' do
      relation.should_receive(operation) do |argument|
        argument.should be(other_relation)
      end
      subject
    end
  end

  describe 'when other has a different adapter' do
    let(:other_adapter) { mock('Other Adapter')                    }
    let(:other)         { described_class.new(other_adapter, stub) }

    before do
      factory.stub!(:new).and_return(binary_relation)
    end

    it { should equal(binary_relation) }

    it 'initializes the binary operation with the gateways' do
      factory.should_receive(:new).with(object, other)
      subject
    end
  end

  describe 'when other has no adapter' do
    let(:other) { mock('Other Relation') }

    before do
      factory.stub!(:new).and_return(binary_relation)
    end

    it { should equal(binary_relation) }

    it 'initializes the binary operation with the gateway and other relation' do
      factory.should_receive(:new).with(object, other)
      subject
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-arango-adapter-0.0.2 spec/shared/binary_relation_method_behaviour.rb
axiom-arango-adapter-0.0.1 spec/shared/binary_relation_method_behaviour.rb