formtastic-rails3 0.9.7 → 0.9.10.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 (50) hide show
  1. data/README.textile +23 -7
  2. data/Rakefile +27 -4
  3. data/generators/formtastic/templates/formtastic.css +9 -7
  4. data/generators/formtastic/templates/formtastic.rb +1 -1
  5. data/generators/formtastic/templates/formtastic_changes.css +4 -0
  6. data/lib/formtastic.rb +190 -142
  7. data/lib/formtastic/i18n.rb +8 -5
  8. data/lib/formtastic/railtie.rb +12 -0
  9. data/lib/formtastic/util.rb +35 -0
  10. data/lib/generators/formtastic/form/form_generator.rb +4 -3
  11. data/lib/generators/formtastic/install/install_generator.rb +2 -1
  12. data/rails/init.rb +5 -0
  13. data/spec/buttons_spec.rb +25 -8
  14. data/spec/commit_button_spec.rb +88 -64
  15. data/spec/custom_builder_spec.rb +1 -1
  16. data/spec/custom_macros.rb +67 -26
  17. data/spec/error_proc_spec.rb +1 -1
  18. data/spec/errors_spec.rb +21 -1
  19. data/spec/form_helper_spec.rb +47 -15
  20. data/spec/i18n_spec.rb +40 -19
  21. data/spec/include_blank_spec.rb +9 -5
  22. data/spec/input_spec.rb +224 -76
  23. data/spec/inputs/boolean_input_spec.rb +22 -11
  24. data/spec/inputs/check_boxes_input_spec.rb +103 -11
  25. data/spec/inputs/country_input_spec.rb +46 -8
  26. data/spec/inputs/date_input_spec.rb +80 -55
  27. data/spec/inputs/datetime_input_spec.rb +134 -83
  28. data/spec/inputs/file_input_spec.rb +4 -3
  29. data/spec/inputs/hidden_input_spec.rb +17 -3
  30. data/spec/inputs/numeric_input_spec.rb +3 -3
  31. data/spec/inputs/password_input_spec.rb +3 -3
  32. data/spec/inputs/radio_input_spec.rb +28 -11
  33. data/spec/inputs/select_input_spec.rb +122 -46
  34. data/spec/inputs/string_input_spec.rb +3 -3
  35. data/spec/inputs/text_input_spec.rb +4 -3
  36. data/spec/inputs/time_input_spec.rb +109 -53
  37. data/spec/inputs/time_zone_input_spec.rb +15 -7
  38. data/spec/inputs_spec.rb +85 -39
  39. data/spec/label_spec.rb +1 -1
  40. data/spec/layout_helper_spec.rb +5 -16
  41. data/spec/semantic_errors_spec.rb +7 -7
  42. data/spec/semantic_fields_for_spec.rb +5 -4
  43. data/spec/spec_helper.rb +102 -36
  44. metadata +11 -14
  45. data/lib/generators/formtastic/form/templates/_form.html.erb +0 -5
  46. data/lib/generators/formtastic/form/templates/_form.html.haml +0 -4
  47. data/lib/generators/formtastic/install/templates/formtastic.css +0 -144
  48. data/lib/generators/formtastic/install/templates/formtastic.rb +0 -58
  49. data/lib/generators/formtastic/install/templates/formtastic_changes.css +0 -10
  50. data/spec/inputs/currency_input_spec.rb +0 -80
@@ -6,76 +6,91 @@ describe 'datetime input' do
6
6
  include FormtasticSpecHelper
7
7
 
8
8
  before do
9
- @output_buffer = ActiveSupport::SafeBuffer.new
9
+ @output_buffer = ''
10
10
  mock_everything
11
11
 
12
12
  @new_post.should_receive(:publish_at=).any_number_of_times
13
13
  @new_post.should_receive(:created_at=).any_number_of_times
14
14
  @bob.should_receive(:created_at=).any_number_of_times
15
15
  @new_post.should_receive(:title=).any_number_of_times # Macro stuff forces this.
