Sha256: da37a0fa9fd26ee5f2c1b23ae323d84e57d19365ab35fd23bdfc51a8a20a2a88

Contents?: true

Size: 1.78 KB

Versions: 5

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'
require 'moblues/data_model/relationship'

module Moblues
  module DataModel
    describe Relationship do
      describe '#initialize' do
        context 'when name, destination_entity, to_many and ordered provided' do
          subject { described_class.new(name: 'relationship', destination_entity: 'entity', to_many: true, ordered: true) }

          it 'returns a Relationship object' do
            expect(subject).to eq(Relationship.new(name: 'relationship', destination_entity: 'entity', to_many: true, ordered: true))
          end
        end

        context 'when name missing' do
          it 'raises an assertion' do
            expect { Relationship.new(destination_entity: 'entity', to_many: true, ordered: true) }.to raise_exception(KeyError)
          end
        end

        context 'when destination_entity missing' do
          it 'raises an assertion' do
            expect { Relationship.new(name: 'relationship', to_many: true, ordered: true) }.to raise_exception(KeyError)
          end
        end

        context 'when to_many missing' do
          subject { described_class.new(name: 'relationship', destination_entity: 'entity', ordered: true) }

          it 'returns a Relationship with to_many false' do
            expect(subject).to eq(Relationship.new(name: 'relationship', destination_entity: 'entity', to_many: false, ordered: true))
          end
        end

        context 'when ordered missing' do
          subject { described_class.new(name: 'relationship', destination_entity: 'entity', to_many: true) }

          it 'returns a Relationship with ordered false' do
            expect(subject).to eq(Relationship.new(name: 'relationship', destination_entity: 'entity', to_many: true, ordered: false))
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
moblues-0.4.0 spec/lib/moblues/data_model/relationship_spec.rb
moblues-0.3.0 spec/lib/moblues/data_model/relationship_spec.rb
moblues-0.2.0 spec/lib/moblues/data_model/relationship_spec.rb
moblues-0.1.0 spec/lib/moblues/data_model/relationship_spec.rb
moblues-0.0.1 spec/moblues/data_model/relationship_spec.rb