Sha256: b1994fb109e15c999dad15beda7ec6b74279f6e3b4a76a560fff77848ad14475

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

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

  after do
    ROM::Memory::Relation.class_eval do
      undef_method :freaking_cool?
      class << self
        undef_method :freaking_awesome?
      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

8 entries across 8 versions & 1 rubygems

Version Path
rom-0.9.1 spec/integration/repositories/extending_relations_spec.rb
rom-0.9.0 spec/integration/repositories/extending_relations_spec.rb
rom-0.9.0.rc1 spec/integration/repositories/extending_relations_spec.rb
rom-0.9.0.beta1 spec/integration/repositories/extending_relations_spec.rb
rom-0.8.1 spec/integration/repositories/extending_relations_spec.rb
rom-0.8.0 spec/integration/repositories/extending_relations_spec.rb
rom-0.7.1 spec/integration/repositories/extending_relations_spec.rb
rom-0.7.0 spec/integration/repositories/extending_relations_spec.rb