speedo-formstrap 1.2.7 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/Gemfile +2 -2
  2. data/Gemfile.lock +67 -65
  3. data/README.md +12 -2
  4. data/Rakefile +1 -1
  5. data/VERSION +1 -1
  6. data/lib/formtastic-bootstrap.rb +1 -0
  7. data/lib/formtastic-bootstrap/actions.rb +4 -0
  8. data/lib/formtastic-bootstrap/actions/base.rb +18 -0
  9. data/lib/formtastic-bootstrap/actions/button_action.rb +7 -0
  10. data/lib/formtastic-bootstrap/actions/input_action.rb +7 -0
  11. data/lib/formtastic-bootstrap/actions/link_action.rb +7 -0
  12. data/lib/formtastic-bootstrap/form_builder.rb +7 -5
  13. data/lib/formtastic-bootstrap/helpers.rb +3 -1
  14. data/lib/formtastic-bootstrap/helpers/action_helper.rb +12 -0
  15. data/lib/formtastic-bootstrap/helpers/actions_helper.rb +23 -0
  16. data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +13 -9
  17. data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +11 -6
  18. data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +4 -4
  19. data/lib/formtastic-bootstrap/inputs/base.rb +2 -1
  20. data/lib/formtastic-bootstrap/inputs/base/choices.rb +12 -23
  21. data/lib/formtastic-bootstrap/inputs/base/labelling.rb +16 -6
  22. data/lib/formtastic-bootstrap/inputs/base/numeric.rb +18 -0
  23. data/lib/formtastic-bootstrap/inputs/base/timeish.rb +5 -12
  24. data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +32 -14
  25. data/lib/formtastic-bootstrap/inputs/boolean_input.rb +7 -11
  26. data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +10 -9
  27. data/lib/formtastic-bootstrap/inputs/hidden_input.rb +5 -3
  28. data/lib/formtastic-bootstrap/inputs/number_input.rb +2 -2
  29. data/lib/formtastic-bootstrap/inputs/radio_input.rb +13 -12
  30. data/lib/formtastic-bootstrap/inputs/range_input.rb +2 -2
  31. data/spec/actions/button_action_spec.rb +68 -0
  32. data/spec/actions/generic_action_spec.rb +486 -0
  33. data/spec/actions/input_action_spec.rb +64 -0
  34. data/spec/actions/link_action_spec.rb +93 -0
  35. data/spec/builder/semantic_fields_for_spec.rb +14 -14
  36. data/spec/helpers/action_helper_spec.rb +365 -0
  37. data/spec/helpers/actions_helper_spec.rb +143 -0
  38. data/spec/helpers/buttons_helper_spec.rb +55 -45
  39. data/spec/helpers/input_helper_spec.rb +188 -188
  40. data/spec/helpers/inputs_helper_spec.rb +116 -102
  41. data/spec/inputs/boolean_input_spec.rb +72 -44
  42. data/spec/inputs/check_boxes_input_spec.rb +108 -80
  43. data/spec/inputs/date_input_spec.rb +80 -14
  44. data/spec/inputs/datetime_input_spec.rb +12 -12
  45. data/spec/inputs/email_input_spec.rb +33 -5
  46. data/spec/inputs/file_input_spec.rb +33 -5
  47. data/spec/inputs/hidden_input_spec.rb +40 -12
  48. data/spec/inputs/number_input_spec.rb +126 -96
  49. data/spec/inputs/password_input_spec.rb +33 -5
  50. data/spec/inputs/phone_input_spec.rb +33 -5
  51. data/spec/inputs/radio_input_spec.rb +72 -44
  52. data/spec/inputs/range_input_spec.rb +93 -65
  53. data/spec/inputs/search_input_spec.rb +32 -5
  54. data/spec/inputs/select_input_spec.rb +123 -77
  55. data/spec/inputs/string_input_spec.rb +66 -21
  56. data/spec/inputs/text_input_spec.rb +40 -13
  57. data/spec/inputs/time_input_spec.rb +22 -22
  58. data/spec/inputs/time_zone_input_spec.rb +17 -17
  59. data/spec/inputs/url_input_spec.rb +33 -5
  60. data/spec/support/custom_macros.rb +59 -188
  61. data/spec/support/formtastic_spec_helper.rb +19 -3
  62. data/speedo-formstrap.gemspec +146 -0
  63. metadata +31 -16
@@ -20,8 +20,8 @@ describe 'date input' do
20
20
  end)
21
21
  end
22
22
 
23
- it_should_have_input_wrapper_with_class("date")
24
- it_should_have_input_wrapper_with_class(:clearfix)
23
+ it_should_have_input_wrapper_with_class("date-wrapper")
24
+ it_should_have_input_wrapper_with_class("control-group")
25
25
  it_should_have_input_wrapper_with_class(:stringish)
26
26
  it_should_have_input_class_in_the_right_place
27
27
  it_should_have_input_wrapper_with_id("post_publish_at_input")
@@ -31,7 +31,7 @@ describe 'date input' do
31
31
  it_should_apply_error_logic_for_input_type(:date)
32
32
 
33
33
  it 'should have a legend and label with the label text inside the fieldset' do
34
- output_buffer.should have_tag('form div.clearfix.date label', /Publish at/)
34
+ output_buffer.should have_tag('form div.control-group.date-wrapper label.control-label', /Publish at/)
35
35
  end
36
36
 
37
37
  # it 'should associate the legend label with the first select' do
@@ -42,8 +42,8 @@ describe 'date input' do
42
42
  # end
43
43
 
44
44
  it 'should (sort of) associate the label with the input' do
45
- output_buffer.should have_tag('form div.clearfix.date label[@for="post_publish_at"]')
46
- output_buffer.should have_tag('form div.clearfix.date div.input input[@id="post_publish_at[date]"]')
45
+ output_buffer.should have_tag('form div.control-group.date-wrapper label.control-label[@for="post_publish_at"]')
46
+ output_buffer.should have_tag('form div.control-group.date-wrapper div.controls input[@id="post_publish_at[date]"]')
47
47
  end
48
48
 
49
49
  # it 'should have an ordered list of three items inside the fieldset' do
