speedo-formstrap 1.2.0 → 1.2.1

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 (82) hide show
  1. data/README.md +2 -2
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/formtastic-bootstrap.gemspec +1 -1
  5. data/lib/formtastic-bootstrap.rb +5 -5
  6. data/lib/formtastic-bootstrap/actions.rb +4 -4
  7. data/lib/formtastic-bootstrap/actions/base.rb +1 -1
  8. data/lib/formtastic-bootstrap/actions/button_action.rb +1 -1
  9. data/lib/formtastic-bootstrap/actions/input_action.rb +1 -1
  10. data/lib/formtastic-bootstrap/actions/link_action.rb +1 -1
  11. data/lib/formtastic-bootstrap/engine.rb +1 -1
  12. data/lib/formtastic-bootstrap/form_builder.rb +9 -11
  13. data/lib/formtastic-bootstrap/helpers.rb +6 -8
  14. data/lib/formtastic-bootstrap/helpers/action_helper.rb +2 -2
  15. data/lib/formtastic-bootstrap/helpers/actions_helper.rb +2 -2
  16. data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +10 -14
  17. data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +7 -12
  18. data/lib/formtastic-bootstrap/helpers/input_helper.rb +2 -2
  19. data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +6 -6
  20. data/lib/formtastic-bootstrap/inputs.rb +21 -21
  21. data/lib/formtastic-bootstrap/inputs/base.rb +10 -11
  22. data/lib/formtastic-bootstrap/inputs/base/choices.rb +24 -13
  23. data/lib/formtastic-bootstrap/inputs/base/errors.rb +1 -1
  24. data/lib/formtastic-bootstrap/inputs/base/hints.rb +1 -1
  25. data/lib/formtastic-bootstrap/inputs/base/html.rb +1 -1
  26. data/lib/formtastic-bootstrap/inputs/base/labelling.rb +7 -17
  27. data/lib/formtastic-bootstrap/inputs/base/numeric.rb +1 -1
  28. data/lib/formtastic-bootstrap/inputs/base/stringish.rb +1 -1
  29. data/lib/formtastic-bootstrap/inputs/base/timeish.rb +13 -6
  30. data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +15 -33
  31. data/lib/formtastic-bootstrap/inputs/boolean_input.rb +1 -1
  32. data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +1 -1
  33. data/lib/formtastic-bootstrap/inputs/date_input.rb +1 -1
  34. data/lib/formtastic-bootstrap/inputs/datetime_input.rb +1 -1
  35. data/lib/formtastic-bootstrap/inputs/email_input.rb +1 -1
  36. data/lib/formtastic-bootstrap/inputs/file_input.rb +1 -1
  37. data/lib/formtastic-bootstrap/inputs/hidden_input.rb +1 -1
  38. data/lib/formtastic-bootstrap/inputs/number_input.rb +3 -3
  39. data/lib/formtastic-bootstrap/inputs/password_input.rb +1 -1
  40. data/lib/formtastic-bootstrap/inputs/phone_input.rb +1 -1
  41. data/lib/formtastic-bootstrap/inputs/radio_input.rb +13 -14
  42. data/lib/formtastic-bootstrap/inputs/range_input.rb +3 -3
  43. data/lib/formtastic-bootstrap/inputs/search_input.rb +1 -1
  44. data/lib/formtastic-bootstrap/inputs/select_input.rb +1 -1
  45. data/lib/formtastic-bootstrap/inputs/string_input.rb +1 -1
  46. data/lib/formtastic-bootstrap/inputs/text_input.rb +1 -1
  47. data/lib/formtastic-bootstrap/inputs/time_input.rb +1 -1
  48. data/lib/formtastic-bootstrap/inputs/time_zone_input.rb +1 -1
  49. data/lib/formtastic-bootstrap/inputs/url_input.rb +1 -1
  50. data/spec/actions/button_action_spec.rb +1 -1
  51. data/spec/actions/generic_action_spec.rb +1 -1
  52. data/spec/actions/input_action_spec.rb +1 -1
  53. data/spec/actions/link_action_spec.rb +1 -1
  54. data/spec/builder/semantic_fields_for_spec.rb +16 -16
  55. data/spec/helpers/action_helper_spec.rb +1 -1
  56. data/spec/helpers/actions_helper_spec.rb +1 -1
  57. data/spec/helpers/buttons_helper_spec.rb +46 -56
  58. data/spec/helpers/input_helper_spec.rb +209 -209
  59. data/spec/helpers/inputs_helper_spec.rb +103 -117
  60. data/spec/inputs/boolean_input_spec.rb +46 -74
  61. data/spec/inputs/check_boxes_input_spec.rb +82 -110
  62. data/spec/inputs/date_input_spec.rb +15 -81
  63. data/spec/inputs/datetime_input_spec.rb +13 -13
  64. data/spec/inputs/email_input_spec.rb +6 -34
  65. data/spec/inputs/file_input_spec.rb +6 -34
  66. data/spec/inputs/hidden_input_spec.rb +13 -41
  67. data/spec/inputs/number_input_spec.rb +97 -127
  68. data/spec/inputs/password_input_spec.rb +6 -34
  69. data/spec/inputs/phone_input_spec.rb +6 -34
  70. data/spec/inputs/radio_input_spec.rb +45 -73
  71. data/spec/inputs/range_input_spec.rb +66 -94
  72. data/spec/inputs/search_input_spec.rb +6 -33
  73. data/spec/inputs/select_input_spec.rb +78 -124
  74. data/spec/inputs/string_input_spec.rb +22 -67
  75. data/spec/inputs/text_input_spec.rb +15 -42
  76. data/spec/inputs/time_input_spec.rb +23 -23
  77. data/spec/inputs/time_zone_input_spec.rb +20 -20
  78. data/spec/inputs/url_input_spec.rb +6 -34
  79. data/spec/support/custom_macros.rb +196 -67
  80. data/spec/support/formtastic_spec_helper.rb +6 -22
  81. data/speedo-formstrap.gemspec +146 -0
  82. metadata +18 -17
