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,22 +8,22 @@ describe 'time_zone 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(:time_zone))
15
15
  end)
16
16
  end
17
17
 
18
- it_should_have_input_wrapper_with_class("time_zone-wrapper")
19
- it_should_have_input_wrapper_with_class("control-group")
18
+ it_should_have_input_wrapper_with_class("time_zone")
19
+ it_should_have_input_wrapper_with_class(:clearfix)
20
20
  it_should_have_input_wrapper_with_id("post_time_zone_input")
21
21
  it_should_apply_error_logic_for_input_type(:time_zone)
22
22
 
23
23
  it 'should generate a label for the input' do
24
- output_buffer.should have_tag('form div label.control-label')
25
- output_buffer.should have_tag('form div label.control-label[@for="post_time_zone"]')
26
- output_buffer.should have_tag('form div label.control-label', /Time zone/)
24
+ output_buffer.should have_tag('form div label')
25
+ output_buffer.should have_tag('form div label[@for="post_time_zone"]')
26
+ output_buffer.should have_tag('form div label', /Time zone/)
27
27
  end
28
28
 
29
29
  it "should generate a select" do
@@ -44,7 +44,7 @@ describe 'time_zone input' do
44
44
  before do
45
45
  @output_buffer = ''
46
46
  mock_everything
47
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
47
+ Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
48
48
 
49
49
  concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
50
50
  concat(builder.input(:time_zone))
@@ -56,13 +56,13 @@ describe 'time_zone input' do
56
56
  it_should_have_label_for("context2_post_time_zone")
57
57
 
58
58
  end
59
-
59
+
60
60
  describe "when index is provided" do
61
61
 
62
62
  before do
63
63
  @output_buffer = ''
64
64
  mock_everything
65
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
65
+ Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
66
66
 
67
67
  concat(semantic_form_for(@new_post) do |builder|
68
68
  concat(builder.fields_for(:author, :index => 3) do |author|
@@ -70,21 +70,21 @@ describe 'time_zone input' do
70
70
  end)
71
71
  end)
72
72
  end
73
-
73
+
74
74
  it 'should index the id of the wrapper' do
75
75
  output_buffer.should have_tag("div#post_author_attributes_3_name_input")
76
76
  end
77
-
77
+
78
78
  it 'should index the id of the select tag' do
79
79
  output_buffer.should have_tag("select#post_author_attributes_3_name")
80
80
  end
81
-
81
+
82
82
  it 'should index the name of the select tag' do
83
83
  output_buffer.should have_tag("select[@name='post[author_attributes][3][name]']")
84
84
  end
85
-
85
+
86
86
  end
87
-
87
+
88
88
 
89
89
  describe 'when no object is given' do
90
90
  before(:each) do
@@ -94,9 +94,9 @@ describe 'time_zone input' do
94
94
  end
95
95
 
96
96
  it 'should generate labels' do
97
- output_buffer.should have_tag('form div label.control-label')
98
- output_buffer.should have_tag('form div label.control-label[@for="project_time_zone"]')
99
- output_buffer.should have_tag('form div label.control-label', /Time zone/)
97
+ output_buffer.should have_tag('form div label')
98
+ output_buffer.should have_tag('form div label[@for="project_time_zone"]')
99
+ output_buffer.should have_tag('form div label', /Time zone/)
100
100
  end
101
101
 
102
102
  it 'should generate select inputs' do
@@ -105,10 +105,10 @@ describe 'time_zone input' do
105
105
  output_buffer.should have_tag("form div select[@name=\"project[time_zone]\"]")
106
106
  end
107
107
  end
108
-
108
+
109
109
  context "when required" do
110
110
  it "should add the required attribute to the input's html options" do
111
- with_config :use_required_attribute, true do
111
+ with_config :use_required_attribute, true do
112
112
  concat(semantic_form_for(@new_post) do |builder|
113
113
  concat(builder.input(:title, :as => :time_zone, :required => true))
114
114
  end)
@@ -116,5 +116,5 @@ describe 'time_zone input' do
116
116
  end
117
117
  end
118
118
  end
119
-
119
+
120
120
  end
@@ -8,7 +8,7 @@ describe 'url 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
  end
13
13
 
14
14
  describe "when object is provided" do
