bootstrap-shoehorn 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/README.md +336 -0
- data/Rakefile +32 -0
- data/lib/shoehorn.rb +15 -0
- data/lib/shoehorn/components.rb +17 -0
- data/lib/shoehorn/components/alert.rb +69 -0
- data/lib/shoehorn/components/badge.rb +38 -0
- data/lib/shoehorn/components/base.rb +18 -0
- data/lib/shoehorn/components/button.rb +72 -0
- data/lib/shoehorn/components/dropdown.rb +55 -0
- data/lib/shoehorn/components/form.rb +14 -0
- data/lib/shoehorn/components/form/input_field.rb +53 -0
- data/lib/shoehorn/components/form/label.rb +8 -0
- data/lib/shoehorn/components/form_builder.rb +13 -0
- data/lib/shoehorn/components/icon.rb +40 -0
- data/lib/shoehorn/components/label.rb +39 -0
- data/lib/shoehorn/components/modal.rb +62 -0
- data/lib/shoehorn/components/navigation.rb +47 -0
- data/lib/shoehorn/components/progress_bar.rb +51 -0
- data/lib/shoehorn/engine.rb +19 -0
- data/lib/shoehorn/helper_collection.rb +58 -0
- data/lib/shoehorn/helper_collection_set.rb +18 -0
- data/lib/shoehorn/helpers.rb +14 -0
- data/lib/shoehorn/helpers/alert_helpers.rb +37 -0
- data/lib/shoehorn/helpers/badge_helpers.rb +38 -0
- data/lib/shoehorn/helpers/button_helpers.rb +122 -0
- data/lib/shoehorn/helpers/form_helpers.rb +11 -0
- data/lib/shoehorn/helpers/icon_helpers.rb +34 -0
- data/lib/shoehorn/helpers/label_helpers.rb +37 -0
- data/lib/shoehorn/helpers/modal_helpers.rb +43 -0
- data/lib/shoehorn/helpers/navigation_helpers.rb +32 -0
- data/lib/shoehorn/helpers/progress_bar_helpers.rb +25 -0
- data/lib/shoehorn/plugins.rb +6 -0
- data/lib/shoehorn/plugins/simple_navigation/renderer/bootstrap_topbar_list.rb +72 -0
- data/lib/shoehorn/version.rb +3 -0
- data/log/development.log +0 -0
- data/shoehorn.gemspec +33 -0
- data/spec/helpers/alert_helpers_spec.rb +138 -0
- data/spec/helpers/button_helpers_spec.rb +102 -0
- data/spec/helpers/form_helpers_spec.rb +136 -0
- data/spec/helpers/inline_label_helpers_spec.rb +50 -0
- data/spec/helpers/modal_helpers_spec.rb +60 -0
- data/spec/helpers/navigation_helpers_spec.rb +61 -0
- data/spec/helpers/progress_bar_helpers_spec.rb +34 -0
- data/spec/integration/action_view_spec.rb +23 -0
- data/spec/integration/readme_spec.rb +14 -0
- data/spec/plugins/bootstrap_topbar_list_spec.rb +11 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/bootstrap_button_macros.rb +8 -0
- data/spec/support/bootstrap_form_macros.rb +8 -0
- data/spec/support/bootstrap_modal_macros.rb +8 -0
- data/spec/support/bootstrap_navigation_macros.rb +8 -0
- data/spec/support/bootstrap_spec_helper.rb +50 -0
- data/spec/support/test_environment.rb +23 -0
- metadata +265 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Twitter::Bootstrap::Markup::Rails::Helpers::FormHelpers do
|
5
|
+
include BootstrapSpecHelper
|
6
|
+
include BootstrapFormMacros
|
7
|
+
|
8
|
+
describe "#bootstrap_form_for" do
|
9
|
+
it "should create a form tag" do
|
10
|
+
block = Proc.new {}
|
11
|
+
concat bootstrap_form_for 'an_object', :url => 'a_url', &block
|
12
|
+
output_buffer.should have_tag('form')
|
13
|
+
end
|
14
|
+
|
15
|
+
context "text_field" do
|
16
|
+
it "should wrap a text input within the magical div tags" do
|
17
|
+
build_bootstrap_form do |f|
|
18
|
+
f.text_field 'method'
|
19
|
+
end
|
20
|
+
|
21
|
+
output_buffer.should have_tag('div.control-group div.controls input[type=text]')
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should add a label tag if :label is true" do
|
25
|
+
build_bootstrap_form do |f|
|
26
|
+
f.text_field 'method', :label => true
|
27
|
+
end
|
28
|
+
|
29
|
+
output_buffer.should have_tag('div.control-group') do |div|
|
30
|
+
div.should have_tag('label.control-label')
|
31
|
+
div.should have_tag('div.controls') do |div|
|
32
|
+
div.should have_tag('input')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should add a label tag with custom text if :label_text is specified" do
|
38
|
+
build_bootstrap_form do |f|
|
39
|
+
f.text_field 'method', :label_text => 'a custom label'
|
40
|
+
end
|
41
|
+
|
42
|
+
output_buffer.should have_tag('div.control-group') do |div|
|
43
|
+
div.should have_tag('label.control-label', :text => 'a custom label')
|
44
|
+
div.should have_tag('div.controls') do |div|
|
45
|
+
div.should have_tag('input')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "add_on" do
|
51
|
+
it "should wrap the input in div.input-prepend if :add_on hash is specified" do
|
52
|
+
build_bootstrap_form do |f|
|
53
|
+
f.text_field 'method', :add_on => {}
|
54
|
+
end
|
55
|
+
|
56
|
+
output_buffer.should have_tag('div.control-group') do |div|
|
57
|
+
div.should have_tag('div.controls') do |div|
|
58
|
+
div.should have_tag('div.input-prepend') do |div|
|
59
|
+
div.should have_tag('input')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should wrap the input in div.input-append if :position is :append" do
|
66
|
+
build_bootstrap_form do |f|
|
67
|
+
f.text_field 'method', :add_on => {:position => :append}
|
68
|
+
end
|
69
|
+
|
70
|
+
output_buffer.should have_tag('div.control-group') do |div|
|
71
|
+
div.should have_tag('div.controls') do |div|
|
72
|
+
div.should have_tag('div.input-append') do |div|
|
73
|
+
div.should have_tag('input')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should add a span with text if :text is specified" do
|
80
|
+
build_bootstrap_form do |f|
|
81
|
+
f.text_field 'method', :add_on => {:text => 'a text'}
|
82
|
+
end
|
83
|
+
|
84
|
+
output_buffer.should have_tag('div.control-group') do |div|
|
85
|
+
div.should have_tag('div.controls') do |div|
|
86
|
+
div.should have_tag('div.input-prepend') do |div|
|
87
|
+
div.should have_tag('input')
|
88
|
+
div.should have_tag('span', :class => 'add-on', :text => 'a text')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should add a span with icon if :icon is specified" do
|
95
|
+
build_bootstrap_form do |f|
|
96
|
+
f.text_field 'method', :add_on => {:icon => 'icon-envelope'}
|
97
|
+
end
|
98
|
+
|
99
|
+
output_buffer.should have_tag('div.control-group') do |div|
|
100
|
+
div.should have_tag('div.controls') do |div|
|
101
|
+
div.should have_tag('div.input-prepend') do |div|
|
102
|
+
div.should have_tag('input')
|
103
|
+
div.should have_tag('span', :class => 'add-on') do |span|
|
104
|
+
span.should have_tag('i', :class => 'icon-envelope')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should add a help-block with custom text if :html_text is specified" do
|
112
|
+
build_bootstrap_form do |f|
|
113
|
+
f.text_field 'method', :help_text => 'You need help!'
|
114
|
+
end
|
115
|
+
|
116
|
+
output_buffer.should have_tag('div.control-group') do |div|
|
117
|
+
div.should have_tag('div.controls') do |div|
|
118
|
+
div.should have_tag('p', :class => 'help-block', :text => 'You need help!')
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "password_field" do
|
127
|
+
it "should wrap a text input within the magical div tags" do
|
128
|
+
build_bootstrap_form do |f|
|
129
|
+
f.password_field 'method'
|
130
|
+
end
|
131
|
+
|
132
|
+
output_buffer.should have_tag('div.control-group div.controls input[type=password]')
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Twitter::Bootstrap::Markup::Rails::Helpers::InlineLabelHelpers do
|
4
|
+
include BootstrapSpecHelper
|
5
|
+
|
6
|
+
describe "#inline_label_tag" do
|
7
|
+
before do
|
8
|
+
@output_buffer = ''
|
9
|
+
end
|
10
|
+
|
11
|
+
it "has label class" do
|
12
|
+
concat bootstrap_inline_label_tag("Hi There")
|
13
|
+
output_buffer.should have_tag("span.label")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "has a message" do
|
17
|
+
concat bootstrap_inline_label_tag("Hi There")
|
18
|
+
output_buffer.should have_tag("span", "Hi There")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should add html_options to the resulting SPAN tag when specified" do
|
22
|
+
concat bootstrap_inline_label_tag("Testing", :html_options => {:"data-test" => "42"})
|
23
|
+
output_buffer.should have_tag("span[data-test='42']")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
%w(success warning important notice).each do |type|
|
28
|
+
describe "#inline_label_#{type}_tag" do
|
29
|
+
before do
|
30
|
+
@output_buffer = ''
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has label class" do
|
34
|
+
concat send("bootstrap_inline_label_#{type}_tag", "Message")
|
35
|
+
output_buffer.should have_tag("span.label")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has #{type} class" do
|
39
|
+
concat send("bootstrap_inline_label_#{type}_tag", "Message")
|
40
|
+
output_buffer.should have_tag("span.#{type}")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has a message" do
|
44
|
+
concat send("bootstrap_inline_label_#{type}_tag", "Message")
|
45
|
+
output_buffer.should have_tag('span', /Message/)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Twitter::Bootstrap::Markup::Rails::Helpers::ModalHelpers do
|
5
|
+
include BootstrapSpecHelper
|
6
|
+
include BootstrapModalMacros
|
7
|
+
|
8
|
+
describe "#bootstrap_modal" do
|
9
|
+
before do
|
10
|
+
@output_buffer = ''
|
11
|
+
build_bootstrap_modal(:dom_id => "an_id", :fade => true, :header_title => "a title") do |modal|
|
12
|
+
modal.body do |body|
|
13
|
+
body.content_tag :div, "the body"
|
14
|
+
end
|
15
|
+
modal.footer do |footer|
|
16
|
+
footer.content_tag :div, "the footer"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should create a modal popup with header, body and footer" do
|
22
|
+
output_buffer.should have_tag('div.modal') do |div|
|
23
|
+
div.should have_tag('div.modal-header')
|
24
|
+
div.should have_tag('div.modal-body')
|
25
|
+
div.should have_tag('div.modal-footer')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should create a modal popup with the given DOM ID" do
|
30
|
+
output_buffer.should have_tag('div.modal#an_id')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should create a modal popup with the CSS class set if fade was passed" do
|
34
|
+
output_buffer.should have_tag('div.modal.fade#an_id')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should create a modal popup with the given header title" do
|
38
|
+
output_buffer.should have_tag('div.modal#an_id') do |div|
|
39
|
+
div.should have_tag("h3", :text => "a title")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should create a modal popup with the given body content placed" do
|
44
|
+
output_buffer.should have_tag('div.modal#an_id') do |div|
|
45
|
+
div.should have_tag("div.modal-body") do |body|
|
46
|
+
body.should have_tag("div", :text => "the body")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should create a modal popup with the given footer content placed" do
|
52
|
+
output_buffer.should have_tag('div.modal#an_id') do |div|
|
53
|
+
div.should have_tag("div.modal-footer") do |body|
|
54
|
+
body.should have_tag("div", :text => "the footer")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Twitter::Bootstrap::Markup::Rails::Helpers::NavigationHelpers do
|
5
|
+
include BootstrapSpecHelper
|
6
|
+
include BootstrapNavigationMacros
|
7
|
+
|
8
|
+
describe "#bootstrap_navigation" do
|
9
|
+
before do
|
10
|
+
@output_buffer = ''
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should create a basic navigation list of type tabs" do
|
14
|
+
build_bootstrap_navigation do |nav|
|
15
|
+
nav.link_to "Nav1", "/link1", :active_nav => true
|
16
|
+
nav.link_to "Nav2", "/link2"
|
17
|
+
end
|
18
|
+
|
19
|
+
output_buffer.should have_tag('ul.nav.nav-tabs') do |ul|
|
20
|
+
ul.should have_tag('li[@class="active"] a[@href="/link1"]')
|
21
|
+
ul.should have_tag('li a[@href="/link1"]')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should create a basic navigation list of type pills" do
|
26
|
+
build_bootstrap_navigation(:type => "pills") do |nav|
|
27
|
+
nav.link_to "Nav1", "/link1"
|
28
|
+
nav.link_to "Nav2", "/link2", :active_nav => true
|
29
|
+
end
|
30
|
+
|
31
|
+
output_buffer.should have_tag('ul.nav.nav-pills') do |ul|
|
32
|
+
ul.should have_tag('li a[@href="/link1"]')
|
33
|
+
ul.should have_tag('li[class="active"] a[@href="/link2"]')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should create a vertical navigation list of type tabs when called with a list of links" do
|
38
|
+
build_bootstrap_navigation(:type => "tabs", :stacked => true) do |nav|
|
39
|
+
nav.link_to "Nav1", "/link1", :active_nav => true
|
40
|
+
nav.link_to "Nav2", "/link2"
|
41
|
+
end
|
42
|
+
|
43
|
+
output_buffer.should have_tag('ul.nav.nav-tabs.nav-stacked') do |ul|
|
44
|
+
ul.should have_tag('li[@class="active"] a[@href="/link1"]')
|
45
|
+
ul.should have_tag('li a[@href="/link1"]')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should create a vertical navigation list of type pills when called with a list of links" do
|
50
|
+
build_bootstrap_navigation(:type => "pills", :stacked => true) do |nav|
|
51
|
+
nav.link_to "Nav1", "/link1"
|
52
|
+
nav.link_to "Nav2", "/link2", :active_nav => true
|
53
|
+
end
|
54
|
+
|
55
|
+
output_buffer.should have_tag('ul.nav.nav-pills.nav-stacked') do |ul|
|
56
|
+
ul.should have_tag('li a[@href="/link1"]')
|
57
|
+
ul.should have_tag('li[@class="active"] a[@href="/link2"]')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Twitter::Bootstrap::Markup::Rails::Helpers::ProgressBarHelpers do
|
4
|
+
include BootstrapSpecHelper
|
5
|
+
|
6
|
+
before do
|
7
|
+
@output_buffer = ''
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should create a bar with the progress class' do
|
11
|
+
concat bootstrap_progress_bar_tag(40)
|
12
|
+
output_buffer.should have_tag("div.progress div.bar")
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have the correct width' do
|
16
|
+
concat bootstrap_progress_bar_tag(40)
|
17
|
+
output_buffer.should have_tag(:div, :style => 'width: 40%;')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'stores sets the type of the progress bar' do
|
21
|
+
concat bootstrap_progress_bar_tag(40, :type => :striped)
|
22
|
+
output_buffer.should have_tag("div.progress.progress-striped")
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'stores sets the types of the progress bar' do
|
26
|
+
concat bootstrap_progress_bar_tag(40, :type => [:striped, :warning])
|
27
|
+
output_buffer.should have_tag("div.progress.progress-striped.progress-warning")
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'stores sets the active flag of the progress bar' do
|
31
|
+
concat bootstrap_progress_bar_tag(40, :active => true)
|
32
|
+
output_buffer.should have_tag("div.progress.active")
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActionView::Base do
|
4
|
+
before do
|
5
|
+
@view = ActionView::Base
|
6
|
+
end
|
7
|
+
|
8
|
+
it "includes alert helpers" do
|
9
|
+
@view.ancestors.should include(Twitter::Bootstrap::Markup::Rails::Helpers::AlertHelpers)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "includes inline label helpers" do
|
13
|
+
@view.ancestors.should include(Twitter::Bootstrap::Markup::Rails::Helpers::InlineLabelHelpers)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "includes inline form helpers" do
|
17
|
+
@view.ancestors.should include(Twitter::Bootstrap::Markup::Rails::Helpers::FormHelpers)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "includes inline navigation helpers" do
|
21
|
+
@view.ancestors.should include(Twitter::Bootstrap::Markup::Rails::Helpers::NavigationHelpers)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
describe "README.md" do
|
2
|
+
let(:version) {
|
3
|
+
require File.expand_path("../../../lib/shoehorn/version",
|
4
|
+
__FILE__)
|
5
|
+
Twitter::Bootstrap::Markup::Rails::VERSION
|
6
|
+
}
|
7
|
+
|
8
|
+
subject { File.read(File.expand_path("../../../README.md", __FILE__)) }
|
9
|
+
|
10
|
+
it "contains correct version number in gem declaration" do
|
11
|
+
subject.should include("gem 'shoehorn', '#{version}'")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'simple_navigation'
|
3
|
+
require "shoehorn/plugins/simple_navigation/renderer/bootstrap_topbar_list"
|
4
|
+
|
5
|
+
describe SimpleNavigation::Renderer::BootstrapTopbarList do
|
6
|
+
it "registers the renderer" do
|
7
|
+
SimpleNavigation.registered_renderers.should include({
|
8
|
+
:bootstrap_topbar_list => SimpleNavigation::Renderer::BootstrapTopbarList
|
9
|
+
})
|
10
|
+
end
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if RUBY_VERSION =~ /^1\.9/
|
4
|
+
require 'simplecov'
|
5
|
+
ENV["COVERAGE"] && SimpleCov.start
|
6
|
+
end
|
7
|
+
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/shoehorn'))
|
9
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/shoehorn/engine'))
|
10
|
+
|
11
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
|