require File.dirname(__FILE__) + '/test_helper'
class StyledInputsTest < Test::Unit::TestCase
include PluginAWeek::StyledInputs
include ActionView::Helpers::TagHelper
def test_should_not_style_input_if_tag_is_not_input
expected = {}
assert_equal expected, styled_input('td', expected)
end
def test_should_not_style_input_if_correct_type_but_tag_is_not_input
expected = {'type' => 'text'}
assert_equal expected, styled_input('td', expected)
end
def test_should_style_input_if_tag_is_input
expected = {'type' => 'text', 'class' => 'text'}
assert_equal expected, styled_input('input', {'type' => 'text'})
end
def test_should_style_input_if_tag_is_symbolic_input
expected = {'type' => 'text', 'class' => 'text'}
assert_equal expected, styled_input(:input, {'type' => 'text'})
end
def test_should_not_style_input_if_tag_is_input_but_type_not_specified
expected = {}
assert_equal expected, styled_input('input', expected)
end
def test_should_append_style_if_class_is_already_populated
expected = {'type' => 'text', 'class' => 'selected text'}
assert_equal expected, styled_input('input', {'type' => 'text', 'class' => 'selected'})
end
def test_should_style_general_tag_builder
assert_equal '', tag('input', {'type' => 'text'})
end
end
class FormTagHelperTest < Test::Unit::TestCase
include PluginAWeek::StyledInputs
include ActionView::Helpers::TagHelper
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::FormHelper
def test_should_style_text_field_tag
assert_equal '', text_field_tag('name')
end
def test_should_style_hidden_field_tag
assert_equal '', hidden_field_tag('name')
end
def test_should_style_file_field_tag
assert_equal '', file_field_tag('picture')
end
def test_should_style_password_field_tag
assert_equal '', password_field_tag('secret')
end
def test_should_style_check_box_tag
assert_equal '', check_box_tag('agree')
end
def test_should_style_radio_button_tag
assert_equal '', radio_button_tag('agree', 1)
end
def test_should_style_submit_tag
assert_equal '', submit_tag('Submit')
end
def test_should_style_image_submit_tag
assert_equal '', image_submit_tag('button.png')
end
private
def path_to_image(source)
source
end
end
class FormHelperTest < Test::Unit::TestCase
class Person
attr_accessor :name,
:agree,
:picture,
:secret
end
include PluginAWeek::StyledInputs
include ActionView::Helpers::TagHelper
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::FormHelper
def setup
@person = Person.new
end
def test_should_style_text_field
assert_equal '', text_field(:person, :name)
end
def test_should_style_password_field
assert_equal '', password_field(:person, :secret)
end
def test_should_style_hidden_field
assert_equal '', hidden_field(:person, :name)
end
def test_should_style_file_field
assert_equal '', file_field(:person, :picture)
end
def test_should_style_check_box
expected =
'' +
''
assert_equal expected, check_box(:person, :agree)
end
def test_should_style_radio_button
assert_equal '', radio_button(:person, :agree, 1)
end
end
class TagHelperTest < Test::Unit::TestCase
include PluginAWeek::StyledInputs
include ActionView::Helpers::TagHelper
def test_should_allow_no_options_to_be_specified
assert_equal '
', tag('br')
end
def test_should_allow_options_to_be_specified
assert_equal '', tag('input', {:type => 'text', :disabled => true})
end
def test_should_allow_open_to_be_specified
assert_equal '
', tag('br', nil, true)
end
def test_should_allow_escape_to_be_specified
assert_equal '', tag('img', {:src => 'open & shut.png'}, false, false)
end
end