16
-
17
- semantic_form_for(@new_post) do |builder|
18
- concat(builder.input(:publish_at, :as => :datetime))
19
- end
20
- end
21
-
22
- it_should_have_input_wrapper_with_class("datetime")
23
- it_should_have_input_wrapper_with_id("post_publish_at_input")
24
- it_should_have_a_nested_fieldset
25
- it_should_apply_error_logic_for_input_type(:datetime)
26
-
27
- it 'should have a legend and label with the label text inside the fieldset' do
28
- output_buffer.should have_tag('form li.datetime fieldset legend.label label', /Publish at/)
29
16
  end
30
17
 
31
- it 'should associate the legend label with the first select' do
32
- output_buffer.should have_tag('form li.datetime fieldset legend.label label[@for="post_publish_at_1i"]')
33
- end
34
-
35
- it 'should have an ordered list of five items inside the fieldset' do
36
- output_buffer.should have_tag('form li.datetime fieldset ol')
37
- output_buffer.should have_tag('form li.datetime fieldset ol li', :count => 5)
38
- end
39
-
40
- it 'should have five labels for year, month, day, hour and minute' do
41
- output_buffer.should have_tag('form li.datetime fieldset ol li label', :count => 5)
42
- output_buffer.should have_tag('form li.datetime fieldset ol li label', /year/i)
43
- output_buffer.should have_tag('form li.datetime fieldset ol li label', /month/i)
44
- output_buffer.should have_tag('form li.datetime fieldset ol li label', /day/i)
45
- output_buffer.should have_tag('form li.datetime fieldset ol li label', /hour/i)
46
- output_buffer.should have_tag('form li.datetime fieldset ol li label', /minute/i)
47
- end
48
-
49
- it 'should have five selects for year, month, day, hour and minute' do
50
- output_buffer.should have_tag('form li.datetime fieldset ol li select', :count => 5)
51
- end
52
-
53
- it 'should generate a sanitized label and matching ids for attribute' do
54
- semantic_form_for(@new_post) do |builder|
55
- builder.semantic_fields_for(@bob, :index => 10) do |bob_builder|
56
- concat(bob_builder.input(:created_at, :as => :datetime))
18
+ describe "general" do
19
+
20
+ before do
21
+ output_buffer.replace ''
22
+ @form = semantic_form_for(@new_post) do |builder|
23
+ concat(builder.input(:publish_at, :as => :datetime))
57
24
  end
58
25
  end
59
-
60
- 1.upto(5) do |i|
61
- output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_10_created_at_#{i}i']")
62
- output_buffer.should have_tag("form li fieldset ol li #post_author_10_created_at_#{i}i")
26
+
27
+ it_should_have_input_wrapper_with_class("datetime")
28
+ it_should_have_input_wrapper_with_id("post_publish_at_input")
29
+ it_should_have_a_nested_fieldset
30
+ it_should_apply_error_logic_for_input_type(:datetime)
31
+
32
+ it 'should have a legend and label with the label text inside the fieldset' do
33
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
34
+ output_buffer.should have_tag('form li.datetime fieldset legend.label label', /Publish at/)
35
+ end
36
+
37
+ it 'should associate the legend label with the first select' do
38
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
39
+ output_buffer.should have_tag('form li.datetime fieldset legend.label label[@for="post_publish_at_1i"]')
40
+ end
41
+
42
+ it 'should have an ordered list of five items inside the fieldset' do
43
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
44
+ output_buffer.should have_tag('form li.datetime fieldset ol')
45
+ output_buffer.should have_tag('form li.datetime fieldset ol li', :count => 5)
46
+ end
47
+
48
+ it 'should have five labels for year, month, day, hour and minute' do
49
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
50
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', :count => 5)
51
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /year/i)
52
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /month/i)
53
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /day/i)
54
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /hour/i)
55
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /minute/i)
56
+ end
57
+
58
+ it 'should have five selects for year, month, day, hour and minute' do
59
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
60
+ output_buffer.should have_tag('form li.datetime fieldset ol li select', :count => 5)
61
+ end
62
+
63
+ it 'should generate a sanitized label and matching ids for attribute' do
64
+ form = semantic_form_for(@new_post) do |builder|
65
+ fields = builder.semantic_fields_for(@bob, :index => 10) do |bob_builder|
66
+ concat(bob_builder.input(:created_at, :as => :datetime))
67
+ end
68
+ concat(fields)
69
+ end
70
+ output_buffer.concat(form) if Formtastic::Util.rails3?
71
+
72
+ 1.upto(5) do |i|
73
+ output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_10_created_at_#{i}i']")
74
+ output_buffer.should have_tag("form li fieldset ol li #post_author_10_created_at_#{i}i")
75
+ end
63
76
  end
