aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/form_tag_helper_test.rb
blob: 8fd6300b829546ffd8ccbeb891897950c2470833 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'test/unit'
require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_tag_helper'

class FormTagHelperTest < Test::Unit::TestCase
  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::FormTagHelper

  MethodToTag = {
    %(text_field_tag("title", "Hello!")) => %(<input id="title" name="title" type="text" value="Hello!" />),
    %(text_field_tag("title", "Hello!", "class" => "admin")) => %(<input class="admin" id="title" name="title" type="text" value="Hello!" />),
    %(hidden_field_tag "id", 3) => %(<input id="id" name="id" type="hidden" value="3" />),
    %(password_field_tag) => %(<input id="password" name="password" type="password" value="" />),
    %(text_area_tag("body", "hello world", :size => "20x40")) => %(<textarea cols="20" id="body" name="body" rows="40">hello world</textarea>),
    %(text_area_tag("body", "hello world", "size" => "20x40")) => %(<textarea cols="20" id="body" name="body" rows="40">hello world</textarea>),
    %(check_box_tag("admin")) => %(<input id="admin" name="admin" type="checkbox" value="1" />),
    %(radio_button_tag("people", "david")) => %(<input id="people" name="people" type="radio" value="david" />),
    %(select_tag("people", "<option>david</option>")) => %(<select id="people" name="people"><option>david</option></select>),
  }

  def test_tags
    MethodToTag.each { |method, tag| assert_equal(tag, eval(method)) }
  end
end