Sha256: 34bb8b8ede1d29698cc81b680f9f4aaf540b3a0fd8ec5fca064c1802f3285c55

Contents?: true

Size: 1.78 KB

Versions: 5

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'

describe MetaTags::ViewHelper do
  subject { ActionView::Base.new }

  it 'should not display icon by default' do
    subject.display_meta_tags(site: 'someSite').tap do |meta|
      expect(meta).to_not have_tag('link', with: { rel: 'icon' })
    end
  end

  it 'should display icon when "set_meta_tags" used' do
    subject.set_meta_tags(icon: '/favicon.ico')
    subject.display_meta_tags(site: 'someSite').tap do |meta|
      expect(meta).to have_tag('link', with: { href: '/favicon.ico', rel: 'icon', type: 'image/x-icon' })
    end
  end

  it 'should display default canonical url' do
    subject.display_meta_tags(site: 'someSite', icon: '/favicon.ico').tap do |meta|
      expect(meta).to have_tag('link', with: { href: '/favicon.ico', rel: 'icon', type: 'image/x-icon' })
    end
  end

  it 'should allow to specify hash as an icon' do
    subject.set_meta_tags(icon: { href: '/favicon.png', type: 'image/png' })
    subject.display_meta_tags(site: 'someSite').tap do |meta|
      expect(meta).to have_tag('link', with: { href: '/favicon.png', rel: 'icon', type: 'image/png' })
    end
  end

  it 'should allow to specify multiple icons' do
    subject.set_meta_tags(icon: [
      { href: '/images/icons/icon_96.png', sizes: '32x32 96x96', type: 'image/png' },
      { href: '/images/icons/icon_itouch_precomp_32.png', rel: 'apple-touch-icon-precomposed', sizes: '32x32', type: 'image/png' },
    ])
    subject.display_meta_tags(site: 'someSite').tap do |meta|
      expect(meta).to have_tag('link', with: { href: '/images/icons/icon_96.png', rel: 'icon', type: 'image/png', sizes: '32x32 96x96' })
      expect(meta).to have_tag('link', with: { href: '/images/icons/icon_itouch_precomp_32.png', rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: '32x32' })
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
meta-tags-2.2.0 spec/view_helper/icon_spec.rb
meta_tags-rails-1.1.1 spec/view_helper/icon_spec.rb
meta_tags-rails-1.1.0 spec/view_helper/icon_spec.rb
meta_tags-rails-1.0.0 spec/view_helper/icon_spec.rb
meta-tags-2.1.0 spec/view_helper/icon_spec.rb