64
77
  end
65
78
 
66
79
  describe 'when :discard_input => true is set' do
67
80
  it 'should use default attribute value when it is not nil' do
68
81
  @new_post.stub!(:publish_at).and_return(Date.new(2007,12,27))
69
- semantic_form_for(@new_post) do |builder|
82
+ form = semantic_form_for(@new_post) do |builder|
70
83
  concat(builder.input(:publish_at, :as => :datetime, :discard_day => true))
71
84
  end
72
-
85
+
86
+ output_buffer.concat(form) if Formtastic::Util.rails3?
73
87
  output_buffer.should have_tag("form li input[@type='hidden'][@value='27']")
74
88
  end
75
89
  end
76
-
90
+
77
91
  describe 'inputs order' do
78
92
  it 'should have a default' do
93
+ output_buffer.replace ''
79
94
  semantic_form_for(@new_post) do |builder|
80
95
  self.should_receive(:select_year).once.ordered.and_return('')
81
96
  self.should_receive(:select_month).once.ordered.and_return('')
@@ -83,18 +98,21 @@ describe 'datetime input' do
83
98
  builder.input(:publish_at, :as => :datetime)
84
99
  end
85
100
  end
86
-
101
+
87
102
  it 'should be specified with :order option' do
88
103
  ::I18n.backend.store_translations 'en', :date => { :order => [:month, :year, :day] }
104
+ output_buffer.replace ''
89
105
  semantic_form_for(@new_post) do |builder|
90
106
  self.should_receive(:select_month).once.ordered.and_return('')
91
107
  self.should_receive(:select_year).once.ordered.and_return('')
92
108
  self.should_receive(:select_day).once.ordered.and_return('')
93
109
  builder.input(:publish_at, :as => :datetime)
110
+ ::I18n.backend.store_translations 'en', :date => nil
94
111
  end
95
112
  end
96
-
113
+
97
114
  it 'should be changed through I18n' do
115
+ output_buffer.replace ''
98
116
  semantic_form_for(@new_post) do |builder|
99
117
  self.should_receive(:select_day).once.ordered.and_return('')
100
118
  self.should_receive(:select_month).once.ordered.and_return('')
@@ -103,26 +121,28 @@ describe 'datetime input' do
103
121
  end
104
122
  end
105
123
  end
106
-
124
+
107
125
  describe 'when the locale changes the label text' do
108
126
  before do
109
127
  ::I18n.backend.store_translations 'en', :datetime => {:prompts => {
110
128
  :year => 'The Year', :month => 'The Month', :day => 'The Day',
111
129
  :hour => 'The Hour', :minute => 'The Minute'
112
130
  }}
113
- semantic_form_for(@new_post) do |builder|
131
+ output_buffer.replace ''
132
+ @form = semantic_form_for(@new_post) do |builder|
114
133
  concat(builder.input(:publish_at, :as => :datetime))
115
134
  end
116
135
  end
117
-
136
+
118
137
  after do
119
138
  ::I18n.backend.store_translations 'en', :formtastic => {
120
139
  :year => nil, :month => nil, :day => nil,
121
140
  :hour => nil, :minute => nil
122
141
  }
123
142
  end
124
-
143
+
125
144
  it 'should have translated labels for year, month, day, hour and minute' do
145
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
126
146
  output_buffer.should have_tag('form li.datetime fieldset ol li label', /The Year/)
127
147
  output_buffer.should have_tag('form li.datetime fieldset ol li label', /The Month/)
128
148
  output_buffer.should have_tag('form li.datetime fieldset ol li label', /The Day/)
@@ -130,87 +150,116 @@ describe 'datetime input' do
130
150
  output_buffer.should have_tag('form li.datetime fieldset ol li label', /The Minute/)
131
151
  end
132
152
  end
133
-
153
+
134
154
  describe 'when no object is given' do
135
155
  before(:each) do
136
156
  output_buffer.replace ''
