Sha256: fad4983f19bc8fdc06379877e82a7962c1a5dd11f920787230a783e38e8f6ab1

Contents?: true

Size: 1.43 KB

Versions: 14

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'
require 'font_assets/mime_types'

describe FontAssets::MimeTypes do
  context 'given an empty hash' do
    let(:hash) { Hash.new }
    subject { described_class.new(hash) }

    it 'adds the known mime types' do
      FontAssets::MimeTypes::MIME_TYPES.each_pair do |ext, type|
        subject[ext].should == type
      end
    end
  end

  context 'given a populated hash' do
    let(:default_type) { 'default/type' }
    let(:hash) { { '.ttf' => default_type, '.svg' => 'test/type' } }
    subject { described_class.new(hash, default_type) }

    it 'retains the non-default-matching mime types' do
      subject['.svg'].should == hash['.svg']
    end

    it 'overrides the default-matching mime types' do
      subject['.ttf'].should_not == hash['.ttf']
    end
  end

  context '#[]' do
    let(:types) { described_class.new({}) }

    it 'returns the mime type of the passed extension' do
      types['.woff'].should == 'application/x-font-woff'
    end

    it 'returns the default mime type for unknown extensions' do
      types['.bad'].should == 'application/octet-stream'
    end
  end

  context '#font?' do
    let(:types) { described_class.new({}) }

    it 'is true for known font extensions' do
      FontAssets::MimeTypes::MIME_TYPES.keys.each do |key|
        types.font?(key).should be_true
      end
    end

    it 'is false for unrecognized font extensions' do
      types.font?('.bad').should be_false
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
font_assets-0.1.14 spec/mime_types_spec.rb
font_assets-0.1.12 spec/mime_types_spec.rb
font_assets-0.1.11 spec/mime_types_spec.rb
font_assets-0.1.10 spec/mime_types_spec.rb
font_assets-0.1.9 spec/mime_types_spec.rb
font_assets-0.1.8 spec/mime_types_spec.rb
font_assets-0.1.7 spec/mime_types_spec.rb
font_assets-0.1.6 spec/mime_types_spec.rb
font_assets-0.1.5 spec/mime_types_spec.rb
font_assets-0.1.4 spec/mime_types_spec.rb
font_assets-0.1.3 spec/mime_types_spec.rb
font_assets-0.1.2 spec/mime_types_spec.rb
font_assets-0.1.1 spec/mime_types_spec.rb
font_assets-0.1.0 spec/mime_types_spec.rb