Sha256: 894ee12acb9a770ec07f5c01922487819cb4baa4f056d00d0907dbdd61f51eb0

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

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

  def value_for(pattern = //)
    meta_tags(pattern).first[:value]
  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: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

4 entries across 4 versions & 1 rubygems

Version Path
crystalmeta-0.9.3 spec/features/meta_tags_spec.rb
crystalmeta-0.9.2 spec/features/meta_tags_spec.rb
crystalmeta-0.9.1 spec/features/meta_tags_spec.rb
crystalmeta-0.9.0 spec/features/meta_tags_spec.rb