Sha256: be3470aff927dfa641fe379a8837beffe75b971908f10c5182db4d5a2b99cad7

Contents?: true

Size: 1.74 KB

Versions: 2

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

require 'test_helper'

module Vedeu

  module Repositories

    class RegisterableTestClass

      include Vedeu::Repositories::Registerable

      null Vedeu::Repositories::ModelTestClass
      real Vedeu::Repositories::ModelTestClass

    end

    describe Registerable do

      let(:described)          { Vedeu::Repositories::Registerable }
      let(:included_described) { Vedeu::Repositories::RegisterableTestClass }

      it { included_described.must_respond_to(:repository) }
      it { included_described.must_respond_to(:register) }

      describe '.included' do
        subject { described.included(included_described) }

        it { subject.must_be_instance_of(Class) }
      end

      describe '.null' do
        subject { included_described.new }

        it { included_described.must_respond_to(:null) }

        it { subject.must_respond_to(:null_model) }
        it { subject.must_respond_to(:null_attributes) }
        it { subject.null_model.must_equal(Vedeu::Repositories::ModelTestClass) }
        it { subject.null_attributes.must_equal({}) }
      end

      describe '.real' do
        subject { included_described.new }

        it { included_described.must_respond_to(:real) }

        it { subject.must_respond_to(:model) }
        it { subject.model.must_equal(Vedeu::Repositories::ModelTestClass) }
      end

      describe '.reset' do
        subject { included_described.reset! }

        before { included_described.stubs(:register) }

        it { included_described.must_respond_to(:reset!) }
        it { included_described.must_respond_to(:reset) }

        it do
          included_described.expects(:register)
          subject
        end
      end

    end # Registerable

  end # Repositories

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.8.17 test/lib/vedeu/repositories/registerable_test.rb
vedeu-0.8.16 test/lib/vedeu/repositories/registerable_test.rb