@@ -18,8 +18,8 @@ describe 'url input' do
18
18
  end)
19
19
  end
20
20
 
21
- it_should_have_input_wrapper_with_class('url-wrapper')
22
- it_should_have_input_wrapper_with_class("control-group")
21
+ it_should_have_input_wrapper_with_class(:url)
22
+ it_should_have_input_wrapper_with_class(:clearfix)
23
23
  it_should_have_input_wrapper_with_class(:stringish)
24
24
  it_should_have_input_class_in_the_right_place
25
25
  it_should_have_input_wrapper_with_id("post_url_input")
@@ -43,38 +43,10 @@ describe 'url input' do
43
43
  it_should_have_label_and_input_with_id("context2_post_url")
44
44
 
45
45
  end
46
-
47
- describe "when index is provided" do
48
-
49
- before do
50
- @output_buffer = ''
51
- mock_everything
52
-
53
- concat(semantic_form_for(@new_post) do |builder|
54
- concat(builder.fields_for(:author, :index => 3) do |author|
55
- concat(author.input(:name, :as => :url))
56
- end)
57
- end)
58
- end
59
-
60
- it 'should index the id of the wrapper' do
61
- output_buffer.should have_tag("div#post_author_attributes_3_name_input")
62
- end
63
-
64
- it 'should index the id of the select tag' do
65
- output_buffer.should have_tag("input#post_author_attributes_3_name")
66
- end
67
-
68
- it 'should index the name of the select tag' do
69
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
70
- end
71
-
72
- end
73
-
74
-
46
+
75
47
  describe "when required" do
76
48
  it "should add the required attribute to the input's html options" do
77
- with_config :use_required_attribute, true do
49
+ with_config :use_required_attribute, true do
78
50
  concat(semantic_form_for(@new_post) do |builder|
79
51
  concat(builder.input(:title, :as => :url, :required => true))
80
52
  end)
@@ -82,6 +54,6 @@ describe 'url input' do
82
54
  end
83
55
  end
84
56
  end
85
-
57
+
86
58
  end
87
59
 
@@ -18,8 +18,8 @@ module CustomMacros
18
18
  # it's located on the outer wrapper. We move it to the inner wrapper.
19
19
  def it_should_have_input_class_in_the_right_place
20
20
  it "should have 'input' class in the right place" do
21
- output_buffer.should have_tag("form div.control-group div.controls")
22
- output_buffer.should_not have_tag("form div.control-group.input")
21
+ output_buffer.should have_tag("form div.clearfix div.input")
22
+ output_buffer.should_not have_tag("form div.clearfix.input")
23
23
  end
24
24
  end
25
25
 
@@ -31,7 +31,7 @@ module CustomMacros
31
31
 
32
32
  def it_should_not_have_a_label
33
33
  it "should not have a label" do
34
- output_buffer.should_not have_tag("form div.control-group label.control-label")
34
+ output_buffer.should_not have_tag("form li label")
35
35
  end
36
36
  end
37
37
 
@@ -40,25 +40,25 @@ module CustomMacros
40
40
  output_buffer.should have_tag("form li fieldset")
41
41
  end
42
42
  end
43
-
43
+
44
44
  def it_should_have_a_nested_fieldset_with_class(klass)
45
45
  it "should have a nested_fieldset with class #{klass}" do
46
46
  output_buffer.should have_tag("form li fieldset.#{klass}")
47
47
  end
48
48
  end
49
-
49
+
50
50
  def it_should_have_a_nested_div
51
51
  it "should have a nested div" do
52
- output_buffer.should have_tag("form div.control-group div")
52
+ output_buffer.should have_tag("form div.clearfix div")
53
53
  end
54
54
  end
55
55
 
56
56
  def it_should_have_a_nested_div_with_class(klass)
57
57
  it "should have a nested div with class #{klass}" do
58
- output_buffer.should have_tag("form div.control-group div.#{klass}")
58
+ output_buffer.should have_tag("form div.clearfix div.#{klass}")
59
59
  end
60
60
  end
61
-
61
+
62
62
  def it_should_have_a_nested_ordered_list_with_class(klass)
63
63
  it "should have a nested fieldset with class #{klass}" do
64
64
  output_buffer.should have_tag("form li ol.#{klass}")