@@ -58,7 +58,7 @@ describe 'date input' do
58
58
  # output_buffer.should have_tag('form li.date fieldset ol li label', /day/i)
59
59
  # end
60
60
  it 'should have an text input inside the div' do
61
- output_buffer.should have_tag('form div.clearfix.date div.input input[@type="text"]')
61
+ output_buffer.should have_tag('form div.control-group.date-wrapper div.controls input[@type="text"]')
62
62
  end
63
63
 
64
64
  # it 'should have three selects for year, month and day' do
@@ -97,7 +97,7 @@ describe 'date input' do
97
97
  # output_buffer.should have_tag('form li.date fieldset ol li label', f == field ? /another #{f} label/i : /#{f}/i)
98
98
  # end
99
99
  # end
100
- #
100
+ #
101
101
  # it "should not display the label for the #{field} field when :labels[:#{field}] is blank" do
102
102
  # output_buffer.replace ''
103
103
  # concat(semantic_form_for(@new_post) do |builder|
@@ -108,7 +108,7 @@ describe 'date input' do
108
108
  # output_buffer.should have_tag('form li.date fieldset ol li label', /#{f}/i) unless field == f
109
109
  # end
110
110
  # end
111
- #
111
+ #
112
112
  # it "should not display the label for the #{field} field when :labels[:#{field}] is false" do
113
113
  # output_buffer.replace ''
114
114
  # concat(semantic_form_for(@new_post) do |builder|
@@ -119,21 +119,21 @@ describe 'date input' do
119
119
  # output_buffer.should have_tag('form li.date fieldset ol li label', /#{f}/i) unless field == f
120
120
  # end
121
121
  # end
122
- #
123
- # it "should not render unsafe HTML when :labels[:#{field}] is false" do
122
+ #
123
+ # it "should not render unsafe HTML when :labels[:#{field}] is false" do
124
124
  # output_buffer.replace ''
125
125
  # concat(semantic_form_for(@new_post) do |builder|
126
126
  # concat(builder.input(:created_at, :as => :time, :include_seconds => true, :labels => { field => false }))
127
127
  # end)
128
128
  # output_buffer.should_not include(">")
129
129
  # end
130
- #
130
+ #
131
131
  # end
132
132
  # end
133
-
133
+
134
134
  describe "when required" do
135
135
  it "should add the required attribute to the input's html options" do
136
- with_config :use_required_attribute, true do
136
+ with_config :use_required_attribute, true do
137
137
  concat(semantic_form_for(@new_post) do |builder|
138
138
  concat(builder.input(:title, :as => :date, :required => true))
139
139
  end)
@@ -143,5 +143,71 @@ describe 'date input' do
143
143
  end
144
144
  end
145
145
  end
146
-
146
+
147
+ # We use text field for dates
148
+
149
+ # describe "when order does not include day" do
150
+ # before do
151
+ # output_buffer.replace ''
152
+ # concat(semantic_form_for(@new_post) do |builder|
153
+ # concat(builder.input(:publish_at, :as => :date, :order => [:year, :month]))
154
+ # end)
155
+ # end
156
+ #
157
+ # it "should include a hidden input for day" do
158
+ # output_buffer.should have_tag('input[@type="hidden"][@name="post[publish_at(3i)]"][@value="1"]')
159
+ # end
160
+ #
161
+ # it "should not include a select for day" do
162
+ # output_buffer.should_not have_tag('select[@name="post[publish_at(3i)]"]')
163
+ # end
164
+ # end
165
+ #
166
+ # describe "when order does not include month" do
167
+ # before do
168
+ # output_buffer.replace ''
169
+ # concat(semantic_form_for(@new_post) do |builder|
170
+ # concat(builder.input(:publish_at, :as => :date, :order => [:year, :day]))
171
+ # end)
172
+ # end
173
+ #
174
+ # it "should include a hidden input for month" do
175
+ # output_buffer.should have_tag('input[@type="hidden"][@name="post[publish_at(2i)]"][@value="1"]')
176
+ # end
177
+ #
178
+ # it "should not include a select for month" do
179
+ # output_buffer.should_not have_tag('select[@name="post[publish_at(2i)]"]')
180
+ # end
181
+ # end
182
+ #
183
+ # describe "when order does not include year" do
184
+ # before do
185
+ # output_buffer.replace ''
186
+ # concat(semantic_form_for(@new_post) do |builder|
187
+ # concat(builder.input(:publish_at, :as => :date, :order => [:month, :day]))
188
+ # end)
189
+ # end
190
+ #
191
+ # it "should include a hidden input for month" do
192
+ # output_buffer.should have_tag("input[@type=\"hidden\"][@name=\"post[publish_at(1i)]\"][@value=\"#{Time.now.year}\"]")
193
+ # end
194
+ #
195
+ # it "should not include a select for month" do
196
+ # output_buffer.should_not have_tag('select[@name="post[publish_at(1i)]"]')
197
+ # end
198
+ # end
199
+ #
200
+ # describe "when order does not have year first" do
201
+ # before do
202
+ # output_buffer.replace ''
203
+ # concat(semantic_form_for(@new_post) do |builder|
204
+ # concat(builder.input(:publish_at, :as => :date, :order => [:day, :month, :year]))
205
+ # end)
206
+ # end
207
+ #
208
+ # it 'should associate the legend label with the new first select' do
209
+ # output_buffer.should have_tag('form li.date fieldset legend.label label[@for="post_publish_at_3i"]')
210
+ # end
211
+ # end
212
+
147
213
  end
@@ -21,8 +21,8 @@ describe 'datetime input' do
21
21
  end)
22
22
  end
23
23
 
24
- it_should_have_input_wrapper_with_class("datetime")
25
- it_should_have_input_wrapper_with_class(:clearfix)
24
+ it_should_have_input_wrapper_with_class("datetime-wrapper")
25
+ it_should_have_input_wrapper_with_class("control-group")
26
26
  it_should_have_input_wrapper_with_class(:stringish) # Decide about this.
27
27
  it_should_have_input_class_in_the_right_place
28
28
  it_should_have_input_wrapper_with_id("post_publish_at_input")
@@ -30,9 +30,9 @@ describe 'datetime input' do
30
30
  # it_should_have_a_nested_fieldset_with_class('fragments')
