require "#{File.dirname(__FILE__)}/../abstract_unit" class FormTagHelperTest < Test::Unit::TestCase include ActionView::Helpers::UrlHelper include ActionView::Helpers::TagHelper include ActionView::Helpers::FormTagHelper include ActionView::Helpers::TextHelper include ActionView::Helpers::CaptureHelper def setup @controller = Class.new do def url_for(options) "http://www.example.com" end end @controller = @controller.new end def test_check_box_tag actual = check_box_tag "admin" expected = %() assert_dom_equal expected, actual end def test_form_tag actual = form_tag expected = %(
) assert_dom_equal expected, actual end def test_form_tag_multipart actual = form_tag({}, { 'multipart' => true }) expected = %() assert_dom_equal expected, actual end def test_form_tag_with_method actual = form_tag({}, { :method => :put }) expected = %(
) assert_dom_equal expected, actual end def test_form_tag_with_block _erbout = '' form_tag("http://example.com") { _erbout.concat "Hello world!" } expected = %(Hello world!
) assert_dom_equal expected, _erbout end def test_form_tag_with_block_and_method _erbout = '' form_tag("http://example.com", :method => :put) { _erbout.concat "Hello world!" } expected = %(
Hello world!
) assert_dom_equal expected, _erbout end def test_hidden_field_tag actual = hidden_field_tag "id", 3 expected = %() assert_dom_equal expected, actual end def test_password_field_tag actual = password_field_tag expected = %() assert_dom_equal expected, actual end def test_radio_button_tag actual = radio_button_tag "people", "david" expected = %() assert_dom_equal expected, actual actual = radio_button_tag("num_people", 5) expected = %() assert_dom_equal expected, actual actual = radio_button_tag("gender", "m") + radio_button_tag("gender", "f") expected = %() assert_dom_equal expected, actual actual = radio_button_tag("opinion", "-1") + radio_button_tag("opinion", "1") expected = %() assert_dom_equal expected, actual end def test_select_tag actual = select_tag "people", "" expected = %() assert_dom_equal expected, actual end def test_text_area_tag_size_string actual = text_area_tag "body", "hello world", "size" => "20x40" expected = %() assert_dom_equal expected, actual end def test_text_area_tag_size_symbol actual = text_area_tag "body", "hello world", :size => "20x40" expected = %() assert_dom_equal expected, actual end def test_text_area_tag_should_disregard_size_if_its_given_as_an_integer actual = text_area_tag "body", "hello world", :size => 20 expected = %() assert_dom_equal expected, actual end def test_text_field_tag actual = text_field_tag "title", "Hello!" expected = %() assert_dom_equal expected, actual end def test_text_field_tag_class_string actual = text_field_tag "title", "Hello!", "class" => "admin" expected = %() assert_dom_equal expected, actual end def test_boolean_optios assert_dom_equal %(), check_box_tag("admin", 1, true, 'disabled' => true, :readonly => "yes") assert_dom_equal %(), check_box_tag("admin", 1, true, :disabled => false, :readonly => nil) assert_dom_equal %(), select_tag("people", "", :multiple => true) assert_dom_equal %(), select_tag("people", "", :multiple => nil) end def test_stringify_symbol_keys actual = text_field_tag "title", "Hello!", :id => "admin" expected = %() assert_dom_equal expected, actual end def test_submit_tag assert_dom_equal( %(), submit_tag("Save", :disable_with => "Saving...", :onclick => "alert('hello!')") ) end def test_pass assert_equal 1, 1 end end