formtastic-bootstrap 1.2.0 → 2.0.0
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.
- data/Gemfile +5 -3
- data/Gemfile.lock +72 -60
- data/README.md +4 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/formtastic-bootstrap.gemspec +49 -16
- data/lib/formtastic-bootstrap/actions/base.rb +22 -0
- data/lib/formtastic-bootstrap/actions/button_action.rb +13 -0
- data/lib/formtastic-bootstrap/actions/input_action.rb +13 -0
- data/lib/formtastic-bootstrap/actions/link_action.rb +12 -0
- data/lib/formtastic-bootstrap/actions.rb +10 -0
- data/lib/formtastic-bootstrap/form_builder.rb +4 -2
- data/lib/formtastic-bootstrap/helpers/action_helper.rb +12 -0
- data/lib/formtastic-bootstrap/helpers/actions_helper.rb +24 -0
- data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +2 -4
- data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +0 -2
- data/lib/formtastic-bootstrap/helpers.rb +6 -8
- data/lib/formtastic-bootstrap/inputs/base/choices.rb +6 -35
- data/lib/formtastic-bootstrap/inputs/base/collections.rb +9 -0
- data/lib/formtastic-bootstrap/inputs/base/grouped_collections.rb +9 -0
- data/lib/formtastic-bootstrap/inputs/base/hints.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/labelling.rb +14 -3
- data/lib/formtastic-bootstrap/inputs/base/numeric.rb +9 -0
- data/lib/formtastic-bootstrap/inputs/base/stringish.rb +4 -5
- data/lib/formtastic-bootstrap/inputs/base/timeish.rb +38 -18
- data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +22 -34
- data/lib/formtastic-bootstrap/inputs/base.rb +29 -6
- data/lib/formtastic-bootstrap/inputs/boolean_input.rb +14 -18
- data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +16 -11
- data/lib/formtastic-bootstrap/inputs/date_input.rb +3 -9
- data/lib/formtastic-bootstrap/inputs/date_select_input.rb +8 -0
- data/lib/formtastic-bootstrap/inputs/datetime_input.rb +3 -12
- data/lib/formtastic-bootstrap/inputs/datetime_select_input.rb +8 -0
- data/lib/formtastic-bootstrap/inputs/email_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/file_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/hidden_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/number_input.rb +3 -3
- data/lib/formtastic-bootstrap/inputs/password_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/phone_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/radio_input.rb +28 -14
- data/lib/formtastic-bootstrap/inputs/range_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/search_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/select_input.rb +3 -1
- data/lib/formtastic-bootstrap/inputs/string_input.rb +0 -7
- data/lib/formtastic-bootstrap/inputs/text_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/time_input.rb +3 -9
- data/lib/formtastic-bootstrap/inputs/time_select_input.rb +8 -0
- data/lib/formtastic-bootstrap/inputs/time_zone_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/url_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs.rb +30 -23
- data/lib/formtastic-bootstrap.rb +16 -1
- data/spec/actions/button_action_spec.rb +63 -0
- data/spec/actions/input_action_spec.rb +59 -0
- data/spec/actions/link_action_spec.rb +92 -0
- data/spec/helpers/action_helper_spec.rb +368 -0
- data/spec/helpers/actions_helper_spec.rb +147 -0
- data/spec/helpers/input_helper_spec.rb +238 -259
- data/spec/helpers/inputs_helper_spec.rb +84 -25
- data/spec/inputs/boolean_input_spec.rb +108 -75
- data/spec/inputs/check_boxes_input_spec.rb +106 -91
- data/spec/inputs/date_select_input_spec.rb +164 -0
- data/spec/inputs/datetime_select_input_spec.rb +112 -0
- data/spec/inputs/deprecated_time_date_datetime_inputs_spec.rb +48 -0
- data/spec/inputs/email_input_spec.rb +30 -3
- data/spec/inputs/file_input_spec.rb +31 -4
- data/spec/inputs/hidden_input_spec.rb +63 -32
- data/spec/inputs/number_input_spec.rb +37 -8
- data/spec/inputs/password_input_spec.rb +30 -3
- data/spec/inputs/phone_input_spec.rb +30 -3
- data/spec/inputs/radio_input_spec.rb +87 -60
- data/spec/inputs/range_input_spec.rb +32 -5
- data/spec/inputs/search_input_spec.rb +29 -3
- data/spec/inputs/select_input_spec.rb +164 -107
- data/spec/inputs/string_input_spec.rb +33 -22
- data/spec/inputs/text_input_spec.rb +39 -14
- data/spec/inputs/time_select_input_spec.rb +191 -0
- data/spec/inputs/time_zone_input_spec.rb +17 -19
- data/spec/inputs/url_input_spec.rb +30 -3
- data/spec/spec_helper.rb +21 -15
- data/spec/support/custom_macros.rb +61 -228
- data/spec/support/fb_custom_macros.rb +23 -0
- metadata +109 -28
- data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +0 -52
- data/spec/builder/errors_spec.rb +0 -214
- data/spec/helpers/buttons_helper_spec.rb +0 -149
- data/spec/inputs/date_input_spec.rb +0 -147
- data/spec/inputs/datetime_input_spec.rb +0 -101
- data/spec/inputs/time_input_spec.rb +0 -206
- data/spec/support/depracation.rb +0 -6
- data/spec/support/formtastic_spec_helper.rb +0 -382
@@ -8,29 +8,28 @@ describe 'text input' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
11
|
|
13
12
|
concat(semantic_form_for(@new_post) do |builder|
|
14
13
|
concat(builder.input(:body, :as => :text))
|
15
14
|
end)
|
16
15
|
end
|
17
16
|
|
17
|
+
it_should_have_bootstrap_horizontal_wrapping
|
18
18
|
it_should_have_input_wrapper_with_class("text")
|
19
|
-
it_should_have_input_wrapper_with_class(:
|
20
|
-
it_should_have_input_class_in_the_right_place
|
19
|
+
it_should_have_input_wrapper_with_class(:input)
|
21
20
|
it_should_have_input_wrapper_with_id("post_body_input")
|
22
21
|
it_should_have_label_with_text(/Body/)
|
23
22
|
it_should_have_label_for("post_body")
|
24
23
|
it_should_have_textarea_with_id("post_body")
|
25
24
|
it_should_have_textarea_with_name("post[body]")
|
26
|
-
it_should_apply_error_logic_for_input_type(:
|
25
|
+
it_should_apply_error_logic_for_input_type(:number)
|
27
26
|
|
28
27
|
it 'should use input_html to style inputs' do
|
29
28
|
output_buffer.replace ''
|
30
29
|
concat(semantic_form_for(@new_post) do |builder|
|
31
30
|
concat(builder.input(:title, :as => :text, :input_html => { :class => 'myclass' }))
|
32
31
|
end)
|
33
|
-
output_buffer.should have_tag("form div.
|
32
|
+
output_buffer.should have_tag("form div.control-group div.controls textarea.myclass")
|
34
33
|
end
|
35
34
|
|
36
35
|
it "should have a cols attribute when :cols is a number in :input_html" do
|
@@ -38,7 +37,7 @@ describe 'text input' do
|
|
38
37
|
concat(semantic_form_for(@new_post) do |builder|
|
39
38
|
concat(builder.input(:title, :as => :text, :input_html => { :cols => 42 }))
|
40
39
|
end)
|
41
|
-
output_buffer.should have_tag("form div.
|
40
|
+
output_buffer.should have_tag("form div.control-group div.controls textarea[@cols='42']")
|
42
41
|
end
|
43
42
|
|
44
43
|
it "should not have a cols attribute when :cols is nil in :input_html" do
|
@@ -46,7 +45,7 @@ describe 'text input' do
|
|
46
45
|
concat(semantic_form_for(@new_post) do |builder|
|
47
46
|
concat(builder.input(:title, :as => :text, :input_html => { :cols => nil }))
|
48
47
|
end)
|
49
|
-
output_buffer.should_not have_tag("form div.
|
48
|
+
output_buffer.should_not have_tag("form div.control-group div.controls textarea[@cols]")
|
50
49
|
end
|
51
50
|
|
52
51
|
it "should have a rows attribute when :rows is a number in :input_html" do
|
@@ -54,7 +53,7 @@ describe 'text input' do
|
|
54
53
|
concat(semantic_form_for(@new_post) do |builder|
|
55
54
|
concat(builder.input(:title, :as => :text, :input_html => { :rows => 42 }))
|
56
55
|
end)
|
57
|
-
output_buffer.should have_tag("form div.
|
56
|
+
output_buffer.should have_tag("form div.control-group div.controls textarea[@rows='42']")
|
58
57
|
|
59
58
|
end
|
60
59
|
|
@@ -63,7 +62,7 @@ describe 'text input' do
|
|
63
62
|
concat(semantic_form_for(@new_post) do |builder|
|
64
63
|
concat(builder.input(:title, :as => :text, :input_html => { :rows => nil }))
|
65
64
|
end)
|
66
|
-
output_buffer.should_not have_tag("form div.
|
65
|
+
output_buffer.should_not have_tag("form div.control-group div.controls textarea[@rows]")
|
67
66
|
end
|
68
67
|
|
69
68
|
describe "when namespace is provided" do
|
@@ -71,7 +70,6 @@ describe 'text input' do
|
|
71
70
|
before do
|
72
71
|
@output_buffer = ''
|
73
72
|
mock_everything
|
74
|
-
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
75
73
|
|
76
74
|
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
77
75
|
concat(builder.input(:body, :as => :text))
|
@@ -84,6 +82,33 @@ describe 'text input' do
|
|
84
82
|
|
85
83
|
end
|
86
84
|
|
85
|
+
describe "when index is provided" do
|
86
|
+
|
87
|
+
before do
|
88
|
+
@output_buffer = ''
|
89
|
+
mock_everything
|
90
|
+
|
91
|
+
concat(semantic_form_for(@new_post) do |builder|
|
92
|
+
concat(builder.fields_for(:author, :index => 3) do |author|
|
93
|
+
concat(author.input(:name, :as => :text))
|
94
|
+
end)
|
95
|
+
end)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should index the id of the control-group' do
|
99
|
+
output_buffer.should have_tag("div.control-group#post_author_attributes_3_name_input")
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should index the id of the select tag' do
|
103
|
+
output_buffer.should have_tag("textarea#post_author_attributes_3_name")
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should index the name of the select tag' do
|
107
|
+
output_buffer.should have_tag("textarea[@name='post[author_attributes][3][name]']")
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
87
112
|
context "when required" do
|
88
113
|
it "should add the required attribute to the input's html options" do
|
89
114
|
with_config :use_required_attribute, true do
|
@@ -119,7 +144,7 @@ describe 'text input' do
|
|
119
144
|
concat(semantic_form_for(@new_post) do |builder|
|
120
145
|
concat(builder.input(:title, :as => :text))
|
121
146
|
end)
|
122
|
-
output_buffer.should have_tag("form div.
|
147
|
+
output_buffer.should have_tag("form div.control-group div.controls textarea[@rows='12']")
|
123
148
|
end
|
124
149
|
end
|
125
150
|
|
@@ -128,7 +153,7 @@ describe 'text input' do
|
|
128
153
|
concat(semantic_form_for(@new_post) do |builder|
|
129
154
|
concat(builder.input(:title, :as => :text))
|
130
155
|
end)
|
131
|
-
output_buffer.should_not have_tag("form div.
|
156
|
+
output_buffer.should_not have_tag("form div.control-group div.controls textarea[@rows]")
|
132
157
|
end
|
133
158
|
|
134
159
|
end
|
@@ -144,7 +169,7 @@ describe 'text input' do
|
|
144
169
|
concat(semantic_form_for(@new_post) do |builder|
|
145
170
|
concat(builder.input(:title, :as => :text))
|
146
171
|
end)
|
147
|
-
output_buffer.should have_tag("form div.
|
172
|
+
output_buffer.should have_tag("form div.control-group div.controls textarea[@cols='10']")
|
148
173
|
end
|
149
174
|
end
|
150
175
|
|
@@ -153,7 +178,7 @@ describe 'text input' do
|
|
153
178
|
concat(semantic_form_for(@new_post) do |builder|
|
154
179
|
concat(builder.input(:title, :as => :text))
|
155
180
|
end)
|
156
|
-
output_buffer.should_not have_tag("form div.
|
181
|
+
output_buffer.should_not have_tag("form div.control-group div.controls textarea[@cols]")
|
157
182
|
end
|
158
183
|
|
159
184
|
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'time select input' do
|
5
|
+
|
6
|
+
include FormtasticSpecHelper
|
7
|
+
|
8
|
+
before do
|
9
|
+
@output_buffer = ''
|
10
|
+
mock_everything
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "general" do
|
14
|
+
before do
|
15
|
+
::I18n.backend.reload!
|
16
|
+
output_buffer.replace ''
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "with :ignore_date => true" do
|
20
|
+
before do
|
21
|
+
concat(semantic_form_for(@new_post) do |builder|
|
22
|
+
concat(builder.input(:publish_at, :as => :time_select, :ignore_date => true))
|
23
|
+
end)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should not have hidden inputs for day, month and year' do
|
27
|
+
output_buffer.should_not have_tag('input#post_publish_at_1i')
|
28
|
+
output_buffer.should_not have_tag('input#post_publish_at_2i')
|
29
|
+
output_buffer.should_not have_tag('input#post_publish_at_3i')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have an input for hour and minute' do
|
33
|
+
output_buffer.should have_tag('select#post_publish_at_4i')
|
34
|
+
output_buffer.should have_tag('select#post_publish_at_5i')
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "with :ignore_date => false" do
|
40
|
+
before do
|
41
|
+
@new_post.stub(:publish_at).and_return(Time.parse('2010-11-07'))
|
42
|
+
concat(semantic_form_for(@new_post) do |builder|
|
43
|
+
concat(builder.input(:publish_at, :as => :time_select, :ignore_date => false))
|
44
|
+
end)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should have a hidden input for day, month and year' do
|
48
|
+
output_buffer.should have_tag('input#post_publish_at_1i')
|
49
|
+
output_buffer.should have_tag('input#post_publish_at_2i')
|
50
|
+
output_buffer.should have_tag('input#post_publish_at_3i')
|
51
|
+
output_buffer.should have_tag('input#post_publish_at_1i[@value="2010"]')
|
52
|
+
output_buffer.should have_tag('input#post_publish_at_2i[@value="11"]')
|
53
|
+
output_buffer.should have_tag('input#post_publish_at_3i[@value="7"]')
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should have an select for hour and minute' do
|
57
|
+
output_buffer.should have_tag('select#post_publish_at_4i')
|
58
|
+
output_buffer.should have_tag('select#post_publish_at_5i')
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "with :ignore_date => false and no initial Time" do
|
64
|
+
before do
|
65
|
+
@new_post.stub(:publish_at)
|
66
|
+
concat(semantic_form_for(@new_post) do |builder|
|
67
|
+
concat(builder.input(:publish_at, :as => :time_select, :ignore_date => false))
|
68
|
+
end)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should have a hidden input for day, month and year' do
|
72
|
+
output_buffer.should have_tag('input#post_publish_at_1i')
|
73
|
+
output_buffer.should have_tag('input#post_publish_at_2i')
|
74
|
+
output_buffer.should have_tag('input#post_publish_at_3i')
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should not have values in hidden inputs for day, month and year' do
|
78
|
+
output_buffer.should have_tag('input#post_publish_at_1i[@value=""]')
|
79
|
+
output_buffer.should have_tag('input#post_publish_at_2i[@value=""]')
|
80
|
+
output_buffer.should have_tag('input#post_publish_at_3i[@value=""]')
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should have an select for hour and minute' do
|
84
|
+
output_buffer.should have_tag('select#post_publish_at_4i')
|
85
|
+
output_buffer.should have_tag('select#post_publish_at_5i')
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "without seconds" do
|
91
|
+
before do
|
92
|
+
concat(semantic_form_for(@new_post) do |builder|
|
93
|
+
concat(builder.input(:publish_at, :as => :time_select))
|
94
|
+
end)
|
95
|
+
end
|
96
|
+
|
97
|
+
it_should_have_bootstrap_horizontal_wrapping
|
98
|
+
it_should_have_input_wrapper_with_class("time_select")
|
99
|
+
it_should_have_input_wrapper_with_class(:input)
|
100
|
+
it_should_have_input_wrapper_with_id("post_publish_at_input")
|
101
|
+
it_should_apply_error_logic_for_input_type(:time_select)
|
102
|
+
|
103
|
+
it 'should have a legend and label with the label text inside the fieldset' do
|
104
|
+
output_buffer.should have_tag('form div.control-group.time_select label.control-label', /Publish at/)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should have two selects for hour and minute' do
|
108
|
+
output_buffer.should have_tag('form div.control-group.time_select div.controls select', :count => 2)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "with seconds" do
|
113
|
+
before do
|
114
|
+
concat(semantic_form_for(@new_post) do |builder|
|
115
|
+
concat(builder.input(:publish_at, :as => :time_select, :include_seconds => true))
|
116
|
+
end)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should have three selects for hour, minute and seconds' do
|
120
|
+
output_buffer.should have_tag('form div.control-group.time_select div.controls select', :count => 3)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe ':labels option' do
|
126
|
+
it "should provide a message that :labels is not supported" do
|
127
|
+
pending ':labels is not supported'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe ':namespace option' do
|
132
|
+
before do
|
133
|
+
concat(semantic_form_for(@new_post, :namespace => 'form2') do |builder|
|
134
|
+
concat(builder.input(:publish_at, :as => :time_select))
|
135
|
+
end)
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should have a tag matching the namespace' do
|
139
|
+
output_buffer.should have_tag('#form2_post_publish_at_input')
|
140
|
+
output_buffer.should have_tag('#form2_post_publish_at_4i')
|
141
|
+
output_buffer.should have_tag('#form2_post_publish_at_5i')
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "when required" do
|
146
|
+
it "should add the required attribute to the input's html options" do
|
147
|
+
with_config :use_required_attribute, true do
|
148
|
+
concat(semantic_form_for(@new_post) do |builder|
|
149
|
+
concat(builder.input(:title, :as => :time_select, :required => true))
|
150
|
+
end)
|
151
|
+
output_buffer.should have_tag("select[@required]", :count => 2)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "when index is provided" do
|
157
|
+
|
158
|
+
before do
|
159
|
+
concat(semantic_form_for(@new_post) do |builder|
|
160
|
+
concat(builder.fields_for(:author, :index => 3) do |author|
|
161
|
+
concat(author.input(:created_at, :as => :time_select))
|
162
|
+
end)
|
163
|
+
end)
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'should index the id of the control-group' do
|
167
|
+
output_buffer.should have_tag("div.control-group#post_author_attributes_3_created_at_input")
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should index the id of the select tag' do
|
171
|
+
output_buffer.should have_tag("input#post_author_attributes_3_created_at_1i")
|
172
|
+
output_buffer.should have_tag("input#post_author_attributes_3_created_at_2i")
|
173
|
+
output_buffer.should have_tag("input#post_author_attributes_3_created_at_3i")
|
174
|
+
output_buffer.should have_tag("select#post_author_attributes_3_created_at_4i")
|
175
|
+
output_buffer.should have_tag("select#post_author_attributes_3_created_at_5i")
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should index the name of the select tag' do
|
179
|
+
output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at(1i)]']")
|
180
|
+
output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at(2i)]']")
|
181
|
+
output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at(3i)]']")
|
182
|
+
output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(4i)]']")
|
183
|
+
output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(5i)]']")
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
|
@@ -8,35 +8,35 @@ describe 'time_zone input' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
11
|
|
13
12
|
concat(semantic_form_for(@new_post) do |builder|
|
14
13
|
concat(builder.input(:time_zone))
|
15
14
|
end)
|
16
15
|
end
|
17
16
|
|
17
|
+
it_should_have_bootstrap_horizontal_wrapping
|
18
18
|
it_should_have_input_wrapper_with_class("time_zone")
|
19
|
-
it_should_have_input_wrapper_with_class(:
|
19
|
+
it_should_have_input_wrapper_with_class(:input)
|
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.control-group label.control-label')
|
25
|
+
output_buffer.should have_tag('form div.control-group label.control-label[@for="post_time_zone"]')
|
26
|
+
output_buffer.should have_tag('form div.control-group label.control-label', /Time zone/)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should generate a select" do
|
30
|
-
output_buffer.should have_tag("form div select")
|
31
|
-
output_buffer.should have_tag("form div select#post_time_zone")
|
32
|
-
output_buffer.should have_tag("form div select[@name=\"post[time_zone]\"]")
|
30
|
+
output_buffer.should have_tag("form div.control-group div.controls select")
|
31
|
+
output_buffer.should have_tag("form div.control-group div.controls select#post_time_zone")
|
32
|
+
output_buffer.should have_tag("form div.control-group div.controls select[@name=\"post[time_zone]\"]")
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should use input_html to style inputs' do
|
36
36
|
concat(semantic_form_for(@new_post) do |builder|
|
37
37
|
concat(builder.input(:time_zone, :input_html => { :class => 'myclass' }))
|
38
38
|
end)
|
39
|
-
output_buffer.should have_tag("form div select.myclass")
|
39
|
+
output_buffer.should have_tag("form div.control-group div.controls select.myclass")
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "when namespace is provided" do
|
@@ -44,7 +44,6 @@ describe 'time_zone input' do
|
|
44
44
|
before do
|
45
45
|
@output_buffer = ''
|
46
46
|
mock_everything
|
47
|
-
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
48
47
|
|
49
48
|
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
50
49
|
concat(builder.input(:time_zone))
|
@@ -62,7 +61,6 @@ describe 'time_zone input' do
|
|
62
61
|
before do
|
63
62
|
@output_buffer = ''
|
64
63
|
mock_everything
|
65
|
-
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
66
64
|
|
67
65
|
concat(semantic_form_for(@new_post) do |builder|
|
68
66
|
concat(builder.fields_for(:author, :index => 3) do |author|
|
@@ -71,8 +69,8 @@ describe 'time_zone input' do
|
|
71
69
|
end)
|
72
70
|
end
|
73
71
|
|
74
|
-
it 'should index the id of the
|
75
|
-
output_buffer.should have_tag("div#post_author_attributes_3_name_input")
|
72
|
+
it 'should index the id of the control group' do
|
73
|
+
output_buffer.should have_tag("div.control-group#post_author_attributes_3_name_input")
|
76
74
|
end
|
77
75
|
|
78
76
|
it 'should index the id of the select tag' do
|
@@ -94,15 +92,15 @@ describe 'time_zone input' do
|
|
94
92
|
end
|
95
93
|
|
96
94
|
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/)
|
95
|
+
output_buffer.should have_tag('form div.control-group label.control-label')
|
96
|
+
output_buffer.should have_tag('form div.control-group label.control-label[@for="project_time_zone"]')
|
97
|
+
output_buffer.should have_tag('form div.control-group label.control-label', /Time zone/)
|
100
98
|
end
|
101
99
|
|
102
100
|
it 'should generate select inputs' do
|
103
|
-
output_buffer.should have_tag("form div select")
|
104
|
-
output_buffer.should have_tag("form div select#project_time_zone")
|
105
|
-
output_buffer.should have_tag("form div select[@name=\"project[time_zone]\"]")
|
101
|
+
output_buffer.should have_tag("form div.control-group div.controls select")
|
102
|
+
output_buffer.should have_tag("form div.control-group div.controls select#project_time_zone")
|
103
|
+
output_buffer.should have_tag("form div.control-group div.controls select[@name=\"project[time_zone]\"]")
|
106
104
|
end
|
107
105
|
end
|
108
106
|
|
@@ -8,7 +8,6 @@ describe 'url input' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
11
|
end
|
13
12
|
|
14
13
|
describe "when object is provided" do
|
@@ -18,10 +17,10 @@ describe 'url input' do
|
|
18
17
|
end)
|
19
18
|
end
|
20
19
|
|
20
|
+
it_should_have_bootstrap_horizontal_wrapping
|
21
21
|
it_should_have_input_wrapper_with_class(:url)
|
22
|
-
it_should_have_input_wrapper_with_class(:
|
22
|
+
it_should_have_input_wrapper_with_class(:input)
|
23
23
|
it_should_have_input_wrapper_with_class(:stringish)
|
24
|
-
it_should_have_input_class_in_the_right_place
|
25
24
|
it_should_have_input_wrapper_with_id("post_url_input")
|
26
25
|
it_should_have_label_with_text(/Url/)
|
27
26
|
it_should_have_label_for("post_url")
|
@@ -44,6 +43,34 @@ describe 'url input' do
|
|
44
43
|
|
45
44
|
end
|
46
45
|
|
46
|
+
describe "when index is provided" do
|
47
|
+
|
48
|
+
before do
|
49
|
+
@output_buffer = ''
|
50
|
+
mock_everything
|
51
|
+
|
52
|
+
concat(semantic_form_for(@new_post) do |builder|
|
53
|
+
concat(builder.fields_for(:author, :index => 3) do |author|
|
54
|
+
concat(author.input(:name, :as => :url))
|
55
|
+
end)
|
56
|
+
end)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should index the id of the control-group' do
|
60
|
+
output_buffer.should have_tag("div.control-group#post_author_attributes_3_name_input")
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should index the id of the select tag' do
|
64
|
+
output_buffer.should have_tag("input#post_author_attributes_3_name")
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should index the name of the select tag' do
|
68
|
+
output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
|
47
74
|
describe "when required" do
|
48
75
|
it "should add the required attribute to the input's html options" do
|
49
76
|
with_config :use_required_attribute, true do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,30 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
|
1
3
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
-
require 'rspec'
|
4
|
-
require 'rspec_tag_matchers'
|
5
|
-
require 'rubygems'
|
6
|
-
require 'bundler'
|
7
|
-
Bundler.setup
|
8
5
|
|
9
|
-
require '
|
10
|
-
require '
|
11
|
-
require '
|
12
|
-
|
13
|
-
|
6
|
+
# require 'rspec'
|
7
|
+
# require 'rspec_tag_matchers'
|
8
|
+
# require 'rubygems'
|
9
|
+
|
10
|
+
# Find Formtastic and grab its testing support first.
|
11
|
+
formtastic_full_gem_path = Bundler.load.specs.find{|s| s.name == "formtastic" }.full_gem_path
|
12
|
+
require File.join(formtastic_full_gem_path, 'spec', 'spec_helper.rb')
|
14
13
|
|
14
|
+
# Now add in ours.
|
15
15
|
require 'formtastic-bootstrap'
|
16
|
+
require File.join(File.dirname(__FILE__), "support", "custom_macros.rb")
|
17
|
+
require File.join(File.dirname(__FILE__), "support", "fb_custom_macros.rb")
|
16
18
|
|
17
|
-
# Requires supporting files with custom matchers and macros, etc,
|
18
|
-
# in ./support/ and its subdirectories.
|
19
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
20
19
|
|
21
20
|
RSpec.configure do |config|
|
22
|
-
config.
|
23
|
-
|
21
|
+
config.before(:suite) do
|
22
|
+
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
23
|
+
end
|
24
|
+
config.include FbCustomMacros
|
24
25
|
end
|
26
|
+
|
27
|
+
# RSpec.configure do |config|
|
28
|
+
# config.include RspecTagMatchers
|
29
|
+
# config.include CustomMacros
|
30
|
+
# end
|