Sha256: 1c7aa2d7a0b1880082333b9ea3ef46c881ba4bdb6c61be6076a0711a4afbe2dd

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'
require 'fixture/record/article'

RSpec.describe Typekit::Record do
  include RecordHelper
  extend RecordHelper

  describe '.identify' do
    record_dictionary.each do |name, klass|
      it "converts :#{name} into :element" do
        expect(described_module.identify(name)).to eq(:element)
      end

      it "converts '#{name}' into :element" do
        expect(described_module.identify(name.to_s)).to eq(:element)
      end
    end

    plural_record_dictionary.each do |name, klass|
      it "converts :#{name} into :collection" do
        expect(described_module.identify(name)).to eq(:collection)
      end

      it "converts '#{name}' into :collection" do
        expect(described_module.identify(name.to_s)).to eq(:collection)
      end
    end

    it 'returns nil for unknown names' do
      expect(described_module.identify('smile')).to be nil
    end

    it 'returns nil for nil' do
      expect(described_module.identify(nil)).to be nil
    end
  end

  describe '.build' do
    let(:article_class) { Fixture::Record::Article }

    let(:client) { double }
    let(:element_class) { described_module.build(:articles, client) }

    it 'creates a new Element class' do
      expect(element_class < article_class).to be true
    end

    describe 'an instance of the new Element class' do
      subject { element_class.new }

      it 'makes use of the provided Client' do
        expect(client).to receive(:process).and_return(element_class.new)
        subject.save
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typekit-client-0.0.6 spec/lib/typekit/record_spec.rb