Sha256: ab44b531a7309a30abb050b69de69f5fa8fd270601763c426da10fef73de3187

Contents?: true

Size: 983 Bytes

Versions: 7

Compression:

Stored size: 983 Bytes

Contents

require 'spec_helper'
require 'rom/memory'

describe 'Repository' do
  let!(:setup) { ROM.setup(:memory) }

  let(:rom) { setup.finalize }

  before do
    module ROM
      module Memory
        class Relation < ROM::Relation
          def self.freaking_awesome?
            true
          end

          def freaking_cool?
            true
          end
        end
      end
    end
  end

  shared_examples_for 'extended relation' do
    it 'can extend relation class' do
      expect(rom.relations.users.class).to be_freaking_awesome
    end

    it 'can extend relation instance' do
      expect(rom.relations.users).to be_freaking_cool
    end
  end

  context 'using DSL' do
    it_behaves_like 'extended relation' do
      before do
        setup.relation(:users)
      end
    end
  end

  context 'using class definition' do
    it_behaves_like 'extended relation' do
      before do
        Class.new(ROM::Relation[:memory]) { dataset :users }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rom-0.6.2 spec/integration/repositories/extending_relations_spec.rb
rom-0.6.1 spec/integration/repositories/extending_relations_spec.rb
rom-0.6.0 spec/integration/repositories/extending_relations_spec.rb
rom-0.6.0.rc1 spec/integration/repositories/extending_relations_spec.rb
rom-0.6.0.beta3 spec/integration/repositories/extending_relations_spec.rb
rom-0.6.0.beta2 spec/integration/repositories/extending_relations_spec.rb
rom-0.6.0.beta1 spec/integration/repositories/extending_relations_spec.rb