bootstrap_forms 3.0.1 → 4.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/.travis.yml +1 -5
- data/Gemfile +1 -1
- data/LICENSE +198 -4
- data/README.md +16 -6
- data/Rakefile +0 -17
- data/bootstrap_forms.gemspec +8 -6
- data/lib/bootstrap_forms.rb +12 -5
- data/lib/bootstrap_forms/engine.rb +2 -0
- data/lib/bootstrap_forms/form_builder.rb +3 -2
- data/lib/bootstrap_forms/helpers.rb +4 -4
- data/lib/bootstrap_forms/helpers/form_tag_helper.rb +4 -3
- data/lib/bootstrap_forms/helpers/wrappers.rb +2 -1
- data/lib/bootstrap_forms/version.rb +3 -0
- data/spec/lib/bootstrap_forms/form_builder_spec.rb +14 -0
- data/spec/spec_helper.rb +0 -2
- data/spec/support/shared_context.rb +13 -15
- metadata +12 -29
- data/.ruby-version +0 -1
- data/Guardfile +0 -7
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
gemspec
|
data/LICENSE
CHANGED
@@ -1,7 +1,201 @@
|
|
1
|
-
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
2
4
|
|
3
|
-
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
4
6
|
|
5
|
-
|
7
|
+
1. Definitions.
|
6
8
|
|
7
|
-
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright 2012-2013 Seth Vargo <sethvargo@gmail.com>
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -270,12 +270,22 @@ I'm pretty dam active on github. Fork and submit a pull request. Most of my pull
|
|
270
270
|
- **Test/Spec** the changes
|
271
271
|
- **Document** your changes
|
272
272
|
|
273
|
-
License
|
274
|
-
|
275
|
-
|
273
|
+
License & Authors
|
274
|
+
-----------------
|
275
|
+
- Author:: Seth Vargo (sethvargo@gmail.com)
|
276
276
|
|
277
|
-
|
277
|
+
```text
|
278
|
+
Copyright 2012-2013 Seth Vargo <sethvargo@gmail.com>
|
278
279
|
|
279
|
-
|
280
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
281
|
+
you may not use this file except in compliance with the License.
|
282
|
+
You may obtain a copy of the License at
|
280
283
|
|
281
|
-
|
284
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
285
|
+
|
286
|
+
Unless required by applicable law or agreed to in writing, software
|
287
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
288
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
289
|
+
See the License for the specific language governing permissions and
|
290
|
+
limitations under the License.
|
291
|
+
```
|
data/Rakefile
CHANGED
@@ -1,18 +1 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
|
4
|
-
desc 'Default: run specs.'
|
5
|
-
task :default => :spec
|
6
|
-
|
7
|
-
desc 'Run specs'
|
8
|
-
RSpec::Core::RakeTask.new do |t|
|
9
|
-
t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
|
10
|
-
# Put spec opts in a file named .rspec in root
|
11
|
-
end
|
12
|
-
|
13
|
-
desc 'Generate code coverage'
|
14
|
-
RSpec::Core::RakeTask.new(:coverage) do |t|
|
15
|
-
t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
|
16
|
-
t.rcov = true
|
17
|
-
t.rcov_opts = ['--exclude', 'spec']
|
18
|
-
end
|
data/bootstrap_forms.gemspec
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'bootstrap_forms/version'
|
3
4
|
|
4
5
|
Gem::Specification.new do |s|
|
5
6
|
s.name = 'bootstrap_forms'
|
6
|
-
s.version =
|
7
|
+
s.version = BootstrapForms::VERSION
|
7
8
|
s.author = 'Seth Vargo'
|
8
9
|
s.email = 'sethvargo@gmail.com'
|
9
10
|
s.homepage = 'https://github.com/sethvargo/bootstrap_forms'
|
@@ -15,12 +16,13 @@ Gem::Specification.new do |s|
|
|
15
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
17
|
s.require_paths = ['lib']
|
17
18
|
|
18
|
-
s.
|
19
|
-
|
19
|
+
s.required_ruby_version = '>= 1.9.1'
|
20
|
+
|
21
|
+
s.add_development_dependency 'rspec-rails', '~> 2.13'
|
22
|
+
s.add_development_dependency 'capybara', '~> 2.1'
|
20
23
|
s.add_development_dependency 'rake'
|
21
|
-
s.add_development_dependency 'rails',
|
22
|
-
s.add_development_dependency 'country_select',
|
23
|
-
s.add_development_dependency 'guard-rspec'
|
24
|
+
s.add_development_dependency 'rails', '~> 3.2'
|
25
|
+
s.add_development_dependency 'country_select', '~> 1.1'
|
24
26
|
s.add_development_dependency 'sqlite3'
|
25
27
|
s.add_development_dependency 'fuubar'
|
26
28
|
end
|
data/lib/bootstrap_forms.rb
CHANGED
@@ -2,10 +2,17 @@
|
|
2
2
|
require 'bootstrap_forms/engine' if defined?(::Rails)
|
3
3
|
|
4
4
|
module BootstrapForms
|
5
|
-
|
5
|
+
require_relative 'bootstrap_forms/engine'
|
6
|
+
require_relative 'bootstrap_forms/form_builder'
|
7
|
+
require_relative 'bootstrap_forms/version'
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
class << self
|
10
|
+
def default_form_builder
|
11
|
+
@default_form_builder ||= BootstrapForms::FormBuilder
|
12
|
+
end
|
13
|
+
|
14
|
+
def default_form_builder=(builder)
|
15
|
+
@default_form_builder = builder
|
16
|
+
end
|
17
|
+
end
|
11
18
|
end
|
@@ -3,6 +3,8 @@ module BootstrapForms
|
|
3
3
|
initializer 'bootstrap_forms.initialize' do
|
4
4
|
config.to_prepare do
|
5
5
|
ActiveSupport.on_load(:action_view) do
|
6
|
+
require_relative 'helpers'
|
7
|
+
|
6
8
|
include BootstrapForms::Helpers::FormHelper
|
7
9
|
include BootstrapForms::Helpers::FormTagHelper
|
8
10
|
include BootstrapForms::Helpers::NestedFormHelper
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module BootstrapForms
|
2
2
|
class FormBuilder < ::ActionView::Helpers::FormBuilder
|
3
|
+
require_relative 'helpers/wrappers'
|
3
4
|
include BootstrapForms::Helpers::Wrappers
|
4
5
|
|
5
6
|
delegate :content_tag, :hidden_field_tag, :check_box_tag, :radio_button_tag, :button_tag, :link_to, :to => :@template
|
@@ -41,7 +42,7 @@ module BootstrapForms
|
|
41
42
|
url_field
|
42
43
|
).each do |method_name|
|
43
44
|
define_method(method_name) do |name, *raw_args|
|
44
|
-
|
45
|
+
|
45
46
|
# Special case for select
|
46
47
|
if method_name == 'select'
|
47
48
|
while raw_args.length < 3
|
@@ -219,7 +220,7 @@ module BootstrapForms
|
|
219
220
|
end
|
220
221
|
|
221
222
|
private
|
222
|
-
|
223
|
+
|
223
224
|
def field_options(args)
|
224
225
|
if @options
|
225
226
|
@options.slice(:namespace, :index).merge(args)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module BootstrapForms
|
2
2
|
module Helpers
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative 'helpers/form_helper'
|
4
|
+
require_relative 'helpers/form_tag_helper'
|
5
|
+
require_relative 'helpers/nested_form_helper'
|
6
|
+
require_relative 'helpers/wrappers'
|
7
7
|
end
|
8
8
|
end
|
@@ -59,7 +59,7 @@ module BootstrapForms
|
|
59
59
|
@field_options = field_options(args)
|
60
60
|
@args = args
|
61
61
|
|
62
|
-
@field_options[:class]
|
62
|
+
@field_options[:class] ||= 'btn btn-primary'
|
63
63
|
button_tag(name, *(args << @field_options))
|
64
64
|
end
|
65
65
|
|
@@ -68,13 +68,14 @@ module BootstrapForms
|
|
68
68
|
@field_options = field_options(args)
|
69
69
|
@args = args
|
70
70
|
|
71
|
-
@field_options[:class]
|
71
|
+
@field_options[:class] ||= 'btn btn-primary'
|
72
72
|
submit_tag(name, *(args << @field_options))
|
73
73
|
end
|
74
74
|
|
75
75
|
def bootstrap_cancel_tag(*args)
|
76
76
|
@field_options = field_options(args)
|
77
|
-
|
77
|
+
@field_options[:class] ||= 'btn cancel'
|
78
|
+
link_to(I18n.t('bootstrap_forms.buttons.cancel'), (@field_options[:back] || :back), @field_options)
|
78
79
|
end
|
79
80
|
|
80
81
|
def bootstrap_actions(&block)
|
@@ -15,6 +15,7 @@ module BootstrapForms
|
|
15
15
|
klasses << 'error' if @field_options[:error]
|
16
16
|
klasses << 'success' if @field_options[:success]
|
17
17
|
klasses << 'warning' if @field_options[:warning]
|
18
|
+
klasses << 'required' if @field_options.merge(required_attribute)[:required]
|
18
19
|
|
19
20
|
control_group_options = {}
|
20
21
|
control_group_options[:class] = klasses if !klasses.empty?
|
@@ -31,7 +32,7 @@ module BootstrapForms
|
|
31
32
|
errors = object.errors[@name]
|
32
33
|
if errors.present?
|
33
34
|
errors.map { |e|
|
34
|
-
|
35
|
+
object.errors.full_message(@name, e)
|
35
36
|
}.join(", ")
|
36
37
|
end
|
37
38
|
end
|
@@ -90,6 +90,20 @@ describe 'BootstrapForms::FormBuilder' do
|
|
90
90
|
@builder.text_field('name', :error => 'This is an error!').should == "<div class=\"control-group error\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><input id=\"item_name\" name=\"item[name]\" size=\"30\" type=\"text\" /><span class=\"help-inline\">This is an error!, Name is invalid</span></div></div>"
|
91
91
|
end
|
92
92
|
end
|
93
|
+
|
94
|
+
context "errors with translations" do
|
95
|
+
before(:all) { I18n.backend.store_translations I18n.locale, {:errors => {:format => "%{message}", :messages => {:invalid => "Nope"}}} }
|
96
|
+
after(:all) { I18n.backend.reload! }
|
97
|
+
|
98
|
+
before(:each) do
|
99
|
+
@project.errors.add('name')
|
100
|
+
@result = @builder.error_messages
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'use i18n format on field error message' do
|
104
|
+
@builder.text_field('name').should match /<span class="help-inline">Nope<\/span>/
|
105
|
+
end
|
106
|
+
end
|
93
107
|
|
94
108
|
context 'an attribute with a PresenceValidator' do
|
95
109
|
it 'adds the required attribute' do
|
data/spec/spec_helper.rb
CHANGED
@@ -3,8 +3,6 @@ require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
|
3
3
|
require 'rspec/rails'
|
4
4
|
require 'capybara/rspec'
|
5
5
|
|
6
|
-
require 'active_support/ordered_hash' if RUBY_VERSION < '1.9'
|
7
|
-
|
8
6
|
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/bootstrap_forms'))
|
9
7
|
|
10
8
|
require 'support/shared_context'
|
@@ -52,13 +52,7 @@ shared_examples 'a bootstrap form' do
|
|
52
52
|
|
53
53
|
describe 'radio_buttons' do
|
54
54
|
before do
|
55
|
-
|
56
|
-
@options = ActiveSupport::OrderedHash.new
|
57
|
-
@options['One'] = '1'
|
58
|
-
@options['Two'] = '2'
|
59
|
-
else
|
60
|
-
@options = {'One' => '1', 'Two' => '2'}
|
61
|
-
end
|
55
|
+
@options = {'One' => '1', 'Two' => '2'}
|
62
56
|
end
|
63
57
|
|
64
58
|
it 'doesn\'t use field_options from previously generated field' do
|
@@ -138,32 +132,32 @@ shared_examples 'a bootstrap form' do
|
|
138
132
|
@result.should match /class=".*baz/
|
139
133
|
end
|
140
134
|
end
|
141
|
-
|
135
|
+
|
142
136
|
describe "select" do
|
143
|
-
|
137
|
+
|
144
138
|
describe "with hash values, options and html options" do
|
145
139
|
it 'is wrapped' do
|
146
140
|
@result = @builder.select(:name, {"False" => false}, { :selected => false }, {:class => "my-special-select"})
|
147
141
|
@result.should match /^<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name<\/label><div class=\"controls\"><select class=\"my-special-select\" id=\"item_name\" name=\"item\[name\]\"><option value=\"false\" selected=\"selected\">False<\/option><\/select><\/div><\/div>$/
|
148
142
|
end
|
149
143
|
end
|
150
|
-
|
144
|
+
|
151
145
|
describe "with only hash values and options" do
|
152
146
|
it 'is wrapped' do
|
153
147
|
@result = @builder.select(:name, {"False" => false}, { :selected => false })
|
154
148
|
@result.should match /^<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name<\/label><div class=\"controls\"><select id=\"item_name\" name=\"item\[name\]\"><option value=\"false\" selected=\"selected\">False<\/option><\/select><\/div><\/div>$/
|
155
149
|
end
|
156
150
|
end
|
157
|
-
|
151
|
+
|
158
152
|
describe "with only hash values" do
|
159
153
|
it 'is wrapped' do
|
160
154
|
@result = @builder.select(:name, {"False" => false})
|
161
155
|
@result.should match /^<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name<\/label><div class=\"controls\"><select id=\"item_name\" name=\"item\[name\]\"><option value=\"false\">False<\/option><\/select><\/div><\/div>$/
|
162
156
|
end
|
163
157
|
end
|
164
|
-
|
158
|
+
|
165
159
|
end
|
166
|
-
|
160
|
+
|
167
161
|
describe 'country_select' do
|
168
162
|
before(:each) do
|
169
163
|
@result = @builder.country_select(:name,[ "United Kingdom", "France", "Germany" ])
|
@@ -173,7 +167,7 @@ shared_examples 'a bootstrap form' do
|
|
173
167
|
@result.should match /^<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name<\/label><div class=\"controls\"><select id=\"item_name\" name=\"item\[name\]\"><option value=\"United Kingdom\">United Kingdom<\/option>/
|
174
168
|
end
|
175
169
|
end
|
176
|
-
|
170
|
+
|
177
171
|
describe 'country_select with html options' do
|
178
172
|
before(:each) do
|
179
173
|
@result = @builder.country_select(:name, [ "United Kingdom", "France", "Germany" ], {}, :class => "baz")
|
@@ -183,7 +177,7 @@ shared_examples 'a bootstrap form' do
|
|
183
177
|
@result.should match /class=".*baz/
|
184
178
|
end
|
185
179
|
end
|
186
|
-
|
180
|
+
|
187
181
|
|
188
182
|
end # no options
|
189
183
|
|
@@ -197,6 +191,10 @@ shared_examples 'a bootstrap form' do
|
|
197
191
|
@builder.text_field(:name, :help_block => 'help me!').should == "<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><input id=\"item_name\" name=\"item[name]\" size=\"30\" type=\"text\" /><span class=\"help-block\">help me!</span></div></div>"
|
198
192
|
end
|
199
193
|
|
194
|
+
it 'marks it as required' do
|
195
|
+
@builder.text_field(:name, :required => true).should == "<div class=\"control-group required\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><input id=\"item_name\" name=\"item[name]\" required=\"required\" size=\"30\" type=\"text\" /></div></div>"
|
196
|
+
end
|
197
|
+
|
200
198
|
it 'adds error message and class' do
|
201
199
|
@builder.text_field(:name, :error => 'This is an error!').should == "<div class=\"control-group error\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><input id=\"item_name\" name=\"item[name]\" size=\"30\" type=\"text\" /><span class=\"help-inline\">This is an error!</span></div></div>"
|
202
200
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-rails
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
21
|
+
version: '2.13'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.
|
29
|
+
version: '2.13'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: capybara
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 2.
|
37
|
+
version: '2.1'
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.
|
45
|
+
version: '2.1'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rake
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 3.2
|
69
|
+
version: '3.2'
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 3.2
|
77
|
+
version: '3.2'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: country_select
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.1
|
85
|
+
version: '1.1'
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,23 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.1
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: guard-rspec
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
93
|
+
version: '1.1'
|
110
94
|
- !ruby/object:Gem::Dependency
|
111
95
|
name: sqlite3
|
112
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,10 +131,8 @@ extensions: []
|
|
147
131
|
extra_rdoc_files: []
|
148
132
|
files:
|
149
133
|
- .gitignore
|
150
|
-
- .ruby-version
|
151
134
|
- .travis.yml
|
152
135
|
- Gemfile
|
153
|
-
- Guardfile
|
154
136
|
- LICENSE
|
155
137
|
- README.md
|
156
138
|
- Rakefile
|
@@ -166,6 +148,7 @@ files:
|
|
166
148
|
- lib/bootstrap_forms/helpers/form_tag_helper.rb
|
167
149
|
- lib/bootstrap_forms/helpers/nested_form_helper.rb
|
168
150
|
- lib/bootstrap_forms/helpers/wrappers.rb
|
151
|
+
- lib/bootstrap_forms/version.rb
|
169
152
|
- spec/dummy/Rakefile
|
170
153
|
- spec/dummy/app/assets/javascripts/application.js
|
171
154
|
- spec/dummy/app/assets/stylesheets/application.css
|
@@ -226,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
209
|
requirements:
|
227
210
|
- - ! '>='
|
228
211
|
- !ruby/object:Gem::Version
|
229
|
-
version:
|
212
|
+
version: 1.9.1
|
230
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
214
|
none: false
|
232
215
|
requirements:
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.9.3-p392
|
data/Guardfile
DELETED