@@ -67,76 +67,71 @@ module CustomMacros
67
67
 
68
68
  def it_should_have_a_nested_unordered_list_with_class(klass)
69
69
  it "should have a nested unordered list with class #{klass}" do
70
- output_buffer.should have_tag("form div.control-group div ul.#{klass}")
70
+ output_buffer.should have_tag("form div.clearfix div ul.#{klass}")
71
71
  end
72
72
  end
73
73
 
74
74
  def it_should_have_label_with_text(string_or_regex)
75
75
  it "should have a label with text '#{string_or_regex}'" do
76
- output_buffer.should have_tag("form div.control-group label.control-label", string_or_regex)
76
+ output_buffer.should have_tag("form div.clearfix label", string_or_regex)
77
77
  end
78
78
  end
79
79
 
80
80
  def it_should_have_label_for(element_id)
81
81
  it "should have a label for ##{element_id}" do
82
82
  # output_buffer.should have_tag("form div label.label[@for='#{element_id}']")
83
- output_buffer.should have_tag("form div.control-group label[@for='#{element_id}']")
83
+ output_buffer.should have_tag("form div.clearfix label[@for='#{element_id}']")
84
+ output_buffer.should_not have_tag("form div.clearfix label.label")
84
85
  end
85
86
  end
86
-
87
+
87
88
  def it_should_have_an_inline_label_for(element_id)
88
89
  it "should have a label for ##{element_id}" do
89
- output_buffer.should have_tag("form div.controls label[@for='#{element_id}']")
90
+ output_buffer.should have_tag("form li label[@for='#{element_id}']")
90
91
  end
91
92
  end
92
93
 
93
94
  def it_should_have_input_with_id(element_id)
94
95
  it "should have an input with id '#{element_id}'" do
95
- # output_buffer.should have_tag("form div.control-group div.controls input##{element_id}")
96
- output_buffer.should have_tag("form div.control-group div.controls input[@id=\"#{element_id}\"]")
96
+ # output_buffer.should have_tag("form div.clearfix div.input input##{element_id}")
97
+ output_buffer.should have_tag("form div.clearfix div.input input[@id=\"#{element_id}\"]")
97
98
  end
98
99
  end
99
100
 
100
101
  def it_should_have_select_with_id(element_id)
101
102
  it "should have a select box with id '#{element_id}'" do
102
- output_buffer.should have_tag("form div.control-group div.controls select##{element_id}")
103
+ output_buffer.should have_tag("form div.clearfix div.input select##{element_id}")
103
104
  end
104
105
  end
105
106
 
106
107
  def it_should_have_input_with_type(input_type)
107
108
  it "should have a #{input_type} input" do
108
- output_buffer.should have_tag("form div.control-group div.controls input[@type=\"#{input_type}\"]")
109
+ output_buffer.should have_tag("form div.clearfix div.input input[@type=\"#{input_type}\"]")
109
110
  end
110
111
  end
111
112
 
112
113
  def it_should_have_input_with_name(name)
113
114
  it "should have an input named #{name}" do
114
- output_buffer.should have_tag("form div.control-group div.controls input[@name=\"#{name}\"]")
115
- end
116
- end
117
-
118
- def it_should_have_select_with_name(name)
119
- it "should have an input named #{name}" do
120
- output_buffer.should have_tag("form div.control-group div.controls select[@name=\"#{name}\"]")
115
+ output_buffer.should have_tag("form div.clearfix div.input input[@name=\"#{name}\"]")
121
116
  end
122
117
  end
123
118
 
124
119
  def it_should_have_textarea_with_name(name)
125
120
  it "should have an input named #{name}" do
126
- output_buffer.should have_tag("form div.control-group div.controls textarea[@name=\"#{name}\"]")
121
+ output_buffer.should have_tag("form div.clearfix div.input textarea[@name=\"#{name}\"]")
127
122
  end
128
123
  end
129
124
 
130
125
  def it_should_have_textarea_with_id(element_id)
131
126
  it "should have an input with id '#{element_id}'" do
132
- output_buffer.should have_tag("form div.control-group div.controls textarea##{element_id}")
127
+ output_buffer.should have_tag("form div.clearfix div.input textarea##{element_id}")
133
128
  end