@@ -8,48 +8,50 @@ describe 'boolean input' do
8
8
  before do
9
9
  @output_buffer = ''
10
10
  mock_everything
11
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
11
+ Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
12
12
 
13
13
  concat(semantic_form_for(@new_post) do |builder|
14
14
  concat(builder.input(:allow_comments, :as => :boolean))
15
15
  end)
16
16
  end
17
17
 
18
- it_should_have_input_wrapper_with_class("boolean-wrapper")
19
- it_should_have_input_wrapper_with_class("control-group")
18
+ it_should_have_input_wrapper_with_class("boolean")
19
+ it_should_have_input_wrapper_with_class(:clearfix)
20
20
  it_should_have_input_class_in_the_right_place
21
21
  it_should_have_input_wrapper_with_id("post_allow_comments_input")
22
22
  it_should_apply_error_logic_for_input_type(:boolean, :block)
23
23
 
24
24
  it 'should generate a label containing the input' do
25
- output_buffer.should have_tag('label.control-label')
26
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox', :count => 1)
27
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox[@for="post_allow_comments"]')
28
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox', /Allow comments/)
29
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@type="checkbox"]', :count => 1)
30
- output_buffer.should have_tag('form div.control-group input[@type="hidden"]', :count => 1)
31
- output_buffer.should_not have_tag('form div.control-group label input[@type="hidden"]', :count => 1) # invalid HTML5
25
+ output_buffer.should_not have_tag('label.label')
26
+
27
+
28
+ output_buffer.should have_tag('form div.clearfix div.input ul li label', :count => 1)
29
+ output_buffer.should have_tag('form div.clearfix div.input ul li label[@for="post_allow_comments"]')
30
+ output_buffer.should have_tag('form div.clearfix div.input ul li label', /Allow comments/)
31
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@type="checkbox"]', :count => 1)
32
+ output_buffer.should have_tag('form div.clearfix input[@type="hidden"]', :count => 1)
33
+ output_buffer.should_not have_tag('form div.clearfix label input[@type="hidden"]', :count => 1) # invalid HTML5
32
34
  end
33
35
 
34
36
  it 'should generate a checkbox input' do
35
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input')
36
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input#post_allow_comments')
37
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@type="checkbox"]')
38
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@name="post[allow_comments]"]')
39
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@type="checkbox"][@value="1"]')
37
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input')
38
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input#post_allow_comments')
39
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@type="checkbox"]')
40
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@name="post[allow_comments]"]')
41
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@type="checkbox"][@value="1"]')
40
42
  end
41
43
 
42
44
  it 'should generate a checked input if object.method returns true' do
43
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@checked="checked"]')
44
- output_buffer.should have_tag('form div.control-group input[@name="post[allow_comments]"]', :count => 2)
45
- output_buffer.should have_tag('form div.control-group div.controls input#post_allow_comments', :count => 1)
45
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@checked="checked"]')
46
+ output_buffer.should have_tag('form div.clearfix input[@name="post[allow_comments]"]', :count => 2)
47
+ output_buffer.should have_tag('form div.clearfix div.input ul li input#post_allow_comments', :count => 1)
46
48
  end
47
49
 
48
50
  it 'should generate a checked input if :input_html is passed :checked => checked' do
49
51
  concat(semantic_form_for(@new_post) do |builder|
50
52
  concat(builder.input(:answer_comments, :as => :boolean, :input_html => {:checked => 'checked'}))
51
53
  end)
52
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@checked="checked"]')
54
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@checked="checked"]')
53
55
  end
54
56
 
55
57
  it 'should name the hidden input with the :name html_option' do
@@ -57,8 +59,8 @@ describe 'boolean input' do
57
59
  concat(builder.input(:answer_comments, :as => :boolean, :input_html => { :name => "foo" }))
