bootstrap_forms 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -166,6 +166,11 @@ You can add as many options to any form helper tag. If they are interpreted by B
166
166
  <td>Adds special text at the end of the input</td>
167
167
  <td>= f.text_field :name, :append => '@'</td>
168
168
  </tr>
169
+ <tr>
170
+ <th>label</th>
171
+ <td>Customize the field's label. Pass false to have no label.</td>
172
+ <td>= f.text_field :name, :label => 'Other name'</td>
173
+ </tr>
169
174
  </table>
170
175
 
171
176
  Internationalization/Custom Errors
data/Rakefile CHANGED
@@ -4,15 +4,15 @@ require 'rspec/core/rake_task'
4
4
  desc 'Default: run specs.'
5
5
  task :default => :spec
6
6
 
7
- desc "Run specs"
7
+ desc 'Run specs'
8
8
  RSpec::Core::RakeTask.new do |t|
9
- t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
9
+ t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
10
10
  # Put spec opts in a file named .rspec in root
11
11
  end
12
12
 
13
- desc "Generate code coverage"
13
+ desc 'Generate code coverage'
14
14
  RSpec::Core::RakeTask.new(:coverage) do |t|
15
- t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
15
+ t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
16
16
  t.rcov = true
17
17
  t.rcov_opts = ['--exclude', 'spec']
18
- end
18
+ end
@@ -1,24 +1,24 @@
1
1
  # encoding: utf-8
