requireFile.expand_path(File.dirname(__FILE__)+'/helper')requireFile.expand_path(File.dirname(__FILE__)+'/fixtures/markup_app/app')classTestTagHelpers<Test::Unit::TestCasedefappMarkupDemo.tap{|app|app.set:environment,:test}endcontext'for #tag method'doshould("support tags with no content no attributes")doassert_has_tag(:br){tag(:br)}endshould("support tags with no content with attributes")doactual_html=tag(:br,:style=>'clear:both',:class=>'yellow')assert_has_tag(:br,:class=>'yellow',:style=>'clear:both'){actual_html}endshould"support selected attribute by using 'selected' if true"doactual_html=tag(:option,:selected=>true)assert_has_tag('option',:selected=>'selected'){actual_html}endshould"support tags with content no attributes"doassert_has_tag(:p,:content=>"Demo String"){tag(:p,:content=>"Demo String")}endshould"support tags with content and attributes"doactual_html=tag(:p,:content=>"Demo",:class=>'large',:id=>'intro')assert_has_tag('p#intro.large',:content=>"Demo"){actual_html}endshould"support open tags"doactual_html=tag(:p,:class=>'demo',:open=>true)assert_equal"<p class=\"demo\">",actual_htmlendendcontext'for #content_tag method'doshould"support tags with content as parameter"doactual_html=content_tag(:p,"Demo",:class=>'large',:id=>'thing')assert_has_tag('p.large#thing',:content=>"Demo"){actual_html}endshould"support tags with content as block"doactual_html=content_tag(:p,:class=>'large',:id=>'star'){"Demo"}assert_has_tag('p.large#star',:content=>"Demo"){actual_html}endshould"support tags with erb"dovisit'/erb/content_tag'assert_have_selector:p,:content=>"Test 1",:class=>'test',:id=>'test1'assert_have_selector:p,:content=>"Test 2"assert_have_selector:p,:content=>"Test 3"assert_have_selector:p,:content=>"Test 4"endshould"support tags with haml"dovisit'/haml/content_tag'assert_have_selector:p,:content=>"Test 1",:class=>'test',:id=>'test1'assert_have_selector:p,:content=>"Test 2"assert_have_selector:p,:content=>"Test 3",:class=>'test',:id=>'test3'assert_have_selector:p,:content=>"Test 4"endshould"support tags with slim"dovisit'/slim/content_tag'assert_have_selector:p,:content=>"Test 1",:class=>'test',:id=>'test1'assert_have_selector:p,:content=>"Test 2"assert_have_selector:p,:content=>"Test 3",:class=>'test',:id=>'test3'assert_have_selector:p,:content=>"Test 4"endendcontext'for #input_tag method'doshould"support field with type"doassert_has_tag('input[type=text]'){input_tag(:text)}endshould"support field with type and options"doactual_html=input_tag(:text,:class=>"first",:id=>'texter')assert_has_tag('input.first#texter[type=text]'){actual_html}endshould"support checked attribute by using 'checked' if true"doactual_html=input_tag(:checkbox,:checked=>true)assert_has_tag('input[type=checkbox]',:checked=>'checked'){actual_html}endshould"remove checked attribute if false"doactual_html=input_tag(:checkbox,:checked=>false)assert_has_no_tag('input[type=checkbox][checked=false]'){actual_html}endshould"support disabled attribute by using 'disabled' if true"doactual_html=input_tag(:checkbox,:disabled=>true)assert_has_tag('input[type=checkbox]',:disabled=>'disabled'){actual_html}endendend