specs for the seo liquid tags
did
committed Feb 03, 2015
commit bdf7848d1fb431019e59b56d8c4bce2359b97e88
Showing 2
changed files with
91 additions
and 0 deletions
spec/support/liquid.rb
+6
-0
| @@ | @@ -21,3 +21,9 @@ module Liquid |
| end | |
| end | |
| end | |
| + | |
| + | def liquid_instance_double(doubled_class, stubs) |
| + | instance_double(doubled_class, stubs).tap do |double| |
| + | allow(double).to receive(:to_liquid).and_return(double) |
| + | end |
| + | end |
spec/unit/liquid/tags/seo_spec.rb
+85
-0
| @@ | @@ -0,0 +1,85 @@ |
| + | require 'spec_helper' |
| + | |
| + | describe Locomotive::Steam::Liquid::Tags::SEO do |
| + | |
| + | let(:page) { nil } |
| + | let(:content_entry) { nil } |
| + | |
| + | let(:site) { instance_double('Site', name: 'Acme', seo_title: 'Acme (SEO)', meta_description: 'A short site description', meta_keywords: 'test only cat dog') } |
| + | let(:assigns) { { 'page' => page, 'content_entry' => content_entry } } |
| + | let(:context) { ::Liquid::Context.new(assigns, {}, { site: site }) } |
| + | |
| + | subject { render_template(source, context).strip } |
| + | |
| + | describe 'seo' do |
| + | |
| + | let(:source) { '{% seo %}' } |
| + | it { is_expected.to include '<title>Acme (SEO)</title>' } |
| + | it { is_expected.to include %Q[<meta name="description" content="A short site description">] } |
| + | it { is_expected.to include %Q[<meta name="keywords" content="test only cat dog">] } |
| + | |
| + | end |
| + | |
| + | describe 'seo_title' do |
| + | |
| + | let(:source) { '{% seo_title %}' } |
| + | |
| + | describe 'no page' do |
| + | |
| + | it { is_expected.to eq '<title>Acme (SEO)</title>' } |
| + | |
| + | describe 'no seo_title site property' do |
| + | |
| + | let(:site) { instance_double('Site', name: 'Acme', seo_title: nil, meta_description: 'A short site description', meta_keywords: 'test only cat dog') } |
| + | it { is_expected.to eq '<title>Acme</title>' } |
| + | |
| + | end |
| + | |
| + | end |
| + | |
| + | describe 'with a page' do |
| + | |
| + | let(:page) { liquid_instance_double('Page', seo_title: 'Snow!') } |
| + | it { is_expected.to eq '<title>Snow!</title>' } |
| + | |
| + | end |
| + | |
| + | describe 'with a content entry' do |
| + | |
| + | let(:content_entry) { liquid_instance_double('Entry', seo_title: 'Snow!') } |
| + | it { is_expected.to eq '<title>Snow!</title>' } |
| + | |
| + | end |
| + | |
| + | end |
| + | |
| + | describe 'seo_metadata' do |
| + | |
| + | let(:source) { '{% seo_metadata %}' } |
| + | |
| + | describe 'no page' do |
| + | |
| + | it { is_expected.to include %Q[<meta name="description" content="A short site description">] } |
| + | it { is_expected.to include %Q[<meta name="keywords" content="test only cat dog">] } |
| + | |
| + | end |
| + | |
| + | describe 'with a page' do |
| + | |
| + | let(:page) { liquid_instance_double('Page', meta_description: "It's snowing", meta_keywords: 'snow') } |
| + | it { is_expected.to include %Q[<meta name="description" content="It's snowing">] } |
| + | it { is_expected.to include %Q[<meta name="keywords" content="snow">] } |
| + | |
| + | end |
| + | |
| + | describe 'with a content entry' do |
| + | |
| + | let(:content_entry) { liquid_instance_double('Entry', meta_description: "It's snowing", meta_keywords: 'snow') } |
| + | it { is_expected.to include %Q[<meta name="description" content="It's snowing">] } |
| + | it { is_expected.to include %Q[<meta name="keywords" content="snow">] } |
| + | |
| + | end |
| + | |
| + | end |
| + | |
| + | end |