134
129
  end
135
130
 
136
131
  def it_should_have_label_and_input_with_id(element_id)
137
132
  it "should have an input with id '#{element_id}'" do
138
- output_buffer.should have_tag("form div.control-group div.controls input##{element_id}")
139
- output_buffer.should have_tag("form div.control-group label.control-label[@for='#{element_id}']")
133
+ output_buffer.should have_tag("form div.clearfix div.input input##{element_id}")
134
+ output_buffer.should have_tag("form div.clearfix label[@for='#{element_id}']")
140
135
  end
141
136
  end
142
137
 
@@ -146,7 +141,7 @@ module CustomMacros
146
141
  concat(semantic_form_for(@new_post) do |builder|
147
142
  concat(builder.input(:title, :as => as))
148
143
  end)
149
- output_buffer.should have_tag("form div.control-group div.controls input[@size='#{FormtasticBootstrap::FormBuilder.default_text_field_size}']")
144
+ output_buffer.should have_tag("form div.clearfix div.input input[@size='#{SpeedoFormstrap::FormBuilder.default_text_field_size}']")
150
145
  end
151
146
  end
152
147
  end
@@ -157,8 +152,8 @@ module CustomMacros
157
152
  concat(semantic_form_for(@new_post) do |builder|
158
153
  concat(builder.input(:title, :as => as))
159
154
  end)
160
- output_buffer.should have_tag("form div.control-group div.controls input")
161
- output_buffer.should_not have_tag("form div.control-group div.controls input[@size]")
155
+ output_buffer.should have_tag("form div.clearfix div.input input")
156
+ output_buffer.should_not have_tag("form div.clearfix div.input input[@size]")
162
157
  end
163
158
  end
164
159
  end
@@ -168,7 +163,7 @@ module CustomMacros
168
163
  concat(semantic_form_for(@new_post) do |builder|
169
164
  concat(builder.input(:title, :as => as, :input_html => { :class => 'myclass' }))
170
165
  end)
171
- output_buffer.should have_tag("form div.control-group div.controls input.myclass")
166
+ output_buffer.should have_tag("form div.clearfix div.input input.myclass")
172
167
  end
173
168
  end
174
169
 
@@ -177,14 +172,14 @@ module CustomMacros
177
172
  concat(semantic_form_for(@new_post) do |builder|
178
173
  concat(builder.input(:title, :as => as, :input_html => { :id => 'myid' }))
179
174
  end)
180
- output_buffer.should have_tag('form div.control-group label.control-label[@for="myid"]')
175
+ output_buffer.should have_tag('form div.clearfix label[@for="myid"]')
181
176
  end
182
177
  end
183
178
 
184
179
  def it_should_have_maxlength_matching_column_limit
185
180
  it 'should have a maxlength matching column limit' do
186
181
  @new_post.column_for_attribute(:title).limit.should == 50
187
- output_buffer.should have_tag("form div.control-group div.controls input[@maxlength='50']")
182
+ output_buffer.should have_tag("form div.clearfix div.input input[@maxlength='50']")
188
183
  end
189
184
  end
190
185
 
@@ -213,15 +208,15 @@ module CustomMacros
213
208
  end
214
209
  @new_post.stub!(:errors).and_return(@errors)
215
210
 
216
- @orig_inline_errors = FormtasticBootstrap::FormBuilder.inline_errors
217
- @orig_inline_error_class = FormtasticBootstrap::FormBuilder.default_inline_error_class
218
- @orig_error_list_class = FormtasticBootstrap::FormBuilder.default_error_list_class
211
+ @orig_inline_errors = SpeedoFormstrap::FormBuilder.inline_errors
212
+ @orig_inline_error_class = SpeedoFormstrap::FormBuilder.default_inline_error_class
213
+ @orig_error_list_class = SpeedoFormstrap::FormBuilder.default_error_list_class
219
214
  end
220
215
 
221
216
  after(:each) do
222
- FormtasticBootstrap::FormBuilder.inline_errors = @orig_inline_errors
223
- FormtasticBootstrap::FormBuilder.default_inline_error_class = @orig_inline_error_class
224
- FormtasticBootstrap::FormBuilder.default_error_list_class = @orig_error_list_class
217
+ SpeedoFormstrap::FormBuilder.inline_errors = @orig_inline_errors
218
+ SpeedoFormstrap::FormBuilder.default_inline_error_class = @orig_inline_error_class
219
+ SpeedoFormstrap::FormBuilder.default_error_list_class = @orig_error_list_class
225
220
  end
