#!/usr/bin/env ruby require 'test/unit' currentPath = File.dirname(__FILE__) require File.join( currentPath, '../lib/masterview' ) require File.join( currentPath, '../lib/masterview/directives/block') class TestBlock < Test::Unit::TestCase include MasterView::Directives def setup @directives = MasterView::DirectiveSet.new end def test_do @directives.directives = [] attr_value = 'if true do' @directives << Block.new(attr_value) assert_equal "<% #{attr_value} %>", @directives.determine_dcs(:stag).render.join assert_equal "<% end %>", @directives.determine_dcs(:etag).render.join end def test_brack @directives.directives = [] attr_value = 'if true {' @directives << Block.new(attr_value) assert_equal "<% #{attr_value} %>", @directives.determine_dcs(:stag).render.join assert_equal "<% } %>", @directives.determine_dcs(:etag).render.join end def test_brack2 @directives.directives = [] attr_value = 'if true { :foo => :bar } {' @directives << Block.new(attr_value) assert_equal "<% #{attr_value} %>", @directives.determine_dcs(:stag).render.join assert_equal "<% } %>", @directives.determine_dcs(:etag).render.join end def test_do2 @directives.directives = [] attr_value = 'if true { :foo => :bar } do' @directives << Block.new(attr_value) assert_equal 1, @directives.directives.size assert_equal "<% #{attr_value} %>", @directives.determine_dcs(:stag).render.join assert_equal "<% end %>", @directives.determine_dcs(:etag).render.join end end