booties 0.0.3 → 0.1.0
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.
- checksums.yaml +4 -4
- data/app/helpers/booties/application_helper.rb +3 -3
- data/app/helpers/booties/badge_helper.rb +11 -26
- data/app/helpers/booties/flag_helper.rb +9 -32
- data/app/helpers/booties/modal_helper.rb +4 -2
- data/app/helpers/booties/panel_helper.rb +3 -1
- data/app/helpers/booties/popover_helper.rb +63 -0
- data/app/helpers/booties/tooltip_helper.rb +21 -15
- data/lib/booties/modal.rb +33 -20
- data/lib/booties/panel.rb +55 -23
- data/lib/booties/utils.rb +9 -1
- data/lib/booties/version.rb +1 -1
- data/test/booties/modal_test.rb +36 -2
- data/test/booties/panel_test.rb +38 -14
- data/test/booties/utils_test.rb +5 -1
- data/test/dummy/app/controllers/home_controller.rb +3 -0
- data/test/dummy/app/views/home/modal.html.erb +1 -1
- data/test/dummy/app/views/home/panel.html.erb +11 -7
- data/test/dummy/app/views/home/popover.html.erb +7 -0
- data/test/dummy/config/routes.rb +1 -0
- data/test/dummy/log/test.log +8190 -0
- data/test/dummy/test/controllers/home_controller_test.rb +34 -12
- data/test/helpers/booties/badge_helper_test.rb +10 -0
- data/test/helpers/booties/flag_helper_test.rb +2 -2
- data/test/helpers/booties/modal_helper_test.rb +32 -2
- data/test/helpers/booties/popover_helper_test.rb +78 -0
- data/test/helpers/booties/tooltip_helper_test.rb +9 -2
- data/test/stub_view.rb +2 -2
- metadata +8 -3
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class HomeControllerTest < ActionController::TestCase
|
4
|
-
|
4
|
+
def test_page_renders_breadcrumbs
|
5
5
|
get :breadcrumbs
|
6
6
|
|
7
7
|
assert_select 'ol.breadcrumb' do
|
@@ -10,14 +10,14 @@ class HomeControllerTest < ActionController::TestCase
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
def test_page_renders_btn_links
|
14
14
|
get :button
|
15
15
|
|
16
16
|
assert_select 'a.btn.btn-default', 'Foo'
|
17
17
|
assert_select 'a.btn.btn-danger.btn-xs[data-method="delete"]', 'Sign out'
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
def test_page_renders_flags
|
21
21
|
get :flag
|
22
22
|
|
23
23
|
assert_select 'span.label.label-default', 'foo'
|
@@ -25,7 +25,7 @@ class HomeControllerTest < ActionController::TestCase
|
|
25
25
|
assert_select 'span#baz.label.label-danger', 'baz'
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
def test_page_renders_badges
|
29
29
|
get :badge
|
30
30
|
|
31
31
|
assert_select 'span.badge', 'foo'
|
@@ -33,7 +33,7 @@ class HomeControllerTest < ActionController::TestCase
|
|
33
33
|
assert_select 'span.badge#foo', 'bar'
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
def test_page_renders_tooltips
|
37
37
|
get :tooltip
|
38
38
|
|
39
39
|
assert_select 'span[data-toggle="tooltip"][title="A tooltip"]',
|
@@ -42,11 +42,31 @@ class HomeControllerTest < ActionController::TestCase
|
|
42
42
|
'This has another tooltip.'
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
def test_page_renders_popovers
|
46
|
+
get :popover
|
47
|
+
|
48
|
+
assert_select 'button', text: 'Button text' do
|
49
|
+
assert_select '[type="button"]'
|
50
|
+
assert_select '[data-toggle="popover"]'
|
51
|
+
assert_select '[data-content="Lorem ipsum dolor sit amet"]'
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_select 'a', text: 'Link text' do
|
55
|
+
assert_select '[role="button"]'
|
56
|
+
assert_select '[data-container="body"]'
|
57
|
+
assert_select '[data-toggle="popover"]'
|
58
|
+
assert_select '[data-placement="right"]'
|
59
|
+
assert_select '[data-trigger="focus"]'
|
60
|
+
assert_select '[title="This is the title"]'
|
61
|
+
assert_select '[data-content="Lorem ipsum dolor sit amet"]'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_page_renders_a_modal
|
46
66
|
get :modal
|
47
67
|
|
48
68
|
assert_select 'div.modal.fade#confirm' do
|
49
|
-
assert_select 'div.modal-dialog' do
|
69
|
+
assert_select 'div.modal-dialog.modal-lg' do
|
50
70
|
assert_select 'div.modal-content' do
|
51
71
|
assert_select 'div.modal-header' do
|
52
72
|
assert_select 'button[class="close"][data-dismiss="modal"][type="button"]' do
|
@@ -66,20 +86,22 @@ class HomeControllerTest < ActionController::TestCase
|
|
66
86
|
end
|
67
87
|
end
|
68
88
|
|
69
|
-
|
89
|
+
def test_page_renders_a_panel
|
70
90
|
get :panel
|
71
91
|
|
72
92
|
assert_select 'div.panel.panel-default' do
|
73
93
|
assert_select 'div.panel-heading' do
|
74
|
-
assert_select 'h3.panel-title', '
|
94
|
+
assert_select 'h3.panel-title', 'Default panel'
|
75
95
|
end
|
76
96
|
assert_select 'div.panel-body', 'Panel body'
|
77
97
|
assert_select 'div.panel-footer', 'Panel footer'
|
78
98
|
end
|
79
99
|
|
80
|
-
assert_select '
|
81
|
-
assert_select 'div.panel-heading'
|
82
|
-
|
100
|
+
assert_select 'fieldset.panel.panel-info' do
|
101
|
+
assert_select 'div.panel-heading' do
|
102
|
+
assert_select 'h3.panel-title', 'Panel with custom container and context'
|
103
|
+
end
|
104
|
+
assert_select 'table tr td', 'A table instead of a body'
|
83
105
|
assert_select 'div.panel-footer', 'Panel footer'
|
84
106
|
end
|
85
107
|
end
|
@@ -16,5 +16,15 @@ module Booties
|
|
16
16
|
expected = '<span class="badge foo">content</span>'
|
17
17
|
assert_equal expected, badge('content', class: 'foo')
|
18
18
|
end
|
19
|
+
|
20
|
+
test '#badge accepts content as a block' do
|
21
|
+
expected = '<span class="badge" id="foo">Bar</span>'
|
22
|
+
assert_equal expected, badge(id: 'foo') { 'Bar' }
|
23
|
+
end
|
24
|
+
|
25
|
+
test '#badge handles nil content when no block is given' do
|
26
|
+
expected = '<span class="badge"></span>'
|
27
|
+
assert_equal expected, badge(nil)
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
@@ -18,8 +18,8 @@ module Booties
|
|
18
18
|
end
|
19
19
|
|
20
20
|
test '#flag accepts content as a block' do
|
21
|
-
expected = '<span class="label label-default">content</span>'
|
22
|
-
assert_equal expected, flag { 'content' }
|
21
|
+
expected = '<span class="label label-default" id="foo">content</span>'
|
22
|
+
assert_equal expected, flag(id: 'foo') { 'content' }
|
23
23
|
end
|
24
24
|
|
25
25
|
test '#flag merges optional classes with label classes' do
|
@@ -7,13 +7,43 @@ module Booties
|
|
7
7
|
modal_class = Minitest::Mock.new
|
8
8
|
modal_instance = Minitest::Mock.new
|
9
9
|
|
10
|
-
modal_class.expect :new, modal_instance,
|
11
|
-
|
10
|
+
modal_class.expect :new, modal_instance,
|
11
|
+
[self, id: 'foo', fade: true, size: nil]
|
12
|
+
modal_instance.expect :render, true, [{}]
|
12
13
|
|
13
14
|
modal 'foo', with: modal_class
|
14
15
|
|
15
16
|
modal_class.verify
|
16
17
|
modal_instance.verify
|
17
18
|
end
|
19
|
+
|
20
|
+
test '#modal passes keyword arguments on to Modal constructor' do
|
21
|
+
modal_class = Minitest::Mock.new
|
22
|
+
modal_instance = Minitest::Mock.new
|
23
|
+
|
24
|
+
modal_class.expect :new, modal_instance,
|
25
|
+
[self, id: 'foo', fade: false, size: :large]
|
26
|
+
modal_instance.expect :render, true, [{}]
|
27
|
+
|
28
|
+
modal 'foo', fade: false, size: :large, with: modal_class
|
29
|
+
|
30
|
+
modal_class.verify
|
31
|
+
modal_instance.verify
|
32
|
+
end
|
33
|
+
|
34
|
+
test '#modal passes optional arguments on to Modal#render' do
|
35
|
+
modal_class = Minitest::Mock.new
|
36
|
+
modal_instance = Minitest::Mock.new
|
37
|
+
|
38
|
+
modal_class.expect :new, modal_instance,
|
39
|
+
[self, id: 'foo', fade: true, size: nil]
|
40
|
+
modal_instance.expect :render, true,
|
41
|
+
[{ class: 'foo', data: { bar: 'baz' } }]
|
42
|
+
|
43
|
+
modal 'foo', with: modal_class, class: 'foo', data: { bar: 'baz' }
|
44
|
+
|
45
|
+
modal_class.verify
|
46
|
+
modal_instance.verify
|
47
|
+
end
|
18
48
|
end
|
19
49
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
module Booties
|
6
|
+
class PopoverHelperTest < ActionView::TestCase
|
7
|
+
CONTENT = 'Lorem ipsum dolor sin amet'
|
8
|
+
|
9
|
+
def test_popover_with_string
|
10
|
+
expected = content_tag :a, 'Link text',
|
11
|
+
role: 'button',
|
12
|
+
data: { toggle: 'popover', content: CONTENT, }
|
13
|
+
assert_equal expected, popover('Link text', content: CONTENT)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_popover_with_block
|
17
|
+
expected = content_tag :a, 'Link text',
|
18
|
+
role: 'button',
|
19
|
+
data: { toggle: 'popover', content: CONTENT, }
|
20
|
+
assert_equal expected, popover(content: CONTENT) { 'Link text' }
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_popover_requires_content_argument
|
24
|
+
e = assert_raises(ArgumentError) { popover 'Link text' }
|
25
|
+
assert_equal 'missing keyword: content', e.message
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_popover_with_title
|
29
|
+
expected = content_tag :a, 'Link text',
|
30
|
+
role: 'button',
|
31
|
+
data: { toggle: 'popover', content: CONTENT, },
|
32
|
+
title: 'Lorem ipsum'
|
33
|
+
assert_equal expected,
|
34
|
+
popover('Link text', content: CONTENT, title: 'Lorem ipsum')
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_popover_with_placement
|
38
|
+
expected = content_tag :a, 'Link text',
|
39
|
+
role: 'button',
|
40
|
+
data: { toggle: 'popover', content: CONTENT, placement: :top, }
|
41
|
+
assert_equal expected,
|
42
|
+
popover('Link text', content: CONTENT, placement: :top)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_popover_with_invalid_placement
|
46
|
+
e = assert_raises(ArgumentError) {
|
47
|
+
popover content: CONTENT, placement: :bogus
|
48
|
+
}
|
49
|
+
assert_equal 'invalid placement: :bogus, ' \
|
50
|
+
'valid placements are :left, :right, :top, :bottom', e.message
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_popover_with_trigger
|
54
|
+
expected = content_tag :a, 'Link text',
|
55
|
+
role: 'button',
|
56
|
+
data: { toggle: 'popover', content: CONTENT, container: 'body', trigger: 'focus', }
|
57
|
+
assert_equal expected,
|
58
|
+
popover('Link text', content: CONTENT, trigger: :focus)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_popover_with_tag
|
62
|
+
expected = content_tag :button, 'Link text',
|
63
|
+
type: 'button',
|
64
|
+
data: { toggle: 'popover', content: CONTENT, }
|
65
|
+
assert_equal expected,
|
66
|
+
popover('Link text', content: CONTENT, tag: :button)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_popover_passes_other_options_through_to_content_tag
|
70
|
+
expected = content_tag :a, 'Link text',
|
71
|
+
class: 'btn btn-default',
|
72
|
+
data: { foo: 'bar', toggle: 'popover', content: CONTENT, },
|
73
|
+
role: 'button'
|
74
|
+
assert_equal expected,
|
75
|
+
popover('Link text', content: CONTENT, class: 'btn btn-default', data: { foo: 'bar' })
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -34,8 +34,15 @@ module Booties
|
|
34
34
|
e = assert_raises ArgumentError do
|
35
35
|
tooltip(title: 'foo bar', placement: :bogus) {}
|
36
36
|
end
|
37
|
-
assert_equal 'invalid placement: :bogus,
|
38
|
-
e.message
|
37
|
+
assert_equal 'invalid placement: :bogus, ' \
|
38
|
+
'valid placements are :left, :right, :top, :bottom', e.message
|
39
|
+
end
|
40
|
+
|
41
|
+
test '#tooltip renders tooltip using alternative wrapper tag' do
|
42
|
+
expected = content_tag :abbr, 'baz',
|
43
|
+
data: { toggle: 'tooltip' }, title: 'foo'
|
44
|
+
|
45
|
+
assert_equal expected, tooltip(title: 'foo', wrapper_tag: :abbr) { 'baz' }
|
39
46
|
end
|
40
47
|
|
41
48
|
test '#tooltip accepts additional html attributes' do
|
data/test/stub_view.rb
CHANGED
@@ -4,7 +4,7 @@ class StubView
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def capture(*args, &block)
|
7
|
-
block.call
|
7
|
+
block.call(*args)
|
8
8
|
end
|
9
9
|
|
10
10
|
def content_tag(tag, content, options = nil, &block)
|
@@ -17,7 +17,7 @@ class StubView
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def translate(*args)
|
20
|
-
I18n.translate
|
20
|
+
I18n.translate(*args)
|
21
21
|
end
|
22
22
|
alias t translate
|
23
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: booties
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Parker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- app/helpers/booties/flag_helper.rb
|
113
113
|
- app/helpers/booties/modal_helper.rb
|
114
114
|
- app/helpers/booties/panel_helper.rb
|
115
|
+
- app/helpers/booties/popover_helper.rb
|
115
116
|
- app/helpers/booties/tooltip_helper.rb
|
116
117
|
- app/views/layouts/booties/application.html.erb
|
117
118
|
- config/routes.rb
|
@@ -141,6 +142,7 @@ files:
|
|
141
142
|
- test/dummy/app/views/home/flag.html.erb
|
142
143
|
- test/dummy/app/views/home/modal.html.erb
|
143
144
|
- test/dummy/app/views/home/panel.html.erb
|
145
|
+
- test/dummy/app/views/home/popover.html.erb
|
144
146
|
- test/dummy/app/views/home/tooltip.html.erb
|
145
147
|
- test/dummy/app/views/layouts/application.html.erb
|
146
148
|
- test/dummy/bin/bundle
|
@@ -179,6 +181,7 @@ files:
|
|
179
181
|
- test/helpers/booties/flag_helper_test.rb
|
180
182
|
- test/helpers/booties/modal_helper_test.rb
|
181
183
|
- test/helpers/booties/panel_helper_test.rb
|
184
|
+
- test/helpers/booties/popover_helper_test.rb
|
182
185
|
- test/helpers/booties/tooltip_helper_test.rb
|
183
186
|
- test/integration/navigation_test.rb
|
184
187
|
- test/stub_view.rb
|
@@ -203,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
206
|
version: '0'
|
204
207
|
requirements: []
|
205
208
|
rubyforge_project:
|
206
|
-
rubygems_version: 2.4
|
209
|
+
rubygems_version: 2.6.4
|
207
210
|
signing_key:
|
208
211
|
specification_version: 4
|
209
212
|
summary: Rails view helpers for Twitter Bootstrap.
|
@@ -225,6 +228,7 @@ test_files:
|
|
225
228
|
- test/dummy/app/views/home/flag.html.erb
|
226
229
|
- test/dummy/app/views/home/modal.html.erb
|
227
230
|
- test/dummy/app/views/home/panel.html.erb
|
231
|
+
- test/dummy/app/views/home/popover.html.erb
|
228
232
|
- test/dummy/app/views/home/tooltip.html.erb
|
229
233
|
- test/dummy/app/views/layouts/application.html.erb
|
230
234
|
- test/dummy/bin/bundle
|
@@ -265,6 +269,7 @@ test_files:
|
|
265
269
|
- test/helpers/booties/flag_helper_test.rb
|
266
270
|
- test/helpers/booties/modal_helper_test.rb
|
267
271
|
- test/helpers/booties/panel_helper_test.rb
|
272
|
+
- test/helpers/booties/popover_helper_test.rb
|
268
273
|
- test/helpers/booties/tooltip_helper_test.rb
|
269
274
|
- test/integration/navigation_test.rb
|
270
275
|
- test/stub_view.rb
|