31
31
  # it_should_have_a_nested_ordered_list_with_class('fragments-group')
32
32
  it_should_apply_error_logic_for_input_type(:datetime)
33
-
33
+
34
34
  it 'should have a legend and label with the label text inside the fieldset' do
35
- output_buffer.should have_tag('form div.clearfix.datetime label', /Publish at/)
35
+ output_buffer.should have_tag('form div.control-group.datetime-wrapper label.control-label', /Publish at/)
36
36
  end
37
37
 
38
38
  # it 'should associate the legend label with the first select' do
@@ -41,7 +41,7 @@ describe 'datetime input' do
41
41
  # output_buffer.should have_tag('form li.datetime fieldset legend.label label[@for]')
42
42
  # output_buffer.should have_tag('form li.datetime fieldset legend.label label[@for="post_publish_at_1i"]')
43
43
  # end
44
-
44
+
45
45
  # it 'should have an ordered list of five items inside the fieldset' do
46
46
  # output_buffer.should have_tag('form li.datetime fieldset ol.fragments-group')
47
47
  # output_buffer.should have_tag('form li.datetime fieldset ol li.fragment', :count => 5)
@@ -55,26 +55,26 @@ describe 'datetime input' do
55
55
  # output_buffer.should have_tag('form li.datetime fieldset ol li label', /hour/i)
56
56
  # output_buffer.should have_tag('form li.datetime fieldset ol li label', /min/i)
57
57
  # end
58
-
58
+
59
59
  # it 'should have five selects' do
60
60
  # output_buffer.should have_tag('form li.datetime fieldset ol li select', :count => 5)
61
61
  # end
62
62
 
63
63
  it 'should have two inputs' do
64
- output_buffer.should have_tag('form div.clearfix.datetime div.input input', :count => 2)
64
+ output_buffer.should have_tag('form div.control-group.datetime-wrapper div.controls input', :count => 2)
65
65
  end
66
66
 
67
67
  end
68
68
 
69
69
  describe "when namespace is provided" do
70
-
70
+
71
71
  before do
72
72
  output_buffer.replace ''
73
73
  concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
74
74
  concat(builder.input(:publish_at, :as => :datetime))
75
75
  end)
76
76
  end
77
-
77
+
78
78
  it_should_have_input_wrapper_with_id("context2_post_publish_at_input")
79
79
  it_should_have_input_with_id("context2_post_publish_at[date]")
80
80
  it_should_have_input_with_id("context2_post_publish_at[time]")
@@ -83,12 +83,12 @@ describe 'datetime input' do
83
83
  # it_should_have_select_with_id("context2_post_publish_at_3i")
84
84
  # it_should_have_select_with_id("context2_post_publish_at_4i")
85
85
  # it_should_have_select_with_id("context2_post_publish_at_5i")
86
-
86
+
87
87
  end
88
88
 
89
89
  describe "when required" do
90
90
  it "should add the required attribute to the input's html options" do
91
- with_config :use_required_attribute, true do
91
+ with_config :use_required_attribute, true do
92
92
  concat(semantic_form_for(@new_post) do |builder|
93
93
  concat(builder.input(:title, :as => :datetime, :required => true))
94
94
  end)
@@ -97,5 +97,5 @@ describe 'datetime input' do
97
97
  end
98
98
  end
99
99
  end
100
-
100
+
101
101
  end
@@ -18,8 +18,8 @@ describe 'email input' do
18
18
  end)
19
19
  end
20
20
 
21
- it_should_have_input_wrapper_with_class(:email)
22
- it_should_have_input_wrapper_with_class(:clearfix)
21
+ it_should_have_input_wrapper_with_class('email-wrapper')
22
+ it_should_have_input_wrapper_with_class("control-group")
23
23
  it_should_have_input_wrapper_with_class(:stringish)
24
24
  it_should_have_input_class_in_the_right_place
25
25
  it_should_have_input_wrapper_with_id("post_email_input")
@@ -43,10 +43,38 @@ describe 'email input' do
43
43
  it_should_have_label_and_input_with_id("context2_post_email")
44
44
 
45
45
  end
46
-
46
+
47
+ describe "when index is provided" do
48
+
49
+ before do
50
+ @output_buffer = ''
51
+ mock_everything
52
+
53
+ concat(semantic_form_for(@new_post) do |builder|
54
+ concat(builder.fields_for(:author, :index => 3) do |author|
55
+ concat(author.input(:name, :as => :email))
56
+ end)
57
+ end)
58
+ end
59
+
60
+ it 'should index the id of the wrapper' do
61
+ output_buffer.should have_tag("div#post_author_attributes_3_name_input")
62
+ end
63
+
64
+ it 'should index the id of the select tag' do
65
+ output_buffer.should have_tag("input#post_author_attributes_3_name")
66
+ end
67
+
68
+ it 'should index the name of the select tag' do
69
+ output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
70
+ end
71
+
72
+ end
73
+
74
+
47
75
  describe "when required" do
48
76
  it "should add the required attribute to the input's html options" do
49
- with_config :use_required_attribute, true do
77
+ with_config :use_required_attribute, true do
50
78
  concat(semantic_form_for(@new_post) do |builder|
51
79
  concat(builder.input(:title, :as => :email, :required => true))
52
80
  end)
@@ -54,6 +82,6 @@ describe 'email input' do
54
82
  end
55
83
  end
56
84
  end
57
-
85
+
58
86
  end
59
87
 
@@ -15,8 +15,8 @@ describe 'file input' do
15
15
  end)
16
16
  end
17
17
 
18
- it_should_have_input_wrapper_with_class("file")
19
- it_should_have_input_wrapper_with_class(:clearfix)
18
+ it_should_have_input_wrapper_with_class("file-wrapper")
19
+ it_should_have_input_wrapper_with_class("control-group")
20
20
  it_should_have_input_class_in_the_right_place
21
21
  it_should_have_input_wrapper_with_id("post_body_input")
22
22
  it_should_have_label_with_text(/Body/)
@@ -29,7 +29,7 @@ describe 'file input' do
29
29
  concat(semantic_form_for(@new_post) do |builder|
30
30
  concat(builder.input(:title, :as => :file, :input_html => { :class => 'myclass' }))
31
31
  end)