58
60
  end)
59
61
 
60
- output_buffer.should have_tag('form div.control-group div.controls input[@type="checkbox"][@name="foo"]', :count => 1)
61
- output_buffer.should have_tag('form div.control-group input[@type="hidden"][@name="foo"]', :count => 1)
62
+ output_buffer.should have_tag('form div.clearfix div.input ul li input[@type="checkbox"][@name="foo"]', :count => 1)
63
+ output_buffer.should have_tag('form div.clearfix input[@type="hidden"][@name="foo"]', :count => 1)
62
64
  end
63
65
 
64
66
  it 'should name the hidden input with the :name html_option' do
@@ -66,33 +68,33 @@ describe 'boolean input' do
66
68
  concat(builder.input(:answer_comments, :as => :boolean, :input_html => { :name => "foo" }))
67
69
  end)
68
70
 
69
- output_buffer.should have_tag('form div.control-group div.controls input[@type="checkbox"][@name="foo"]', :count => 1)
70
- output_buffer.should have_tag('form div.control-group input[@type="hidden"][@name="foo"]', :count => 1)
71
+ output_buffer.should have_tag('form div.clearfix div.input ul li input[@type="checkbox"][@name="foo"]', :count => 1)
72
+ output_buffer.should have_tag('form div.clearfix input[@type="hidden"][@name="foo"]', :count => 1)
71
73
  end
72
74
 
73
75
  it "should generate a disabled input and hidden input if :input_html is passed :disabled => 'disabled' " do
74
76
  concat(semantic_form_for(@new_post) do |builder|
75
77
  concat(builder.input(:allow_comments, :as => :boolean, :input_html => {:disabled => 'disabled'}))
76
78
  end)
77
- output_buffer.should have_tag('form div.control-group div.controls label input[@disabled="disabled"]', :count => 1)
78
- output_buffer.should have_tag('form div.control-group input[@type="hidden"][@disabled="disabled"]', :count => 1)
79
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@disabled="disabled"]', :count => 1)
80
+ output_buffer.should have_tag('form div.clearfix input[@type="hidden"][@disabled="disabled"]', :count => 1)
79
81
  end
80
82
 
81
83
  it 'should generate an input[id] with matching label[for] when id passed in :input_html' do
82
84
  concat(semantic_form_for(@new_post) do |builder|
83
85
  concat(builder.input(:allow_comments, :as => :boolean, :input_html => {:id => 'custom_id'}))
84
86
  end)
85
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@id="custom_id"]')
86
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox[@for="custom_id"]')
87
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@id="custom_id"]')
88
+ output_buffer.should have_tag('form div.clearfix div.input ul li label[@for="custom_id"]')
87
89
  end
88
90
 
89
91
  it 'should allow checked and unchecked values to be sent' do
90
92
  concat(semantic_form_for(@new_post) do |builder|
91
93
  concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'checked', :unchecked_value => 'unchecked'))
92
94
  end)
93
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@type="checkbox"][@value="checked"]:not([@unchecked_value][@checked_value])')
94
- output_buffer.should have_tag('form div.control-group input[@type="hidden"][@value="unchecked"]')
95
- output_buffer.should_not have_tag('form div.control-group label.checkbox input[@type="hidden"]') # invalid HTML5
95
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@type="checkbox"][@value="checked"]:not([@unchecked_value][@checked_value])')
96
+ output_buffer.should have_tag('form div.clearfix input[@type="hidden"][@value="unchecked"]')
97
+ output_buffer.should_not have_tag('form div.clearfix label input[@type="hidden"]') # invalid HTML5
96
98
  end
97
99
 
98
100
  it 'should generate a checked input if object.method returns checked value' do
@@ -102,7 +104,7 @@ describe 'boolean input' do
102
104
  concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'yes', :unchecked_value => 'no'))
103
105
  end)
104
106
 
105
- output_buffer.should have_tag('form label.checkbox input[@type="checkbox"][@value="yes"][@checked="checked"]')
107
+ output_buffer.should have_tag('form li label input[@type="checkbox"][@value="yes"][@checked="checked"]')
106
108
  end
107
109
 
108
110
  it 'should not generate a checked input if object.method returns unchecked value' do
@@ -112,7 +114,7 @@ describe 'boolean input' do
112
114
  concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'yes', :unchecked_value => 'no'))
113
115
  end)
114
116
 
115
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@type="checkbox"][@value="yes"]:not([@checked])')
117
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@type="checkbox"][@value="yes"]:not([@checked])')
116
118
  end
117
119
 
118
120
  it 'should generate a checked input if object.method returns checked value' do
@@ -122,7 +124,7 @@ describe 'boolean input' do
122
124
  concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'yes', :unchecked_value => 'no'))
123
125
  end)
124
126
 
