shway 3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. data/CHANGELOG +11 -0
  2. data/Manifest +41 -0
  3. data/README +14 -0
  4. data/Rakefile +47 -0
  5. data/init.rb +2 -0
  6. data/install.rb +0 -0
  7. data/install_files/javascripts/iepngfix.htc +193 -0
  8. data/install_files/javascripts/iepngfix_tilebg.js +155 -0
  9. data/install_files/stylesheets/reset.css +47 -0
  10. data/install_files/templates/example_presenter.rb +12 -0
  11. data/install_files/templates/example_stylesheet.css.rb +20 -0
  12. data/lib/rubygems/commands/shway_init_command.rb +112 -0
  13. data/lib/rubygems_plugin.rb +3 -0
  14. data/lib/shway/controllers/shway_controller.rb +22 -0
  15. data/lib/shway/css/css_helper.rb +221 -0
  16. data/lib/shway/css/css_parser.rb +155 -0
  17. data/lib/shway/css/css_styles.rb +368 -0
  18. data/lib/shway/extensions/routing_extensions.rb +22 -0
  19. data/lib/shway/helpers/html_helper.rb +54 -0
  20. data/lib/shway/helpers/shway_controller_helper.rb +51 -0
  21. data/lib/shway/helpers/shway_helper.rb +187 -0
  22. data/lib/shway/presenters/shway_model_presenter.rb +10 -0
  23. data/lib/shway/presenters/shway_presenter.rb +184 -0
  24. data/lib/shway/test/shway_test_helper.rb +78 -0
  25. data/lib/shway.rb +129 -0
  26. data/shway.gemspec +31 -0
  27. data/templates/css.html.erb +3 -0
  28. data/templates/css.rhtml +3 -0
  29. data/test/shway_core/css_config_test.rb +186 -0
  30. data/test/shway_core/css_helper_test.rb +655 -0
  31. data/test/shway_core/css_parser_test.rb +219 -0
  32. data/test/shway_core/html_helper_test.rb +32 -0
  33. data/test/shway_core/shway_controller_test.rb +44 -0
  34. data/test/shway_core/shway_core_test_helper.rb +45 -0
  35. data/test/shway_core/shway_helper_test.rb +280 -0
  36. data/test/shway_core/shway_presenter_test.rb +173 -0
  37. data/test/shway_core/shway_routes_test.rb +31 -0
  38. data/test/shway_core/views/mock_foos/_list_header.html.erb +1 -0
  39. data/test/shway_core/views/mock_foos/_list_item.html.erb +5 -0
  40. data/test/shway_core/views/model_list/list_for_action.html.erb +1 -0
  41. data/test/shway_core/views/model_list/list_item_for_action.html.erb +1 -0
  42. data/test/shway_core/views/shway_helper_test.html.erb +24 -0
  43. metadata +123 -0
