Sha256: 394064174b6d6b32f74a1fbd7c8a315c3eeb20524097a7b57f8469d4ef948a7f

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 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 equal(gateway) }

    it 'passes the other relation to the binary operation' do
      relation.should_receive(operation).with(other_relation)
      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

4 entries across 4 versions & 2 rubygems

Version Path
axiom-do-adapter-0.1.0 spec/shared/binary_relation_method_behaviour.rb
veritas-do-adapter-0.0.7 spec/shared/binary_relation_method_behaviour.rb
veritas-do-adapter-0.0.6 spec/shared/binary_relation_method_behaviour.rb
veritas-do-adapter-0.0.5 spec/shared/binary_relation_method_behaviour.rb