Sha256: dc2128c44ef77c994d182d2fb46bacd03889ece638c3b0c390f40c1fb1f0ebd6

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'
require 'meta_tags_helper'

describe MetaTagsHelper, type: [:helper] do
  describe '#title' do
    it 'sets and returns page title' do
      title = helper.title('Foo bar')

      expect(title).to eq('Foo bar')
      expect(helper.title).to eq('Foo bar')
    end
  end

  describe '#title_tag' do
    it 'builds "title" tag with base suffix' do
      helper.title('Foo bar')

      expect(helper.title_tag('Baz')).to eq('<title>Foo bar — Baz</title>')
    end
  end

  describe '#meta_tag' do
    it 'builds meta tag' do
      meta = helper.meta_tag('name', 'content')
      meta_html = '<meta content="content" name="name" />'

      expect(meta).to eq(meta_html)
    end

    it 'uses "property" attribute for namespaced names' do
      meta = helper.meta_tag('ns:name', 'content')
      meta_html = '<meta content="content" property="ns:name" />'

      expect(meta).to eq(meta_html)
    end
  end

  describe '#meta_tags' do
    it 'builds list of meta tags' do
      meta = meta_tags(description: 'Foo bar baz', keywords: %[foo bar baz])
      meta_html = '<meta content="Foo bar baz" name="description" />' +
                  '<meta content="foo bar baz" name="keywords" />'

      expect(meta).to eq(meta_html)
    end

    it 'allows to specify properties namespace' do
      og = meta_tags(og: { description: 'Foo bar baz', image: 'image.jpg' })
      og_html = '<meta content="Foo bar baz" property="og:description" />' +
                '<meta content="image.jpg" property="og:image" />'

      expect(og).to eq(og_html)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
meta_tags_helper-0.1.0 spec/helpers/meta_tags_helper_spec.rb