125
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@type="checkbox"][@value="yes"][@checked="checked"]')
127
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@type="checkbox"][@value="yes"][@checked="checked"]')
126
128
  end
127
129
 
128
130
  it 'should not generate a checked input if object.method returns unchecked value' do
@@ -132,7 +134,7 @@ describe 'boolean input' do
132
134
  concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'yes', :unchecked_value => 'no'))
133
135
  end)
134
136
 
135
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@type="checkbox"][@value="yes"]:not([@checked])')
137
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@type="checkbox"][@value="yes"]:not([@checked])')
136
138
  end
137
139
 
138
140
  it 'should generate a label and a checkbox even if no object is given' do
@@ -140,17 +142,17 @@ describe 'boolean input' do
140
142
  concat(builder.input(:allow_comments, :as => :boolean))
141
143
  end)
142
144
 
143
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox[@for="project_allow_comments"]')
144
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox', /Allow comments/)
145
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@type="checkbox"]')
145
+ output_buffer.should have_tag('form div.clearfix div.input ul li label[@for="project_allow_comments"]')
146
+ output_buffer.should have_tag('form div.clearfix div.input ul li label', /Allow comments/)
147
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@type="checkbox"]')
146
148
 
147
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input#project_allow_comments')
148
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@type="checkbox"]')
149
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@name="project[allow_comments]"]')
149
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input#project_allow_comments')
150
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@type="checkbox"]')
151
+ output_buffer.should have_tag('form div.clearfix div.input ul li label input[@name="project[allow_comments]"]')
150
152
  end
151
153
 
152
154
  context "when required" do
153
-
155
+
154
156
  it "should add the required attribute to the input's html options" do
155
157
  with_config :use_required_attribute, true do