226
221
 
227
222
  it 'should apply an errors class to the list item' do
@@ -239,7 +234,7 @@ module CustomMacros
239
234
  end
240
235
 
241
236
  it 'should render a paragraph for the errors' do
242
- FormtasticBootstrap::FormBuilder.inline_errors = :sentence
237
+ SpeedoFormstrap::FormBuilder.inline_errors = :sentence
243
238
  concat(semantic_form_for(@new_post) do |builder|
244
239
  concat(builder.input(:title, :as => type))
245
240
  end)
@@ -252,7 +247,7 @@ module CustomMacros
252
247
  end
253
248
 
254
249
  it 'should not display an error list' do
255
- FormtasticBootstrap::FormBuilder.inline_errors = :list
250
+ SpeedoFormstrap::FormBuilder.inline_errors = :list
256
251
  concat(semantic_form_for(@new_post) do |builder|
257
252
  concat(builder.input(:title, :as => type))
258
253
  end)
@@ -324,7 +319,7 @@ module CustomMacros
324
319
  concat(semantic_form_for(@new_post) do |builder|
325
320
  concat(builder.input(:author, :as => as, :collection => @authors))
326
321
  end)
327
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}", :count => @authors.size + (as == :select ? 1 : 0))
322
+ output_buffer.should have_tag("form div.#{as} #{countable}", :count => @authors.size + (as == :select ? 1 : 0))
328
323
  end
329
324
 
330
325
  describe 'and the :collection is an array of strings' do
@@ -338,8 +333,8 @@ module CustomMacros
338
333
  end)
339
334
 
340
335
  @categories.each do |value|
341
- output_buffer.should have_tag("form div.#{as}-wrapper", /#{value}/)
342
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{value}']")
336
+ output_buffer.should have_tag("form div.#{as}", /#{value}/)
337
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{value}']")
343
338
  end
344
339
  end
345
340
 
@@ -352,10 +347,10 @@ module CustomMacros
352
347
  end
353
348
  concat(fields)
354
349
  end)
355
- output_buffer.should have_tag("form div div label.radio[@for='post_author_category_name_general']")
356
- output_buffer.should have_tag("form div div label.radio[@for='post_author_category_name_design']")
357
- output_buffer.should have_tag("form div div label.radio[@for='post_author_category_name_development']")
358
- output_buffer.should have_tag("form div div label.radio[@for='post_author_category_name_quasi-serious_inventions']")
350
+ output_buffer.should have_tag("form div div ul li label[@for='post_author_category_name_general']")
351
+ output_buffer.should have_tag("form div div ul li label[@for='post_author_category_name_design']")
352
+ output_buffer.should have_tag("form div div ul li label[@for='post_author_category_name_development']")
353
+ output_buffer.should have_tag("form div div ul li label[@for='post_author_category_name_quasi-serious_inventions']")
359
354
  end
360
355
  end
361
356
  end
@@ -371,8 +366,8 @@ module CustomMacros
371
366
  end)
372
367
 
373
368
  @categories.each do |label, value|
374
- output_buffer.should have_tag("form div.#{as}-wrapper", /#{label}/)
375
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{value}']")
369
+ output_buffer.should have_tag("form div.#{as}", /#{label}/)
370
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{value}']")
376
371
  end
377
372
  end
378
373
  end
@@ -389,9 +384,9 @@ module CustomMacros
389
384
 
390
385
  @categories.each do |text, value|
391
386
  label = as == :select ? :option : :label
392
- output_buffer.should have_tag("form div.#{as}-wrapper #{label}", /#{text}/i)
393
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{value.to_s}']")
394
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}#post_category_name_#{value.to_s}") if as == :radio
387
+ output_buffer.should have_tag("form div.#{as} #{label}", /#{text}/i)
388
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{value.to_s}']")
389
+ output_buffer.should have_tag("form div.#{as} #{countable}#post_category_name_#{value.to_s}") if as == :radio
395
390
  end
396
391
  end
397
392
  end
@@ -407,8 +402,8 @@ module CustomMacros
407
402
  concat(builder.input(:category_name, :as => as, :collection => @choices))
408
403
  end)
409
404
 
410
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}#post_category_name_true")
411
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}#post_category_name_false")
405
+ output_buffer.should have_tag("form div.#{as} #{countable}#post_category_name_true")
406
+ output_buffer.should have_tag("form div.#{as} #{countable}#post_category_name_false")
412
407
  end
