Sha256: 821294749a48f87aa70bc10cf460d2571991621ed3e78a1d04bd26b86f9a8572

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'
require 'rom/memory'

describe 'Repository' do
  include_context 'container'
  include_context 'users and tasks'

  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(container.relations.users.class).to be_freaking_awesome
    end

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rom-2.0.2 spec/integration/repositories/extending_relations_spec.rb
rom-2.0.1 spec/integration/repositories/extending_relations_spec.rb
rom-2.0.0 spec/integration/repositories/extending_relations_spec.rb
rom-1.0.0 spec/integration/repositories/extending_relations_spec.rb
rom-1.0.0.rc1 spec/integration/repositories/extending_relations_spec.rb
rom-1.0.0.beta2 spec/integration/repositories/extending_relations_spec.rb
rom-1.0.0.beta1 spec/integration/repositories/extending_relations_spec.rb