Sha256: 5048d749c5ae33e81804a70bba17b87d07c9c9e52b622091af7a7316d0cf1cea

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe 'meta tags' do
  def meta_tags(pattern = //)
    all('meta').select{|meta| pattern === meta[:property] || pattern === meta[:name] }
  end

  def value_for(pattern = //)
    meta_tags(pattern).first[:content]
  end

  def title
    page.html.match(%r{<title>(.*?)</title>})[1]
  end

  context 'on movie page' do
    before do
      visit movie_path('rock')
    end

    it 'include og:title from controller' do
      value_for('og:title').should == 'The Rock (1996)'
    end

    it 'include og:image from locale' do
      value_for('og:image').should == '/images/rock.jpg'
    end

    it 'include og:image from locale' do
      value_for('twitter:card').should == 'summary'
    end

    it 'include og:type from controller defaults' do
      value_for('og:type').should == 'video.movie'
    end

    it 'include title with interpolation' do
      title.should == 'The Rock (1996) - IMDb'
    end
  end

  context 'on movies page' do
    before do
      visit movies_path
    end

    it 'include og:title & og:type from views' do
      value_for('og:title').should == 'Movies'
      value_for('og:type').should == 'article'
    end

    it 'include default title' do
      title.should == 'Movies on IMDb'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crystalmeta-0.9.4 spec/features/meta_tags_spec.rb