#!/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_remote') require File.join( currentPath, '../directive_test_helper' ) DirectiveTestHelpers.load_masterview_directive('form_remote') class TestFormRemote < Test::Unit::TestCase include DirectiveTestHelpers FormRemote = MasterView::Directives::FormRemote # test subject ELEMENT_TAG = 'form' def test_metadata assert_equal MasterView::ConfigSettings.namespace_prefix, FormRemote.namespace_prefix assert_equal 'form_remote', FormRemote.attribute_name end def test_default create_template_element ELEMENT_TAG attr_value = ":action => 'create'" create_directive FormRemote, attr_value assert_equal "<%= form_remote_tag( :action => 'create' ) %>", render_element_event(:stag) assert_equal "", render_element_event(:etag) end def test_get create_template_element ELEMENT_TAG, :attributes => { 'method' => 'get' } attr_value = ":action => 'create'" create_directive FormRemote, attr_value assert_equal "<%= form_remote_tag( :action => 'create', :method => \"get\" ) %>", render_element_event(:stag) end def test_get_uppercase create_template_element ELEMENT_TAG, :attributes => { 'method' => 'GET'} attr_value = ":action => 'create'" create_directive FormRemote, attr_value assert_equal "<%= form_remote_tag( :action => 'create', :method => \"GET\" ) %>", render_element_event(:stag) assert_equal "", render_element_event(:etag) end def test_post create_template_element ELEMENT_TAG, :attributes => { 'method' => 'post' } attr_value = ":action => 'create'" create_directive FormRemote, attr_value assert_equal "<%= form_remote_tag( :action => 'create', :method => \"post\" ) %>", render_element_event(:stag) end def test_post_uppercase create_template_element ELEMENT_TAG, :attributes => { 'method' => 'POST' } attr_value = ":action => 'create'" create_directive FormRemote, attr_value assert_equal "<%= form_remote_tag( :action => 'create', :method => \"POST\" ) %>", render_element_event(:stag) end end