Sha256: 0ce51079b74a5474fc42d71901ab28731032a80e52a0dd2c0f671ce4a27bd3c2

Contents?: true

Size: 894 Bytes

Versions: 15

Compression:

Stored size: 894 Bytes

Contents

shared_examples_for 'a relation that returns one tuple' do
  describe '#one' do
    it 'returns first tuple' do
      rom.relations.users.delete(name: 'Joe', email: 'joe@doe.org')
      expect(relation.one).to eql(name: 'Jane', email: 'jane@doe.org')
    end

    it 'raises error when there is more than one tuple' do
      expect { relation.one }.to raise_error(ROM::TupleCountMismatchError)
    end
  end

  describe '#one!' do
    it 'returns first tuple' do
      rom.relations.users.delete(name: 'Joe', email: 'joe@doe.org')
      expect(relation.one!).to eql(name: 'Jane', email: 'jane@doe.org')
    end

    it 'raises error when there is no tuples' do
      rom.relations.users.delete(name: 'Jane', email: 'jane@doe.org')
      rom.relations.users.delete(name: 'Joe', email: 'joe@doe.org')

      expect { relation.one! }.to raise_error(ROM::TupleCountMismatchError)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rom-0.9.1 spec/shared/one_behavior.rb
rom-0.9.0 spec/shared/one_behavior.rb
rom-0.9.0.rc1 spec/shared/one_behavior.rb
rom-0.9.0.beta1 spec/shared/one_behavior.rb
rom-0.8.1 spec/shared/one_behavior.rb
rom-0.8.0 spec/shared/one_behavior.rb
rom-0.7.1 spec/shared/one_behavior.rb
rom-0.7.0 spec/shared/one_behavior.rb
rom-0.6.2 spec/shared/one_behavior.rb
rom-0.6.1 spec/shared/one_behavior.rb
rom-0.6.0 spec/shared/one_behavior.rb
rom-0.6.0.rc1 spec/shared/one_behavior.rb
rom-0.6.0.beta3 spec/shared/one_behavior.rb
rom-0.6.0.beta2 spec/shared/one_behavior.rb
rom-0.6.0.beta1 spec/shared/one_behavior.rb