engine/spec/lib/locomotive/liquid/drops/site_spec.rb

33 lines
855 B
Ruby
Raw Normal View History

2011-02-27 16:14:14 +00:00
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')
2011-02-27 16:14:14 +00:00
@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