bootstrap_forms 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'bootstrap_forms'
6
- s.version = '3.0.0'
6
+ s.version = '3.0.1'
7
7
  s.author = 'Seth Vargo'
8
8
  s.email = 'sethvargo@gmail.com'
9
9
  s.homepage = 'https://github.com/sethvargo/bootstrap_forms'
@@ -41,6 +41,13 @@ module BootstrapForms
41
41
  url_field
42
42
  ).each do |method_name|
43
43
  define_method(method_name) do |name, *raw_args|
44
+
45
+ # Special case for select
46
+ if method_name == 'select'
47
+ while raw_args.length < 3
48
+ raw_args << {}
49
+ end
50
+ end
44
51
 
45
52
  options = {}
46
53
  html_options = {}
@@ -212,6 +219,7 @@ module BootstrapForms
212
219
  end
213
220
 
214
221
  private
222
+
215
223
  def field_options(args)
216
224
  if @options
217
225
  @options.slice(:namespace, :index).merge(args)
@@ -139,6 +139,30 @@ shared_examples 'a bootstrap form' do
139
139
  end
140
140
  end
141
141
 
142
+ describe "select" do
143
+
144
+ describe "with hash values, options and html options" do
145
+ it 'is wrapped' do
146
+ @result = @builder.select(:name, {"False" => false}, { :selected => false }, {:class => "my-special-select"})
147
+ @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
+ end
149
+ end
150
+
151
+ describe "with only hash values and options" do
152
+ it 'is wrapped' do
153
+ @result = @builder.select(:name, {"False" => false}, { :selected => false })
154
+ @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
+ end
156
+ end
157
+
158
+ describe "with only hash values" do
159
+ it 'is wrapped' do
160
+ @result = @builder.select(:name, {"False" => false})
161
+ @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
+ end
163
+ end
164
+
165
+ end
142
166
 
143
167
  describe 'country_select' do
144
168
  before(:each) do
@@ -150,7 +174,7 @@ shared_examples 'a bootstrap form' do
150
174
  end
151
175
  end
152
176
 
153
- describe 'collection_select with html options' do
177
+ describe 'country_select with html options' do
154
178
  before(:each) do
155
179
  @result = @builder.country_select(:name, [ "United Kingdom", "France", "Germany" ], {}, :class => "baz")
156
180
  end
@@ -235,7 +259,7 @@ shared_examples 'a bootstrap form' do
235
259
  end
236
260
 
237
261
  context 'label option' do
238
- %w(select email_field file_field number_field password_field search_field text_area text_field url_field).each do |method_name|
262
+ %w(email_field file_field number_field password_field search_field text_area text_field url_field).each do |method_name|
239
263
 
240
264
  it "should not add a label when ''" do
241
265
  @builder.send(method_name.to_sym, 'name', :label => '').should_not match /<\/label>/
@@ -245,6 +269,17 @@ shared_examples 'a bootstrap form' do
245
269
  @builder.send(method_name.to_sym, 'name', :label => false).should_not match /<\/label>/
246
270
  end
247
271
  end
272
+
273
+ %w(select).each do |method_name|
274
+
275
+ it "should not add a label when ''" do
276
+ @builder.send(method_name.to_sym, 'name', [1,2], :label => '').should_not match /<\/label>/
277
+ end
278
+
279
+ it 'should not add a label when false' do
280
+ @builder.send(method_name.to_sym, 'name', [1,2], :label => false).should_not match /<\/label>/
281
+ end
282
+ end
248
283
  end
249
284
  end # extras
250
285
 
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: 3.0.0
4
+ version: 3.0.1
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-05-06 00:00:00.000000000 Z
12
+ date: 2013-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec-rails