Sha256: 09d595e198fad3a0f72086ce8ed7abdcf2b65d65bb5412493c30a2e1e9d54d24

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require File.dirname(__FILE__) + '/helper'

class TestBase < Test::Unit::TestCase

  context 'Frank::TemplateHelpers' do
    
    setup do
      proj_dir = File.join(File.dirname(__FILE__), 'template')
      settings = YAML.load_file(File.join(proj_dir, 'settings.yml'))
      require File.join(proj_dir, 'helpers')
      @frank = Frank.new do
        settings.each do |name, value|
          set name.to_s, value
        end
        set :environment, :test
        set :proj_dir, proj_dir
      end
    end
    
    should 'render haml and use hello_helper' do
      template = @frank.render_path('helper_test.haml')
      assert_equal "<div id='layout'>\n  <h1>hello from helper</h1>\n</div>\n", template
    end
    
    context 'Lorem' do
      should 'render haml with 3 random lorem words' do
        template = @frank.render_path('lorem_test.haml')
        reg = /<p class='words'>(?:\w+\s?){3}<\/p>/
        assert_match reg, template
      end
    
      should 'render haml with 2 random lorem sentences' do
        template = @frank.render_path('lorem_test.haml')
        reg = /<p class='sentences'>(?:[^.]+.){2}<\/p>/
        assert_match reg, template
      end
      
      should 'render haml with 1 random lorem paragraph' do
        template = @frank.render_path('lorem_test.haml')
        reg = /<p class='paragraphs'>(?:[^\n]+(?:\n\n)?){1}<\/p>/m
        assert_match reg, template
      end
      
      should 'render image url using imager' do
        template = @frank.render_path('lorem_test.haml')
        reg = /<img src='\/_img\/400x300.jpg\?random' \/>/
        assert_match reg, template
      end
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
frank-0.2.0 test/test_helpers.rb