32
- output_buffer.should have_tag("form div.clearfix div.input input.myclass")
32
+ output_buffer.should have_tag("form div.control-group div.controls input.myclass")
33
33
  end
34
34
 
35
35
  describe "when namespace is provided" do
@@ -47,7 +47,35 @@ describe 'file input' do
47
47
  it_should_have_label_and_input_with_id("context2_post_body")
48
48
 
49
49
  end
50
-
50
+
51
+ describe "when index is provided" do
52
+
53
+ before do
54
+ @output_buffer = ''
55
+ mock_everything
56
+
57
+ concat(semantic_form_for(@new_post) do |builder|
58
+ concat(builder.fields_for(:author, :index => 3) do |author|
59
+ concat(author.input(:name, :as => :file))
60
+ end)
61
+ end)
62
+ end
63
+
64
+ it 'should index the id of the wrapper' do
65
+ output_buffer.should have_tag("div#post_author_attributes_3_name_input")
66
+ end
67
+
68
+ it 'should index the id of the select tag' do
69
+ output_buffer.should have_tag("input#post_author_attributes_3_name")
70
+ end
71
+
72
+ it 'should index the name of the select tag' do
73
+ output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
74
+ end
75
+
76
+ end
77
+
78
+
51
79
  context "when required" do
52
80
  it "should add the required attribute to the input's html options" do
53
81
  with_config :use_required_attribute, true do
@@ -58,6 +86,6 @@ describe 'file input' do
58
86
  end
59
87
  end
60
88
  end
61
-
89
+
62
90
  end
63
91
 
@@ -19,37 +19,37 @@ describe 'hidden input' do
19
19
  end)
20
20
  end
21
21
 
22
- it_should_have_input_wrapper_with_class("hidden")
23
- it_should_have_input_wrapper_with_class(:clearfix)
22
+ it_should_have_input_wrapper_with_class("hidden-wrapper")
23
+ it_should_have_input_wrapper_with_class("control-group")
24
24
  it_should_have_input_class_in_the_right_place
25
25
  it_should_have_input_wrapper_with_id("post_secret_input")
26
26
  it_should_not_have_a_label
27
27
 
28
28
  it "should generate a input field" do
29
- output_buffer.should have_tag("form div.clearfix div.input input#post_secret")
30
- output_buffer.should have_tag("form div.clearfix div.input input#post_secret[@type=\"hidden\"]")
31
- output_buffer.should have_tag("form div.clearfix div.input input#post_secret[@name=\"post[secret]\"]")
29
+ output_buffer.should have_tag("form div.control-group div.controls input#post_secret")
30
+ output_buffer.should have_tag("form div.control-group div.controls input#post_secret[@type=\"hidden\"]")
31
+ output_buffer.should have_tag("form div.control-group div.controls input#post_secret[@name=\"post[secret]\"]")
32
32
  end
33
33
 
34
34
  it "should get value from the object" do
35
- output_buffer.should have_tag("form div.clearfix div.input input#post_secret[@type=\"hidden\"][@value=\"1\"]")
35
+ output_buffer.should have_tag("form div.control-group div.controls input#post_secret[@type=\"hidden\"][@value=\"1\"]")
36
36
  end
37
-
37
+
38
38
  it "should pass any explicitly specified value - using :value" do
39
- output_buffer.should have_tag("form div.clearfix div.input input#post_author_id[@type=\"hidden\"][@value=\"99\"]")
39
+ output_buffer.should have_tag("form div.control-group div.controls input#post_author_id[@type=\"hidden\"][@value=\"99\"]")
40
40
  end
41
41
 
42
42
  # Handle Formtastic :input_html options for consistency.
43
43
  it "should pass any explicitly specified value - using :input_html options" do
44
- output_buffer.should have_tag("form div.clearfix div.input input#post_published[@type=\"hidden\"][@value=\"true\"]")
44
+ output_buffer.should have_tag("form div.control-group div.controls input#post_published[@type=\"hidden\"][@value=\"true\"]")
45
45
  end
46
46
 
47
47
  it "should pass any option specified using :input_html" do
48
- output_buffer.should have_tag("form div.clearfix div.input input#new_post_reviewer[@type=\"hidden\"][@class=\"new_post_reviewer\"]")
48
+ output_buffer.should have_tag("form div.control-group div.controls input#new_post_reviewer[@type=\"hidden\"][@class=\"new_post_reviewer\"]")
49
49
  end
50
50
 
51
51
  it "should prefer :input_html over directly supplied options" do
52
- output_buffer.should have_tag("form div.clearfix div.input input#post_author_id[@type=\"hidden\"][@value=\"formtastic_value\"]")
52
+ output_buffer.should have_tag("form div.control-group div.controls input#post_author_id[@type=\"hidden\"][@value=\"formtastic_value\"]")
53
53
  end
54
54
 
55
55
  it "should not render inline errors" do
@@ -99,7 +99,35 @@ describe 'hidden input' do
99
99
  end
100
100
 
101
101
  end
102
-
102
+
103
+ describe "when index is provided" do
104
+
105
+ before do
106
+ @output_buffer = ''
107
+ mock_everything
108
+
109
+ concat(semantic_form_for(@new_post) do |builder|
110
+ concat(builder.fields_for(:author, :index => 3) do |author|
111
+ concat(author.input(:name, :as => :hidden))
112
+ end)
113
+ end)
114
+ end
115
+
116
+ it 'should index the id of the wrapper' do
117
+ output_buffer.should have_tag("div#post_author_attributes_3_name_input")
118
+ end
119
+
120
+ it 'should index the id of the select tag' do
121
+ output_buffer.should have_tag("input#post_author_attributes_3_name")
122
+ end
123
+
124
+ it 'should index the name of the select tag' do
125
+ output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
126
+ end
127
+
128
+ end
129
+
130
+
103
131
  context "when required" do
104
132
  it "should not add the required attribute to the input's html options" do
105
133
  concat(semantic_form_for(@new_post) do |builder|
@@ -14,9 +14,9 @@ describe 'number input' do
14
14
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=>2})
15
15
  ])
16
16
  end
17
-
17
+
18
18
  describe "all cases" do
