Sha256: 9688d1172c7a948e7fbc52b3b3fb168dca2a7ffde5d0aead0b6427621e04ab94

Contents?: true

Size: 840 Bytes

Versions: 22

Compression:

Stored size: 840 Bytes

Contents

require 'spec_helper'

describe Locomotive::Liquid::Drops::Site do

  before(:each) do
    @site   = FactoryGirl.build(:site)
    page_1  = FactoryGirl.build(:page, site: @site)
    page_2  = FactoryGirl.build(:page, site: @site, title: 'About us', slug: 'about_us')
    @site.stubs(:pages).returns([page_1, page_2])
  end

  context '#pages' do

    it 'has access to all the pages' do
      render_template('{{ site.pages.size }}').should == '2'
    end

    it 'loops thru the pages' do
      render_template('{% for page in site.pages %}{{ page.title }} {% endfor %}').should == 'Home page About us '
    end

  end

  def render_template(template = '', assigns = {})
    assigns = {
      'site' => @site
    }.merge(assigns)

    Liquid::Template.parse(template).render(::Liquid::Context.new({}, assigns, { site: @site }))
  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
locomotive_cms-2.5.5 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.5.4 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.5.3 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.5.2 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.5.1 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.5.0 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.5.0.rc3 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.5.0.rc2 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.5.0.rc1 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.4.1 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.4.0 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.3.1 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.3.0 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.2.3 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.2.2 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.2.1 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.2.0 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.1.4 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.1.3 spec/lib/locomotive/liquid/drops/site_spec.rb
locomotive_cms-2.1.2 spec/lib/locomotive/liquid/drops/site_spec.rb