bootstrap-form 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -34,14 +34,15 @@ Will generate something like:
34
34
  </div>
35
35
  </div>
36
36
 
37
- ## Password Field
37
+ ## Other helpers
38
38
 
39
- Same as above, but, with a password_field
39
+ So far, I have implemented the following helpers:
40
40
 
41
- form_for @account do |f|
42
- f.bootstrap_password_field :password
43
- f.bootstrap_password_field :password_confirmation
44
- end
41
+ * bootstrap_text_field
42
+ * bootstrap_password_field
43
+ * bootstrap_collection_select
44
+
45
+ Expect more in the near future
45
46
 
46
47
  ## Error handling
47
48
 
@@ -9,6 +9,10 @@ module ActionView
9
9
  bootstrap_clearfix_wrap(object_name, method, options.dup, password_field(object_name, method, options))
10
10
  end
11
11
 
12
+ def bootstrap_collection_select(object_name, method, collection, value_method, text_method, options = {}, html_options = {})
13
+ bootstrap_clearfix_wrap(object_name, method, options.dup, collection_select(object_name, method, collection, value_method, text_method, options, html_options))
14
+ end
15
+
12
16
  def bootstrap_clearfix_wrap(object_name, method, options={}, content)
13
17
  error_messages = options[:object].errors[method]
14
18
  clearfix_tag = error_messages.empty? ? 'clearfix' : 'clearfix error'
@@ -33,4 +37,8 @@ class ActionView::Helpers::FormBuilder #:nodoc:
33
37
  def bootstrap_password_field(method, options = {})
34
38
  @template.bootstrap_password_field(@object_name, method, objectify_options(options))
35
39
  end
40
+
41
+ def bootstrap_collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
42
+ @template.bootstrap_collection_select(@object_name, method, collection, value_method, text_method, objectify_options(options), html_options)
43
+ end
36
44
  end
@@ -1,5 +1,5 @@
1
1
  module Bootstrap
2
2
  module Form
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -2,43 +2,54 @@ require 'test_helper'
2
2
 
3
3
  class FormHelperTest < ActionView::TestCase
4
4
  def test_bootstrap_clearfix_wrap
5
- object = mock
6
- errors = {:name => []}
7
- stub(object).errors { errors }
8
- stub(object).name { 'Object Name' }
5
+ object = mock
6
+ errors = { :name => [] }
9
7
  options = { :object => object }
10
8
  content = ::ActiveSupport::SafeBuffer.new('content')
11
- # content = ''
9
+ stub(object).errors { errors }
10
+ stub(object).name { 'Object Name' }
12
11
 
13
12
  expected_code = %{<div class="clearfix"><label for="post_name">Name</label><div class="input">content</div></div>}
14
13
  assert_equal expected_code, bootstrap_clearfix_wrap(:post, :name, options, content)
15
14
  end
16
15
 
17
16
  def test_bootstrap_clearfix_wrap_with_errors
18
- object = mock
19
- errors = {:name => ["can't be blank"]}
20
- stub(object).errors { errors }
21
- stub(object).name { 'Object Name' }
17
+ object = mock
18
+ errors = { :name => ["can't be blank"] }
22
19
  options = { :object => object }
23
20
  content = ::ActiveSupport::SafeBuffer.new('content')
21
+ stub(object).errors { errors }
22
+ stub(object).name { 'Object Name' }
24
23
 
25
24
  expected_code = %{<div class="clearfix error"><label for="post_name">Name</label><div class="input">content<span class="help-inline"> can't be blank</span></div></div>}
26
25
  assert_equal expected_code, bootstrap_clearfix_wrap(:post, :name, options, content)
27
26
  end
28
27
 
29
28
  def test_bootstrap_text_field
30
- options = { :object => mock }
31
29
  html, text_field = mock, mock
30
+ options = { :object => mock }
31
+
32
32
  mock(self).text_field(:post, :name, options) { text_field }
33
33
  mock(self).bootstrap_clearfix_wrap(:post, :name, options.dup, text_field) { html }
34
34
  assert_equal html, bootstrap_text_field(:post, :name, options)
35
35
  end
36
36
 
37
37
  def test_bootstrap_password_field
38
- options = { :object => mock }
39
38
  html, password_field = mock, mock
40
- mock(self).password_field(:post, :name, options) { password_field }
41
- mock(self).bootstrap_clearfix_wrap(:post, :name, options.dup, password_field) { html }
42
- assert_equal html, bootstrap_password_field(:post, :name, options)
39
+ options = { :object => mock }
40
+
41
+ mock(self).password_field(:post, :password, options) { password_field }
42
+ mock(self).bootstrap_clearfix_wrap(:post, :password, options.dup, password_field) { html }
43
+ assert_equal html, bootstrap_password_field(:post, :password, options)
44
+ end
45
+
46
+ def test_bootstrap_collection_select
47
+ html, collection_select_html, collection, object = mock, mock, mock, mock
48
+ options = { :object => mock }
49
+
50
+ mock(self).collection_select(:post, :name, collection, :id, :name, options, {}) { collection_select_html }
51
+ mock(self).bootstrap_clearfix_wrap(:post, :name, options.dup, collection_select_html) { html }
52
+
53
+ assert_equal html, bootstrap_collection_select(:post, :name, collection, :id ,:name, options)
43
54
  end
44
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-07 00:00:00.000000000 Z
12
+ date: 2011-09-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70319989305380 !ruby/object:Gem::Requirement
16
+ requirement: &70254815421580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70319989305380
24
+ version_requirements: *70254815421580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &70319989286820 !ruby/object:Gem::Requirement
27
+ requirement: &70254815421160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70319989286820
35
+ version_requirements: *70254815421160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rr
38
- requirement: &70319985555820 !ruby/object:Gem::Requirement
38
+ requirement: &70254815420700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70319985555820
46
+ version_requirements: *70254815420700
47
47
  description: Twitter Bootstrap Form helpers
48
48
  email:
49
49
  - david@crowdint.com