Skip to content

Commit

Permalink
release new version
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed Nov 15, 2012
1 parent 76e2be4 commit 47c8fa7
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 98 deletions.
10 changes: 5 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ require 'rspec/core/rake_task'
desc 'Default: run specs.'
task :default => :spec

desc "Run specs"
desc 'Run specs'
RSpec::Core::RakeTask.new do |t|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
# Put spec opts in a file named .rspec in root
end

desc "Generate code coverage"
desc 'Generate code coverage'
RSpec::Core::RakeTask.new(:coverage) do |t|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
t.rcov = true
t.rcov_opts = ['--exclude', 'spec']
end
end
26 changes: 13 additions & 13 deletions bootstrap_forms.gemspec
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# encoding: utf-8
$:.push File.expand_path("../lib", __FILE__)
$:.push File.expand_path('../lib', __FILE__)

Gem::Specification.new do |s|
s.name = "bootstrap_forms"
s.version = "2.0.4"
s.author = "Seth Vargo"
s.email = "[email protected]"
s.homepage = "https://github.com/sethvargo/bootstrap_forms"
s.name = 'bootstrap_forms'
s.version = '2.0.5'
s.author = 'Seth Vargo'
s.email = '[email protected]'
s.homepage = 'https://github.com/sethvargo/bootstrap_forms'
s.summary = %q{Bootstrap Forms makes Twitter's Bootstrap on Rails easy!}
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.}

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.require_paths = ['lib']

s.add_development_dependency "rspec-rails", "~> 2.10.1"
s.add_development_dependency "capybara", "~> 1.1.0"
s.add_development_dependency "rake"
s.add_development_dependency "rails", "~> 3.2.0"
s.add_development_dependency "guard-rspec"
s.add_development_dependency "sqlite3"
s.add_development_dependency 'rspec-rails', '~> 2.12.0'
s.add_development_dependency 'capybara', '~> 2.0.0'
s.add_development_dependency 'rake'
s.add_development_dependency 'rails', '~> 3.2.0'
s.add_development_dependency 'guard-rspec'
s.add_development_dependency 'sqlite3'
end
18 changes: 9 additions & 9 deletions spec/lib/bootstrap_forms/bootstrap_form_for_spec.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
require 'spec_helper'

describe "bootstrap_form_for" do
describe "default_form_builder" do
it "should be accessible" do
describe 'bootstrap_form_for' do
describe 'default_form_builder' do
it 'should be accessible' do
BootstrapForms.should respond_to(:default_form_builder)
end

it "should be the BootstrapForms form_builder by default" do
it 'should be the BootstrapForms form_builder by default' do
BootstrapForms.default_form_builder.should == BootstrapForms::FormBuilder
end

context "when set to something else" do
context 'when set to something else' do
before do
BootstrapForms.default_form_builder = MyCustomFormBuilder
end

it "should be that other thing" do
it 'should be that other thing' do
BootstrapForms.default_form_builder.should == MyCustomFormBuilder
end

describe "projects/new.html.erb", :type => :view do
describe 'projects/new.html.erb', :type => :view do
before do
assign :project, Project.new
render :file => "projects/new.html.erb", :layout => "layouts/application.html.erb"
render :file => 'projects/new.html.erb', :layout => 'layouts/application.html.erb'
end

it "should render with the other form builder" do
it 'should render with the other form builder' do
# in other words, it shouldn't be wrapped with the bootstrap stuff
rendered.should_not match /<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name<\/label><div class=\"controls\">.*<\/div><\/div>/
end
Expand Down
10 changes: 2 additions & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper.rb"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require File.expand_path('../dummy/config/environment.rb', __FILE__)

require 'rspec/rails'
require 'capybara/rspec'
Expand All @@ -22,4 +16,4 @@
config.include RSpec::Rails::ViewExampleGroup, :type => :view
end

Rails.backtrace_cleaner.remove_silencers!
Rails.backtrace_cleaner.remove_silencers!
126 changes: 63 additions & 63 deletions spec/support/shared_context.rb
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
shared_examples "a bootstrap form" do
describe "with no options" do
describe "error_messages" do
it "returns empty string without errors" do
@builder.error_messages.should == ""
shared_examples 'a bootstrap form' do
describe 'with no options' do
describe 'error_messages' do
it 'returns empty string without errors' do
@builder.error_messages.should == ''
end
end

describe "text_area" do
describe 'text_area' do
before(:each) do
@result = @builder.text_area "name"
@result = @builder.text_area 'name'
end

it "has textarea input" do
it 'has textarea input' do
@result.should match /textarea/
end
end

describe "uneditable_input" do
it "generates wrapped input" do
@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>"
describe 'uneditable_input' do
it 'generates wrapped input' do
@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>"
end

it "allows for an id" do
@builder.uneditable_input("name", :id => "myid").should match /<span.*id="myid"/
it 'allows for an id' do
@builder.uneditable_input('name', :id => 'myid').should match /<span.*id="myid"/
end
end

describe "check_box" do
it "generates wrapped input" do
@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>"
describe 'check_box' do
it 'generates wrapped input' do
@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>"
end

it "allows custom label" do
@builder.check_box("name", :label => "custom label").should match /custom label<\/label>/
it 'allows custom label' do
@builder.check_box('name', :label => 'custom label').should match /custom label<\/label>/
end