2
- $:.push File.expand_path("../lib", __FILE__)
2
+ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = "bootstrap_forms"
6
- s.version = "2.0.4"
7
- s.author = "Seth Vargo"
8
- s.email = "sethvargo@gmail.com"
9
- s.homepage = "https://github.com/sethvargo/bootstrap_forms"
5
+ s.name = 'bootstrap_forms'
6
+ s.version = '2.0.5'
7
+ s.author = 'Seth Vargo'
8
+ s.email = 'sethvargo@gmail.com'
9
+ s.homepage = 'https://github.com/sethvargo/bootstrap_forms'
10
10
  s.summary = %q{Bootstrap Forms makes Twitter's Bootstrap on Rails easy!}
11
11
  s.description = %q{Bootstrap Forms makes Twitter's Bootstrap on Rails easy to use by creating helpful form builders that minimize markup in your views.}
12
12
 
13
13
  s.files = `git ls-files`.split("\n")
14
14
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
- s.require_paths = ["lib"]
16
+ s.require_paths = ['lib']
17
17
 
18
- s.add_development_dependency "rspec-rails", "~> 2.10.1"
19
- s.add_development_dependency "capybara", "~> 1.1.0"
20
- s.add_development_dependency "rake"
21
- s.add_development_dependency "rails", "~> 3.2.0"
22
- s.add_development_dependency "guard-rspec"
23
- s.add_development_dependency "sqlite3"
18
+ s.add_development_dependency 'rspec-rails', '~> 2.12.0'
19
+ s.add_development_dependency 'capybara', '~> 2.0.0'
20
+ s.add_development_dependency 'rake'
21
+ s.add_development_dependency 'rails', '~> 3.2.0'
22
+ s.add_development_dependency 'guard-rspec'
23
+ s.add_development_dependency 'sqlite3'
24
24
  end
@@ -58,12 +58,8 @@ module BootstrapForms
58
58
  control_group_div do
59
59
  label_field + input_div do
60
60
  values.map do |text, value|
61
- if @field_options[:label] == '' || @field_options[:label] == false
61
+ label("#{@name}_#{value}", :class => 'radio') do
62
62
  extras { radio_button(name, value, @field_options) + text }
63
- else
64
- label("#{@name}_#{value}", :class => 'radio') do
65
- extras { radio_button(name, value, @field_options) + text }
66
- end
67
63
  end
68
64
  end.join.html_safe
69
65
  end
@@ -1,31 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "bootstrap_form_for" do
4
- describe "default_form_builder" do
5
- it "should be accessible" do
3
+ describe 'bootstrap_form_for' do
4
+ describe 'default_form_builder' do
5
+ it 'should be accessible' do
6
6
  BootstrapForms.should respond_to(:default_form_builder)
7
7
  end
8
8
 
9
- it "should be the BootstrapForms form_builder by default" do
9
+ it 'should be the BootstrapForms form_builder by default' do
10
10
  BootstrapForms.default_form_builder.should == BootstrapForms::FormBuilder
11
11
  end
12
12
 
13
- context "when set to something else" do
13
+ context 'when set to something else' do
14
14
  before do
15
15
  BootstrapForms.default_form_builder = MyCustomFormBuilder
16
16
  end
17
17
 
18
- it "should be that other thing" do
18
+ it 'should be that other thing' do
19
19
  BootstrapForms.default_form_builder.should == MyCustomFormBuilder
20
20
  end
21
21
 
22
- describe "projects/new.html.erb", :type => :view do
22
+ describe 'projects/new.html.erb', :type => :view do
23
23
  before do
24
24
  assign :project, Project.new
25
- render :file => "projects/new.html.erb", :layout => "layouts/application.html.erb"
25
+ render :file => 'projects/new.html.erb', :layout => 'layouts/application.html.erb'
26
26
  end
27
27
 
28
- it "should render with the other form builder" do
28
+ it 'should render with the other form builder' do
29
29
  # in other words, it shouldn't be wrapped with the bootstrap stuff
30
30
  rendered.should_not match /<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name<\/label><div class=\"controls\">.*<\/div><\/div>/
31
31
  end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,4 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper.rb"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
1
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
8
2
 
9
3
  require 'rspec/rails'
10
4
  require 'capybara/rspec'
@@ -22,4 +16,4 @@ RSpec.configure do |config|
22
16
  config.include RSpec::Rails::ViewExampleGroup, :type => :view
23
17
  end
24
18
 
25
- Rails.backtrace_cleaner.remove_silencers!
19
+ Rails.backtrace_cleaner.remove_silencers!
@@ -1,49 +1,49 @@
1
- shared_examples "a bootstrap form" do
2
- describe "with no options" do
3
- describe "error_messages" do
4
- it "returns empty string without errors" do
5
- @builder.error_messages.should == ""
1
+ shared_examples 'a bootstrap form' do
2
+ describe 'with no options' do
3
+ describe 'error_messages' do
4
+ it 'returns empty string without errors' do
5
+ @builder.error_messages.should == ''
6
6
  end
7
7
  end
8
8
 
9
- describe "text_area" do
9
+ describe 'text_area' do
10
10
  before(:each) do
11
- @result = @builder.text_area "name"
11
+ @result = @builder.text_area 'name'
12
12
  end
13
13
 
14
- it "has textarea input" do
14
+ it 'has textarea input' do
15
15
  @result.should match /textarea/
16
16
  end
17
17
  end
18
18
 
19
- describe "uneditable_input" do
20
- it "generates wrapped input" do
21
- @builder.uneditable_input("name").should == "<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><span class=\"uneditable-input\"></span></div></div>"
19
+ describe 'uneditable_input' do
20
+ it 'generates wrapped input' do
21
+ @builder.uneditable_input('name').should == "<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><span class=\"uneditable-input\"></span></div></div>"
22
22
  end
23
23
 
24
- it "allows for an id" do
25
- @builder.uneditable_input("name", :id => "myid").should match /<span.*id="myid"/
24
+ it 'allows for an id' do
25
+ @builder.uneditable_input('name', :id => 'myid').should match /<span.*id="myid"/
26
26
  end
27
27
  end
28
28
 
29
- describe "check_box" do
30
- it "generates wrapped input" do
31
- @builder.check_box("name").should == "<div class=\"control-group\"><div class=\"controls\"><label class=\"checkbox\" for=\"item_name\"><input name=\"item[name]\" type=\"hidden\" value=\"0\" /><input id=\"item_name\" name=\"item[name]\" type=\"checkbox\" value=\"1\" />Name</label></div></div>"
29
+ describe 'check_box' do
30
+ it 'generates wrapped input' do
31
+ @builder.check_box('name').should == "<div class=\"control-group\"><div class=\"controls\"><label class=\"checkbox\" for=\"item_name\"><input name=\"item[name]\" type=\"hidden\" value=\"0\" /><input id=\"item_name\" name=\"item[name]\" type=\"checkbox\" value=\"1\" />Name</label></div></div>"
32
32
  end
33
33
 
34
- it "allows custom label" do
35
- @builder.check_box("name", :label => "custom label").should match /custom label<\/label>/
34
+ it 'allows custom label' do
35
+ @builder.check_box('name', :label => 'custom label').should match /custom label<\/label>/
36
36
  end
37
37
 
38
- it "allows no label with :label => false " do
39
- @builder.check_box("name", :label => false).should_not match /<\/label>/
38
+ it 'allows no label with :label => false ' do
39
+ @builder.check_box('name', :label => false).should_not match /<\/label>/
40
40
  end
41
- it "allows no label with :label => '' " do
42
- @builder.check_box("name", :label => '').should_not match /<\/label>/
41
+ it 'allows no label with :label => '' ' do
42
+ @builder.check_box('name', :label => '').should_not match /<\/label>/
43
43
  end
44
44
  end
45
45
 
46
- describe "radio_buttons" do
46
+ describe 'radio_buttons' do
47
47
  before do
48
48
  if RUBY_VERSION < '1.9'
49
49
  @options = ActiveSupport::OrderedHash.new
@@ -54,33 +54,37 @@ shared_examples "a bootstrap form" do
54
54
  end
55
55
  end
56
56
 
57
- it "doesn't use field_options from previously generated field" do
57
+ it 'doesn\'t use field_options from previously generated field' do
58
58
  @builder.text_field :name, :label => 'Heading', :help_inline => 'Inline help', :help_block => 'Block help'
59
59
  @builder.radio_buttons(:name, @options).should == "<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><label class=\"radio\" for=\"item_name_1\"><input id=\"item_name_1\" name=\"item[name]\" type=\"radio\" value=\"1\" />One</label><label class=\"radio\" for=\"item_name_2\"><input id=\"item_name_2\" name=\"item[name]\" type=\"radio\" value=\"2\" />Two</label></div></div>"
60
60
  end
61
61
 
62
- it "sets field_options" do
63
- @builder.radio_buttons(:name, {"One" => "1", "Two" => "2"})
64
- @builder.instance_variable_get("@field_options").should == {:error => nil}
62
+ it 'sets field_options' do
63
+ @builder.radio_buttons(:name, {'One' => '1', 'Two' => '2'})
64
+ @builder.instance_variable_get('@field_options').should == {:error => nil}
65
65
  end
66
66
 
67
- it "generates wrapped input" do
67
+ it 'generates wrapped input' do
68
68
  @builder.radio_buttons(:name, @options).should == "<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><label class=\"radio\" for=\"item_name_1\"><input id=\"item_name_1\" name=\"item[name]\" type=\"radio\" value=\"1\" />One</label><label class=\"radio\" for=\"item_name_2\"><input id=\"item_name_2\" name=\"item[name]\" type=\"radio\" value=\"2\" />Two</label></div></div>"
69
69
  end
70
70
 
71
- it "allows custom label" do
72
- @builder.radio_buttons(:name, @options, {:label => "custom label"}).should match /custom label<\/label>/
71
+ it 'allows custom label' do
72
+ @builder.radio_buttons(:name, @options, {:label => 'custom label'}).should match /custom label<\/label>/
73
+ end
74
+
75
+ it 'allows no label' do
76
+ @builder.radio_buttons(:name, @options, {:label => false}).should == "<div class=\"control-group\"><div class=\"controls\"><label class=\"radio\" for=\"item_name_1\"><input id=\"item_name_1\" name=\"item[name]\" type=\"radio\" value=\"1\" />One</label><label class=\"radio\" for=\"item_name_2\"><input id=\"item_name_2\" name=\"item[name]\" type=\"radio\" value=\"2\" />Two</label></div></div>"
73
77
  end
74
78
  end
75
79
 
76
- (%w{email file number password range search text url }.map{|field| ["#{field}_field",field]} + [["telephone_field", "tel"], ["phone_field", "tel"]]).each do |field, type|
80
+ (%w{email file number password range search text url }.map{|field| ["#{field}_field",field]} + [['telephone_field', 'tel'], ['phone_field', 'tel']]).each do |field, type|
77
81
  describe "#{field}" do
78
- context "result" do
82
+ context 'result' do
79
83
  before(:each) do
80
- @result = @builder.send(field, "name")
84
+ @result = @builder.send(field, 'name')
81
85
  end
82
86
 
83
- it "is wrapped" do
87
+ it 'is wrapped' do
84
88
  @result.should match /^<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name<\/label><div class=\"controls\">.*<\/div><\/div>$/
85
89
  end
86
90
 
@@ -89,7 +93,7 @@ shared_examples "a bootstrap form" do
89
93
  end
90
94
  end # result
91
95
 
92
- context "call expectations" do
96
+ context 'call expectations' do
93
97
  %w(control_group_div label_field input_div extras).map(&:to_sym).each do |method|
94
98
  it "calls #{method}" do
95
99
  @builder.should_receive(method).and_return("")
@@ -97,7 +101,7 @@ shared_examples "a bootstrap form" do
97
101
  end
98
102
 
99
103
  after(:each) do
100
- @builder.send(field, "name")
104
+ @builder.send(field, 'name')
101
105
  end
102
106
  end # call expectations
103
107
 
@@ -105,91 +109,91 @@ shared_examples "a bootstrap form" do
105
109
  end # fields
106
110
  end # no options
107
111
 
108
- describe "extras" do
109
- context "text_field" do
110
- it "adds span for inline help" do
112
+ describe 'extras' do
113
+ context 'text_field' do
114
+ it 'adds span for inline help' do
111
115
  @builder.text_field(:name, :help_inline => '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-inline\">help me!</span></div></div>"
112
116
  end
113
117
 
114
- it "adds help block" do
118
+ it 'adds help block' do
115
119
  @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\" /><p class=\"help-block\">help me!</p></div></div>"
116
120
  end
117
121
 
118
- it "adds error message and class" do
122
+ it 'adds error message and class' do
119
123
  @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>"
120
124
  end
121
125
 
122
- it "adds success message and class" do
126
+ it 'adds success message and class' do
123
127
  @builder.text_field(:name, :success => 'This checked out OK').should == "<div class=\"control-group success\"><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 checked out OK</span></div></div>"
124
128
  end
125
129
 
126
- it "adds warning message and class" do
130
+ it 'adds warning message and class' do
127
131
  @builder.text_field(:name, :warning => 'Take a look at this...').should == "<div class=\"control-group warning\"><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\">Take a look at this...</span></div></div>"
128
132
  end
129
133
 
130
- it "prepends passed text" do
134
+ it 'prepends passed text' do
131
135
  @builder.text_field(:name, :prepend => '@').should == "<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><div class=\"input-prepend\"><span class=\"add-on\">@</span><input id=\"item_name\" name=\"item[name]\" size=\"30\" type=\"text\" /></div></div></div>"
132
136
  end
133
137
 
134
- it "appends passed text" do
138
+ it 'appends passed text' do
135
139
  @builder.text_field(:name, :append => '@').should == "<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><div class=\"input-append\"><input id=\"item_name\" name=\"item[name]\" size=\"30\" type=\"text\" /><span class=\"add-on\">@</span></div></div></div>"
136
140
  end
137
141
 
138
- it "prepends and appends passed text" do
142
+ it 'prepends and appends passed text' do
139
143
  @builder.text_field(:name, :append => '@', :prepend => '#').should == "<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name</label><div class=\"controls\"><div class=\"input-prepend input-append\"><span class=\"add-on\">\#</span><input id=\"item_name\" name=\"item[name]\" size=\"30\" type=\"text\" /><span class=\"add-on\">@</span></div></div></div>"
140
144
  end
141
145
  end
142
146
 
143
- context "label option" do
147
+ context 'label option' do
144
148
  %w(select email_field file_field number_field password_field search_field text_area text_field url_field).each do |method_name|
145
-
149
+
146
150
  it "should not add a label when ''" do
147
151
  @builder.send(method_name.to_sym, 'name', :label => '').should_not match /<\/label>/
148
152
  end
149
153
 
150
- it "should not add a label when false" do
154
+ it 'should not add a label when false' do
151
155
  @builder.send(method_name.to_sym, 'name', :label => false).should_not match /<\/label>/
152
156
  end
153
157
  end
154
158
  end
155
159
  end # extras
156
160
 
157
- describe "form actions" do
158
- context "actions" do
159
- it "adds additional block content" do
161
+ describe 'form actions' do
162
+ context 'actions' do
163
+ it 'adds additional block content' do
160
164
  @builder.actions do
161
165
  @builder.submit
162
166
  end.should match(/<div class=\"form-actions\">.*?<\/div>/)
163
167
  end
164
168
  end
165
169
 
166
- context "submit" do
167
- it "adds btn primary class if no class is defined" do
170
+ context 'submit' do
171
+ it 'adds btn primary class if no class is defined' do
168
172
  @builder.submit.should match /class=\"btn btn-primary\"/
169
173
  end
170
174
 
171
- it "allows for custom classes" do
175
+ it 'allows for custom classes' do
172
176
  @builder.submit(:class => 'btn btn-large btn-success').should match /class=\"btn btn-large btn-success\"/
173
177
  end
174
178
  end
175
179
 
176
- context "button" do
177
- it "adds btn primary class if no class is defined" do
180
+ context 'button' do
181
+ it 'adds btn primary class if no class is defined' do
178
182
  @builder.button.should match /class=\"btn btn-primary\"/
179
183
  end
180
184
 
181
- it "allows for custom classes" do
185
+ it 'allows for custom classes' do
182
186
  @builder.button(:class => 'btn btn-large btn-success').should match /class=\"btn btn-large btn-success\"/
183
187
  end
184
188
  end
185
189
 
186
- context "cancel" do
187
- it "creates a link with cancel btn class if no class is defined" do
190
+ context 'cancel' do
191
+ it 'creates a link with cancel btn class if no class is defined' do
188
192
  @builder.should_receive(:link_to).with(I18n.t('bootstrap_forms.buttons.cancel'), :back, :class => 'btn cancel').and_return("")
189
193
  @builder.cancel
190
194
  end
191
195
 
192
- it "creates a link with custom classes when defined" do
196
+ it 'creates a link with custom classes when defined' do
193
197
  @builder.should_receive(:link_to).with(I18n.t('bootstrap_forms.buttons.cancel'), :back, :class => 'btn btn-large my-cancel').and_return("")
194
198
  @builder.cancel(:class => 'btn btn-large my-cancel')
195
199
  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: 2.0.4
4
+ version: 2.0.5
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: 2012-11-07 00:00:00.000000000 Z
12
+ date: 2012-11-15 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.10.1
21
+ version: 2.12.0
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.10.1
29
+ version: 2.12.0
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: 1.1.0
37
+ version: 2.0.0
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: 1.1.0
45
+ version: 2.0.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rake
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -195,7 +195,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  segments:
197
197
  - 0
198
- hash: -722096709655512624
198
+ hash: -4298855100164431662
199
199
  required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  none: false
201
201
  requirements:
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  version: '0'
205
205
  segments:
206
206
  - 0
207
- hash: -722096709655512624
207
+ hash: -4298855100164431662
208
208
  requirements: []
209
209
  rubyforge_project:
210
210
  rubygems_version: 1.8.24