speedo-formstrap 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +67 -65
- data/README.md +12 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/formtastic-bootstrap.rb +1 -0
- data/lib/formtastic-bootstrap/actions.rb +4 -0
- data/lib/formtastic-bootstrap/actions/base.rb +18 -0
- data/lib/formtastic-bootstrap/actions/button_action.rb +7 -0
- data/lib/formtastic-bootstrap/actions/input_action.rb +7 -0
- data/lib/formtastic-bootstrap/actions/link_action.rb +7 -0
- data/lib/formtastic-bootstrap/form_builder.rb +7 -5
- data/lib/formtastic-bootstrap/helpers.rb +3 -1
- data/lib/formtastic-bootstrap/helpers/action_helper.rb +12 -0
- data/lib/formtastic-bootstrap/helpers/actions_helper.rb +23 -0
- data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +13 -9
- data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +11 -6
- data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +4 -4
- data/lib/formtastic-bootstrap/inputs/base.rb +2 -1
- data/lib/formtastic-bootstrap/inputs/base/choices.rb +12 -23
- data/lib/formtastic-bootstrap/inputs/base/labelling.rb +16 -6
- data/lib/formtastic-bootstrap/inputs/base/numeric.rb +18 -0
- data/lib/formtastic-bootstrap/inputs/base/timeish.rb +5 -12
- data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +32 -14
- data/lib/formtastic-bootstrap/inputs/boolean_input.rb +7 -11
- data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +10 -9
- data/lib/formtastic-bootstrap/inputs/hidden_input.rb +5 -3
- data/lib/formtastic-bootstrap/inputs/number_input.rb +2 -2
- data/lib/formtastic-bootstrap/inputs/radio_input.rb +13 -12
- data/lib/formtastic-bootstrap/inputs/range_input.rb +2 -2
- data/spec/actions/button_action_spec.rb +68 -0
- data/spec/actions/generic_action_spec.rb +486 -0
- data/spec/actions/input_action_spec.rb +64 -0
- data/spec/actions/link_action_spec.rb +93 -0
- data/spec/builder/semantic_fields_for_spec.rb +14 -14
- data/spec/helpers/action_helper_spec.rb +365 -0
- data/spec/helpers/actions_helper_spec.rb +143 -0
- data/spec/helpers/buttons_helper_spec.rb +55 -45
- data/spec/helpers/input_helper_spec.rb +188 -188
- data/spec/helpers/inputs_helper_spec.rb +116 -102
- data/spec/inputs/boolean_input_spec.rb +72 -44
- data/spec/inputs/check_boxes_input_spec.rb +108 -80
- data/spec/inputs/date_input_spec.rb +80 -14
- data/spec/inputs/datetime_input_spec.rb +12 -12
- data/spec/inputs/email_input_spec.rb +33 -5
- data/spec/inputs/file_input_spec.rb +33 -5
- data/spec/inputs/hidden_input_spec.rb +40 -12
- data/spec/inputs/number_input_spec.rb +126 -96
- data/spec/inputs/password_input_spec.rb +33 -5
- data/spec/inputs/phone_input_spec.rb +33 -5
- data/spec/inputs/radio_input_spec.rb +72 -44
- data/spec/inputs/range_input_spec.rb +93 -65
- data/spec/inputs/search_input_spec.rb +32 -5
- data/spec/inputs/select_input_spec.rb +123 -77
- data/spec/inputs/string_input_spec.rb +66 -21
- data/spec/inputs/text_input_spec.rb +40 -13
- data/spec/inputs/time_input_spec.rb +22 -22
- data/spec/inputs/time_zone_input_spec.rb +17 -17
- data/spec/inputs/url_input_spec.rb +33 -5
- data/spec/support/custom_macros.rb +59 -188
- data/spec/support/formtastic_spec_helper.rb +19 -3
- data/speedo-formstrap.gemspec +146 -0
- metadata +31 -16
@@ -15,15 +15,15 @@ describe 'time_zone input' do
|
|
15
15
|
end)
|
16
16
|
end
|
17
17
|
|
18
|
-
it_should_have_input_wrapper_with_class("time_zone")
|
19
|
-
it_should_have_input_wrapper_with_class(
|
18
|
+
it_should_have_input_wrapper_with_class("time_zone-wrapper")
|
19
|
+
it_should_have_input_wrapper_with_class("control-group")
|
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')
|
25
|
-
output_buffer.should have_tag('form div label[@for="post_time_zone"]')
|
26
|
-
output_buffer.should have_tag('form div label', /Time zone/)
|
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/)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should generate a select" do
|
@@ -56,7 +56,7 @@ 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
|
@@ -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')
|
98
|
-
output_buffer.should have_tag('form div label[@for="project_time_zone"]')
|
99
|
-
output_buffer.should have_tag('form div label', /Time zone/)
|
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/)
|
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
|
@@ -18,8 +18,8 @@ describe 'url input' do
|
|
18
18
|
end)
|
19
19
|
end
|
20
20
|
|
21
|
-
it_should_have_input_wrapper_with_class(
|
22
|
-
it_should_have_input_wrapper_with_class(
|
21
|
+
it_should_have_input_wrapper_with_class('url-wrapper')
|
22
|
+
it_should_have_input_wrapper_with_class("control-group")
|
23
23
|
it_should_have_input_wrapper_with_class(:stringish)
|
24
24
|
it_should_have_input_class_in_the_right_place
|
25
25
|
it_should_have_input_wrapper_with_id("post_url_input")
|
@@ -43,10 +43,38 @@ describe 'url input' do
|
|
43
43
|
it_should_have_label_and_input_with_id("context2_post_url")
|
44
44
|
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
|
+
describe "when index is provided" do
|
48
|
+
|
49
|
+
before do
|
50
|
+
@output_buffer = ''
|
51
|
+
mock_everything
|
52
|
+
|
53
|
+
concat(semantic_form_for(@new_post) do |builder|
|
54
|
+
concat(builder.fields_for(:author, :index => 3) do |author|
|
55
|
+
concat(author.input(:name, :as => :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
|
+
|
47
75
|
describe "when required" do
|
48
76
|
it "should add the required attribute to the input's html options" do
|
49
|
-
with_config :use_required_attribute, true do
|
77
|
+
with_config :use_required_attribute, true do
|
50
78
|
concat(semantic_form_for(@new_post) do |builder|
|
51
79
|
concat(builder.input(:title, :as => :url, :required => true))
|
52
80
|
end)
|
@@ -54,6 +82,6 @@ describe 'url input' do
|
|
54
82
|
end
|
55
83
|
end
|
56
84
|
end
|
57
|
-
|
85
|
+
|
58
86
|
end
|
59
87
|
|
@@ -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.
|
22
|
-
output_buffer.should_not have_tag("form div.
|
21
|
+
output_buffer.should have_tag("form div.control-group div.controls")
|
22
|
+
output_buffer.should_not have_tag("form div.control-group.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
|
34
|
+
output_buffer.should_not have_tag("form div.control-group label.control-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.
|
52
|
+
output_buffer.should have_tag("form div.control-group 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.
|
58
|
+
output_buffer.should have_tag("form div.control-group 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,71 +67,76 @@ 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.
|
70
|
+
output_buffer.should have_tag("form div.control-group 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.
|
76
|
+
output_buffer.should have_tag("form div.control-group label.control-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.
|
84
|
-
output_buffer.should_not have_tag("form div.clearfix label.label")
|
83
|
+
output_buffer.should have_tag("form div.control-group label[@for='#{element_id}']")
|
85
84
|
end
|
86
85
|
end
|
87
|
-
|
86
|
+
|
88
87
|
def it_should_have_an_inline_label_for(element_id)
|
89
88
|
it "should have a label for ##{element_id}" do
|
90
|
-
output_buffer.should have_tag("form
|
89
|
+
output_buffer.should have_tag("form div.controls label[@for='#{element_id}']")
|
91
90
|
end
|
92
91
|
end
|
93
92
|
|
94
93
|
def it_should_have_input_with_id(element_id)
|
95
94
|
it "should have an input with id '#{element_id}'" do
|
96
|
-
# output_buffer.should have_tag("form div.
|
97
|
-
output_buffer.should have_tag("form div.
|
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}\"]")
|
98
97
|
end
|
99
98
|
end
|
100
99
|
|
101
100
|
def it_should_have_select_with_id(element_id)
|
102
101
|
it "should have a select box with id '#{element_id}'" do
|
103
|
-
output_buffer.should have_tag("form div.
|
102
|
+
output_buffer.should have_tag("form div.control-group div.controls select##{element_id}")
|
104
103
|
end
|
105
104
|
end
|
106
105
|
|
107
106
|
def it_should_have_input_with_type(input_type)
|
108
107
|
it "should have a #{input_type} input" do
|
109
|
-
output_buffer.should have_tag("form div.
|
108
|
+
output_buffer.should have_tag("form div.control-group div.controls input[@type=\"#{input_type}\"]")
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
113
112
|
def it_should_have_input_with_name(name)
|
114
113
|
it "should have an input named #{name}" do
|
115
|
-
output_buffer.should have_tag("form div.
|
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}\"]")
|
116
121
|
end
|
117
122
|
end
|
118
123
|
|
119
124
|
def it_should_have_textarea_with_name(name)
|
120
125
|
it "should have an input named #{name}" do
|
121
|
-
output_buffer.should have_tag("form div.
|
126
|
+
output_buffer.should have_tag("form div.control-group div.controls textarea[@name=\"#{name}\"]")
|
122
127
|
end
|
123
128
|
end
|
124
129
|
|
125
130
|
def it_should_have_textarea_with_id(element_id)
|
126
131
|
it "should have an input with id '#{element_id}'" do
|
127
|
-
output_buffer.should have_tag("form div.
|
132
|
+
output_buffer.should have_tag("form div.control-group div.controls textarea##{element_id}")
|
128
133
|
end
|
129
134
|
end
|
130
135
|
|
131
136
|
def it_should_have_label_and_input_with_id(element_id)
|
132
137
|
it "should have an input with id '#{element_id}'" do
|
133
|
-
output_buffer.should have_tag("form div.
|
134
|
-
output_buffer.should have_tag("form div.
|
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}']")
|
135
140
|
end
|
136
141
|
end
|
137
142
|
|
@@ -141,7 +146,7 @@ module CustomMacros
|
|
141
146
|
concat(semantic_form_for(@new_post) do |builder|
|
142
147
|
concat(builder.input(:title, :as => as))
|
143
148
|
end)
|
144
|
-
output_buffer.should have_tag("form div.
|
149
|
+
output_buffer.should have_tag("form div.control-group div.controls input[@size='#{FormtasticBootstrap::FormBuilder.default_text_field_size}']")
|
145
150
|
end
|
146
151
|
end
|
147
152
|
end
|
@@ -152,8 +157,8 @@ module CustomMacros
|
|
152
157
|
concat(semantic_form_for(@new_post) do |builder|
|
153
158
|
concat(builder.input(:title, :as => as))
|
154
159
|
end)
|
155
|
-
output_buffer.should have_tag("form div.
|
156
|
-
output_buffer.should_not have_tag("form div.
|
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]")
|
157
162
|
end
|
158
163
|
end
|
159
164
|
end
|
@@ -163,7 +168,7 @@ module CustomMacros
|
|
163
168
|
concat(semantic_form_for(@new_post) do |builder|
|
164
169
|
concat(builder.input(:title, :as => as, :input_html => { :class => 'myclass' }))
|
165
170
|
end)
|
166
|
-
output_buffer.should have_tag("form div.
|
171
|
+
output_buffer.should have_tag("form div.control-group div.controls input.myclass")
|
167
172
|
end
|
168
173
|
end
|
169
174
|
|
@@ -172,14 +177,14 @@ module CustomMacros
|
|
172
177
|
concat(semantic_form_for(@new_post) do |builder|
|
173
178
|
concat(builder.input(:title, :as => as, :input_html => { :id => 'myid' }))
|
174
179
|
end)
|
175
|
-
output_buffer.should have_tag('form div.
|
180
|
+
output_buffer.should have_tag('form div.control-group label.control-label[@for="myid"]')
|
176
181
|
end
|
177
182
|
end
|
178
183
|
|
179
184
|
def it_should_have_maxlength_matching_column_limit
|
180
185
|
it 'should have a maxlength matching column limit' do
|
181
186
|
@new_post.column_for_attribute(:title).limit.should == 50
|
182
|
-
output_buffer.should have_tag("form div.
|
187
|
+
output_buffer.should have_tag("form div.control-group div.controls input[@maxlength='50']")
|
183
188
|
end
|
184
189
|
end
|
185
190
|
|
@@ -319,7 +324,7 @@ module CustomMacros
|
|
319
324
|
concat(semantic_form_for(@new_post) do |builder|
|
320
325
|
concat(builder.input(:author, :as => as, :collection => @authors))
|
321
326
|
end)
|
322
|
-
output_buffer.should have_tag("form div.#{as} #{countable}", :count => @authors.size + (as == :select ? 1 : 0))
|
327
|
+
output_buffer.should have_tag("form div.#{as}-wrapper #{countable}", :count => @authors.size + (as == :select ? 1 : 0))
|
323
328
|
end
|
324
329
|
|
325
330
|
describe 'and the :collection is an array of strings' do
|
@@ -333,8 +338,8 @@ module CustomMacros
|
|
333
338
|
end)
|
334
339
|
|
335
340
|
@categories.each do |value|
|
336
|
-
output_buffer.should have_tag("form div.#{as}", /#{value}/)
|
337
|
-
output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{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}']")
|
338
343
|
end
|
339
344
|
end
|
340
345
|
|
@@ -347,10 +352,10 @@ module CustomMacros
|
|
347
352
|
end
|
348
353
|
concat(fields)
|
349
354
|
end)
|
350
|
-
output_buffer.should have_tag("form div div
|
351
|
-
output_buffer.should have_tag("form div div
|
352
|
-
output_buffer.should have_tag("form div div
|
353
|
-
output_buffer.should have_tag("form div div
|
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']")
|
354
359
|
end
|
355
360
|
end
|
356
361
|
end
|
@@ -366,8 +371,8 @@ module CustomMacros
|
|
366
371
|
end)
|
367
372
|
|
368
373
|
@categories.each do |label, value|
|
369
|
-
output_buffer.should have_tag("form div.#{as}", /#{label}/)
|
370
|
-
output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{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}']")
|
371
376
|
end
|
372
377
|
end
|
373
378
|
end
|
@@ -384,9 +389,9 @@ module CustomMacros
|
|
384
389
|
|
385
390
|
@categories.each do |text, value|
|
386
391
|
label = as == :select ? :option : :label
|
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
|
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
|
390
395
|
end
|
391
396
|
end
|
392
397
|
end
|
@@ -402,8 +407,8 @@ module CustomMacros
|
|
402
407
|
concat(builder.input(:category_name, :as => as, :collection => @choices))
|
403
408
|
end)
|
404
409
|
|
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")
|
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")
|
407
412
|
end
|
408
413
|
end
|
409
414
|
end
|
@@ -420,8 +425,8 @@ module CustomMacros
|
|
420
425
|
|
421
426
|
@categories.each do |value|
|
422
427
|
label = as == :select ? :option : :label
|
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}']")
|
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}']")
|
425
430
|
end
|
426
431
|
end
|
427
432
|
end
|
@@ -437,8 +442,8 @@ module CustomMacros
|
|
437
442
|
end)
|
438
443
|
|
439
444
|
@categories.each do |label, value|
|
440
|
-
output_buffer.should have_tag("form div.#{as}", /#{label}/)
|
441
|
-
output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{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}']")
|
442
447
|
end
|
443
448
|
end
|
444
449
|
|
@@ -455,7 +460,7 @@ module CustomMacros
|
|
455
460
|
|
456
461
|
it 'should have options with text content from the specified method' do
|
457
462
|
::Author.all.each do |author|
|
458
|
-
output_buffer.should have_tag("form div.#{as}", /#{author.login}/)
|
463
|
+
output_buffer.should have_tag("form div.#{as}-wrapper", /#{author.login}/)
|
459
464
|
end
|
460
465
|
end
|
461
466
|
end
|
@@ -469,7 +474,7 @@ module CustomMacros
|
|
469
474
|
|
470
475
|
it 'should have options with the proc applied to each' do
|
471
476
|
::Author.all.each do |author|
|
472
|
-
output_buffer.should have_tag("form div.#{as}", /#{author.login.reverse}/)
|
477
|
+
output_buffer.should have_tag("form div.#{as}-wrapper", /#{author.login.reverse}/)
|
473
478
|
end
|
474
479
|
end
|
475
480
|
end
|
@@ -486,7 +491,7 @@ module CustomMacros
|
|
486
491
|
|
487
492
|
it 'should have options with the proc applied to each' do
|
488
493
|
::Author.all.each do |author|
|
489
|
-
output_buffer.should have_tag("form div.#{as}", /#{author.login.reverse}/)
|
494
|
+
output_buffer.should have_tag("form div.#{as}-wrapper", /#{author.login.reverse}/)
|
490
495
|
end
|
491
496
|
end
|
492
497
|
end
|
@@ -507,7 +512,7 @@ module CustomMacros
|
|
507
512
|
|
508
513
|
it "should render the options with #{label_method} as the label" do
|
509
514
|
::Author.all.each do |author|
|
510
|
-
output_buffer.should have_tag("form div.#{as}", /The Label Text/)
|
515
|
+
output_buffer.should have_tag("form div.#{as}-wrapper", /The Label Text/)
|
511
516
|
end
|
512
517
|
end
|
513
518
|
end
|
@@ -526,7 +531,7 @@ module CustomMacros
|
|
526
531
|
|
527
532
|
it 'should have options with values from specified method' do
|
528
533
|
::Author.all.each do |author|
|
529
|
-
output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{author.login}']")
|
534
|
+
output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{author.login}']")
|
530
535
|
end
|
531
536
|
end
|
532
537
|
end
|
@@ -540,7 +545,7 @@ module CustomMacros
|
|
540
545
|
|
541
546
|
it 'should have options with the proc applied to each value' do
|
542
547
|
::Author.all.each do |author|
|
543
|
-
output_buffer.should have_tag("form div.#{as} #{countable}[@value='#{author.login.reverse}']")
|
548
|
+
output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{author.login.reverse}']")
|
544
549
|
end
|
545
550
|
end
|
546
551
|
end
|
@@ -557,141 +562,7 @@ module CustomMacros
|
|
557
562
|
|
558
563
|
it 'should have options with the proc applied to each value' do
|
559
564
|
::Author.all.each do |author|
|
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}']")
|
565
|
+
output_buffer.should have_tag("form div.#{as}-wrapper #{countable}[@value='#{author.login.reverse}']")
|
695
566
|
end
|
696
567
|
end
|
697
568
|
end
|