137
- semantic_form_for(:project, :url => 'http://test.host') do |builder|
157
+ @form = semantic_form_for(:project, :url => 'http://test.host') do |builder|
138
158
  concat(builder.input(:publish_at, :as => :datetime))
139
159
  end
140
160
  end
141
-
161
+
142
162
  it 'should have fieldset with legend - classified as a label' do
163
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
143
164
  output_buffer.should have_tag('form li.datetime fieldset legend.label', /Publish at/)
144
165
  end
145
-
166
+
146
167
  it 'should have labels for each input' do
168
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
147
169
  output_buffer.should have_tag('form li.datetime fieldset ol li label', :count => 5)
148
170
  end
149
-
171
+
150
172
  it 'should have selects for each inputs' do
173
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
151
174
  output_buffer.should have_tag('form li.datetime fieldset ol li select', :count => 5)
152
175
  end
153
176
  end
154
177
 
155
- describe ':default option' do
178
+ #describe 'when an object is given and the attribute value is nil' do
179
+ # before(:each) do
180
+ # @new_post.stub!(:publish_at).and_return(nil)
181
+ # output_buffer.replace ''
182
+ # semantic_form_for(@new_post) do |builder|
183
+ # concat(builder.input(:publish_at, :as => :datetime))
184
+ # end
185
+ # end
186
+ #
187
+ # it 'should not select a value' do
188
+ # output_buffer.should_not have_tag('form li.datetime option[@selected]')
189
+ # end
190
+ #
191
+ #end
192
+
193
+ describe ':selected option' do
156
194
 
157
195
  describe "when the object has a value" do
158
- it "should select the object value (ignoring :default)" do
196
+ it "should select the object value (ignoring :selected)" do
159
197
  output_buffer.replace ''
160
198
  @new_post.stub!(:created_at => Time.mktime(2012))
161
- semantic_form_for(@new_post) do |builder|
162
- concat(builder.input(:created_at, :as => :datetime, :default => Time.mktime(1999)))
199
+ with_deprecation_silenced do
200
+ @form = semantic_form_for(@new_post) do |builder|
201
+ concat(builder.input(:created_at, :as => :datetime, :selected => Time.mktime(1999)))
202
+ end
163
203
  end
204
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
164
205
  output_buffer.should have_tag("form li ol li select#post_created_at_1i option[@selected]", :count => 1)
165
206
  output_buffer.should have_tag("form li ol li select#post_created_at_1i option[@value='2012'][@selected]", :count => 1)
166
207
  end
167
208
  end
168
209
 
169
210
  describe 'when the object has no value' do
170
- it "should select the :default if provided as a Date" do
211
+ it "should select the :selected if provided as a Date" do
171
212
  output_buffer.replace ''
172
213
  @new_post.stub!(:created_at => nil)
173
- semantic_form_for(@new_post) do |builder|
174
- concat(builder.input(:created_at, :as => :datetime, :default => Date.new(1999)))
214
+ with_deprecation_silenced do
215
+ @form = semantic_form_for(@new_post) do |builder|
216
+ concat(builder.input(:created_at, :as => :datetime, :selected => Date.new(1999)))
217
+ end
175
218
  end
219
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
176
220
  output_buffer.should have_tag("form li ol li select#post_created_at_1i option[@selected]", :count => 1)
177
221
  output_buffer.should have_tag("form li ol li select#post_created_at_1i option[@value='1999'][@selected]", :count => 1)
178
222
  end
179
223
 
180
- it "should select the :default if provided as a Time" do
224
+ it "should select the :selected if provided as a Time" do
181
225
  output_buffer.replace ''
182
226
  @new_post.stub!(:created_at => nil)
183
- semantic_form_for(@new_post) do |builder|
184
- concat(builder.input(:created_at, :as => :datetime, :default => Time.mktime(1999)))
227
+ with_deprecation_silenced do
228
+ @form = semantic_form_for(@new_post) do |builder|
229
+ concat(builder.input(:created_at, :as => :datetime, :selected => Time.mktime(1999)))
230
+ end
185
231
  end
232
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
186
233
  output_buffer.should have_tag("form li ol li select#post_created_at_1i option[@selected]", :count => 1)
187
234
  output_buffer.should have_tag("form li ol li select#post_created_at_1i option[@value='1999'][@selected]", :count => 1)