@@ -0,0 +1,655 @@
1
+ require File.join(File.dirname(__FILE__), 'shway_test_helper')
2
+
3
+ class CssHelperTest < Test::Unit::TestCase
4
+
5
+ include Shway::Css::CssHelper
6
+ include Shway::Helpers::ShwayHelper
7
+ include Shway::Helpers::ShwayControllerHelper
8
+
9
+ def test_can_set_and_get_css_style
10
+ set_valid_simple_style
11
+ retreived_style = get_css_style valid_simple_style_name
12
+ assert_styles_equal expected_valid_simple_style, retreived_style
13
+ end
14
+
15
+ def test_can_set_and_get_merged_css_styles
16
+ CssStyles.css_style valid_merged_style_name, valid_simple_style_hash, valid_complex_style_hash
17
+ retreived_style = get_css_style valid_merged_style_name
18
+ assert_styles_equal expected_valid_merged_style, retreived_style
19
+ end
20
+
21
+ def test_can_set_and_get_browser_css_styles
22
+ CssStyles.css_style valid_browser_style_name, valid_browser_style_hash
23
+ retreived_main_style = get_css_style valid_browser_style_name
24
+ assert_styles_equal expected_valid_browser_main_style, retreived_main_style
25
+
26
+ retreived_ie7_style = CssStyles.get_css_style valid_browser_style_name, :ie7
27
+ assert_styles_equal expected_valid_browser_ie7_style, retreived_ie7_style
28
+
29
+ retreived_ie6_style = CssStyles.get_css_style valid_browser_style_name, :ie6
30
+ assert_styles_equal expected_valid_browser_ie6_style, retreived_ie6_style
31
+
32
+ retreived_safari_style = CssStyles.get_css_style valid_browser_style_name, :safari
33
+ assert_styles_equal expected_valid_browser_safari_style, retreived_safari_style
34
+ end
35
+
36
+ def test_setting_css_styles_without_name_raises
37
+ assert_raise RuntimeError do
38
+ CssStyles.css_style(:arbitrary_key => :arbitrary_value)
39
+ end
40
+ end
41
+
42
+ def test_generating_or_setting_css_styles_with_main_hash_raises
43
+ assert_raise RuntimeError do
44
+ CssStyles.css_style(:css_style_with_main_hash, :main => {:arbitrary_key => :arbitrary_value})
45
+ end
46
+ assert_raise RuntimeError do
47
+ css_for_hash(:main => {:arbitrary_key => :arbitrary_value})
48
+ end
49
+ end
50
+
51
+ def test_generating_css_for_browser_styles_raises
52
+ set_valid_value
53
+ assert_raise RuntimeError do
54
+ css_for_hash(valid_browser_style_hash)
55
+ end
56
+ end
57
+
58
+ def test_generating_or_setting_css_for_a_non_ie6_hash_with_alpha_filter_raises
59
+ assert_raise RuntimeError do
60
+ css_for_hash(valid_alpha_filter_style_hash[:ie6])
61
+ end
62
+ assert_raise RuntimeError do
63
+ CssStyles.css_style(:main_style_with_alpha_filter, valid_alpha_filter_style_hash[:ie6])
64
+ end
65
+ assert_raise RuntimeError do
66
+ CssStyles.css_style(:ie_style_with_alpha_filter, :ie7 => valid_alpha_filter_style_hash[:ie6])
67
+ end
68
+ assert_raise RuntimeError do
69
+ CssStyles.css_style(:safari_style_with_alpha_filter, :safari => valid_alpha_filter_style_hash[:ie6])
70
+ end
71
+ end
72
+
73
+ def test_setting_css_style_with_alpha_filter_and_no_background_raises
74
+ assert_raise RuntimeError do
75
+ CssStyles.css_style(:alpha_filter_and_no_background_hash, alpha_filter_and_no_background_hash)
76
+ end
77
+ end
78
+
79
+ def test_setting_css_style_with_alpha_filter_and_invalid_background_raises
80
+ assert_raise RuntimeError do
81
+ CssStyles.css_style(:alpha_filter_and_invalid_background_hash, alpha_filter_and_invalid_background_hash)
82
+ end
83
+ end
84
+
85
+ def test_setting_css_style_with_alpha_filter_assigns_correct_values
86
+ CssStyles.css_style(:valid_alpha_filter_style_hash, valid_alpha_filter_style_hash)
87
+ main_style = CssStyles.get_css_style(:valid_alpha_filter_style_hash)
88
+ ie6_style = CssStyles.get_css_style(:valid_alpha_filter_style_hash, :ie6)
89
+ assert_contains ie6_style, 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='
90
+ assert_contains ie6_style, 'background-image:none;'
91
+ assert_contains main_style, 'background:'
92
+ end
93
+
94
+ def test_simple_hash_generates_expected_css
95
+ style = css_for_hash(valid_simple_style_hash)
96
+ assert_styles_equal expected_valid_simple_style, style
97
+ end
98
+
99
+ def test_complex_hash_generates_expected_css
100
+ set_valid_value
101
+ style = css_for_hash(valid_complex_style_hash)
102
+ assert_styles_equal expected_valid_complex_style, style
103
+ end
104
+
105
+ def test_tag_style_with_pseudo_classes_generates_expected_css
106
+ CssStyles.css_style :valid_tag_style_with_pseudo_classes, valid_tag_style_with_pseudo_classes
107
+
108
+ page = css_page_for_filename('global-main.css')
109
+
110
+ assert_not_nil page.index('.valid_tag_style_with_pseudo_classes {font-weight:bold;}')
111
+ assert_not_nil page.index('.valid_tag_style_with_pseudo_classes a:link {text-decoration:none;}')
112
+ assert_not_nil page.index('.valid_tag_style_with_pseudo_classes a:visited {text-decoration:none;}')
113
+ assert_not_nil page.index('.valid_tag_style_with_pseudo_classes a:active {text-decoration:underline;}')
114
+ assert_not_nil page.index('.valid_tag_style_with_pseudo_classes a:hover {text-decoration:underline;}')
115
+ end
116
+
117
+ def test_generating_css_for_hash_with_id_raises
118
+ assert_raise RuntimeError do
119
+ css_for_hash(valid_simple_style_hash.merge(:id => "test_id"))
120
+ end
121
+ end
122
+
123
+ def test_generating_css_for_hash_with_class_raises
124
+ assert_raise RuntimeError do
125
+ css_for_hash(valid_simple_style_hash.merge(:class => "test_class"))
126
+ end
127
+ end
128
+
129
+ def test_can_set_and_get_css_value
130
+ set_valid_value
131
+ retreived_value = get_css_value valid_value_name
132
+ assert_equal valid_value, retreived_value
133
+ end
134
+
135
+ def test_getting_invalid_css_style_raises
136
+ assert_raise RuntimeError do
137
+ get_css_style invalid_style_name
138
+ end
139
+ end
140
+
141
+ def test_getting_invalid_value_returns_to_s
142
+ value = get_css_value(invalid_value_name)
143
+ expected_value = invalid_value_name.to_s.dasherize
144
+ assert_equal expected_value, value
145
+ end
146
+
147
+ def test_simple_div_generates_expected_html
148
+ set_response_body simple_div
149
+ assert_select simple_div_selector
150
+ end
151
+
152
+ def test_complex_div_generates_expected_html
153
+ set_response_body complex_div
154
+ assert_select complex_div_selector
155
+ end
156
+
157
+ def test_div_with_class_generates_expected_html
158
+ set_response_body div_with_class
159
+ assert_select div_with_class_selector
160
+ end
161
+
162
+ def test_div_with_no_class_or_name_generates_expected_html
163
+ set_response_body div_with_no_class_or_name
164
+ assert_select div_with_no_class_or_name_selector
165
+ assert_response_does_not_contain 'class='
166
+ end
167
+
168
+ def test_setting_id_and_other_options_generates_expected_html
169
+ html = div(:id => :div_with_id_display_and_color, :display => :none, :color => :black)
170
+ set_response_body html
171
+ assert_select div_with_id_display_and_color
172
+ end
173
+
174
+ def div_with_id_display_and_color
175
+ %{div[id="div_with_id_display_and_color"][style*="display:none"][style*="color:black"]}
176
+ end
177
+
178
+ def test_div_with_class_and_name_raises
179
+ set_valid_simple_style
180
+ assert_raise RuntimeError do
181
+ div_with_class_and_name
182
+ end
183
+ end
184
+
185
+ def test_id_and_class_attribute_helpers_generate_expected_output
186
+ assert_equal 'id="test_id"', id_att(:test_id)
187
+ assert_equal 'id="test_id"', id_att('test_id')
188
+ assert_equal 'class="test_class"', class_att(:test_class)
189
+ assert_equal 'class="test_class"', class_att('test_class')
190
+ end
191
+
192
+ def test_hashes_to_style_tag_generates_expected_output
193
+ styletag = hashes_to_style_tag(:test_one => {:margin => 0}, :test_two => {:margin => 10})
194
+ assert_equal '<style>#test_one{margin:0px;}#test_two{margin:10px;}</style>', styletag
195
+ styletag_ie6 = hashes_to_style_tag(true, :test_ie6_one => {:margin => 5}, :test_ie6_two => {:margin => 15})
196
+ assert_equal '<!--[if lt IE 7]><style>#test_ie6_one{margin:5px;}#test_ie6_two{margin:15px;}</style><![endif]-->', styletag_ie6
197
+ end
198
+
199
+ def test_generating_css_for_hash_with_selectors_generates_expected_css
200
+ style = css_for_hash ".?_style_one .?_style_two", :test_with_selectors, :margin => 0
201
+ expected_style = ".test_with_selectors_style_one,.test_with_selectors_style_two { margin:0px; }"
202
+ assert_styles_equal expected_style, style
203
+ end
204
+
205
+ #css_html = style_tag_for_css(*style_args)
206
+
207
+ def test_can_set_and_get_css_config
208
+ set_valid_simple_config
209
+ retreived_config = get_css_config valid_simple_config_name
210
+ assert_configs_equal valid_simple_config_hash, retreived_config
211
+ end
212
+
213
+ def test_can_merge_with_existing_css_configs
214
+ set_valid_value
215
+ CssStyles.css_config valid_merged_config_name, valid_simple_config_hash
216
+ CssStyles.css_config valid_merged_config_name, valid_complex_config_hash
217
+ retreived_config = get_css_config valid_merged_config_name
218
+ assert_configs_equal expected_merged_config_hash, retreived_config
219
+ end
220
+
221
+ def test_getting_undefined_config_raises
222
+ assert_raise RuntimeError do
223
+ get_css_config(:undefined_config_name)
224
+ end
225
+ end
226
+
227
+ def test_expand_css_array_yields_expected_results
228
+ one_value_array = [:one]
229
+ two_value_array = [:one,:two]
230
+ three_value_array = [:one,:two,:three]
231
+ four_value_array = [:one,:two,:three,:four]
232
+ five_value_array = [:one,:two,:three,:four, :five]
233
+ assert_equal expand_css_array(one_value_array), [:one,:one,:one,:one]
234
+ assert_equal expand_css_array(two_value_array), [:one,:two,:one,:two]
235
+ assert_equal expand_css_array(three_value_array), [:one,:two,:three,:two]
236
+ assert_equal expand_css_array(four_value_array), [:one,:two,:three,:four]
237
+ assert_equal expand_css_array(five_value_array), [:one,:two,:three,:four]
238
+ end
239
+
240
+ private
241
+
242
+ def assert_contains(search_this_string, for_this_string)
243
+ assert_not_nil search_this_string.index(for_this_string)
244
+ end
245
+
246
+ def assert_styles_equal(expected_style, actual_style)
247
+ assert_equal expected_style.gsub("\n",' ').squeeze.strip, actual_style.gsub("\n",' ').squeeze.strip
248
+ end
249
+
250
+ def assert_configs_equal(expected_config, actual_config)
251
+ assert_equal expected_config, actual_config
252
+ end
253
+
254
+ def assert_response_does_not_contain(string)
255
+ flunk "The response should not contain '#{string}', but it does." if @response.body.index string
256
+ end
257
+
258
+ def invalid_style_name
259
+ :invalid_style_name
260
+ end
261
+
262
+ def set_valid_simple_style
263
+ CssStyles.css_style valid_simple_style_name, valid_simple_style_hash
264
+ end
265
+
266
+ def valid_simple_style_name
267
+ :valid_style_name
268
+ end
269
+
270
+ def valid_simple_style_hash
271
+ {
272
+ :border => '1px solid black',
273
+ :font_size => 12,
274
+ :font_weight => :normal,
275
+ }
276
+ end
277
+
278
+ def expected_valid_simple_style
279
+ %{
280
+ border:1px solid black;
281
+ font-size:12px;
282
+ font-weight:normal;
283
+ }
284
+ end
285
+
286
+ def simple_div
287
+ set_valid_simple_style
288
+ div valid_simple_style_name, :id => :simple_div
289
+ end
290
+
291
+ def simple_div_selector
292
+ %{div[class="#{valid_simple_style_name}"][id="simple_div"]}
293
+ end
294
+
295
+ def set_valid_complex_style
296
+ CssStyles.css_style valid_complex_style_name, valid_complex_style_hash
297
+ end
298
+
299
+ def valid_complex_style_name
300
+ :valid_complex_style_name
301
+ end
302
+
303
+ def valid_complex_style_hash
304
+ {
305
+ :margin => [2,5],
306
+ :padding => [5,10],
307
+ :margin_bottom => 10,
308
+ :padding_top => 0,
309
+ :font_size => 24,
310
+ :z_index => 22,
311
+ :font_weight => :bold,
312
+ :test_value => valid_value_name,
313
+ }
314
+ end
315
+
316
+ def expected_valid_complex_style
317
+ %{
318
+ font-size:24px;
319
+ font-weight:bold;
320
+ margin:2px 5px;
321
+ margin-bottom:10px;
322
+ padding:5px 10px;
323
+ padding-top:0px;
324
+ test-value:#{valid_value};
325
+ z-index:2;
326
+ }
327
+ end
328
+
329
+ def valid_tag_style_with_pseudo_classes
330
+ {
331
+ :font_weight => :bold,
332
+ :link => {:text_decoration => 'none'},
333
+ :visited => {:text_decoration => 'none'},
334
+ :active => {:text_decoration => 'underline'},
335
+ :hover => {:text_decoration => 'underline'},
336
+ }
337
+ end
338
+
339
+ def expected_tag_style_with_pseudo_classes
340
+ %{
341
+ font-weight:bold;
342
+ }
343
+ end
344
+
345
+ def complex_div
346
+ set_valid_complex_style
347
+ div valid_complex_style_name, :id => :complex_div, :display => :none, :margin_bottom => 10
348
+ end
349
+
350
+ def complex_div_selector
351
+ %{div[class="#{valid_complex_style_name}"][id="complex_div"][style*="display:none"][style*="margin-bottom:10px"]}
352
+ end
353
+
354
+ def div_with_class
355
+ div :id => :div_with_class, :class => :non_shway_css_class, :display => :none, :margin_bottom => 10
356
+ end
357
+
358
+ def div_with_class_selector
359
+ %{div[class="non_shway_css_class"][id="div_with_class"][style*="display:none"][style*="margin-bottom:10px"]}
360
+ end
361
+
362
+ def div_with_no_class_or_name
363
+ div :id => :div_with_no_class_or_name, :display => :none, :margin_bottom => 10
364
+ end
365
+
366
+ def div_with_no_class_or_name_selector
367
+ %{div[id="div_with_no_class_or_name"][style*="display:none"][style*="margin-bottom:10px"]}
368
+ end
369
+
370
+ def div_with_class_and_name
371
+ div valid_simple_style_name, :class => :div_with_class_and_name
372
+ end
373
+
374
+ def valid_browser_style_name
375
+ :valid_browser_style_name
376
+ end
377
+
378
+ def valid_browser_style_hash
379
+ {
380
+ :test => 'TEST_MAIN',
381
+ :safari => {
382
+ :test => 'TEST_SAFARI',
383
+ },
384
+ :ie6 => {
385
+ :test => 'TEST_IE6',
386
+ :test_2 => 'TEST_2_IE6',
387
+ # :alpha_filter => true,
388
+ },
389
+ :ie7 => {
390
+ :test => 'TEST_IE7',
391
+ :test_3 => 'TEST_3_IE7',
392
+ }
393
+ }
394
+ end
395
+
396
+ def valid_alpha_filter_style_hash
397
+ {
398
+ :background => "url(/images/image_name.png) no-repeat",
399
+ :ie6 => {
400
+ :alpha_filter => true,
401
+ }
402
+ }
403
+ end
404
+
405
+ def alpha_filter_and_no_background_hash
406
+ hash = valid_alpha_filter_style_hash.clone
407
+ hash.delete(:background)
408
+ hash
409
+ end
410
+
411
+ def alpha_filter_and_invalid_background_hash
412
+ hash = valid_alpha_filter_style_hash.clone
413
+ hash[:background] = 'invalid.png'
414
+ hash
415
+ end
416
+
417
+ def expected_valid_browser_main_style
418
+ %{
419
+ test:TEST_MAIN;
420
+ }
421
+ end
422
+
423
+ def expected_valid_browser_ie7_style
424
+ %{
425
+ test:TEST_IE7;
426
+ test-3:TEST_3_IE7;
427
+ }
428
+ end
429
+
430
+ def expected_valid_browser_ie6_style
431
+ %{
432
+ test:TEST_IE6;
433
+ test-2:TEST_2_IE6;
434
+ }
435
+ end
436
+
437
+ def expected_valid_browser_safari_style
438
+ %{
439
+ test:TEST_SAFARI;
440
+ }
441
+ end
442
+
443
+ def valid_merged_style_name
444
+ :valid_merged_style_name
445
+ end
446
+
447
+ def expected_valid_merged_style
448
+ %{
449
+ border:1px solid black;
450
+ font-size:24px;
451
+ font-weight:bold;
452
+ margin:2px 5px;
453
+ margin-bottom:10px;
454
+ padding:5px 10px;
455
+ padding-top:0px;
456
+ test-value:#{valid_value};
457
+ z-index:2;
458
+ }
459
+ end
460
+
461
+ def invalid_value_name
462
+ :invalid_value_name
463
+ end
464
+
465
+ def valid_value_name
466
+ :valid_value_name
467
+ end
468
+
469
+ def valid_value
470
+ "arbitrary value"
471
+ end
472
+
473
+ def valid_value_hash
474
+ { valid_value_name => valid_value }
475
+ end
476
+
477
+ def set_valid_value
478
+ CssStyles.value valid_value_hash
479
+ end
480
+
481
+
482
+ def set_valid_simple_config
483
+ CssStyles.css_config valid_simple_config_name, valid_simple_config_hash
484
+ end
485
+
486
+ def valid_simple_config_name
487
+ :valid_config_name
488
+ end
489
+
490
+ def valid_simple_config_hash
491
+ {
492
+ :image => 'images/whatever.gif',
493
+ :width => 100,
494
+ :height => 24,
495
+ }
496
+ end
497
+
498
+ def set_valid_complex_config
499
+ CssStyles.css_config valid_complex_config_name, valid_complex_config_hash
500
+ end
501
+
502
+ def valid_complex_config_name
503
+ :valid_complex_config_name
504
+ end
505
+
506
+ def valid_complex_config_hash
507
+ {
508
+ :data => ["DATA 1","DATA 2","DATA 3"],
509
+ :height => 999,
510
+ :test_value => valid_value_name,
511
+ }
512
+ end
513
+
514
+ def valid_merged_config_name
515
+ :valid_complex_config_name
516
+ end
517
+
518
+ def expected_merged_config_hash
519
+ {
520
+ :data => ["DATA 1","DATA 2","DATA 3"],
521
+ :image => 'images/whatever.gif',
522
+ :width => 100,
523
+ :height => 999,
524
+ :test_value => valid_value,
525
+ }
526
+ end
527
+
528
+ # assert_dom_equal '<label for="post_body">Body</label>', label_for('post', 'body')
529
+ # assert_dom_equal '<label for="post_body" class="foo">Body</label>', label_for('post', 'body', {:class => :foo})
530
+ # assert_dom_equal '<label for="post_body" class="foo">Text</label>', label_for('post', 'body', {:class => :foo, :text => 'Text'})
531
+
532
+ # def test_labeled_form_for
533
+ # _erbout = ''
534
+ #
535
+ # labeled_form_for(:post, @post) do |f|
536
+ # _erbout.concat f.text_field(:title)
537
+ # _erbout.concat f.text_area(:body)
538
+ # _erbout.concat f.check_box(:secret)
539
+ # end
540
+ #
541
+ # expected =
542
+ # "<form action='http://www.example.com' method='post'>" +
543
+ # "<p><label for='post_title'>Title</label><br />" +
544
+ # "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /></p>" +
545
+ # "<p><label for='post_body'>Body</label><br />" +
546
+ # "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea></p>" +
547
+ # "<p><label for='post_secret'>Secret</label><br />" +
548
+ # "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
549
+ # "<input name='post[secret]' type='hidden' value='0' /></p>" +
550
+ # "</form>"
551
+ #
552
+ # assert_dom_equal expected, _erbout
553
+ # end
554
+ #
555
+ # def test_labeled_form_for_with_single_argument
556
+ # _erbout = ''
557
+ #
558
+ # labeled_form_for(:post) do |f|
559
+ # _erbout.concat f.text_field(:title)
560
+ # _erbout.concat f.text_area(:body)
561
+ # _erbout.concat f.check_box(:secret)
562
+ # end
563
+ #
564
+ # expected =
565
+ # "<form action='http://www.example.com' method='post'>" +
566
+ # "<p><label for='post_title'>Title</label><br />" +
567
+ # "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /></p>" +
568
+ # "<p><label for='post_body'>Body</label><br />" +
569
+ # "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea></p>" +
570
+ # "<p><label for='post_secret'>Secret</label><br />" +
571
+ # "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
572
+ # "<input name='post[secret]' type='hidden' value='0' /></p>" +
573
+ # "</form>"
574
+ #
575
+ # assert_dom_equal expected, _erbout
576
+ # end
577
+ #
578
+ # def test_labeled_form_for_and_fields_for
579
+ # _erbout = ''
580
+ #
581
+ # labeled_form_for(:post, @post) do |post_form|
582
+ # _erbout.concat post_form.text_field(:title)
583
+ # _erbout.concat post_form.text_area(:body)
584
+ #
585
+ # post_form.fields_for(:parent_post, @post) do |parent_fields|
586
+ # _erbout.concat parent_fields.check_box(:secret)
587
+ # end
588
+ # end
589
+ #
590
+ # expected =
591
+ # "<form action='http://www.example.com' method='post'>" +
592
+ # "<p><label for='post_title'>Title</label><br />" +
593
+ # "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /></p>" +
594
+ # "<p><label for='post_body'>Body</label><br />" +
595
+ # "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea></p>" +
596
+ # "<p><label for='parent_post_secret'>Secret</label><br />" +
597
+ # "<input name='parent_post[secret]' checked='checked' type='checkbox' id='parent_post_secret' value='1' />" +
598
+ # "<input name='parent_post[secret]' type='hidden' value='0' /></p>" +
599
+ # "</form>"
600
+ #
601
+ # assert_dom_equal expected, _erbout
602
+ # end
603
+ #
604
+ # def test_labeled_fields_for
605
+ # _erbout = ''
606
+ #
607
+ # labeled_fields_for(:post, @post) do |f|
608
+ # _erbout.concat f.text_field(:title)
609
+ # _erbout.concat f.text_area(:body)
610
+ # _erbout.concat f.check_box(:secret)
611
+ # end
612
+ #
613
+ # expected =
614
+ # "<p><label for='post_title'>Title</label><br />" +
615
+ # "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /></p>" +
616
+ # "<p><label for='post_body'>Body</label><br />" +
617
+ # "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea></p>" +
618
+ # "<p><label for='post_secret'>Secret</label><br />" +
619
+ # "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
620
+ # "<input name='post[secret]' type='hidden' value='0' /></p>"
621
+ #
622
+ # assert_dom_equal expected, _erbout
623
+ # end
624
+ #
625
+ # def test_labeled_fields_for_with_single_attribute
626
+ # _erbout = ''
627
+ #
628
+ # labeled_fields_for(:post) do |f|
629
+ # _erbout.concat f.text_field(:title)
630
+ # _erbout.concat f.text_area(:body)
631
+ # _erbout.concat f.check_box(:secret)
632
+ # end
633
+ #
634
+ # expected =
635
+ # "<p><label for='post_title'>Title</label><br />" +
636
+ # "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /></p>" +
637
+ # "<p><label for='post_body'>Body</label><br />" +
638
+ # "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea></p>" +
639
+ # "<p><label for='post_secret'>Secret</label><br />" +
640
+ # "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
641
+ # "<input name='post[secret]' type='hidden' value='0' /></p>"
642
+ #
643
+ # assert_dom_equal expected, _erbout
644
+ # end
645
+ #
646
+ # # form tag helpers
647
+ # def test_label_tag
648
+ # assert_dom_equal %(<label for="title">Page Title</label>), label_tag('title', 'Page Title')
649
+ # end
650
+ #
651
+ # def test_label_tag_with_class
652
+ # assert_dom_equal %(<label for="title" class="frm_txt">Page Title</label>), label_tag('title', 'Page Title', :class => 'frm_txt')
653
+ # end
654
+
655
+ end