Sha256: 9fd515df2baa2fe4557f3c1981a6eb24b96eabafe1480fdbeb5e75b15f5a873c

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

require_relative '../../../lib/locomotive/steam/adapters/memory.rb'

describe Locomotive::Steam::ContentTypeFieldRepository do

  let(:collection)  { [{ name: 'title', type: 'string' }, { name: 'body', type: 'text' }] }
  let(:adapter)     { Locomotive::Steam::MemoryAdapter.new(nil) }
  let(:repository)  { described_class.new(adapter) }

  before { allow(adapter).to receive(:collection).and_return(collection) }

  describe '#by_name' do

    let(:name) { nil }

    subject { repository.by_name(name) }

    it { expect(subject).to eq nil }

    context 'with an existing name' do

      let(:name) { 'title' }
      it { expect(subject.type).to eq :string }

    end

  end

  describe '#no_associations' do

    let(:collection) { [{ name: 'title', type: 'string' }, { name: 'author', type: 'belongs_to' }] }

    subject { repository.no_associations }

    it { expect(subject.size).to eq 1 }
    it { expect(subject.size).to eq 1 }

  end

  describe '#unique' do

    let(:collection)  { [{ name: 'name', type: 'string' }, { name: 'email', type: 'email', unique: true }] }

    subject { repository.unique }

    it { expect(subject.keys).to eq ['email'] }

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.rc10 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.rc9 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.rc8 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.rc6 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.rc4 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.rc3 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.rc2 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.rc1 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.pre.beta.3 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.pre.beta.2 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.pre.beta.1 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.pre.alpha.3 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.pre.alpha.2 spec/unit/repositories/content_type_field_repository_spec.rb
locomotivecms_steam-1.0.0.pre.alpha.1 spec/unit/repositories/content_type_field_repository_spec.rb