188
235
  end
189
236
 
190
- it "should not select an option if the :default is provided as nil" do
237
+ it "should not select an option if the :selected is provided as nil" do
191
238
  output_buffer.replace ''
192
239
  @new_post.stub!(:created_at => nil)
193
- semantic_form_for(@new_post) do |builder|
194
- concat(builder.input(:created_at, :as => :datetime, :default => nil))
240
+ with_deprecation_silenced do
241
+ @form = semantic_form_for(@new_post) do |builder|
242
+ concat(builder.input(:created_at, :as => :datetime, :selected => nil))
243
+ end
195
244
  end
245
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
196
246
  output_buffer.should_not have_tag("form li ol li select#post_created_at_1i option[@selected]")
197
247
  end
198
248
 
199
- it "should select Time.now if a :default is not provided" do
249
+ it "should select nothing if a :selected is not provided" do
200
250
  output_buffer.replace ''
201
251
  @new_post.stub!(:created_at => nil)
202
- semantic_form_for(@new_post) do |builder|
252
+ form = semantic_form_for(@new_post) do |builder|
203
253
  concat(builder.input(:created_at, :as => :datetime))
204
254
  end
205
- output_buffer.should have_tag("form li ol li select#post_created_at_1i option[@selected]", :count => 1)
206
- output_buffer.should have_tag("form li ol li select#post_created_at_1i option[@value='#{Time.now.year}'][@selected]", :count => 1)
207
-
255
+ output_buffer.concat(form) if Formtastic::Util.rails3?
256
+ output_buffer.should_not have_tag("form li ol li select option[@selected]")
208
257
  end
209
258
  end
210
259
 
211
260
  it 'should warn about :selected deprecation' do
212
261
  with_deprecation_silenced do
213
- ::ActiveSupport::Deprecation.should_receive(:warn)
262
+ ::ActiveSupport::Deprecation.should_receive(:warn).any_number_of_times
214
263
  semantic_form_for(@new_post) do |builder|
215
264
  concat(builder.input(:created_at, :as => :date, :selected => Time.mktime(1999)))
216
265
  end
@@ -218,26 +267,28 @@ describe 'datetime input' do
218
267
  end
219
268
 
220
269
  end
221
-
270
+
222
271
  describe ':labels option' do
223
272
  fields = [:year, :month, :day, :hour, :minute]
224
273
  fields.each do |field|
225
274
  it "should replace the #{field} label with the specified text if :labels[:#{field}] is set" do
226
275
  output_buffer.replace ''
227
- semantic_form_for(@new_post) do |builder|
276
+ form = semantic_form_for(@new_post) do |builder|
228
277
  concat(builder.input(:created_at, :as => :datetime, :labels => { field => "another #{field} label" }))
229
278
  end
279
+ output_buffer.concat(form) if Formtastic::Util.rails3?
230
280
  output_buffer.should have_tag('form li.datetime fieldset ol li label', :count => fields.length)
231
281
  fields.each do |f|