156
158
  concat(semantic_form_for(@new_post) do |builder|
@@ -159,7 +161,7 @@ describe 'boolean input' do
159
161
  output_buffer.should have_tag("input[@required]")
160
162
  end
161
163
  end
162
-
164
+
163
165
  it "should not add the required attribute to the boolean fields input's html options" do
164
166
  with_config :use_required_attribute, true do
165
167
  concat(semantic_form_for(@new_post) do |builder|
@@ -168,7 +170,7 @@ describe 'boolean input' do
168
170
  output_buffer.should_not have_tag("input[@required]")
169
171
  end
170
172
  end
171
-
173
+
172
174
  end
173
175
 
174
176
  describe "when namespace is provided" do
@@ -176,7 +178,7 @@ describe 'boolean input' do
176
178
  before do
177
179
  @output_buffer = ''
178
180
  mock_everything
179
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
181
+ Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
180
182
 
181
183
  concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
182
184
  concat(builder.input(:allow_comments, :as => :boolean))
@@ -188,34 +190,4 @@ describe 'boolean input' do
188
190
 
189
191
  end
190
192
 
191
- describe "when index is provided" do
192
-
193
- before do
194
- @output_bugger = ''
195
- mock_everything
196
-
197
- concat(semantic_form_for(@new_post) do |builder|
198
- concat(builder.fields_for(:author, :index => 3) do |author|
199
- concat(author.input(:name, :as => :boolean))
200
- end)
201
- end)
202
- end
203
-
204
- it 'should index the id of the wrapper' do
205
- output_buffer.should have_tag("div#post_author_attributes_3_name_input")
206
- end
207
-
208
- it 'should index the id of the input tag' do
209
- output_buffer.should have_tag("input#post_author_attributes_3_name")
210
- end
211
-
212
- it 'should index the name of the hidden input' do
213
- output_buffer.should have_tag("input[@type='hidden'][@name='post[author_attributes][3][name]']")
214
- end
215
-
216
- it 'should index the name of the checkbox input' do
217
- output_buffer.should have_tag("input[@type='checkbox'][@name='post[author_attributes][3][name]']")
218
- end
219
- end
220
-
221
193
  end
@@ -9,109 +9,109 @@ describe 'check_boxes input' do
9
9
  before do
10
10
  @output_buffer = ''
11
11
  mock_everything
12
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
13
-
12
+ Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
13
+
14
14
  concat(semantic_form_for(@fred) do |builder|
15
15
  concat(builder.input(:posts, :as => :check_boxes, :value_as_class => true, :required => true))
16
16
  end)
17
17
  end
18
18
 
19
- it_should_have_input_wrapper_with_class("check_boxes-wrapper")
20
- it_should_have_input_wrapper_with_class("control-group")
19
+ it_should_have_input_wrapper_with_class("check_boxes")
20
+ it_should_have_input_wrapper_with_class(:clearfix)
21
21
  it_should_have_input_class_in_the_right_place
22
22
  it_should_have_input_wrapper_with_id("author_posts_input")
23
23
  it_should_have_a_nested_div
24
- it_should_have_a_nested_div_with_class('choices.controls')
25
- #it_should_have_a_nested_unordered_list_with_class('choices-group.inputs-list')
24
+ it_should_have_a_nested_div_with_class('choices.input')
25
+ it_should_have_a_nested_unordered_list_with_class('choices-group.inputs-list')
26
26
  it_should_apply_error_logic_for_input_type(:check_boxes, :block)
27
27
  it_should_call_find_on_association_class_when_no_collection_is_provided(:check_boxes)
28
28
  it_should_use_the_collection_when_provided(:check_boxes, 'input[@type="checkbox"]')
29
29
 
30
30
  # TODO Refactor out the next three tests and their bretheren in radio_input_spec
31
31
  it 'should generate a \'legend\' containing a label with text for the input' do
32
- output_buffer.should have_tag('form div.control-group label.control-label')
33
- output_buffer.should have_tag('form div.control-group label.control-label', /Posts/)
32
+ output_buffer.should have_tag('form div.clearfix label')
33
+ output_buffer.should have_tag('form div.clearfix label', /Posts/)
34
34
  end
35
35
 
36
36
  it 'should not link the \'legend\' label to any input' do
37
- output_buffer.should_not have_tag('form div.control-group > label.control-label[@for]')
37
+ output_buffer.should_not have_tag('form div.clearfix > label[@for]')
38
38
  end
39
39
 
40
- # it 'should generate an unordered list with a list item for each choice' do
41
- # output_buffer.should have_tag('form div.control-group div.controls ul')
42
- # output_buffer.should have_tag('form div.control-group div.controls ul li.choice', :count => ::Post.all.size)
43
- # end
40
+ it 'should generate an unordered list with a list item for each choice' do
41
+ output_buffer.should have_tag('form div.clearfix div.input ul')
42
+ output_buffer.should have_tag('form div.clearfix div.input ul li.choice', :count => ::Post.all.size)
43
+ end
44
44
 
45
45
  # it 'should generate a legend containing a label with text for the input' do
46
46
  # output_buffer.should have_tag('form li fieldset legend.label label')
47
47
  # output_buffer.should have_tag('form li fieldset legend.label label', /Posts/)
48
48
  # end
49
- #
49
+ #
50
50
  # it 'should not link the label within the legend to any input' do
51
51
  # output_buffer.should_not have_tag('form li fieldset legend label[@for^="author_post_ids_"]')
52
52
  # end
53
- #
53
+ #
54
54
  # it 'should generate an ordered list with an li.choice for each choice' do
55
55
  # output_buffer.should have_tag('form li fieldset ol')
56
56
  # output_buffer.should have_tag('form li fieldset ol li.choice input[@type=checkbox]', :count => ::Post.all.size)
57
57
  # end
58
58
 
59
59
  it 'should have one option with a "checked" attribute' do
60
- output_buffer.should have_tag('form .controls input[@checked]', :count => 1)
60
+ output_buffer.should have_tag('form li input[@checked]', :count => 1)
61
61
  end
62
62
 
63
63
  it 'should not generate hidden inputs with default value blank' do
64
- output_buffer.should_not have_tag("form div div label input[@type='hidden'][@value='']")
64
+ output_buffer.should_not have_tag("form div div ul li label input[@type='hidden'][@value='']")
65
65
  end
66
66
 
67
- # it 'should not render hidden inputs inside the ol' do
68
- # output_buffer.should_not have_tag("form div div ul li input[@type='hidden']")
69
- # end
67
+ it 'should not render hidden inputs inside the ol' do
68
+ output_buffer.should_not have_tag("form div div ul li input[@type='hidden']")
69
+ end
70
70
 
71
71
  it 'should render one hidden input for each choice outside the ol' do
72
- output_buffer.should have_tag("form div.control-group > input[@type='hidden']", :count => 1)
72
+ output_buffer.should have_tag("form div.clearfix > input[@type='hidden']", :count => 1)
73
73
  end
74
74
 
75
75
  describe "each choice" do
76
-
77
- it 'should not give the choice label the .control-label class' do
78
- output_buffer.should_not have_tag('div.controls label.control-label')
76
+
77
+ it 'should not give the choice label the .label class' do
78
+ output_buffer.should_not have_tag('li.choice label.label')
79
79
  end
80
-
80
+
81
81
  it 'should not be marked as required' do
82
- output_buffer.should_not have_tag('div.checkbox input[@required]')
82
+ output_buffer.should_not have_tag('li.choice input[@required]')
83
83
  end
84
-
84
+
85
85
  it 'should contain a label for the radio input with a nested input and label text' do
86
86
  ::Post.all.each do |post|
87
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox', /#{post.to_label}/)
88
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox[@for='author_post_ids_#{post.id}']")
87
+ output_buffer.should have_tag('form div.clearfix div.input ul li label', /#{post.to_label}/)
88
+ output_buffer.should have_tag("form div.clearfix div.input ul li label[@for='author_post_ids_#{post.id}']")
89
89
  end
90
90
  end
91
91
 
92
92
  it 'should use values as li.class when value_as_class is true' do
93
93
  ::Post.all.each do |post|
94
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox.post_#{post.id}")
94
+ output_buffer.should have_tag("form div.clearfix div.input ul li.post_#{post.id} label")
95
95
  end
96
96
  end
97
-
97
+
98
98
  it 'should have a checkbox input but no hidden field for each post' do
99
99
  ::Post.all.each do |post|
100
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input#author_post_ids_#{post.id}")
101
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@name='author[post_ids][]']", :count => 1)
100
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input#author_post_ids_#{post.id}")
101
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@name='author[post_ids][]']", :count => 1)
102
102
  end
103
103
  end
104
104
 
105
105
  it 'should have a hidden field with an empty array value for the collection to allow clearing of all checkboxes' do
106
- output_buffer.should have_tag("form div.control-group > input[@type=hidden][@name='author[post_ids][]'][@value='']", :count => 1)
106
+ output_buffer.should have_tag("form div.clearfix > input[@type=hidden][@name='author[post_ids][]'][@value='']", :count => 1)
107
107
  end
108
108
 
109
- it 'the hidden field with an empty array value should be followed by the div.controls and the ul' do
110
- output_buffer.should have_tag("form div.control-group > input[@type=hidden][@name='author[post_ids][]'][@value=''] + div.controls", :count => 1)
109
+ it 'the hidden field with an empty array value should be followed by the div.input and the ul' do
110
+ output_buffer.should have_tag("form div.clearfix > input[@type=hidden][@name='author[post_ids][]'][@value=''] + div.input ul", :count => 1)
111
111
  end
112
112
 
113
113
  it 'should not have a hidden field with an empty string value for the collection' do
114
- output_buffer.should_not have_tag("form div.control-group > input[@type=hidden][@name='author[post_ids]'][@value='']", :count => 1)
114
+ output_buffer.should_not have_tag("form div.clearfix > input[@type=hidden][@name='author[post_ids]'][@value='']", :count => 1)
115
115
  end
116
116
 
117
117
  it 'should have a checkbox and a hidden field for each post with :hidden_field => true' do
@@ -122,15 +122,15 @@ describe 'check_boxes input' do
122
122
  end)