413
408
  end
414
409
  end
@@ -425,8 +420,8 @@ module CustomMacros
425
420
 
426
421
  @categories.each do |value|
427
422
  label = as == :select ? :option : :label
428
- output_buffer.should have_tag("form div.#{as}-wrapper #{label}", /#{value}/i)
429
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{value.to_s}']")
423
+ output_buffer.should have_tag("form div.#{as} #{label}", /#{value}/i)
424
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{value.to_s}']")
430
425
  end
431
426
  end
432
427
  end
@@ -442,8 +437,8 @@ module CustomMacros
442
437
  end)
443
438
 
444
439
  @categories.each do |label, value|
445
- output_buffer.should have_tag("form div.#{as}-wrapper", /#{label}/)
446
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{value}']")
440
+ output_buffer.should have_tag("form div.#{as}", /#{label}/)
441
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{value}']")
447
442
  end
448
443
  end
449
444
 
@@ -460,7 +455,7 @@ module CustomMacros
460
455
 
461
456
  it 'should have options with text content from the specified method' do
462
457
  ::Author.all.each do |author|
463
- output_buffer.should have_tag("form div.#{as}-wrapper", /#{author.login}/)
458
+ output_buffer.should have_tag("form div.#{as}", /#{author.login}/)
464
459
  end
465
460
  end
466
461
  end
@@ -474,7 +469,7 @@ module CustomMacros
474
469
 
475
470
  it 'should have options with the proc applied to each' do
476
471
  ::Author.all.each do |author|
477
- output_buffer.should have_tag("form div.#{as}-wrapper", /#{author.login.reverse}/)
472
+ output_buffer.should have_tag("form div.#{as}", /#{author.login.reverse}/)
478
473
  end
479
474
  end
480
475
  end
@@ -491,7 +486,7 @@ module CustomMacros
491
486
 
492
487
  it 'should have options with the proc applied to each' do
493
488
  ::Author.all.each do |author|
494
- output_buffer.should have_tag("form div.#{as}-wrapper", /#{author.login.reverse}/)
489
+ output_buffer.should have_tag("form div.#{as}", /#{author.login.reverse}/)
495
490
  end
496
491
  end
497
492
  end
@@ -512,7 +507,7 @@ module CustomMacros
512
507
 
513
508
  it "should render the options with #{label_method} as the label" do
514
509
  ::Author.all.each do |author|
515
- output_buffer.should have_tag("form div.#{as}-wrapper", /The Label Text/)
510
+ output_buffer.should have_tag("form div.#{as}", /The Label Text/)
516
511
  end
517
512
  end
518
513
  end
@@ -531,7 +526,7 @@ module CustomMacros
531
526
 
532
527
  it 'should have options with values from specified method' do
533
528
  ::Author.all.each do |author|
534
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{author.login}']")
529
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{author.login}']")
535
530
  end
536
531
  end
537
532
  end
@@ -545,7 +540,7 @@ module CustomMacros
545
540
 
546
541
  it 'should have options with the proc applied to each value' do
547
542
  ::Author.all.each do |author|
548
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{author.login.reverse}']")
543
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{author.login.reverse}']")
549
544
  end
550
545
  end
551
546
  end
@@ -562,7 +557,141 @@ module CustomMacros
562
557
 
563
558
  it 'should have options with the proc applied to each value' do
564
559
  ::Author.all.each do |author|
565
- output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{author.login.reverse}']")
560
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{author.login.reverse}']")
561
+ end
562
+ end
563
+ end
564
+ end
565
+
566
+ describe 'when the deprecated :label_method option is provided' do
567
+
568
+ describe 'as a symbol' do
569
+ before do
570
+ with_deprecation_silenced do
571
+ concat(semantic_form_for(@new_post) do |builder|
572
+ concat(builder.input(:author, :as => as, :label_method => :login))
573
+ end)
574
+ end
575
+ end
576
+
577
+ it 'should have options with text content from the specified method' do
578
+ ::Author.all.each do |author|
579
+ output_buffer.should have_tag("form div.#{as}", /#{author.login}/)
580
+ end
581
+ end
582
+ end
583
+
584
+ describe 'as a proc' do
585
+
586
+ before do
587
+ with_deprecation_silenced do
588
+ concat(semantic_form_for(@new_post) do |builder|
589
+ concat(builder.input(:author, :as => as, :label_method => Proc.new {|a| a.login.reverse }))
590
+ end)
591
+ end
592
+ end
593
+
594
+ it 'should have options with the proc applied to each' do
595
+ ::Author.all.each do |author|
596
+ output_buffer.should have_tag("form div.#{as}", /#{author.login.reverse}/)
597
+ end
598
+ end
599
+ end
600
+
601
+ describe 'as a method object' do
602
+ before do
603
+ def reverse_login(a)
604
+ a.login.reverse
605
+ end
606
+ with_deprecation_silenced do
607
+ concat(semantic_form_for(@new_post) do |builder|
608
+ concat(builder.input(:author, :as => as, :label_method => method(:reverse_login)))
609
+ end)
610
+ end
611
+ end
612
+
613
+ it 'should have options with the proc applied to each' do
614
+ ::Author.all.each do |author|
615
+ output_buffer.should have_tag("form div.#{as}", /#{author.login.reverse}/)
616
+ end
617
+ end
618
+ end
619
+ end
620
+
621
+ describe 'when the deprecated :label_method option is not provided' do
622
+ Formtastic::FormBuilder.collection_label_methods.each do |label_method|
623
+
624
+ describe "when the collection objects respond to #{label_method}" do
625
+ before do
626
+ @fred.stub!(:respond_to?).and_return { |m| m.to_s == label_method || m.to_s == 'id' }
627
+ ::Author.all.each { |a| a.stub!(label_method).and_return('The Label Text') }
628
+
629
+ with_deprecation_silenced do
630
+ concat(semantic_form_for(@new_post) do |builder|
631
+ concat(builder.input(:author, :as => as))
632
+ end)
633
+ end
634
+ end
635
+
636
+ it "should render the options with #{label_method} as the label" do
637
+ ::Author.all.each do |author|
638
+ output_buffer.should have_tag("form div.#{as}", /The Label Text/)
639
+ end
640
+ end
641
+ end
642
+
643
+ end
644
+ end
645
+
646
+ describe 'when the deprecated :value_method option is provided' do
647
+
648
+ describe 'as a symbol' do
649
+ before do
650
+ with_deprecation_silenced do
651
+ concat(semantic_form_for(@new_post) do |builder|
652
+ concat(builder.input(:author, :as => as, :value_method => :login))
653
+ end)
654
+ end
655
+ end
656
+
657
+ it 'should have options with values from specified method' do
658
+ ::Author.all.each do |author|
659
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{author.login}']")
660
+ end
661
+ end
662
+ end
663
+
664
+ describe 'as a proc' do
665
+ before do
666
+ with_deprecation_silenced do
667
+ concat(semantic_form_for(@new_post) do |builder|
668
+ concat(builder.input(:author, :as => as, :value_method => Proc.new {|a| a.login.reverse }))
669
+ end)
670
+ end
671
+ end
672
+
673
+ it 'should have options with the proc applied to each value' do
674
+ ::Author.all.each do |author|
675
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{author.login.reverse}']")
676
+ end
677
+ end
678
+ end
679
+
680
+ describe 'as a method object' do
681
+ before do
682
+ def reverse_login(a)
683
+ a.login.reverse
684
+ end
685
+ with_deprecation_silenced do
686
+ concat(semantic_form_for(@new_post) do |builder|
687
+ concat(builder.input(:author, :as => as, :value_method => method(:reverse_login)))
688
+ end)
689
+ end
690
+ end
691
+
692
+ it 'should have options with the proc applied to each value' do
693
+ ::Author.all.each do |author|
694
+ output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{author.login.reverse}']")
566
695
  end
567
696
  end
568
697
  end