Sha256: cea54284f02aaa86814c682d70f34cd1a63b6a7d7ab2c68310c18f06ae3cb429

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

RSpec.describe Typekit::Converter do
  def create(name)
    Typekit::Converter.build(name)
  end

  let(:request) { double(code: 200) }

  describe '.build#process' do
    %w{family kit library}.each do |name|
      it "maps '#{name}' to a Element" do
        result = create(name).process(request, {})
        expect(result).to be_kind_of(Typekit::Element::Base)
      end
    end

    %w{families kits libraries}.each do |name|
      it "maps '#{name}' to an array of Elements" do
        result = create(name).process(request, [{}])
        result.each { |r| expect(r).to be_kind_of(Typekit::Element::Base) }
      end
    end

    %w{ok}.each do |name|
      it "maps '#{name}' to a boolean" do
        result = create(name).process(request, true)
        expect(result).to be_kind_of(::TrueClass)
      end
    end

    %w{published}.each do |name|
      it "maps '#{name}' to a datetime" do
        result = create(name).process(request, '2010-05-20T21:15:31Z')
        expect(result).to be_kind_of(::DateTime)
      end
    end

    [nil, 'errors'].each do |name|
      it "raises an exception for '#{name}'" do
        expect { create(name).process(request, nil) }.to \
          raise_error(Typekit::ServerError)
      end
    end

    %w{kittens puppies}.each do |name|
      it "returns unknowns like '#{name}' as they are" do
        result = create(name).process(request, 42)
        expect(result).to eq(name => 42)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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