Sha256: f4a991b1711ca8decd00edb2998c0564c03120ee8c2719ccaf1ed870dc0315d2

Contents?: true

Size: 1.68 KB

Versions: 10

Compression:

Stored size: 1.68 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 'spec/helper'
spec_require 'haml'

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

class SpecHaml < Ramaze::Controller
  map '/'
  engine :Haml

  def index
    '%h1 Haml Index'
  end

  def links
    '
    %ul
      %li
        %a{:href => r(:index)} Index page
      %li
        %a{:href => r(:internal)} Internal template
      %li
        %a{:href => r(:external)} External template
    '.ui
  end

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

describe Ramaze::View::Haml do
  behaves_like :mock

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

  should 'use other helper methods' 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>"
  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>Haml Test</title>
  </head>
  <body>
    <h1>Haml 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

10 entries across 10 versions & 3 rubygems

Version Path
Pistos-ramaze-2009.04.08 spec/ramaze/view/haml.rb
manveru-ramaze-2009.04.01 spec/ramaze/view/haml.rb
manveru-ramaze-2009.04.08 spec/ramaze/view/haml.rb
manveru-ramaze-2009.04.18 spec/ramaze/view/haml.rb
manveru-ramaze-2009.04.22 spec/ramaze/view/haml.rb
manveru-ramaze-2009.04 spec/ramaze/view/haml.rb
manveru-ramaze-2009.05.08 spec/ramaze/view/haml.rb
manveru-ramaze-2009.05 spec/ramaze/view/haml.rb
ramaze-2009.05 spec/ramaze/view/haml.rb
ramaze-2009.04 spec/ramaze/view/haml.rb