123
123
 
124
124
  ::Post.all.each do |post|
125
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input#author_post_ids_#{post.id}")
126
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@name='author[post_ids][]']", :count => 2)
125
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input#author_post_ids_#{post.id}")
126
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@name='author[post_ids][]']", :count => 2)
127
127
  end
128
128
 
129
129
  end
130
130
 
131
131
  it "should mark input as checked if it's the the existing choice" do
132
132
  ::Post.all.include?(@fred.posts.first).should be_true
133
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@checked='checked']")
133
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@checked='checked']")
134
134
  end
135
135
  end
136
136
 
@@ -143,26 +143,26 @@ describe 'check_boxes input' do
143
143
  end
144
144
 
145
145
  it 'should generate a top-level div with \'legend\'' do
146
- output_buffer.should have_tag('form div.control-group > label.control-label', /Author/)
146
+ output_buffer.should have_tag('form div.clearfix > label', /Author/)
147
147
  end
148
148
 
149
149
  it 'shold generate an li tag for each item in the collection' do
150
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox input[@type=checkbox]', :count => ::Author.all.size)
150
+ output_buffer.should have_tag('form div.clearfix div.input ul li input[@type=checkbox]', :count => ::Author.all.size)
151
151
  end
152
152
 
153
153
  it 'should generate labels for each item' do
154
154
  ::Author.all.each do |author|
155
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox', /#{author.to_label}/)
156
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox[@for='project_author_id_#{author.id}']")
155
+ output_buffer.should have_tag('form div.clearfix div.input ul li label', /#{author.to_label}/)
156
+ output_buffer.should have_tag("form div.clearfix div.input ul li label[@for='project_author_id_#{author.id}']")
157
157
  end
158
158
  end
159
159
 
160
160
  it 'should generate inputs for each item' do
161
161
  ::Author.all.each do |author|
162
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input#project_author_id_#{author.id}")
163
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@type='checkbox']")
164
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@value='#{author.id}']")
165
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@name='project[author_id][]']")
162
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input#project_author_id_#{author.id}")
163
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@type='checkbox']")
164
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@value='#{author.id}']")
165
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@name='project[author_id][]']")
166
166
  end
167
167
  end
168
168
 
@@ -171,7 +171,7 @@ describe 'check_boxes input' do
171
171
  concat(builder.input(:author_id, :as => :check_boxes, :collection => [["<b>Item 1</b>", 1], ["<b>Item 2</b>", 2]]))
172
172
  end)
173
173
 
174
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox') do |label|
174
+ output_buffer.should have_tag('form div.clearfix div.input ul li label') do |label|
175
175
  # label.body.should match /&lt;b&gt;Item [12]&lt;\/b&gt;$/
