Sha256: 6c004f4ec74432fcbee4899fcaf63bf56c09f52488f497c1e5e20df49544b172

Contents?: true

Size: 1.73 KB

Versions: 14

Compression:

Stored size: 1.73 KB

Contents

#          Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

require File.expand_path('../../../../spec/helper', __FILE__)
spec_require 'liquid'

Ramaze::App.options.views = 'liquid'

class SpecLiquid < Ramaze::Controller
  map '/'
  engine :Liquid

  def index
    '<h1>Liquid Index</h1>'
  end

  def links
    '<ul>
      <li>{% anchor "Index page" index %}</li>
      <li>{% anchor "Internal template" internal %}</li>
      <li>{% anchor "External template" external %}</li>
    </ul>'.ui
  end

  def sum(num1, num2)
    @sum = num1.to_i + num2.to_i
  end
end

describe 'Ramaze::View::Liquid' do
  behaves_like :rack_test

  should 'render' do
    got = get('/')
    got.status.should == 200
    got['Content-Type'].should == 'text/html'
    got.body.strip.should == "<h1>Liquid Index</h1>"
  end

  should 'use custom tags for default helpers' do
    got = get('/links')
    got.status.should == 200
    got['Content-Type'].should == 'text/html'
    got.body.strip.should ==
    '<ul>
      <li><a href="/index">Index page</a></li>
      <li><a href="/internal">Internal template</a></li>
      <li><a href="/external">External template</a></li>
    </ul>'.ui
  end

  should 'render external template' do
    got = get('/external')
    got.status.should == 200
    got['Content-Type'].should == 'text/html'
    got.body.strip.should ==
"<html>
  <head>
    <title>Liquid Test</title>
  </head>
  <body>
    <h1>Liquid Template</h1>
  </body>
</html>"
  end

  should 'render external template with instance variables' do
    got = get('/sum/1/2')
    got.status.should == 200
    got['Content-Type'].should == 'text/html'
    got.body.strip.should == "<div>3</div>"
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
Pistos-ramaze-2009.06.12 spec/ramaze/view/liquid.rb
manveru-ramaze-2009.07 spec/ramaze/view/liquid.rb
ramaze-2011.12.28 spec/ramaze/view/liquid.rb
ramaze-2011.10.23 spec/ramaze/view/liquid.rb
ramaze-2011.07.25 spec/ramaze/view/liquid.rb
ramaze-2011.01.30 spec/ramaze/view/liquid.rb
ramaze-2011.01 spec/ramaze/view/liquid.rb
ramaze-2010.06.18 spec/ramaze/view/liquid.rb
ramaze-2010.04.04 spec/ramaze/view/liquid.rb
ramaze-2010.04 spec/ramaze/view/liquid.rb
ramaze-2010.03 spec/ramaze/view/liquid.rb
ramaze-2010.01 spec/ramaze/view/liquid.rb
ramaze-2009.10 spec/ramaze/view/liquid.rb
ramaze-2009.07 spec/ramaze/view/liquid.rb