Sha256: e61f2959c1fc0efe2d1d6f2517ca87ef41f41a0fc1a05815665286802bc2aa5a

Contents?: true

Size: 1.72 KB

Versions: 3

Compression:

Stored size: 1.72 KB

Contents

require_relative '../../../test_helper'

module Vedeu
  class Dummy
    attr_accessor :id

    def name
      "dummy"
    end
  end

  class DummyRepository
    extend Repository

    def self.klass
      Dummy
    end
  end

  describe Repository do
    let(:described_class) { DummyRepository }

    before do
      @dummy = DummyRepository.create(Dummy.new)
    end

    after do
      DummyRepository.reset
    end

    describe '#adaptor' do
      let(:subject) { described_class.adaptor }

      it { subject.must_be_instance_of(Storage) }
    end

    describe '#adaptor=' do
      let(:subject) { described_class.adaptor=(adaptor) }
      let(:adaptor) { Storage.new }

      it { subject.must_be_instance_of(Storage) }
    end

    describe '#find' do
      let(:subject) { described_class.find(id) }
      let(:id)      { @dummy.id }

      it { subject.must_be_instance_of(Dummy) }
    end

    describe '#all' do
      let(:subject) { described_class.all }

      it { subject.must_be_instance_of(Array) }
    end

    describe '#query' do
      let(:subject)   { described_class.query(klass, attribute, value) }
      let(:klass)     { Dummy }
      let(:attribute) { :name }
      let(:value)     { "dummy" }

      it { subject.must_be_instance_of(Dummy) }
    end

    describe '#create' do
      let(:subject) { described_class.create(model) }
      let(:model)   { @dummy }

      it { subject.must_be_instance_of(Dummy) }
    end

    describe '#delete' do
      let(:subject) { described_class.delete(model) }
      let(:model)   { @dummy }

      it { subject.must_be_instance_of(Dummy) }
    end

    describe '#reset' do
      let(:subject) { described_class.reset }

      it { subject.must_be_instance_of(Array) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.0.14 test/lib/vedeu/repository/repository_test.rb
vedeu-0.0.13 test/lib/vedeu/repository/repository_test.rb
vedeu-0.0.12 test/lib/vedeu/repository/repository_test.rb