176
176
  label.body.should match /&lt;b&gt;Item [12]&lt;\/b&gt;/
177
177
  end
@@ -190,18 +190,18 @@ describe 'check_boxes input' do
190
190
 
191
191
  it 'should have a checkbox input for each post' do
192
192
  ::Post.all.each do |post|
193
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input#author_post_ids_#{post.id}")
194
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@name='author[post_ids][]']", :count => ::Post.all.length)
193
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input#author_post_ids_#{post.id}")
194
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@name='author[post_ids][]']", :count => ::Post.all.length)
195
195
  end
196
196
  end
197
197
 
198
198
  it "should mark input as checked if it's the the existing choice" do
199
199
  ::Post.all.include?(@fred.posts.first).should be_true
200
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@checked='checked']")
200
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@checked='checked']")
201
201
  end
202
202
 
203
203
  it 'should not generate empty hidden inputs' do
204
- output_buffer.should_not have_tag("form div.control-group div.controls label.checkbox input[@type='hidden'][@value='']", :count => ::Post.all.length)
204
+ output_buffer.should_not have_tag("form div.clearfix div.input ul li label input[@type='hidden'][@value='']", :count => ::Post.all.length)
205
205
  end
206
206
  end
207
207
 
@@ -220,7 +220,7 @@ describe 'check_boxes input' do
220
220
  end
221
221
 
222
222
  it 'should not have any disabled item(s)' do
223
- output_buffer.should_not have_tag("form div.control-group div.controls label.checkbox input[@disabled='disabled']")
223
+ output_buffer.should_not have_tag("form div.clearfix div.input ul li label input[@disabled='disabled']")
224
224
  end
225
225
  end
226
226
 
@@ -234,9 +234,9 @@ describe 'check_boxes input' do
234
234
  end
235
235
 
236
236
  it "should have one item disabled; the specified one" do
237
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@disabled='disabled']", :count => 1)
238
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox[@for='post_author_ids_#{@fred.id}']", /fred/i)
239
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@disabled='disabled'][@value='#{@fred.id}']")
237
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@disabled='disabled']", :count => 1)
238
+ output_buffer.should have_tag("form div.clearfix div.input ul li label[@for='post_author_ids_#{@fred.id}']", /fred/i)
239
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@disabled='disabled'][@value='#{@fred.id}']")
240
240
  end
241
241
  end
242
242
 
@@ -250,11 +250,11 @@ describe 'check_boxes input' do
250
250
  end
251
251
 
252
252
  it "should have multiple items disabled; the specified ones" do
253
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@disabled='disabled']", :count => 2)
254
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox[@for='post_author_ids_#{@bob.id}']", /bob/i)
255
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@disabled='disabled'][@value='#{@bob.id}']")
256
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox[@for='post_author_ids_#{@fred.id}']", /fred/i)
257
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@disabled='disabled'][@value='#{@fred.id}']")
253
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@disabled='disabled']", :count => 2)
254
+ output_buffer.should have_tag("form div.clearfix div.input ul li label[@for='post_author_ids_#{@bob.id}']", /bob/i)
255
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@disabled='disabled'][@value='#{@bob.id}']")
256
+ output_buffer.should have_tag("form div.clearfix div.input ul li label[@for='post_author_ids_#{@fred.id}']", /fred/i)
257
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@disabled='disabled'][@value='#{@fred.id}']")
258
258
  end
259
259
  end
260
260
 
@@ -277,7 +277,7 @@ describe 'check_boxes input' do
277
277
  end
278
278
 
279
279
  it "should do foo" do
280
- output_buffer.should have_tag("div.control-group > label.control-label", /Translated/)
280
+ output_buffer.should have_tag("div.clearfix > label", /Translated/)
281
281
  end
282
282
 
283
283
  end
@@ -291,7 +291,7 @@ describe 'check_boxes input' do
291
291
  end
292
292
 
293
293
  it "should output the correct label title" do
294
- output_buffer.should have_tag("div.control-group > label.control-label", /The authors/)
294
+ output_buffer.should have_tag("div.clearfix > label", /The authors/)
295
295
  end
296
296
  end
297
297
 
@@ -305,13 +305,13 @@ describe 'check_boxes input' do
305
305
  end
306
306
 
307
307
  it "should output an empty \'legend\'" do
308
- output_buffer.should have_tag("div.control-group > label.control-label", "")
308
+ output_buffer.should have_tag("div.clearfix > label", "")
309
309
  end
310
-
310
+
311
311
  it "should not cause escaped HTML" do
312
312
  output_buffer.should_not include("&gt;")
313
313
  end
314
-
314
+
315
315
  end
316
316
 
317
317
  describe "when :required option is true" do
@@ -323,7 +323,7 @@ describe 'check_boxes input' do
323
323
  end
