Sha256: e3d3be54e19e3870b63f02cb29b6c83606230c4ed0ad924142573afb824b74e0

Contents?: true

Size: 800 Bytes

Versions: 3

Compression:

Stored size: 800 Bytes

Contents

require 'spec_helper'

RSpec.describe 'Inheritance relation hierarchy' do
  before do
    ROM.setup(:memory)

    module Test
      class Users < ROM::Relation[:memory]
        dataset :users

        def by_email(email)
          restrict(email: email)
        end
      end

      class OtherUsers < Users
        register_as :other_users
      end
    end

    ROM.finalize
  end

  it 'registers parent and descendant relations' do
    rom = ROM.env

    users = rom.relations.users
    other_users = rom.relations.other_users

    expect(users).to be_instance_of(Test::Users)
    expect(other_users).to be_instance_of(Test::OtherUsers)

    jane = { name: 'Jane', email: 'jane@doe.org' }

    other_users.insert(jane)

    expect(other_users.by_email('jane@doe.org').one).to eql(jane)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-0.9.1 spec/integration/relations/inheritance_spec.rb
rom-0.9.0 spec/integration/relations/inheritance_spec.rb
rom-0.9.0.rc1 spec/integration/relations/inheritance_spec.rb