Sha256: bce2aa3886edd9c70f039b3dbbc4419ecb33f4093aa6ac324bc9fa0622b6082f

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'
 
describe Locomotive::Liquid::Drops::Page do
  
  before(:each) do
    @home = Factory.build(:page)
    @home.stubs(:children).returns([
      Page.new(:title => 'Child #1'), 
      Page.new(:title => 'Child #2'),
      Page.new(:title => 'Child #3')
      ])
    @home.children.last.stubs(:children).returns([
      Page.new(:title => 'Child #3.1'),
      Page.new(:title => 'Child #3.2')
      ])
  end
  
  context '#rendering' do
    
    context '#children' do
      
      it 'renders title of all children pages' do
        content = render_template '{% for child in home.children %}{{ child.title }},{% endfor %}'
        content.should == 'Child #1,Child #2,Child #3,'
      end
      
    end
    
    context '#sub children' do
      
      it 'renders title of all sub children pages' do
        content = render_template '{% for child in home.children.last.children %}{{ child.title }},{% endfor %}'
        content.should == 'Child #3.1,Child #3.2,'
      end
    
    end
    
  end
  
  def render_template(template = '', assigns = {})
    assigns = {
      'home' => @home
    }.merge(assigns)
    
    Liquid::Template.parse(template).render assigns
  end
    
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
locomotive_cms-0.0.3.3 spec/lib/locomotive/liquid/drops/page_spec.rb
locomotive_cms-0.0.3.1 spec/lib/locomotive/liquid/drops/page_spec.rb
locomotive_cms-0.0.2.9 spec/lib/locomotive/liquid/drops/page_spec.rb
locomotive_cms-0.0.2.8 spec/lib/locomotive/liquid/drops/page_spec.rb
locomotive_cms-0.0.2.7 spec/lib/locomotive/liquid/drops/page_spec.rb
locomotive_cms-0.0.2.6 spec/lib/locomotive/liquid/drops/page_spec.rb