speedo-formstrap 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +42 -40
- data/README.md +8 -15
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/formtastic-bootstrap.gemspec +133 -0
- data/lib/{speedo-formstrap → formtastic-bootstrap}/engine.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/form_builder.rb +9 -11
- data/lib/{speedo-formstrap → formtastic-bootstrap}/helpers/buttons_helper.rb +10 -14
- data/lib/{speedo-formstrap → formtastic-bootstrap}/helpers/fieldset_wrapper.rb +7 -12
- data/lib/{speedo-formstrap → formtastic-bootstrap}/helpers/input_helper.rb +2 -2
- data/lib/{speedo-formstrap → formtastic-bootstrap}/helpers/inputs_helper.rb +6 -6
- data/lib/{speedo-formstrap → formtastic-bootstrap}/helpers.rb +6 -8
- data/lib/formtastic-bootstrap/inputs/base/choices.rb +49 -0
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/base/errors.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/base/hints.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/base/html.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/labelling.rb +18 -0
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/base/stringish.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/base/timeish.rb +13 -6
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/base/wrapping.rb +15 -33
- data/lib/formtastic-bootstrap/inputs/base.rb +22 -0
- data/lib/formtastic-bootstrap/inputs/boolean_input.rb +33 -0
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/check_boxes_input.rb +10 -11
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/date_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/datetime_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/email_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/file_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/hidden_input.rb +12 -0
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/number_input.rb +3 -3
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/password_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/phone_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/radio_input.rb +13 -14
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/range_input.rb +3 -3
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/search_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/select_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/string_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/text_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/time_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/time_zone_input.rb +1 -1
- data/lib/{speedo-formstrap → formtastic-bootstrap}/inputs/url_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs.rb +29 -0
- data/lib/formtastic-bootstrap.rb +6 -0
- data/spec/builder/errors_spec.rb +214 -0
- data/spec/builder/semantic_fields_for_spec.rb +14 -14
- data/spec/helpers/buttons_helper_spec.rb +45 -55
- data/spec/helpers/input_helper_spec.rb +188 -188
- data/spec/helpers/inputs_helper_spec.rb +102 -116
- data/spec/inputs/boolean_input_spec.rb +44 -72
- data/spec/inputs/check_boxes_input_spec.rb +80 -108
- data/spec/inputs/date_input_spec.rb +14 -80
- data/spec/inputs/datetime_input_spec.rb +12 -12
- data/spec/inputs/email_input_spec.rb +5 -33
- data/spec/inputs/file_input_spec.rb +5 -33
- data/spec/inputs/hidden_input_spec.rb +12 -40
- data/spec/inputs/number_input_spec.rb +96 -126
- data/spec/inputs/password_input_spec.rb +5 -33
- data/spec/inputs/phone_input_spec.rb +5 -33
- data/spec/inputs/radio_input_spec.rb +44 -72
- data/spec/inputs/range_input_spec.rb +65 -93
- data/spec/inputs/search_input_spec.rb +5 -32
- data/spec/inputs/select_input_spec.rb +77 -123
- data/spec/inputs/string_input_spec.rb +21 -66
- data/spec/inputs/text_input_spec.rb +13 -40
- 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 +5 -33
- data/spec/spec_helper.rb +1 -1
- data/spec/support/custom_macros.rb +188 -59
- data/spec/support/formtastic_spec_helper.rb +3 -19
- data/vendor/assets/stylesheets/formtastic-bootstrap.css +3 -0
- metadata +62 -74
- data/lib/speedo-formstrap/actions/base.rb +0 -18
- data/lib/speedo-formstrap/actions/button_action.rb +0 -7
- data/lib/speedo-formstrap/actions/input_action.rb +0 -7
- data/lib/speedo-formstrap/actions/link_action.rb +0 -7
- data/lib/speedo-formstrap/actions.rb +0 -4
- data/lib/speedo-formstrap/helpers/action_helper.rb +0 -12
- data/lib/speedo-formstrap/helpers/actions_helper.rb +0 -23
- data/lib/speedo-formstrap/inputs/base/choices.rb +0 -38
- data/lib/speedo-formstrap/inputs/base/labelling.rb +0 -28
- data/lib/speedo-formstrap/inputs/base/numeric.rb +0 -18
- data/lib/speedo-formstrap/inputs/base.rb +0 -23
- data/lib/speedo-formstrap/inputs/boolean_input.rb +0 -29
- data/lib/speedo-formstrap/inputs/hidden_input.rb +0 -14
- data/lib/speedo-formstrap/inputs.rb +0 -29
- data/lib/speedo-formstrap.rb +0 -7
- data/spec/actions/button_action_spec.rb +0 -68
- data/spec/actions/generic_action_spec.rb +0 -486
- data/spec/actions/input_action_spec.rb +0 -64
- data/spec/actions/link_action_spec.rb +0 -93
- data/spec/helpers/action_helper_spec.rb +0 -365
- data/spec/helpers/actions_helper_spec.rb +0 -143
- data/speedo-formstrap.gemspec +0 -145
@@ -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")
|
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
|
25
|
-
output_buffer.should have_tag('form div label
|
26
|
-
output_buffer.should have_tag('form div label
|
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
|
@@ -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
|
99
|
-
output_buffer.should have_tag('form div label
|
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
|
@@ -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)
|
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
|
|
data/spec/spec_helper.rb
CHANGED
@@ -12,7 +12,7 @@ require 'action_view'
|
|
12
12
|
require 'action_controller'
|
13
13
|
require 'action_dispatch'
|
14
14
|
|
15
|
-
require '
|
15
|
+
require 'formtastic-bootstrap'
|
16
16
|
|
17
17
|
# Requires supporting files with custom matchers and macros, etc,
|
18
18
|
# in ./support/ and its subdirectories.
|
@@ -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.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
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
|
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.
|
96
|
-
output_buffer.should have_tag("form div.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
139
|
-
output_buffer.should have_tag("form div.
|
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.
|
144
|
+
output_buffer.should have_tag("form div.clearfix div.input input[@size='#{FormtasticBootstrap::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.
|
161
|
-
output_buffer.should_not have_tag("form div.
|
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.
|
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.
|
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.
|
182
|
+
output_buffer.should have_tag("form div.clearfix div.input input[@maxlength='50']")
|
188
183
|
end
|
189
184
|
end
|
190
185
|
|
@@ -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}
|
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}
|
342
|
-
output_buffer.should have_tag("form div.#{as}
|
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
|
356
|
-
output_buffer.should have_tag("form div div label
|
357
|
-
output_buffer.should have_tag("form div div label
|
358
|
-
output_buffer.should have_tag("form div div label
|
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}
|
375
|
-
output_buffer.should have_tag("form div.#{as}
|
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}
|
393
|
-
output_buffer.should have_tag("form div.#{as}
|
394
|
-
output_buffer.should have_tag("form div.#{as}
|
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}
|
411
|
-
output_buffer.should have_tag("form div.#{as}
|
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}
|
429
|
-
output_buffer.should have_tag("form div.#{as}
|
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}
|
446
|
-
output_buffer.should have_tag("form div.#{as}
|
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}
|
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}
|
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}
|
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}
|
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}
|
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}
|
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}
|
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
|