padrino-helpers 0.10.5 → 0.10.6.a
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.
- data/lib/padrino-helpers/asset_tag_helpers.rb +3 -3
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +31 -0
- data/lib/padrino-helpers/form_helpers.rb +206 -19
- data/lib/padrino-helpers/format_helpers.rb +2 -2
- data/lib/padrino-helpers/tag_helpers.rb +160 -47
- data/test/fixtures/markup_app/views/form_for.erb +20 -4
- data/test/fixtures/markup_app/views/form_for.haml +15 -3
- data/test/fixtures/markup_app/views/form_for.slim +15 -3
- data/test/fixtures/markup_app/views/form_tag.erb +30 -0
- data/test/fixtures/markup_app/views/form_tag.haml +25 -0
- data/test/fixtures/markup_app/views/form_tag.slim +25 -0
- data/test/test_asset_tag_helpers.rb +0 -5
- data/test/test_form_builder.rb +114 -4
- data/test/test_form_helpers.rb +132 -7
- data/test/test_format_helpers.rb +2 -2
- data/test/test_tag_helpers.rb +4 -22
- metadata +32 -9
@@ -5,14 +5,30 @@
|
|
5
5
|
<%= f.label :username, :caption => "Login: ", :class => 'user-label' %>
|
6
6
|
<%= f.text_field :username, :class => 'user-text', :value => "John" %>
|
7
7
|
</p>
|
8
|
-
<p>
|
9
|
-
<%= f.label :email, :caption => "Email", :class => 'user-email' %>
|
10
|
-
<%= f.text_field :email %>
|
11
|
-
</p>
|
12
8
|
<p>
|
13
9
|
<%= f.label :password %>
|
14
10
|
<%= f.password_field :password, :class => 'user-password', :value => "secret" %>
|
15
11
|
</p>
|
12
|
+
<p>
|
13
|
+
<%= f.label :age %>
|
14
|
+
<%= f.number_field :age, :class => 'numeric '%>
|
15
|
+
</p>
|
16
|
+
<p>
|
17
|
+
<%= f.label :telephone %>
|
18
|
+
<%= f.telephone_field :telephone, :class => 'numeric' %>
|
19
|
+
</p>
|
20
|
+
<p>
|
21
|
+
<%= f.label :email, :caption => 'Email Address: ' %>
|
22
|
+
<%= f.email_field :email, :class => 'string' %>
|
23
|
+
</p>
|
24
|
+
<p>
|
25
|
+
<%= f.label :webpage, :caption => 'Your Web Page: ' %>
|
26
|
+
<%= f.url_field :webpage, :class => 'string' %>
|
27
|
+
</p>
|
28
|
+
<p>
|
29
|
+
<%= f.label :search %>
|
30
|
+
<%= f.search_field :search, :class => 'string' %>
|
31
|
+
</p>
|
16
32
|
<p>
|
17
33
|
<%= f.label :photo %>
|
18
34
|
<%= f.file_field :photo, :class => 'user-photo' %>
|
@@ -4,12 +4,24 @@
|
|
4
4
|
%p
|
5
5
|
= f.label :username, :caption => "Login: ", :class => 'user-label'
|
6
6
|
= f.text_field :username, :class => 'user-text', :value => "John"
|
7
|
-
%p
|
8
|
-
= f.label :email, :caption => "Email", :class => 'user-email'
|
9
|
-
= f.text_field :email
|
10
7
|
%p
|
11
8
|
= f.label :password
|
12
9
|
= f.password_field :password, :class => 'user-password', :value => "secret"
|
10
|
+
%p
|
11
|
+
= f.label :age
|
12
|
+
= f.number_field :age, :class => 'numeric'
|
13
|
+
%p
|
14
|
+
= f.label :telephone
|
15
|
+
= f.telephone_field :telephone, :class => 'numeric'
|
16
|
+
%p
|
17
|
+
= f.label :email, :caption => 'Email Address: '
|
18
|
+
= f.email_field :email, :class => 'string'
|
19
|
+
%p
|
20
|
+
= f.label :webpage, :caption => 'Your Web Page: '
|
21
|
+
= f.url_field :webpage, :class => 'string'
|
22
|
+
%p
|
23
|
+
= f.label :search
|
24
|
+
= f.search_field :search, :class => 'string'
|
13
25
|
%p
|
14
26
|
= f.label :photo
|
15
27
|
= f.file_field :photo, :class => 'user-photo'
|
@@ -4,12 +4,24 @@
|
|
4
4
|
p
|
5
5
|
== f.label :username, :caption => "Login: ", :class => 'user-label'
|
6
6
|
== f.text_field :username, :class => 'user-text', :value => "John"
|
7
|
-
p
|
8
|
-
== f.label :email, :caption => "Email", :class => 'user-email'
|
9
|
-
== f.text_field :email
|
10
7
|
p
|
11
8
|
== f.label :password
|
12
9
|
== f.password_field :password, :class => 'user-password', :value => "secret"
|
10
|
+
p
|
11
|
+
== f.label :age
|
12
|
+
== f.number_field :age, :class => 'numeric'
|
13
|
+
p
|
14
|
+
== f.label :telephone
|
15
|
+
== f.telephone_field :telephone, :class => 'numeric'
|
16
|
+
p
|
17
|
+
== f.label :email, :caption => 'Email Address: '
|
18
|
+
== f.email_field :email, :class => 'string'
|
19
|
+
p
|
20
|
+
== f.label :webpage, :caption => 'Your Web Page: '
|
21
|
+
== f.url_field :webpage, :class => 'string'
|
22
|
+
p
|
23
|
+
== f.label :search
|
24
|
+
== f.search_field :search, :class => 'string'
|
13
25
|
p
|
14
26
|
== f.label :photo
|
15
27
|
== f.file_field :photo, :class => 'user-photo'
|
@@ -5,6 +5,16 @@
|
|
5
5
|
<%= text_field_tag :username %>
|
6
6
|
<%= label_tag :password %>
|
7
7
|
<%= password_field_tag :password %>
|
8
|
+
<%= label_tag :email %>
|
9
|
+
<%= email_field_tag :email %>
|
10
|
+
<%= label_tag :age %>
|
11
|
+
<%= number_field_tag :age %>
|
12
|
+
<%= label_tag :telephone %>
|
13
|
+
<%= telephone_field_tag :telephone %>
|
14
|
+
<%= label_tag :webpage %>
|
15
|
+
<%= url_field_tag :webpage %>
|
16
|
+
<%= label_tag :search %>
|
17
|
+
<%= search_field_tag :search %>
|
8
18
|
<%= check_box_tag :remember_me %>
|
9
19
|
<%= label_tag :gender %>
|
10
20
|
<%= label_tag :color %>
|
@@ -27,6 +37,26 @@
|
|
27
37
|
<%= label_tag :password, :class => 'first' %>
|
28
38
|
<%= password_field_tag :password, :value => params[:password] %>
|
29
39
|
</p>
|
40
|
+
<p>
|
41
|
+
<%= label_tag :email, :caption => 'Email Address' %>
|
42
|
+
<%= email_field_tag :email, :class => 'string' %>
|
43
|
+
</p>
|
44
|
+
<p>
|
45
|
+
<%= label_tag :age, :class => 'age' %>
|
46
|
+
<%= number_field_tag :age, :class => 'numeric' %>
|
47
|
+
</p>
|
48
|
+
<p>
|
49
|
+
<%= label_tag :telephone, :class => 'telephone' %>
|
50
|
+
<%= telephone_field_tag :telephone, :class => 'numeric' %>
|
51
|
+
</p>
|
52
|
+
<p>
|
53
|
+
<%= label_tag :webpage, :caption => 'Your Home Page' %>
|
54
|
+
<%= url_field_tag :webpage, :class => 'string' %>
|
55
|
+
</p>
|
56
|
+
<p>
|
57
|
+
<%= label_tag :search %>
|
58
|
+
<%= search_field_tag :search, :class => 'string' %>
|
59
|
+
</p>
|
30
60
|
<p>
|
31
61
|
<%= label_tag :about, :class => 'about', :caption => "About Me" %>
|
32
62
|
<%= text_area_tag :about, :class => 'large' %>
|
@@ -6,6 +6,16 @@
|
|
6
6
|
= text_field_tag :username
|
7
7
|
= label_tag :password
|
8
8
|
= password_field_tag :password
|
9
|
+
= label_tag :email
|
10
|
+
= email_field_tag :email
|
11
|
+
= label_tag :age
|
12
|
+
= number_field_tag :age
|
13
|
+
= label_tag :telephone
|
14
|
+
= telephone_field_tag :telephone
|
15
|
+
= label_tag :webpage
|
16
|
+
= url_field_tag :webpage
|
17
|
+
= label_tag :search
|
18
|
+
= search_field_tag :search
|
9
19
|
= label_tag :color
|
10
20
|
= select_tag :color, :options => ['green', 'orange', 'purple']
|
11
21
|
= label_tag :gender
|
@@ -24,6 +34,21 @@
|
|
24
34
|
%p
|
25
35
|
= label_tag :password, :class => 'first'
|
26
36
|
= password_field_tag :password, :value => params[:password]
|
37
|
+
%p
|
38
|
+
= label_tag :email, :caption => 'Email Address'
|
39
|
+
= email_field_tag :email, :class => 'string'
|
40
|
+
%p
|
41
|
+
= label_tag :age, :class => 'age'
|
42
|
+
= number_field_tag :age, :class => 'numeric'
|
43
|
+
%p
|
44
|
+
= label_tag :telephone, :class => 'telephone'
|
45
|
+
= telephone_field_tag :telephone, :class => 'numeric'
|
46
|
+
%p
|
47
|
+
= label_tag :webpage, :caption => 'Your Home Page'
|
48
|
+
= url_field_tag :webpage, :class => 'string'
|
49
|
+
%p
|
50
|
+
= label_tag :search
|
51
|
+
= search_field_tag :search, :class => 'string'
|
27
52
|
%p
|
28
53
|
= label_tag :about, :class => 'about', :caption => "About Me"
|
29
54
|
= text_area_tag :about, :class => 'large'
|
@@ -6,6 +6,16 @@
|
|
6
6
|
== text_field_tag :username
|
7
7
|
== label_tag :password
|
8
8
|
== password_field_tag :password
|
9
|
+
== label_tag :email
|
10
|
+
== email_field_tag :email
|
11
|
+
== label_tag :age
|
12
|
+
== number_field_tag :age
|
13
|
+
== label_tag :telephone
|
14
|
+
== telephone_field_tag :telephone
|
15
|
+
== label_tag :webpage
|
16
|
+
== url_field_tag :webpage
|
17
|
+
== label_tag :search
|
18
|
+
== search_field_tag :search
|
9
19
|
== label_tag :color
|
10
20
|
== select_tag :color, :options => ['green', 'orange', 'purple']
|
11
21
|
== label_tag :gender
|
@@ -24,6 +34,21 @@
|
|
24
34
|
p
|
25
35
|
== label_tag :password, :class => 'first'
|
26
36
|
== password_field_tag :password, :value => params[:password]
|
37
|
+
p
|
38
|
+
== label_tag :email, :caption => 'Email Address'
|
39
|
+
== email_field_tag :email, :class => 'string'
|
40
|
+
p
|
41
|
+
== label_tag :age, :class => 'age'
|
42
|
+
== number_field_tag :age, :class => 'numeric'
|
43
|
+
p
|
44
|
+
== label_tag :telephone, :class => 'telephone'
|
45
|
+
== telephone_field_tag :telephone, :class => 'numeric'
|
46
|
+
p
|
47
|
+
== label_tag :webpage, :caption => 'Your Home Page'
|
48
|
+
== url_field_tag :webpage, :class => 'string'
|
49
|
+
p
|
50
|
+
== label_tag :search
|
51
|
+
== search_field_tag :search, :class => 'string'
|
27
52
|
p
|
28
53
|
== label_tag :about, :class => 'about', :caption => "About Me"
|
29
54
|
== text_area_tag :about, :class => 'large'
|
@@ -176,11 +176,6 @@ describe "AssetTagHelpers" do
|
|
176
176
|
self.class.expects(:asset_stamp).returns(false)
|
177
177
|
assert_has_tag('img', :src => "/absolute/pic.gif") { image_tag('/absolute/pic.gif') }
|
178
178
|
end
|
179
|
-
|
180
|
-
should "have xhtml convention tag" do
|
181
|
-
self.class.expects(:asset_stamp).returns(false)
|
182
|
-
assert_equal image_tag('/absolute/pic.gif'), '<img src="/absolute/pic.gif" />'
|
183
|
-
end
|
184
179
|
end
|
185
180
|
|
186
181
|
context 'for #stylesheet_link_tag method' do
|
data/test/test_form_builder.rb
CHANGED
@@ -199,7 +199,7 @@ describe "FormBuilder" do
|
|
199
199
|
assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
200
200
|
assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
|
201
201
|
assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
202
|
-
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'invalid'
|
202
|
+
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
203
203
|
end
|
204
204
|
|
205
205
|
should "display correct form in erb" do
|
@@ -212,7 +212,7 @@ describe "FormBuilder" do
|
|
212
212
|
assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
213
213
|
assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
|
214
214
|
assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
215
|
-
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'invalid'
|
215
|
+
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
216
216
|
end
|
217
217
|
|
218
218
|
should "display correct form in slim" do
|
@@ -225,7 +225,7 @@ describe "FormBuilder" do
|
|
225
225
|
assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
226
226
|
assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
|
227
227
|
assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
228
|
-
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'invalid'
|
228
|
+
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
229
229
|
end
|
230
230
|
end
|
231
231
|
|
@@ -325,6 +325,116 @@ describe "FormBuilder" do
|
|
325
325
|
end
|
326
326
|
end
|
327
327
|
|
328
|
+
context 'for #number_field method' do
|
329
|
+
should "display correct number field html" do
|
330
|
+
actual_html = standard_builder.number_field(:age, :class => 'numeric')
|
331
|
+
assert_has_tag('input.numeric[type=number]', :id => 'user_age', :name => 'user[age]') { actual_html }
|
332
|
+
end
|
333
|
+
|
334
|
+
should "display correct number field in haml" do
|
335
|
+
visit '/haml/form_for'
|
336
|
+
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
337
|
+
end
|
338
|
+
|
339
|
+
should "display correct number field in erb" do
|
340
|
+
visit '/erb/form_for'
|
341
|
+
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
342
|
+
end
|
343
|
+
|
344
|
+
should "display correct number field in slim" do
|
345
|
+
visit '/slim/form_for'
|
346
|
+
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
context 'for #telephone_field method' do
|
351
|
+
should "display correct telephone field html" do
|
352
|
+
actual_html = standard_builder.telephone_field(:telephone, :class => 'numeric')
|
353
|
+
assert_has_tag('input.numeric[type=tel]', :id => 'user_telephone', :name => 'user[telephone]') { actual_html }
|
354
|
+
end
|
355
|
+
|
356
|
+
should "display correct telephone field in haml" do
|
357
|
+
visit '/haml/form_for'
|
358
|
+
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
359
|
+
end
|
360
|
+
|
361
|
+
should "display correct telephone field in erb" do
|
362
|
+
visit '/erb/form_for'
|
363
|
+
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
364
|
+
end
|
365
|
+
|
366
|
+
should "display correct telephone field in slim" do
|
367
|
+
visit '/slim/form_for'
|
368
|
+
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
context 'for #search_field method' do
|
373
|
+
should "display correct search field html" do
|
374
|
+
actual_html = standard_builder.search_field(:search, :class => 'string')
|
375
|
+
assert_has_tag('input.string[type=search]', :id => 'user_search', :name => 'user[search]') { actual_html }
|
376
|
+
end
|
377
|
+
|
378
|
+
should "display correct search field in haml" do
|
379
|
+
visit '/haml/form_for'
|
380
|
+
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
381
|
+
end
|
382
|
+
|
383
|
+
should "display correct search field in erb" do
|
384
|
+
visit '/erb/form_for'
|
385
|
+
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
386
|
+
end
|
387
|
+
|
388
|
+
should "display correct search field in slim" do
|
389
|
+
visit '/slim/form_for'
|
390
|
+
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
context 'for #email_field method' do
|
395
|
+
should "display correct email field html" do
|
396
|
+
actual_html = standard_builder.email_field(:email, :class => 'string')
|
397
|
+
assert_has_tag('input.string[type=email]', :id => 'user_email', :name => 'user[email]') { actual_html }
|
398
|
+
end
|
399
|
+
|
400
|
+
should "display correct email field in haml" do
|
401
|
+
visit '/haml/form_for'
|
402
|
+
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
403
|
+
end
|
404
|
+
|
405
|
+
should "display correct email field in erb" do
|
406
|
+
visit '/erb/form_for'
|
407
|
+
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
408
|
+
end
|
409
|
+
|
410
|
+
should "display correct email field in slim" do
|
411
|
+
visit '/slim/form_for'
|
412
|
+
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
context 'for #url_field method' do
|
417
|
+
should "display correct url field html" do
|
418
|
+
actual_html = standard_builder.url_field(:webpage, :class => 'string')
|
419
|
+
assert_has_tag('input.string[type=url]', :id => 'user_webpage', :name => 'user[webpage]') { actual_html }
|
420
|
+
end
|
421
|
+
|
422
|
+
should "display correct url field in haml" do
|
423
|
+
visit '/haml/form_for'
|
424
|
+
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
425
|
+
end
|
426
|
+
|
427
|
+
should "display correct url field in erb" do
|
428
|
+
visit '/erb/form_for'
|
429
|
+
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
430
|
+
end
|
431
|
+
|
432
|
+
should "display correct url field in slim" do
|
433
|
+
visit '/slim/form_for'
|
434
|
+
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
328
438
|
context 'for #check_box method' do
|
329
439
|
should "display correct checkbox html" do
|
330
440
|
actual_html = standard_builder.check_box(:confirm_destroy, :class => 'large')
|
@@ -430,7 +540,7 @@ describe "FormBuilder" do
|
|
430
540
|
context 'for #text_area method' do
|
431
541
|
should "display correct text_area html" do
|
432
542
|
actual_html = standard_builder.text_area(:about, :class => 'large')
|
433
|
-
assert_has_tag('textarea.large', :id => 'user_about', :name => 'user[about]'
|
543
|
+
assert_has_tag('textarea.large', :id => 'user_about', :name => 'user[about]') { actual_html }
|
434
544
|
end
|
435
545
|
|
436
546
|
should "display correct text_area html and content" do
|
data/test/test_form_helpers.rb
CHANGED
@@ -193,14 +193,14 @@ describe "FormHelpers" do
|
|
193
193
|
|
194
194
|
should "display label tag in erb for simple form" do
|
195
195
|
visit '/erb/form_tag'
|
196
|
-
assert_have_selector 'form.simple-form label', :count =>
|
196
|
+
assert_have_selector 'form.simple-form label', :count => 9
|
197
197
|
assert_have_selector 'form.simple-form label', :content => "Username", :for => 'username'
|
198
198
|
assert_have_selector 'form.simple-form label', :content => "Password", :for => 'password'
|
199
199
|
assert_have_selector 'form.simple-form label', :content => "Gender", :for => 'gender'
|
200
200
|
end
|
201
201
|
should "display label tag in erb for advanced form" do
|
202
202
|
visit '/erb/form_tag'
|
203
|
-
assert_have_selector 'form.advanced-form label', :count =>
|
203
|
+
assert_have_selector 'form.advanced-form label', :count => 11
|
204
204
|
assert_have_selector 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
|
205
205
|
assert_have_selector 'form.advanced-form label.first', :content => "Password", :for => 'password'
|
206
206
|
assert_have_selector 'form.advanced-form label.about', :content => "About Me", :for => 'about'
|
@@ -210,7 +210,7 @@ describe "FormHelpers" do
|
|
210
210
|
|
211
211
|
should "display label tag in haml for simple form" do
|
212
212
|
visit '/haml/form_tag'
|
213
|
-
assert_have_selector 'form.simple-form label', :count =>
|
213
|
+
assert_have_selector 'form.simple-form label', :count => 9
|
214
214
|
assert_have_selector 'form.simple-form label', :content => "Username", :for => 'username'
|
215
215
|
assert_have_selector 'form.simple-form label', :content => "Password", :for => 'password'
|
216
216
|
assert_have_selector 'form.simple-form label', :content => "Gender", :for => 'gender'
|
@@ -218,7 +218,7 @@ describe "FormHelpers" do
|
|
218
218
|
|
219
219
|
should "display label tag in haml for advanced form" do
|
220
220
|
visit '/haml/form_tag'
|
221
|
-
assert_have_selector 'form.advanced-form label', :count =>
|
221
|
+
assert_have_selector 'form.advanced-form label', :count => 11
|
222
222
|
assert_have_selector 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
|
223
223
|
assert_have_selector 'form.advanced-form label.first', :content => "Password", :for => 'password'
|
224
224
|
assert_have_selector 'form.advanced-form label.about', :content => "About Me", :for => 'about'
|
@@ -228,7 +228,7 @@ describe "FormHelpers" do
|
|
228
228
|
|
229
229
|
should "display label tag in slim for simple form" do
|
230
230
|
visit '/slim/form_tag'
|
231
|
-
assert_have_selector 'form.simple-form label', :count =>
|
231
|
+
assert_have_selector 'form.simple-form label', :count => 9
|
232
232
|
assert_have_selector 'form.simple-form label', :content => "Username", :for => 'username'
|
233
233
|
assert_have_selector 'form.simple-form label', :content => "Password", :for => 'password'
|
234
234
|
assert_have_selector 'form.simple-form label', :content => "Gender", :for => 'gender'
|
@@ -236,7 +236,7 @@ describe "FormHelpers" do
|
|
236
236
|
|
237
237
|
should "display label tag in slim for advanced form" do
|
238
238
|
visit '/slim/form_tag'
|
239
|
-
assert_have_selector 'form.advanced-form label', :count =>
|
239
|
+
assert_have_selector 'form.advanced-form label', :count => 11
|
240
240
|
assert_have_selector 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
|
241
241
|
assert_have_selector 'form.advanced-form label.first', :content => "Password", :for => 'password'
|
242
242
|
assert_have_selector 'form.advanced-form label.about', :content => "About Me", :for => 'about'
|
@@ -295,10 +295,135 @@ describe "FormHelpers" do
|
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
298
|
+
context 'for #number_field_tag method' do
|
299
|
+
should "display number field in ruby" do
|
300
|
+
actual_html = number_field_tag(:age, :class => 'numeric')
|
301
|
+
assert_has_tag(:input, :type => 'number', :class => 'numeric', :name => 'age') { actual_html }
|
302
|
+
end
|
303
|
+
|
304
|
+
should "display number field in erb" do
|
305
|
+
visit '/erb/form_tag'
|
306
|
+
assert_have_selector 'form.simple-form input[type=number]', :count => 1, :name => 'age'
|
307
|
+
assert_have_selector 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric'
|
308
|
+
end
|
309
|
+
|
310
|
+
should "display number field in haml" do
|
311
|
+
visit '/haml/form_tag'
|
312
|
+
assert_have_selector 'form.simple-form input[type=number]', :count => 1, :name => 'age'
|
313
|
+
assert_have_selector 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric'
|
314
|
+
end
|
315
|
+
|
316
|
+
should "display number field in slim" do
|
317
|
+
visit '/slim/form_tag'
|
318
|
+
assert_have_selector 'form.simple-form input[type=number]', :count => 1, :name => 'age'
|
319
|
+
assert_have_selector 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric'
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
context 'for #telephone_field_tag method' do
|
324
|
+
should "display number field in ruby" do
|
325
|
+
actual_html = telephone_field_tag(:telephone, :class => 'numeric')
|
326
|
+
assert_has_tag(:input, :type => 'tel', :class => 'numeric', :name => 'telephone') { actual_html }
|
327
|
+
end
|
328
|
+
|
329
|
+
should "display telephone field in erb" do
|
330
|
+
visit '/erb/form_tag'
|
331
|
+
assert_have_selector 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone'
|
332
|
+
assert_have_selector 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric'
|
333
|
+
end
|
334
|
+
|
335
|
+
should "display telephone field in haml" do
|
336
|
+
visit '/haml/form_tag'
|
337
|
+
assert_have_selector 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone'
|
338
|
+
assert_have_selector 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric'
|
339
|
+
end
|
340
|
+
|
341
|
+
should "display telephone field in slim" do
|
342
|
+
visit '/slim/form_tag'
|
343
|
+
assert_have_selector 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone'
|
344
|
+
assert_have_selector 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric'
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
context 'for #search_field_tag method' do
|
349
|
+
should "display search field in ruby" do
|
350
|
+
actual_html = search_field_tag(:search, :class => 'string')
|
351
|
+
assert_has_tag(:input, :type => 'search', :class => 'string', :name => 'search') { actual_html }
|
352
|
+
end
|
353
|
+
|
354
|
+
should "display search field in erb" do
|
355
|
+
visit '/erb/form_tag'
|
356
|
+
assert_have_selector 'form.simple-form input[type=search]', :count => 1, :name => 'search'
|
357
|
+
assert_have_selector 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string'
|
358
|
+
end
|
359
|
+
|
360
|
+
should "display search field in haml" do
|
361
|
+
visit '/haml/form_tag'
|
362
|
+
assert_have_selector 'form.simple-form input[type=search]', :count => 1, :name => 'search'
|
363
|
+
assert_have_selector 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string'
|
364
|
+
end
|
365
|
+
|
366
|
+
should "display search field in slim" do
|
367
|
+
visit '/slim/form_tag'
|
368
|
+
assert_have_selector 'form.simple-form input[type=search]', :count => 1, :name => 'search'
|
369
|
+
assert_have_selector 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string'
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
context 'for #email_field_tag method' do
|
374
|
+
should "display email field in ruby" do
|
375
|
+
actual_html = email_field_tag(:email, :class => 'string')
|
376
|
+
assert_has_tag(:input, :type => 'email', :class => 'string', :name => 'email') { actual_html }
|
377
|
+
end
|
378
|
+
|
379
|
+
should "display email field in erb" do
|
380
|
+
visit '/erb/form_tag'
|
381
|
+
assert_have_selector 'form.simple-form input[type=email]', :count => 1, :name => 'email'
|
382
|
+
assert_have_selector 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string'
|
383
|
+
end
|
384
|
+
|
385
|
+
should "display email field in haml" do
|
386
|
+
visit '/haml/form_tag'
|
387
|
+
assert_have_selector 'form.simple-form input[type=email]', :count => 1, :name => 'email'
|
388
|
+
assert_have_selector 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string'
|
389
|
+
end
|
390
|
+
|
391
|
+
should "display email field in slim" do
|
392
|
+
visit '/slim/form_tag'
|
393
|
+
assert_have_selector 'form.simple-form input[type=email]', :count => 1, :name => 'email'
|
394
|
+
assert_have_selector 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string'
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
context 'for #url_field_tag method' do
|
399
|
+
should "display url field in ruby" do
|
400
|
+
actual_html = url_field_tag(:webpage, :class => 'string')
|
401
|
+
assert_has_tag(:input, :type => 'url', :class => 'string', :name => 'webpage') { actual_html }
|
402
|
+
end
|
403
|
+
|
404
|
+
should "display url field in erb" do
|
405
|
+
visit '/erb/form_tag'
|
406
|
+
assert_have_selector 'form.simple-form input[type=url]', :count => 1, :name => 'webpage'
|
407
|
+
assert_have_selector 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string'
|
408
|
+
end
|
409
|
+
|
410
|
+
should "display url field in haml" do
|
411
|
+
visit '/haml/form_tag'
|
412
|
+
assert_have_selector 'form.simple-form input[type=url]', :count => 1, :name => 'webpage'
|
413
|
+
assert_have_selector 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string'
|
414
|
+
end
|
415
|
+
|
416
|
+
should "display url field in slim" do
|
417
|
+
visit '/slim/form_tag'
|
418
|
+
assert_have_selector 'form.simple-form input[type=url]', :count => 1, :name => 'webpage'
|
419
|
+
assert_have_selector 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string'
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
298
423
|
context 'for #text_area_tag method' do
|
299
424
|
should "display text area in ruby" do
|
300
425
|
actual_html = text_area_tag(:about, :class => 'long')
|
301
|
-
assert_has_tag(:textarea, :class => "long", :name => 'about'
|
426
|
+
assert_has_tag(:textarea, :class => "long", :name => 'about') { actual_html }
|
302
427
|
end
|
303
428
|
|
304
429
|
should "display text area in ruby with specified content" do
|