formtastic 1.0.1 → 1.1.0.beta

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