it "allows no label with :label => false " do
@builder.check_box("name", :label => false).should_not match /<\/label>/
it 'allows no label with :label => false ' do
@builder.check_box('name', :label => false).should_not match /<\/label>/
end
it "allows no label with :label => '' " do
@builder.check_box("name", :label => '').should_not match /<\/label>/
it 'allows no label with :label => '' ' do
@builder.check_box('name', :label => '').should_not match /<\/label>/
end
end

describe "radio_buttons" do
describe 'radio_buttons' do
before do
if RUBY_VERSION < '1.9'
@options = ActiveSupport::OrderedHash.new
Expand All @@ -54,37 +54,37 @@
end
end

it "doesn't use field_options from previously generated field" do
it 'doesn\'t use field_options from previously generated field' do
@builder.text_field :name, :label => 'Heading', :help_inline => 'Inline help', :help_block => 'Block help'
@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>"
end

it "sets field_options" do
@builder.radio_buttons(:name, {"One" => "1", "Two" => "2"})
@builder.instance_variable_get("@field_options").should == {:error => nil}
it 'sets field_options' do
@builder.radio_buttons(:name, {'One' => '1', 'Two' => '2'})
@builder.instance_variable_get('@field_options').should == {:error => nil}
end

it "generates wrapped input" do
it 'generates wrapped input' do
@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>"
end

it "allows custom label" do
@builder.radio_buttons(:name, @options, {:label => "custom label"}).should match /custom label<\/label>/
it 'allows custom label' do
@builder.radio_buttons(:name, @options, {:label => 'custom label'}).should match /custom label<\/label>/
end
it "allows no label" do

it 'allows no label' do
@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>"
end
end

(%w{email file number password range search text url }.map{|field| ["#{field}_field",field]} + [["telephone_field", "tel"], ["phone_field", "tel"]]).each do |field, type|
(%w{email file number password range search text url }.map{|field| ["#{field}_field",field]} + [['telephone_field', 'tel'], ['phone_field', 'tel']]).each do |field, type|
describe "#{field}" do
context "result" do
context 'result' do
before(:each) do
@result = @builder.send(field, "name")
@result = @builder.send(field, 'name')
end

it "is wrapped" do
it 'is wrapped' do
@result.should match /^<div class=\"control-group\"><label class=\"control-label\" for=\"item_name\">Name<\/label><div class=\"controls\">.*<\/div><\/div>$/
end

Expand All @@ -93,107 +93,107 @@
end
end # result

context "call expectations" do
context 'call expectations' do
%w(control_group_div label_field input_div extras).map(&:to_sym).each do |method|
it "calls #{method}" do
@builder.should_receive(method).and_return("")
end
end

after(:each) do
@builder.send(field, "name")
@builder.send(field, 'name')
end
end # call expectations

end # field
end # fields
end # no options

describe "extras" do
context "text_field" do
it "adds span for inline help" do
describe 'extras' do
context 'text_field' do
it 'adds span for inline help' do
@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>"
end

it "adds help block" do
it 'adds help block' do
@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>"
end

it "adds error message and class" do
it 'adds error message and class' do
@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>"
end

it "adds success message and class" do
it 'adds success message and class' do
@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>"
end

it "adds warning message and class" do
it 'adds warning message and class' do
@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>"
end

it "prepends passed text" do
it 'prepends passed text' do
@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>"
end

it "appends passed text" do
it 'appends passed text' do
@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>"
end

it "prepends and appends passed text" do
it 'prepends and appends passed text' do
@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>"
end
end

context "label option" do
context 'label option' do
%w(select email_field file_field number_field password_field search_field text_area text_field url_field).each do |method_name|

it "should not add a label when ''" do
@builder.send(method_name.to_sym, 'name', :label => '').should_not match /<\/label>/
end

it "should not add a label when false" do
it 'should not add a label when false' do
@builder.send(method_name.to_sym, 'name', :label => false).should_not match /<\/label>/
end
end
end
end # extras

describe "form actions" do
context "actions" do
it "adds additional block content" do
describe 'form actions' do
context 'actions' do
it 'adds additional block content' do
@builder.actions do
@builder.submit
end.should match(/<div class=\"form-actions\">.*?<\/div>/)
end
end

context "submit" do
it "adds btn primary class if no class is defined" do
context 'submit' do
it 'adds btn primary class if no class is defined' do
@builder.submit.should match /class=\"btn btn-primary\"/
end

it "allows for custom classes" do
it 'allows for custom classes' do
@builder.submit(:class => 'btn btn-large btn-success').should match /class=\"btn btn-large btn-success\"/
end
end

context "button" do
it "adds btn primary class if no class is defined" do
context 'button' do
it 'adds btn primary class if no class is defined' do
@builder.button.should match /class=\"btn btn-primary\"/
end

it "allows for custom classes" do
it 'allows for custom classes' do
@builder.button(:class => 'btn btn-large btn-success').should match /class=\"btn btn-large btn-success\"/
end
end

context "cancel" do
it "creates a link with cancel btn class if no class is defined" do
context 'cancel' do
it 'creates a link with cancel btn class if no class is defined' do
@builder.should_receive(:link_to).with(I18n.t('bootstrap_forms.buttons.cancel'), :back, :class => 'btn cancel').and_return("")
@builder.cancel
end

it "creates a link with custom classes when defined" do
it 'creates a link with custom classes when defined' do
@builder.should_receive(:link_to).with(I18n.t('bootstrap_forms.buttons.cancel'), :back, :class => 'btn btn-large my-cancel').and_return("")
@builder.cancel(:class => 'btn btn-large my-cancel')
end
Expand Down

0 comments on commit 47c8fa7

Please sign in to comment.