#!/usr/bin/env ruby require 'test/unit' currentPath = File.dirname(__FILE__) require File.join( currentPath, '../lib/masterview' ) require File.join( currentPath, '../lib/masterview/directives/form') class TestForm < Test::Unit::TestCase include MasterView::Directives def setup @directives = MasterView::DirectiveSet.new end def test_default tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil) @directives.directives = [] attr_value = ":action => 'create'" @directives << Form.new(attr_value) dcs = @directives.determine_dcs(:stag) dcs.context = tag.create_context assert_equal "<%= form_tag :action => 'create' %>", dcs.render assert_equal "<%= end_form_tag %>", @directives.determine_dcs(:etag).render end def test_get_uc tag = MasterView::Tag.new(@directives, 'foo', { 'method' => 'GET'}, :normal, nil) @directives.directives = [] attr_value = ":action => 'create'" @directives << Form.new(attr_value) dcs = @directives.determine_dcs(:stag) dcs.context = tag.create_context assert_equal "<%= form_tag {:action => 'create'}, :method => \"get\" %>", dcs.render end def test_get tag = MasterView::Tag.new(@directives, 'foo', { 'method' => 'get' }, :normal, nil) @directives.directives = [] attr_value = ":action => 'create'" @directives << Form.new(attr_value) dcs = @directives.determine_dcs(:stag) dcs.context = tag.create_context assert_equal "<%= form_tag {:action => 'create'}, :method => \"get\" %>", dcs.render end def test_post_uc tag = MasterView::Tag.new(@directives, 'foo', { 'method' => 'POST' }, :normal, nil) @directives.directives = [] attr_value = ":action => 'create'" @directives << Form.new(attr_value) dcs = @directives.determine_dcs(:stag) dcs.context = tag.create_context assert_equal "<%= form_tag :action => 'create' %>", dcs.render end def test_post tag = MasterView::Tag.new(@directives, 'foo', { 'method' => 'post' }, :normal, nil) @directives.directives = [] attr_value = ":action => 'create'" @directives << Form.new(attr_value) dcs = @directives.determine_dcs(:stag) dcs.context = tag.create_context assert_equal "<%= form_tag :action => 'create' %>", dcs.render end end