Sha256: 870c267fa4b5180e50d30b809e01027edbb833d3218560c316a0185d5b63692c

Contents?: true

Size: 687 Bytes

Versions: 8

Compression:

Stored size: 687 Bytes

Contents

RSpec.describe ROM::Relation, '#exist?' do
  include_context 'users and tasks'

  subject(:relation) { users }

  with_adapters do
    it 'returns true if relation has at least one tuple' do
      expect(relation.exist?).to be(true)
    end

    it 'returns false if relation is empty' do
      expect(relation.where(name: 'Klaus').exist?).to be(false)
    end

    it 'accepts a condition' do
      expect(relation.exist?(name: 'Jane')).to be(true)
      expect(relation.exist?(name: 'Klaus')).to be(false)
    end

    it 'accepts a block' do
      expect(relation.exist? { name.is('Jane') }).to be true
      expect(relation.exist? { name.is('Klaus') }).to be false
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rom-sql-1.3.5 spec/unit/relation/exist_predicate_spec.rb
rom-sql-1.3.4 spec/unit/relation/exist_predicate_spec.rb
rom-sql-2.0.0.beta2 spec/unit/relation/exist_predicate_spec.rb
rom-sql-2.0.0.beta1 spec/unit/relation/exist_predicate_spec.rb
rom-sql-1.3.3 spec/unit/relation/exist_predicate_spec.rb
rom-sql-1.3.2 spec/unit/relation/exist_predicate_spec.rb
rom-sql-1.3.1 spec/unit/relation/exist_predicate_spec.rb
rom-sql-1.3.0 spec/unit/relation/exist_predicate_spec.rb