232
282
  output_buffer.should have_tag('form li.datetime fieldset ol li label', f == field ? /another #{f} label/i : /#{f}/i)
233
283
  end
234
284
  end
235
-
285
+
236
286
  it "should not display the label for the #{field} field when :labels[:#{field}] is blank" do
237
287
  output_buffer.replace ''
238
- semantic_form_for(@new_post) do |builder|
288
+ form = semantic_form_for(@new_post) do |builder|
239
289
  concat(builder.input(:created_at, :as => :datetime, :labels => { field => "" }))
240
290
  end
291
+ output_buffer.concat(form) if Formtastic::Util.rails3?
241
292
  output_buffer.should have_tag('form li.datetime fieldset ol li label', :count => fields.length-1)
242
293
  fields.each do |f|
243
294
  output_buffer.should have_tag('form li.datetime fieldset ol li label', /#{f}/i) unless field == f
@@ -245,10 +296,10 @@ describe 'datetime input' do
245
296
  end
246
297
  end
247
298
  end
248
-
299
+
249
300
  it 'should warn about :selected deprecation' do
250
301
  with_deprecation_silenced do
251
- ::ActiveSupport::Deprecation.should_receive(:warn)
302
+ ::ActiveSupport::Deprecation.should_receive(:warn).any_number_of_times
252
303
  semantic_form_for(@new_post) do |builder|
253
304
  concat(builder.input(:created_at, :as => :datetime, :selected => Time.mktime(1999)))
254
305
  end
@@ -6,10 +6,10 @@ describe 'file input' do
6
6
  include FormtasticSpecHelper
7
7
 
8
8
  before do
9
- @output_buffer = ActiveSupport::SafeBuffer.new
9
+ @output_buffer = ''
10
10
  mock_everything
11
11
 
12
- semantic_form_for(@new_post) do |builder|
12
+ @form = semantic_form_for(@new_post) do |builder|
13
13
  concat(builder.input(:body, :as => :file))
14
14
  end
15
15
  end
@@ -23,9 +23,10 @@ describe 'file input' do
23
23
  it_should_apply_error_logic_for_input_type(:file)
24
24
 
25
25
  it 'should use input_html to style inputs' do
26
- semantic_form_for(@new_post) do |builder|
26
+ form = semantic_form_for(@new_post) do |builder|
27
27
  concat(builder.input(:title, :as => :file, :input_html => { :class => 'myclass' }))
28
28
  end
29
+ output_buffer.concat(form) if Formtastic::Util.rails3?
29
30
  output_buffer.should have_tag("form li input.myclass")
30
31
  end
31
32
 
@@ -6,10 +6,10 @@ describe 'hidden input' do
6
6
  include FormtasticSpecHelper
7
7
 
8
8
  before do
9
- @output_buffer = ActiveSupport::SafeBuffer.new
9
+ @output_buffer = ''
10
10
  mock_everything
11
11
 
12
- semantic_form_for(@new_post) do |builder|
12
+ @form = semantic_form_for(@new_post) do |builder|
13
13
  concat(builder.input(:secret, :as => :hidden))
14
14
  concat(builder.input(:author_id, :as => :hidden, :value => 99))
15
15
  concat(builder.input(:published, :as => :hidden, :input_html => {:value => true}))
@@ -21,17 +21,20 @@ describe 'hidden input' do
21
21
  it_should_not_have_a_label
22
22
 
23
23
  it "should generate a input field" do
24
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
24
25
  output_buffer.should have_tag("form li input#post_secret")
25
26
  output_buffer.should have_tag("form li input#post_secret[@type=\"hidden\"]")
26
27
  output_buffer.should have_tag("form li input#post_secret[@name=\"post[secret]\"]")
27
28
  end
28
29
 
29
30
  it "should pass any explicitly specified value - using :value" do
31
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
30
32
  output_buffer.should have_tag("form li input#post_author_id[@type=\"hidden\"][@value=\"99\"]")
31
33
  end
32
34
 
33
35
  # Handle Formtastic :input_html options for consistency.
34
36
  it "should pass any explicitly specified value - using :input_html options" do
37
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
35
38
  output_buffer.should have_tag("form li input#post_published[@type=\"hidden\"][@value=\"true\"]")
36
39
  end
37
40
 
@@ -40,13 +43,24 @@ describe 'hidden input' do
40
43
  @errors.stub!(:[]).with(:secret).and_return(["foo", "bah"])
41
44
  @new_post.stub!(:errors).and_return(@errors)
42
45
 
43
- semantic_form_for(@new_post) do |builder|
46
+ form = semantic_form_for(@new_post) do |builder|
44
47
  concat(builder.input(:secret, :as => :hidden))
45
48
  end
46
49
 
50
+ output_buffer.concat(form) if Formtastic::Util.rails3?
47
51
  output_buffer.should_not have_tag("form li p.inline-errors")
48
52
  output_buffer.should_not have_tag("form li ul.errors")
49
53
  end
54
+
55
+ it "should not render inline hints" do
56
+ form = semantic_form_for(@new_post) do |builder|
57
+ concat(builder.input(:secret, :as => :hidden, :hint => "all your base are belong to use"))
58
+ end
59
+
60
+ output_buffer.concat(form) if Formtastic::Util.rails3?
61
+ output_buffer.should_not have_tag("form li p.inline-hints")
62
+ output_buffer.should_not have_tag("form li ul.hints")
63
+ end
50
64
 
51
65
  end
52
66