324
324
 
325
325
  it "should output the correct label title" do
326
- output_buffer.should have_tag("div.control-group > label.control-label abbr")
326
+ output_buffer.should have_tag("div.clearfix > label abbr")
327
327
  end
328
328
  end
329
329
 
@@ -366,7 +366,7 @@ describe 'check_boxes input' do
366
366
  item.should_not_receive(:id)
367
367
  item.stub!(:custom_value).and_return('custom_value')
368
368
  item.should_receive(:custom_value).exactly(3).times
369
- @new_post.author.should_receive(:custom_value).exactly(1).times
369
+ @new_post.author.should_receive(:custom_value).exactly(3).times
370
370
  concat(semantic_form_for(@new_post) do |builder|
371
371
  concat(builder.input(:author, :as => :check_boxes, :member_value => :custom_value, :collection => [item, item, item]))
372
372
  end)
@@ -374,21 +374,21 @@ describe 'check_boxes input' do
374
374
  end
375
375
  end
376
376
  end
377
-
377
+
378
378
  describe 'when :collection is provided as an array of arrays' do
379
379
  before do
380
380
  @output_buffer = ''
381
381
  mock_everything
382
382
  @fred.stub(:genres) { ['fiction', 'biography'] }
383
-
383
+
384
384
  concat(semantic_form_for(@fred) do |builder|
385
385
  concat(builder.input(:genres, :as => :check_boxes, :collection => [['Fiction', 'fiction'], ['Non-fiction', 'non_fiction'], ['Biography', 'biography']]))
386
386
  end)
387
387
  end
388
-
388
+
389
389
  it 'should check the correct checkboxes' do
390
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@value='fiction'][@checked='checked']")
391
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox input[@value='biography'][@checked='checked']")
390
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@value='fiction'][@checked='checked']")
391
+ output_buffer.should have_tag("form div.clearfix div.input ul li label input[@value='biography'][@checked='checked']")
392
392
  end
393
393
  end
394
394
 
@@ -402,50 +402,22 @@ describe 'check_boxes input' do
402
402
  concat(builder.input(:posts, :as => :check_boxes))
403
403
  end)
404
404
  end
405
-
405
+
406
406
  it "should have a label for #context2_author_post_ids_19" do
407
- output_buffer.should have_tag("form label.checkbox[@for='context2_author_post_ids_19']")
407
+ output_buffer.should have_tag("form li label[@for='context2_author_post_ids_19']")
408
408
  end
409
409
 
410
410
  it_should_have_input_with_id('context2_author_post_ids_19')
411
411
  it_should_have_input_wrapper_with_id("context2_author_posts_input")
412
412
  end
413
413
 
414
- describe "when index is provided" do
415
-
416
- before do
417
- @output_buffer = ''
418
- mock_everything
419
-
420
- concat(semantic_form_for(@fred) do |builder|
421
- concat(builder.fields_for(@fred.posts.first, :index => 3) do |author|
422
- concat(author.input(:authors, :as => :check_boxes))
423
- end)
424
- end)
425
- end
426
-
427
- it 'should index the id of the wrapper' do
428
- output_buffer.should have_tag("div#author_post_3_authors_input")
429
- end
430
-
431
- it 'should index the id of the input tag' do
432
- output_buffer.should have_tag("input#author_post_3_author_ids_42")
433
- end
434
-
435
- it 'should index the name of the checkbox input' do
436
- output_buffer.should have_tag("input[@type='checkbox'][@name='author[post][3][author_ids][]']")
437
- end
438
-
439
- end
440
-
441
-
442
414
  describe "when collection is an array" do
443
415
  before do
444
416
  @output_buffer = ''
445
417
  @_collection = [["First", 1], ["Second", 2]]
446
418
  mock_everything
447
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
448
-
419
+ Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
420
+
449
421
  concat(semantic_form_for(@fred) do |builder|
450
422
  concat(builder.input(:posts, :as => :check_boxes, :collection => @_collection))
451
423
  end)
@@ -453,15 +425,15 @@ describe 'check_boxes input' do
453
425
 
454
426
  it "should use array items for labels and values" do
455
427
  @_collection.each do |post|
456
- output_buffer.should have_tag('form div.control-group div.controls label.checkbox', /#{post.first}/)
457
- output_buffer.should have_tag("form div.control-group div.controls label.checkbox[@for='author_post_ids_#{post.last}']")
428
+ output_buffer.should have_tag('form div.clearfix div.input ul li label', /#{post.first}/)
429
+ output_buffer.should have_tag("form div.clearfix div.input ul li label[@for='author_post_ids_#{post.last}']")
458
430
  end
459
431
  end
460
432
 
461
433
  it "should not check any items" do
462
434
  output_buffer.should have_tag('form li input[@checked]', :count => 0)
463
- end
435
+ end
464
436
  end
465
-
437
+
466
438
  end
467
439