19
-
19
+
20
20
  before do
21
21
  concat(
22
22
  semantic_form_for(@new_post) do |builder|
@@ -25,8 +25,9 @@ describe 'number input' do
25
25
  )
26
26
  end
27
27
 
28
- it_should_have_input_wrapper_with_class(:number)
29
- it_should_have_input_wrapper_with_class(:clearfix)
28
+ it_should_have_input_wrapper_with_class('number-wrapper')
29
+ it_should_have_input_wrapper_with_class("control-group")
30
+ it_should_have_input_wrapper_with_class(:numeric)
30
31
  it_should_have_input_wrapper_with_class(:stringish)
31
32
  it_should_have_input_class_in_the_right_place
32
33
  it_should_have_input_wrapper_with_id("post_title_input")
@@ -35,12 +36,13 @@ describe 'number input' do
35
36
  it_should_have_input_with_id("post_title")
36
37
  it_should_have_input_with_type(:number)
37
38
  it_should_have_input_with_name("post[title]")
38
- it_should_use_default_text_field_size_when_not_nil(:string)
39
- it_should_not_use_default_text_field_size_when_nil(:string)
40
- it_should_apply_custom_input_attributes_when_input_html_provided(:string)
41
- it_should_apply_custom_for_to_label_when_input_html_id_provided(:string)
39
+ # @todo this is not testing what it should be testing!
40
+ # it_should_use_default_text_field_size_when_not_nil(:string)
41
+ # it_should_not_use_default_text_field_size_when_nil(:string)
42
+ # it_should_apply_custom_input_attributes_when_input_html_provided(:string)
43
+ # it_should_apply_custom_for_to_label_when_input_html_id_provided(:string)
42
44
  it_should_apply_error_logic_for_input_type(:number)
43
-
45
+
44
46
  end
45
47
 
46
48
  describe "when no object is provided" do
@@ -49,7 +51,7 @@ describe 'number input' do
49
51
  concat(builder.input(:title, :as => :number, :input_html => { :min => 1, :max => 2 }))
50
52
  end)
51
53
  end
52
-
54
+
53
55
  it_should_have_label_with_text(/Title/)
54
56
  it_should_have_label_for("project_title")
55
57
  it_should_have_input_with_id("project_title")
@@ -63,14 +65,42 @@ describe 'number input' do
63
65
  concat(builder.input(:title, :as => :number))
64
66
  end)
65
67
  end
66
-
68
+
67
69
  it_should_have_input_wrapper_with_id("context2_post_title_input")
68
70
  it_should_have_label_and_input_with_id("context2_post_title")
69
71
  end
70
-
72
+
73
+ describe "when index is provided" do
74
+
75
+ before do
76
+ @output_buffer = ''
77
+ mock_everything
78
+
79
+ concat(semantic_form_for(@new_post) do |builder|
80
+ concat(builder.fields_for(:author, :index => 3) do |author|
81
+ concat(author.input(:name, :as => :number))
82
+ end)
83
+ end)
84
+ end
85
+
86
+ it 'should index the id of the wrapper' do
87
+ output_buffer.should have_tag("div#post_author_attributes_3_name_input")
88
+ end
89
+
90
+ it 'should index the id of the select tag' do
91
+ output_buffer.should have_tag("input#post_author_attributes_3_name")
92
+ end
93
+
94
+ it 'should index the name of the select tag' do
95
+ output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
96
+ end
97
+
98
+ end
99
+
100
+
71
101
  describe "when required" do
72
102
  it "should add the required attribute to the input's html options" do
73
- with_config :use_required_attribute, true do
103
+ with_config :use_required_attribute, true do
74
104
  concat(semantic_form_for(@new_post) do |builder|
75
105
  concat(builder.input(:title, :as => :number, :required => true))
76
106
  end)
@@ -78,47 +108,47 @@ describe 'number input' do
78
108
  end
79
109
  end
80
110
  end
81
-
111
+
82
112
  describe "when validations require a minimum value (:greater_than)" do
83
113
  before do
84
114
  @new_post.class.stub!(:validators_on).with(:title).and_return([
85
115
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=>2})
86
116
  ])
87
117
  end
88
-
118
+
89
119
  it "should allow :input_html to override :min" do
90
120
  concat(semantic_form_for(@new_post) do |builder|
91
121
  builder.input(:title, :as => :number, :input_html => { :min => 5 })
92
122
  end)
93
123
  output_buffer.should have_tag('input[@min="5"]')
94
124
  end
95
-
125
+
96
126
  it "should allow :input_html to override :min through :in" do
97
127
  concat(semantic_form_for(@new_post) do |builder|
98
128
  builder.input(:title, :as => :number, :input_html => { :in => 5..102 })
99
129
  end)
100
130
  output_buffer.should have_tag('input[@min="5"]')
101
131
  end
102
-
132
+
103
133
  it "should allow options to override :min" do
104
134
  concat(semantic_form_for(@new_post) do |builder|
105
135
  builder.input(:title, :as => :number, :min => 5)
106
136
  end)
107
137
  output_buffer.should have_tag('input[@min="5"]')
108
138
  end
109
-
139
+
110
140
  it "should allow options to override :min through :in" do
111
141
  concat(semantic_form_for(@new_post) do |builder|
112
142
  builder.input(:title, :as => :number, :in => 5..102)
113
143
  end)
114
144
  output_buffer.should have_tag('input[@min="5"]')
115
145
  end
116
-
146
+
117
147
  describe "and the column is an integer" do
118
148
  before do
119
149
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
120
150
  end
121
-
151
+
122
152
  it "should add a min attribute to the input one greater than the validation" do
