Sha256: 781ce13b2f259ef42f9c25d24b7ffa72e6dc6ddef9f42ff0a2fb2045b62c316b

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

require_relative '../../../test_helper'
require_relative '../../../../lib/vedeu/repository/repository'

module Vedeu
  class Dummy
    def name
      'dummy'
    end
  end

  class DummyRepository
    extend Repository

    def self.entity
      Dummy
    end
  end

  describe Repository do
    describe '#adaptor' do
      it 'returns a Storage' do
        DummyRepository.adaptor.must_be_instance_of(Storage)
      end
    end

    describe '#all' do
      it 'returns all the stored items' do
        DummyRepository.all.must_be_instance_of(Array)
      end
    end

    describe '#query' do
      it 'delegates to the adaptor' do
        dumb = Dummy.new
        DummyRepository.create(dumb)

        result = DummyRepository.query(Dummy, :name, 'dummy')
        result.must_equal(dumb)

        result = DummyRepository.query(Dummy, :name, 'dumber')
        result.must_equal(false)
      end
    end

    describe '#create' do
      it 'returns a Dummy' do
        dummy = DummyRepository.create(Dummy.new)
        DummyRepository.create(dummy).must_be_instance_of(Dummy)
      end
    end

    describe '#reset' do
      it 'returns an Array' do
        DummyRepository.reset.must_be_instance_of(Array)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vedeu-0.0.38 test/lib/vedeu/repository/repository_test.rb
vedeu-0.0.37 test/lib/vedeu/repository/repository_test.rb
vedeu-0.0.36 test/lib/vedeu/repository/repository_test.rb
vedeu-0.0.35 test/lib/vedeu/repository/repository_test.rb
vedeu-0.0.34 test/lib/vedeu/repository/repository_test.rb