Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8911

Show
Ignore:
Timestamp:
02/20/08 04:23:18 (11 months ago)
Author:
nzkoz
Message:

Make date_helper use tag and content_tag. Move to assert_dom_equal instead of assert_equal to avoid being dependent on hash ordering. Closes #11131 [ernesto.jimenez]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_view/helpers/date_helper.rb

    r8467 r8911  
    11require "date" 
     2require 'action_view/helpers/tag_helper' 
    23 
    34module ActionView 
     
    1213    #   method would use simply "date" (which can be overwritten using <tt>:prefix</tt>) instead of "date[month]". 
    1314    module DateHelper 
     15      include ActionView::Helpers::TagHelper 
    1416      DEFAULT_PREFIX = 'date' unless const_defined?('DEFAULT_PREFIX') 
    1517 
     
    338340          0.upto(59) do |second| 
    339341            second_options << ((val == second) ? 
    340               %(<option value="#{leading_zero_on_single_digits(second)}" selected="selected">#{leading_zero_on_single_digits(second)}</option>\n) : 
    341               %(<option value="#{leading_zero_on_single_digits(second)}">#{leading_zero_on_single_digits(second)}</option>\n
     342              content_tag(:option, leading_zero_on_single_digits(second), :value => leading_zero_on_single_digits(second), :selected => "selected") : 
     343              content_tag(:option, leading_zero_on_single_digits(second), :value => leading_zero_on_single_digits(second)
    342344            ) 
     345            second_options << "\n" 
    343346          end 
    344347          select_html(options[:field_name] || 'second', second_options.join, options) 
     
    372375          0.step(59, options[:minute_step] || 1) do |minute| 
    373376            minute_options << ((val == minute) ? 
    374               %(<option value="#{leading_zero_on_single_digits(minute)}" selected="selected">#{leading_zero_on_single_digits(minute)}</option>\n) : 
    375               %(<option value="#{leading_zero_on_single_digits(minute)}">#{leading_zero_on_single_digits(minute)}</option>\n
     377              content_tag(:option, leading_zero_on_single_digits(minute), :value => leading_zero_on_single_digits(minute), :selected => "selected") : 
     378              content_tag(:option, leading_zero_on_single_digits(minute), :value => leading_zero_on_single_digits(minute)
    376379            ) 
     380            minute_options << "\n" 
    377381          end 
    378382          select_html(options[:field_name] || 'minute', minute_options.join, options) 
     
    405409          0.upto(23) do |hour| 
    406410            hour_options << ((val == hour) ? 
    407               %(<option value="#{leading_zero_on_single_digits(hour)}" selected="selected">#{leading_zero_on_single_digits(hour)}</option>\n) : 
    408               %(<option value="#{leading_zero_on_single_digits(hour)}">#{leading_zero_on_single_digits(hour)}</option>\n
     411              content_tag(:option, leading_zero_on_single_digits(hour), :value => leading_zero_on_single_digits(hour), :selected => "selected") : 
     412              content_tag(:option, leading_zero_on_single_digits(hour), :value => leading_zero_on_single_digits(hour)
    409413            ) 
     414            hour_options << "\n" 
    410415          end 
    411416          select_html(options[:field_name] || 'hour', hour_options.join, options) 
     
    438443          1.upto(31) do |day| 
    439444            day_options << ((val == day) ? 
    440               %(<option value="#{day}" selected="selected">#{day}</option>\n) : 
    441               %(<option value="#{day}">#{day}</option>\n
     445              content_tag(:option, day, :value => day, :selected => "selected") : 
     446              content_tag(:option, day, :value => day
    442447            ) 
     448            day_options << "\n" 
    443449          end 
    444450          select_html(options[:field_name] || 'day', day_options.join, options) 
     
    498504 
    499505            month_options << ((val == month_number) ? 
    500               %(<option value="#{month_number}" selected="selected">#{month_name}</option>\n) : 
    501               %(<option value="#{month_number}">#{month_name}</option>\n
     506              content_tag(:option, month_name, :value => month_number, :selected => "selected") : 
     507              content_tag(:option, month_name, :value => month_number
    502508            ) 
     509            month_options << "\n" 
    503510          end 
    504511          select_html(options[:field_name] || 'month', month_options.join, options) 
     
    540547          start_year.step(end_year, step_val) do |year| 
    541548            year_options << ((val == year) ? 
    542               %(<option value="#{year}" selected="selected">#{year}</option>\n) : 
    543               %(<option value="#{year}">#{year}</option>\n
     549              content_tag(:option, year, :value => year, :selected => "selected") : 
     550              content_tag(:option, year, :value => year
    544551            ) 
     552            year_options << "\n" 
    545553          end 
    546554          select_html(options[:field_name] || 'year', year_options.join, options) 
     
    552560        def select_html(type, html_options, options) 
    553561          name_and_id_from_options(options, type) 
    554           select_html  = %(<select id="#{options[:id]}" name="#{options[:name]}") 
    555           select_html << %( disabled="disabled") if options[:disabled] 
    556           select_html << %(>\n) 
    557           select_html << %(<option value=""></option>\n) if options[:include_blank] 
     562          select_options = {:id => options[:id], :name => options[:name]} 
     563          select_options.merge!(:disabled => 'disabled') if options[:disabled] 
     564          select_html = "\n" 
     565          select_html << content_tag(:option, '', :value => '') + "\n" if options[:include_blank] 
    558566          select_html << html_options.to_s 
    559           select_html << "</select>\n" 
     567          content_tag(:select, select_html, select_options) + "\n" 
    560568        end 
    561569 
    562570        def hidden_html(type, value, options) 
    563571          name_and_id_from_options(options, type) 
    564           hidden_html = %(<input type="hidden" id="#{options[:id]}" name="#{options[:name]}" value="#{value}" />\n) 
     572          hidden_html = tag(:input, :type => "hidden", :id => options[:id], :name => options[:name], :value => value) + "\n" 
    565573        end 
    566574 
  • trunk/actionpack/test/template/date_helper_test.rb

    r8883 r8911  
    125125    expected << "</select>\n" 
    126126 
    127     assert_equal expected, select_day(Time.mktime(2003, 8, 16)) 
    128     assert_equal expected, select_day(16) 
     127    assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16)) 
     128    assert_dom_equal expected, select_day(16) 
    129129  end 
    130130 
     
    134134    expected << "</select>\n" 
    135135 
    136     assert_equal expected, select_day(Time.mktime(2003, 8, 16), :include_blank => true) 
    137     assert_equal expected, select_day(16, :include_blank => true) 
     136    assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16), :include_blank => true) 
     137    assert_dom_equal expected, select_day(16, :include_blank => true) 
    138138  end 
    139139 
     
    143143    expected << "</select>\n" 
    144144 
    145     assert_equal expected, select_day(nil, :include_blank => true) 
     145    assert_dom_equal expected, select_day(nil, :include_blank => true) 
    146146  end 
    147147 
     
    151151    expected << "</select>\n" 
    152152 
    153     assert_equal expected, select_month(Time.mktime(2003, 8, 16)) 
    154     assert_equal expected, select_month(8) 
     153    assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16)) 
     154    assert_dom_equal expected, select_month(8) 
    155155  end 
    156156 
     
    160160    expected << "</select>\n" 
    161161 
    162     assert_equal expected, select_month(Time.mktime(2003, 8, 16), :disabled => true) 
    163     assert_equal expected, select_month(8, :disabled => true) 
     162    assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :disabled => true) 
     163    assert_dom_equal expected, select_month(8, :disabled => true) 
    164164  end 
    165165 
     
    169169    expected << "</select>\n" 
    170170 
    171     assert_equal expected, select_month(Time.mktime(2003, 8, 16), :field_name => 'mois') 
    172     assert_equal expected, select_month(8, :field_name => 'mois') 
     171    assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :field_name => 'mois') 
     172    assert_dom_equal expected, select_month(8, :field_name => 'mois') 
    173173  end 
    174174 
     
    178178    expected << "</select>\n" 
    179179 
    180     assert_equal expected, select_month(Time.mktime(2003, 8, 16), :include_blank => true) 
    181     assert_equal expected, select_month(8, :include_blank => true) 
     180    assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :include_blank => true) 
     181    assert_dom_equal expected, select_month(8, :include_blank => true) 
    182182  end 
    183183 
     
    187187    expected << "</select>\n" 
    188188 
    189     assert_equal expected, select_month(nil, :include_blank => true) 
     189    assert_dom_equal expected, select_month(nil, :include_blank => true) 
    190190  end 
    191191 
     
    195195    expected << "</select>\n" 
    196196 
    197     assert_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_numbers => true) 
    198     assert_equal expected, select_month(8, :use_month_numbers => true) 
     197    assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_numbers => true) 
     198    assert_dom_equal expected, select_month(8, :use_month_numbers => true) 
    199199  end 
    200200 
     
    204204    expected << "</select>\n" 
    205205 
    206     assert_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true) 
    207     assert_equal expected, select_month(8, :add_month_numbers => true) 
     206    assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true) 
     207    assert_dom_equal expected, select_month(8, :add_month_numbers => true) 
    208208  end 
    209209 
     
    213213    expected << "</select>\n" 
    214214 
    215     assert_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true, :use_short_month => true) 
    216     assert_equal expected, select_month(8, :add_month_numbers => true, :use_short_month => true) 
     215    assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true, :use_short_month => true) 
     216    assert_dom_equal expected, select_month(8, :add_month_numbers => true, :use_short_month => true) 
    217217  end 
    218218 
     
    222222    expected << "</select>\n" 
    223223 
    224     assert_equal expected, select_month(Time.mktime(2003, 8, 16), :use_short_month => true) 
    225     assert_equal expected, select_month(8, :use_short_month => true) 
     224    assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_short_month => true) 
     225    assert_dom_equal expected, select_month(8, :use_short_month => true) 
    226226  end 
    227227 
     
    233233    expected << "</select>\n" 
    234234 
    235     assert_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_names => month_names) 
    236     assert_equal expected, select_month(8, :use_month_names => month_names) 
     235    assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_names => month_names) 
     236    assert_dom_equal expected, select_month(8, :use_month_names => month_names) 
    237237  end 
    238238 
     
    244244    expected << "</select>\n" 
    245245 
    246     assert_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_names => month_names) 
    247     assert_equal expected, select_month(8, :use_month_names => month_names) 
     246    assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_names => month_names) 
     247    assert_dom_equal expected, select_month(8, :use_month_names => month_names) 
    248248  end 
    249249 
     
    261261    expected << "</select>\n" 
    262262 
    263     assert_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005) 
    264     assert_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005) 
     263    assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005) 
     264    assert_dom_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005) 
    265265  end 
    266266 
     
    270270    expected << "</select>\n" 
    271271 
    272     assert_equal expected, select_year(Time.mktime(2003, 8, 16), :disabled => true, :start_year => 2003, :end_year => 2005) 
    273     assert_equal expected, select_year(2003, :disabled => true, :start_year => 2003, :end_year => 2005) 
     272    assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :disabled => true, :start_year => 2003, :end_year => 2005) 
     273    assert_dom_equal expected, select_year(2003, :disabled => true, :start_year => 2003, :end_year => 2005) 
    274274  end 
    275275 
     
    279279    expected << "</select>\n" 
    280280 
    281     assert_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :field_name => 'annee') 
    282     assert_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005, :field_name => 'annee') 
     281    assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :field_name => 'annee') 
     282    assert_dom_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005, :field_name => 'annee') 
    283283  end 
    284284 
     
    288288    expected << "</select>\n" 
    289289 
    290     assert_equal expected, select_year( 
     290    assert_dom_equal expected, select_year( 
    291291      Time.mktime(2003, 8, 16), :prefix => "date_year", :discard_type => true, :start_year => 2003, :end_year => 2005) 
    292     assert_equal expected, select_year( 
     292    assert_dom_equal expected, select_year( 
    293293      2003, :prefix => "date_year", :discard_type => true, :start_year => 2003, :end_year => 2005) 
    294294  end 
     
    299299    expected << "</select>\n" 
    300300 
    301     assert_equal expected, select_year(Time.mktime(2005, 8, 16), :start_year => 2005, :end_year => 2003) 
    302     assert_equal expected, select_year(2005, :start_year => 2005, :end_year => 2003) 
     301    assert_dom_equal expected, select_year(Time.mktime(2005, 8, 16), :start_year => 2005, :end_year => 2003) 
     302    assert_dom_equal expected, select_year(2005, :start_year => 2005, :end_year => 2003) 
    303303  end 
    304304 
     
    316316    expected << "</select>\n" 
    317317 
    318     assert_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18)) 
     318    assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18)) 
    319319  end 
    320320 
     
    324324    expected << "</select>\n" 
    325325 
    326     assert_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) 
     326    assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) 
    327327  end 
    328328 
     
    332332    expected << "</select>\n" 
    333333 
    334     assert_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'heure') 
     334    assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'heure') 
    335335  end 
    336336 
     
    340340    expected << "</select>\n" 
    341341 
    342     assert_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) 
     342    assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) 
    343343  end 
    344344 
     
    348348    expected << "</select>\n" 
    349349 
    350     assert_equal expected, select_hour(nil, :include_blank => true) 
     350    assert_dom_equal expected, select_hour(nil, :include_blank => true) 
    351351  end 
    352352 
     
    356356    expected << "</select>\n" 
    357357 
    358     assert_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18)) 
     358    assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18)) 
    359359  end 
    360360 
     
    364364    expected << "</select>\n" 
    365365 
    366     assert_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) 
     366    assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) 
    367367  end 
    368368 
     
    372372    expected << "</select>\n" 
    373373 
    374     assert_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'minuto') 
     374    assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'minuto') 
    375375  end 
    376376 
     
    380380    expected << "</select>\n" 
    381381 
    382     assert_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) 
     382    assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) 
    383383  end 
    384384 
     
    388388    expected << "</select>\n" 
    389389 
    390     assert_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), { :include_blank => true , :minute_step => 15 }) 
     390    assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), { :include_blank => true , :minute_step => 15 }) 
    391391  end 
    392392 
     
    396396    expected << "</select>\n" 
    397397 
    398     assert_equal expected, select_minute(nil, :include_blank => true) 
     398    assert_dom_equal expected, select_minute(nil, :include_blank => true) 
    399399  end 
    400400 
     
    404404    expected << "</select>\n" 
    405405 
    406     assert_equal expected, select_minute(nil, { :include_blank => true , :minute_step => 15 }) 
     406    assert_dom_equal expected, select_minute(nil, { :include_blank => true , :minute_step => 15 }) 
    407407  end 
    408408 
     
    420420    expected << "</select>\n" 
    421421 
    422     assert_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18)) 
     422    assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18)) 
    423423  end 
    424424 
     
    428428    expected << "</select>\n" 
    429429 
    430     assert_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) 
     430    assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) 
    431431  end 
    432432 
     
    436436    expected << "</select>\n" 
    437437 
    438     assert_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'segundo') 
     438    assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'segundo') 
    439439  end 
    440440 
     
    444444    expected << "</select>\n" 
    445445 
    446     assert_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) 
     446    assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) 
    447447  end 
    448448 
     
    452452    expected << "</select>\n" 
    453453 
    454     assert_equal expected, select_second(nil, :include_blank => true) 
     454    assert_dom_equal expected, select_second(nil, :include_blank => true) 
    455455  end 
    456456 
     
    468468    expected << "</select>\n" 
    469469 
    470     assert_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]") 
     470    assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]") 
    471471  end 
    472472 
     
    484484    expected << "</select>\n" 
    485485 
    486     assert_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:month, :day, :year]) 
     486    assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:month, :day, :year]) 
    487487  end 
    488488 
     
    500500    expected << "</select>\n" 
    501501 
    502     assert_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:day]) 
     502    assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:day]) 
    503503  end 
    504504 
     
    516516    expected << "</select>\n" 
    517517 
    518     assert_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :disabled => true) 
     518    assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :disabled => true) 
    519519  end 
    520520 
     
    538538    expected << "</select>\n" 
    539539 
    540     assert_equal expected, select_date( 
     540    assert_dom_equal expected, select_date( 
    541541      Time.mktime(Date.today.year, 8, 16), :end_year => Date.today.year+1, :prefix => "date[first]" 
    542542    ) 
     
    562562    expected << "</select>\n" 
    563563 
    564     assert_equal expected, select_date( 
     564    assert_dom_equal expected, select_date( 
    565565      Time.mktime(2003, 8, 16), :start_year => 2003, :prefix => "date[first]" 
    566566    ) 
     
    586586    expected << "</select>\n" 
    587587 
    588     assert_equal expected, select_date( 
     588    assert_dom_equal expected, select_date( 
    589589      Time.mktime(Date.today.year, 8, 16), :prefix => "date[first]" 
    590590    ) 
     
    604604    expected << "</select>\n" 
    605605 
    606     assert_equal expected, select_date(0, :start_year => 2003, :end_year => 2005, :prefix => "date[first]") 
     606    assert_dom_equal expected, select_date(0, :start_year => 2003, :end_year => 2005, :prefix => "date[first]") 
    607607  end 
    608608 
     
    620620    expected << "</select>\n" 
    621621 
    622     assert_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]") 
     622    assert_dom_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]") 
    623623  end 
    624624 
     
    637637    expected << "</select>\n" 
    638638 
    639     assert_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]") 
     639    assert_dom_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]") 
    640640  end 
    641641 
     
    653653    expected << "</select>\n" 
    654654 
    655     assert_equal expected, select_date(0, :prefix => "date[first]") 
     655    assert_dom_equal expected, select_date(0, :prefix => "date[first]") 
    656656  end 
    657657 
     
    669669    expected << "</select>\n" 
    670670 
    671     assert_equal expected, select_date(nil, :prefix => "date[first]") 
     671    assert_dom_equal expected, select_date(nil, :prefix => "date[first]") 
    672672  end 
    673673 
     
    693693    expected << "</select>\n" 
    694694 
    695     assert_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]") 
     695    assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]") 
    696696  end 
    697697 
     
    721721    expected << "</select>\n" 
    722722 
    723     assert_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :datetime_separator => ' &mdash; ', :time_separator => ' : ') 
     723    assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :datetime_separator => ' &mdash; ', :time_separator => ' : ') 
    724724  end 
    725725 
     
    745745    expected << "</select>\n" 
    746746 
    747     assert_equal expected, select_datetime(nil, :prefix => "date[first]") 
     747    assert_dom_equal expected, select_datetime(nil, :prefix => "date[first]") 
    748748  end 
    749749 
     
    757757    expected << "</select>\n" 
    758758 
    759     assert_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18)) 
    760     assert_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => false) 
     759    assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18)) 
     760    assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => false) 
    761761  end 
    762762 
     
    772772    expected << "</select>\n" 
    773773 
    774     assert_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :time_separator => ' : ') 
    775     assert_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :time_separator => ' : ', :include_seconds => false) 
     774    assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :time_separator => ' : ') 
     775    assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :time_separator => ' : ', :include_seconds => false) 
    776776  end 
    777777 
     
    789789    expected << "</select>\n" 
    790790 
    791     assert_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true) 
     791    assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true) 
    792792  end 
    793793 
     
    809809    expected << "</select>\n" 
    810810 
    811     assert_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true, :time_separator => ' : ') 
     811    assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true, :time_separator => ' : ') 
    812812  end 
    813813 
     
    829829    expected << "</select>\n" 
    830830 
    831     assert_equal expected, date_select("post", "written_on") 
     831    assert_dom_equal expected, date_select("post", "written_on") 
    832832  end 
    833833 
     
    846846    expected << "</select>\n" 
    847847 
    848     assert_equal expected, date_select("post", "written_on", :order => [ :month, :year ]) 
     848    assert_dom_equal expected, date_select("post", "written_on", :order => [ :month, :year ]) 
    849849  end 
    850850 
     
    884884    expected << "</select>\n" 
    885885 
    886     assert_equal expected, date_select("post", "written_on", :index => id) 
     886    assert_dom_equal expected, date_select("post", "written_on", :index => id) 
    887887  end 
    888888 
     
    904904    expected << "</select>\n" 
    905905 
    906     assert_equal expected, date_select("post[]", "written_on") 
     906    assert_dom_equal expected, date_select("post[]", "written_on") 
    907907  end 
    908908 
     
    923923    expected << "</select>\n" 
    924924 
    925     assert_equal expected, date_select("post", "written_on", :order => [:day, :month, :year]) 
     925    assert_dom_equal expected, date_select("post", "written_on", :order => [:day, :month, :year]) 
    926926  end 
    927927 
     
    943943    expected << "</select>\n" 
    944944 
    945     assert_equal expected, date_select("post", "written_on") 
     945    assert_dom_equal expected, date_select("post", "written_on") 
    946946  end 
    947947 
     
    966966    expected << "</select>\n" 
    967967 
    968     assert_equal expected, date_select("post", "written_on", :include_blank => true) 
     968    assert_dom_equal expected, date_select("post", "written_on", :include_blank => true) 
    969969  end 
    970970 
     
    985985    expected << "</select>\n" 
    986986 
    987     assert_equal expected, date_select("post", "written_on", :discard_hour => false) 
     987    assert_dom_equal expected, date_select("post", "written_on", :discard_hour => false) 
    988988  end 
    989989 
     
    10041004    expected << "</select>\n" 
    10051005 
    1006     assert_equal expected, time_select("post", "written_on") 
     1006    assert_dom_equal expected, time_select("post", "written_on") 
    10071007  end 
    10081008 
     
    10271027    expected << "</select>\n" 
    10281028 
    1029     assert_equal expected, time_select("post", "written_on", :include_seconds => true) 
     1029    assert_dom_equal expected, time_select("post", "written_on", :include_seconds => true) 
    10301030  end 
    10311031 
     
    10561056    expected << "</select>\n" 
    10571057 
    1058     assert_equal expected, datetime_select("post", "updated_at") 
     1058    assert_dom_equal expected, datetime_select("post", "updated_at") 
    10591059  end 
    10601060 
     
    10921092    expected << "</select>\n" 
    10931093 
    1094     assert_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]") 
     1094    assert_dom_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]") 
    10951095  end 
    10961096 
     
    11101110    expected << "</select>\n" 
    11111111 
    1112     assert_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]") 
     1112    assert_dom_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]") 
    11131113  end 
    11141114 
     
    11271127    expected << "</select>\n" 
    11281128 
    1129     assert_equal expected, select_date(0, :prefix => "date[first]") 
     1129    assert_dom_equal expected, select_date(0, :prefix => "date[first]") 
    11301130  end 
    11311131 
     
    11441144    expected << "</select>\n" 
    11451145 
    1146     assert_equal expected, select_date(nil, :prefix => "date[first]") 
     1146    assert_dom_equal expected, select_date(nil, :prefix => "date[first]") 
    11471147  end 
    11481148 
     
    11691169    expected << "</select>\n" 
    11701170 
    1171     assert_equal expected, select_datetime(nil, :prefix => "date[first]") 
     1171    assert_dom_equal expected, select_datetime(nil, :prefix => "date[first]") 
    11721172  end 
    11731173 
     
    12001200    expected << "</select>\n" 
    12011201 
    1202     assert_equal expected, datetime_select("post", "updated_at", :index => id) 
     1202    assert_dom_equal expected, datetime_select("post", "updated_at", :index => id) 
    12031203  end 
    12041204 
     
    12301230    expected << "</select>\n" 
    12311231 
    1232     assert_equal expected, datetime_select("post[]", "updated_at") 
     1232    assert_dom_equal expected, datetime_select("post[]", "updated_at") 
    12331233  end 
    12341234 
     
    12611261    expected << "</select>\n" 
    12621262 
    1263     assert_equal expected, datetime_select("post", "updated_at", :include_seconds => true) 
     1263    assert_dom_equal expected, datetime_select("post", "updated_at", :include_seconds => true) 
    12641264  end 
    12651265 
     
    12861286    expected << "</select>\n" 
    12871287 
    1288     assert_equal expected, datetime_select("post", "updated_at", :discard_year => true) 
     1288    assert_dom_equal expected, datetime_select("post", "updated_at", :discard_year => true) 
    12891289  end 
    12901290 
     
    13091309    expected << "</select>\n" 
    13101310 
    1311     assert_equal expected, datetime_select("post", "updated_at", :discard_month => true) 
     1311    assert_dom_equal expected, datetime_select("post", "updated_at", :discard_month => true) 
    13121312  end 
    13131313 
     
    13281328    expected << "</select>\n" 
    13291329 
    1330     assert_equal expected, datetime_select("post", "updated_at", :discard_year => true, :discard_month => true) 
     1330    assert_dom_equal expected, datetime_select("post", "updated_at", :discard_year => true, :discard_month => true) 
    13311331  end 
    13321332 
     
    13551355    expected << "</select>\n" 
    13561356 
    1357     assert_equal expected, datetime_select("post", "updated_at", :order => [:minute, :day, :hour, :month, :year, :second]) 
     1357    assert_dom_equal expected, datetime_select("post", "updated_at", :order => [:minute, :day, :hour, :month, :year, :second]) 
    13581358  end 
    13591359 
     
    13801380    expected << "</select>\n" 
    13811381 
    1382     assert_equal expected, datetime_select("post", "updated_at", :order => [:day, :month]) 
     1382    assert_dom_equal expected, datetime_select("post", "updated_at", :order => [:day, :month]) 
    13831383  end 
    13841384 
     
    14071407    expected << "</select>\n" 
    14081408 
    1409     assert_equal expected, datetime_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35)) 
     1409    assert_dom_equal expected, datetime_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35)) 
    14101410  end 
    14111411 
     
    14271427    expected << "</select>\n" 
    14281428 
    1429     assert_equal expected, date_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true) 
     1429    assert_dom_equal expected, date_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true) 
    14301430  end 
    14311431 
     
    14541454    expected << "</select>\n" 
    14551455 
    1456     assert_equal expected, datetime_select("post", "updated_at", :default => { :month => 10, :minute => 42, :hour => 9 }) 
     1456    assert_dom_equal expected, datetime_select("post", "updated_at", :default => { :month => 10, :minute => 42, :hour => 9 }) 
    14571457  end 
    14581458end