123
153
  concat(semantic_form_for(@new_post) do |builder|
124
154
  builder.input(:title, :as => :number)
@@ -126,12 +156,12 @@ describe 'number input' do
126
156
  output_buffer.should have_tag('input[@min="3"]')
127
157
  end
128
158
  end
129
-
159
+
130
160
  describe "and the column is a float" do
131
161
  before do
132
162
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
133
163
  end
134
-
164
+
135
165
  it "should raise an error" do
136
166
  lambda {
137
167
  concat(semantic_form_for(@new_post) do |builder|
@@ -140,12 +170,12 @@ describe 'number input' do
140
170
  }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
141
171
  end
142
172
  end
143
-
173
+
144
174
  describe "and the column is a big decimal" do
145
175
  before do
146
176
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
147
177
  end
148
-
178
+
149
179
  it "should raise an error" do
150
180
  lambda {
151
181
  concat(semantic_form_for(@new_post) do |builder|
@@ -154,49 +184,49 @@ describe 'number input' do
154
184
  }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
155
185
  end
156
186
  end
157
-
187
+
158
188
  end
159
-
189
+
160
190
  describe "when validations require a minimum value (:greater_than) that takes a proc" do
161
191
  before do
162
192
  @new_post.class.stub!(:validators_on).with(:title).and_return([
163
193
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=> Proc.new {|post| 2}})
164
194
  ])
165
195
  end
166
-
196
+
167
197
  it "should allow :input_html to override :min" do
168
198
  concat(semantic_form_for(@new_post) do |builder|
169
199
  builder.input(:title, :as => :number, :input_html => { :min => 5 })
170
200
  end)
171
201
  output_buffer.should have_tag('input[@min="5"]')
172
202
  end
173
-
203
+
174
204
  it "should allow :input_html to override :min through :in" do
175
205
  concat(semantic_form_for(@new_post) do |builder|
176
206
  builder.input(:title, :as => :number, :input_html => { :in => 5..102 })
177
207
  end)
178
208
  output_buffer.should have_tag('input[@min="5"]')
179
209
  end
180
-
210
+
181
211
  it "should allow options to override :min" do
182
212
  concat(semantic_form_for(@new_post) do |builder|
183
213
  builder.input(:title, :as => :number, :min => 5)
184
214
  end)
185
215
  output_buffer.should have_tag('input[@min="5"]')
186
216
  end
187
-
217
+
188
218
  it "should allow options to override :min through :in" do
189
219
  concat(semantic_form_for(@new_post) do |builder|
190
220
  builder.input(:title, :as => :number, :in => 5..102)
191
221
  end)
192
222
  output_buffer.should have_tag('input[@min="5"]')
193
223
  end
194
-
224
+
195
225
  describe "and the column is an integer" do
196
226
  before do
197
227
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
198
228
  end
199
-
229
+
200
230
  it "should add a min attribute to the input one greater than the validation" do
201
231
  concat(semantic_form_for(@new_post) do |builder|
202
232
  builder.input(:title, :as => :number)
@@ -204,12 +234,12 @@ describe 'number input' do
204
234
  output_buffer.should have_tag('input[@min="3"]')
205
235
  end
206
236
  end
207
-
237
+
208
238
  describe "and the column is a float" do
209
239
  before do
210
240
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
211
241
  end
212
-
242
+
213
243
  it "should raise an error" do
214
244
  lambda {
215
245
  concat(semantic_form_for(@new_post) do |builder|
@@ -218,12 +248,12 @@ describe 'number input' do
218
248
  }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
219
249
  end
220
250
  end
221
-
251
+
222
252
  describe "and the column is a big decimal" do
223
253
  before do
224
254
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
225
255
  end
226
-
256
+
227
257
  it "should raise an error" do
228
258
  lambda {
229
259
  concat(semantic_form_for(@new_post) do |builder|
@@ -232,23 +262,23 @@ describe 'number input' do
232
262
  }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
233
263
  end
234
264
  end
235
-
265
+
236
266
  end
237
-
267
+
238
268
  describe "when validations require a minimum value (:greater_than_or_equal_to)" do
239
269
  before do
240
270
  @new_post.class.stub!(:validators_on).with(:title).and_return([
241
271
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than_or_equal_to=>2})
242
272
  ])
243
273
  end
244
-
274
+
245
275
  it "should allow :input_html to override :min" do
246
276
  concat(semantic_form_for(@new_post) do |builder|
247
277
  builder.input(:title, :as => :number, :input_html => { :min => 5 })
248
278
  end)
249
279
  output_buffer.should have_tag('input[@min="5"]')
250
280
  end
251
-
281
+
252
282
  it "should allow options to override :min" do
253
283
  concat(semantic_form_for(@new_post) do |builder|
254
284
  builder.input(:title, :as => :number, :min => 5)
@@ -262,14 +292,14 @@ describe 'number input' do
262
292
  end)
263
293
  output_buffer.should have_tag('input[@min="5"]')
264
294
  end
265
-
295
+
266
296
  it "should allow options to override :min with :in" do
267
297
  concat(semantic_form_for(@new_post) do |builder|
268
298
  builder.input(:title, :as => :number, :in => 5..102)
269
299
  end)
270
300
  output_buffer.should have_tag('input[@min="5"]')
271
301
  end
272
-
302
+
273
303
 
274
304
  [:integer, :decimal, :float].each do |column_type|
275
305
  describe "and the column is a #{column_type}" do
@@ -290,7 +320,7 @@ describe 'number input' do
290
320
  before do
291
321
  @new_post.stub!(:column_for_attribute).with(:title).and_return(nil)
292
322
  end
293
-
323
+
294
324
  it "should add a max attribute to the input equal to the validation" do
295
325
  concat(semantic_form_for(@new_post) do |builder|
296
326
  builder.input(:title, :as => :number)
@@ -299,7 +329,7 @@ describe 'number input' do
299
329
  end
300
330
  end
301
331
  end
302
-
332
+
303
333
  describe "when validations require a minimum value (:greater_than_or_equal_to) that takes a Proc" do
304
334
  before do
305
335
  @new_post.class.stub!(:validators_on).with(:title).and_return([
@@ -366,27 +396,27 @@ describe 'number input' do
366
396
  end
367
397
 
368
398
  describe "when validations require a maximum value (:less_than)" do
369
-
399
+
370
400
  before do
371
401
  @new_post.class.stub!(:validators_on).with(:title).and_return([
372
402
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than=>20})
373
403
  ])
374
404
  end
375
-
405
+
376
406
  it "should allow :input_html to override :max" do
377
407
  concat(semantic_form_for(@new_post) do |builder|
378
408
  builder.input(:title, :as => :number, :input_html => { :max => 102 })
379
409
  end)
380
410
  output_buffer.should have_tag('input[@max="102"]')
381
411
  end
382
-
412
+
383
413
  it "should allow option to override :max" do
384
414
  concat(semantic_form_for(@new_post) do |builder|
385
415
  builder.input(:title, :as => :number, :max => 102)
386
416
  end)
387
417
  output_buffer.should have_tag('input[@max="102"]')
388
418
  end
389
-
419
+
390
420
  it "should allow :input_html to override :max with :in" do
391
421
  concat(semantic_form_for(@new_post) do |builder|
392
422
  builder.input(:title, :as => :number, :input_html => { :in => 1..102 })
@@ -400,12 +430,12 @@ describe 'number input' do
400
430
  end)
401
431
  output_buffer.should have_tag('input[@max="102"]')
402
432
  end
403
-
433
+
404
434
  describe "and the column is an integer" do
405
435
  before do
406
436
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
407
437
  end
408
-
438
+
409
439
  it "should add a max attribute to the input one greater than the validation" do
410
440
  concat(semantic_form_for(@new_post) do |builder|
411
441
  builder.input(:title, :as => :number)
@@ -413,12 +443,12 @@ describe 'number input' do
413
443
  output_buffer.should have_tag('input[@max="19"]')
414
444
  end
415
445
  end
416
-
446
+
417
447
  describe "and the column is a float" do
418
448
  before do
419
449
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
420
450
  end
421
-
451
+
422
452
  it "should raise an error" do
423
453
  lambda {
424
454
  concat(semantic_form_for(@new_post) do |builder|
@@ -427,12 +457,12 @@ describe 'number input' do
427
457
  }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
428
458
  end
429
459
  end
430
-
460
+
431
461
  describe "and the column is a big decimal" do
432
462
  before do
433
463
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
434
464
  end
435
-
465
+
436
466
  it "should raise an error" do
437
467
  lambda {
438
468
  concat(semantic_form_for(@new_post) do |builder|
@@ -447,29 +477,29 @@ describe 'number input' do
447
477
  end
448
478
  end
449
479
  end
450
-
480
+
451
481
  describe "when validations require a maximum value (:less_than) that takes a Proc" do
452
-
482
+
453
483
  before do
454
484
  @new_post.class.stub!(:validators_on).with(:title).and_return([
455
485
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than=> Proc.new {|post| 20 }})
456
486
  ])
457
487
  end
458
-
488
+
459
489
  it "should allow :input_html to override :max" do
460
490
  concat(semantic_form_for(@new_post) do |builder|
461
491
  builder.input(:title, :as => :number, :input_html => { :max => 102 })
462
492
  end)
463
493
  output_buffer.should have_tag('input[@max="102"]')
464
494
  end
465
-
495
+
466
496
  it "should allow option to override :max" do
467
497
  concat(semantic_form_for(@new_post) do |builder|
468
498
  builder.input(:title, :as => :number, :max => 102)
469
499
  end)
470
500
  output_buffer.should have_tag('input[@max="102"]')
471
501
  end
472
-
502
+
473
503
  it "should allow :input_html to override :max with :in" do
474
504
  concat(semantic_form_for(@new_post) do |builder|
475
505
  builder.input(:title, :as => :number, :input_html => { :in => 1..102 })
@@ -483,12 +513,12 @@ describe 'number input' do
483
513
  end)
484
514
  output_buffer.should have_tag('input[@max="102"]')
485
515
  end
486
-
516
+
487
517
  describe "and the column is an integer" do
488
518
  before do
489
519
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
490
520
  end
491
-
521
+
492
522
  it "should add a max attribute to the input one greater than the validation" do
493
523
  concat(semantic_form_for(@new_post) do |builder|
494
524
  builder.input(:title, :as => :number)
@@ -496,12 +526,12 @@ describe 'number input' do
496
526
  output_buffer.should have_tag('input[@max="19"]')
497
527
  end
498
528
  end
499
-
529
+
500
530
  describe "and the column is a float" do
501
531
  before do
502
532
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
503
533
  end
504
-
534
+
505
535
  it "should raise an error" do
506
536
  lambda {
507
537
  concat(semantic_form_for(@new_post) do |builder|
@@ -510,12 +540,12 @@ describe 'number input' do
510
540
  }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
511
541
  end
512
542
  end
513
-
543
+
514
544
  describe "and the column is a big decimal" do
515
545
  before do
516
546
  @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
517
547
  end
518
-
548
+
519
549
  it "should raise an error" do
520
550
  lambda {
521
551
  concat(semantic_form_for(@new_post) do |builder|
@@ -530,36 +560,36 @@ describe 'number input' do
530
560
  end
531
561
  end
532
562
  end
533
-
534
-
563
+
564
+
535
565
  describe "when validations require a maximum value (:less_than_or_equal_to)" do
536
566
  before do
537
567
  @new_post.class.stub!(:validators_on).with(:title).and_return([
538
568
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than_or_equal_to=>20})
539
569
  ])
540
570
  end
541
-
571
+
542
572
  it "should allow :input_html to override :max" do
543
573
  concat(semantic_form_for(@new_post) do |builder|
544
574
  builder.input(:title, :as => :number, :input_html => { :max => 102 })
545
575
  end)
546
576
  output_buffer.should have_tag('input[@max="102"]')
547
577
  end
548
-
578
+
549
579
  it "should allow options to override :max" do
550
580
  concat(semantic_form_for(@new_post) do |builder|
551
581
  builder.input(:title, :as => :number, :max => 102)
552
582
  end)
553
583
  output_buffer.should have_tag('input[@max="102"]')
554
584
  end
555
-
585
+
556
586
  it "should allow :input_html to override :max with :in" do
557
587
  concat(semantic_form_for(@new_post) do |builder|
558
588
  builder.input(:title, :as => :number, :input_html => { :in => 1..102 })
559
589
  end)
560
590
  output_buffer.should have_tag('input[@max="102"]')
561
591
  end
562
-
592
+
563
593
  it "should allow options to override :max with :in" do
564
594
  concat(semantic_form_for(@new_post) do |builder|
565
595
  builder.input(:title, :as => :number, :in => 1..102)
@@ -586,7 +616,7 @@ describe 'number input' do
586
616
  before do
587
617
  @new_post.stub!(:column_for_attribute).with(:title).and_return(nil)
588
618
  end
589
-
619
+
590
620
  it "should add a max attribute to the input equal to the validation" do
591
621
  concat(semantic_form_for(@new_post) do |builder|
592
622
  builder.input(:title, :as => :number)
@@ -595,7 +625,7 @@ describe 'number input' do
595
625
  end
596
626
  end
597
627
  end
598
-
628
+
599
629
  describe "when validations require a maximum value (:less_than_or_equal_to) that takes a proc" do
600
630
  before do
601
631
  @new_post.class.stub!(:validators_on).with(:title).and_return([
@@ -659,14 +689,14 @@ describe 'number input' do
659
689
  end
660
690
  end
661
691
  end
662
-
692
+
663
693
  describe "when validations require conflicting minimum values (:greater_than, :greater_than_or_equal_to)" do
664
694
  before do
665
695
  @new_post.class.stub!(:validators_on).with(:title).and_return([
666
696
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than => 20, :greater_than_or_equal_to=>2})
667
697
  ])
668
698
  end
669
-
699
+
670
700
  it "should add a max attribute to the input equal to the :greater_than_or_equal_to validation" do
671
701
  concat(semantic_form_for(@new_post) do |builder|
672
702
  builder.input(:title, :as => :number)
@@ -674,14 +704,14 @@ describe 'number input' do
674
704
  output_buffer.should have_tag('input[@min="2"]')
675
705
  end
676
706
  end
677
-
707
+
678
708
  describe "when validations require conflicting maximum values (:less_than, :less_than_or_equal_to)" do
679
709
  before do
680
710
  @new_post.class.stub!(:validators_on).with(:title).and_return([
681
711
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than => 20, :less_than_or_equal_to=>2})
682
712
  ])
683
713
  end
684
-
714
+
685
715
  it "should add a max attribute to the input equal to the :greater_than_or_equal_to validation" do
686
716
  concat(semantic_form_for(@new_post) do |builder|
687
717
  builder.input(:title, :as => :number)
@@ -689,99 +719,99 @@ describe 'number input' do
689
719
  output_buffer.should have_tag('input[@max="2"]')
690
720
  end
691
721
  end
692
-
722
+
693
723
  describe "when validations require only an integer (:only_integer)" do
694
-
724
+
695
725
  before do
696
726
  @new_post.class.stub!(:validators_on).with(:title).and_return([
697
727
  active_model_numericality_validator([:title], {:allow_nil=>false, :only_integer=>true})
698
728
  ])
699
729
  end
700
-
730
+
701
731
  it "should add a step=1 attribute to the input to signify that only whole numbers are allowed" do
702
732
  concat(semantic_form_for(@new_post) do |builder|
703
733
  builder.input(:title, :as => :number)
704
734
  end)
705
735
  output_buffer.should have_tag('input[@step="1"]')
706
736
  end
707
-
737
+
708
738
  it "should let input_html override :step" do
709
739
  concat(semantic_form_for(@new_post) do |builder|
710
740
  builder.input(:title, :as => :number, :input_html => { :step => 3 })
711
741
  end)
712
742
  output_buffer.should have_tag('input[@step="3"]')
713
743
  end
714
-
744
+
715
745
  it "should let options override :step" do
716
746
  concat(semantic_form_for(@new_post) do |builder|
717
747
  builder.input(:title, :as => :number, :step => 3)
718
748
  end)
719
749
  output_buffer.should have_tag('input[@step="3"]')
720
750
  end
721
-
751
+
722
752
  end
723
-
753
+
724
754
  describe "when validations require a :step (non standard)" do
725
-
755
+
726
756
  before do
727
757
  @new_post.class.stub!(:validators_on).with(:title).and_return([
728
758
  active_model_numericality_validator([:title], {:allow_nil=>false, :only_integer=>true, :step=>2})
729
759
  ])
730
760
  end
731
-
761
+
732
762
  it "should add a step=1 attribute to the input to signify that only whole numbers are allowed" do
733
763
  concat(semantic_form_for(@new_post) do |builder|
734
764
  builder.input(:title, :as => :number)
735
765
  end)
736
766
  output_buffer.should have_tag('input[@step="2"]')
737
767
  end
738
-
768
+
739
769
  it "should let input_html override :step" do
740
770
  concat(semantic_form_for(@new_post) do |builder|
741
771
  builder.input(:title, :as => :number, :input_html => { :step => 3 })
742
772
  end)
743
773
  output_buffer.should have_tag('input[@step="3"]')
744
774
  end
745
-
775
+
746
776
  it "should let options override :step" do
747
777
  concat(semantic_form_for(@new_post) do |builder|
748
778
  builder.input(:title, :as => :number, :step => 3)
749
779
  end)
750
780
  output_buffer.should have_tag('input[@step="3"]')
751
781
  end
752
-
782
+
753
783
  end
754
-
784
+
755
785
  describe "when validations do not specify :step (non standard) or :only_integer" do
756
-
786
+
757
787
  before do
758
788
  @new_post.class.stub!(:validators_on).with(:title).and_return([
759
789
  active_model_numericality_validator([:title], {:allow_nil=>false})
760
790
  ])
761
791
  end
762
-
792
+
763
793
  it "should default step to 'any'" do
764
794
  concat(semantic_form_for(@new_post) do |builder|
765
795
  builder.input(:title, :as => :number)
766
796
  end)
767
797
  output_buffer.should have_tag('input[@step="any"]')
768
798
  end
769
-
799
+
770
800
  it "should let input_html set :step" do
771
801
  concat(semantic_form_for(@new_post) do |builder|
772
802
  builder.input(:title, :as => :number, :input_html => { :step => 3 })
773
803
  end)
774
804
  output_buffer.should have_tag('input[@step="3"]')
775
805
  end
776
-
806
+
777
807
  it "should let options set :step" do
778
808
  concat(semantic_form_for(@new_post) do |builder|
779
809
  builder.input(:title, :as => :number, :step => 3)
780
810
  end)
781
811
  output_buffer.should have_tag('input[@step="3"]')
782
812
  end
783
-
813
+
784
814
  end
785
-
815
+
786
816
  end
787
817