booties 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.
@@ -10,6 +10,13 @@ class HomeControllerTest < ActionController::TestCase
10
10
  end
11
11
  end
12
12
 
13
+ test 'page renders btn links' do
14
+ get :button
15
+
16
+ assert_select 'a.btn.btn-default', 'Foo'
17
+ assert_select 'a.btn.btn-danger.btn-xs[data-method="delete"]', 'Sign out'
18
+ end
19
+
13
20
  test 'page renders flags' do
14
21
  get :flag
15
22
 
@@ -26,6 +33,15 @@ class HomeControllerTest < ActionController::TestCase
26
33
  assert_select 'span.badge#foo', 'bar'
27
34
  end
28
35
 
36
+ test 'page renders tooltips' do
37
+ get :tooltip
38
+
39
+ assert_select 'span[data-toggle="tooltip"][title="A tooltip"]',
40
+ 'This has a tooltip.'
41
+ assert_select 'span[data-toggle="tooltip"][data-placement="left"][title="Another tooltip"]',
42
+ 'This has another tooltip.'
43
+ end
44
+
29
45
  test 'page renders a modal' do
30
46
  get :modal
31
47
 
@@ -7,84 +7,5 @@ module Booties
7
7
  expected = '<ol class="breadcrumb"></ol>'
8
8
  assert_equal expected, render_breadcrumbs {}
9
9
  end
10
-
11
- test '#flag renders span tag with label classes' do
12
- expected = '<span class="label label-default">content</span>'
13
- assert_equal expected, flag('content')
14
- end
15
-
16
- test '#flag accepts a custom context' do
17
- expected = '<span class="label label-primary">content</span>'
18
- assert_equal expected, flag('content', context: :primary)
19
- end
20
-
21
- test '#flag passes miscellaneous options through to #content_tag' do
22
- expected = '<span class="label label-default" id="foo">content</span>'
23
- assert_equal expected, flag('content', id: 'foo')
24
- end
25
-
26
- test '#flag accepts content as a block' do
27
- expected = '<span class="label label-default">content</span>'
28
- assert_equal expected, flag { 'content' }
29
- end
30
-
31
- test '#flag merges optional classes with label classes' do
32
- expected = '<span class="label label-default foo">content</span>'
33
- assert_equal expected, flag('content', class: 'foo')
34
- end
35
-
36
- test '#badge renders span tag with badge class' do
37
- expected = '<span class="badge">content</span>'
38
- assert_equal expected, badge('content')
39
- end
40
-
41
- test '#badge passes miscellaneous options through to #content_tag' do
42
- expected = '<span class="badge" id="foo">content</span>'
43
- assert_equal expected, badge('content', id: 'foo')
44
- end
45
-
46
- test '#badge merges optional classes with badge class' do
47
- expected = '<span class="badge foo">content</span>'
48
- assert_equal expected, badge('content', class: 'foo')
49
- end
50
-
51
- test '#modal instantiates a new Modal and calls render' do
52
- modal_class = Minitest::Mock.new
53
- modal_instance = Minitest::Mock.new
54
-
55
- modal_class.expect :new, modal_instance, [self, id: 'foo', fade: true]
56
- modal_instance.expect :render, true
57
-
58
- modal 'foo', with: modal_class
59
-
60
- modal_class.verify
61
- modal_instance.verify
62
- end
63
-
64
- test '#panel instantiates a new Panel and calls render' do
65
- panel_class = Minitest::Mock.new
66
- panel_instance = Minitest::Mock.new
67
-
68
- panel_class.expect :new, panel_instance, [self, {}]
69
- panel_instance.expect :render, true
70
-
71
- panel with: panel_class
72
-
73
- panel_class.verify
74
- panel_instance.verify
75
- end
76
-
77
- test '#panel instantiates a new Panel with the given context' do
78
- panel_class = Minitest::Mock.new
79
- panel_instance = Minitest::Mock.new
80
-
81
- panel_class.expect :new, panel_instance, [self, { context: :primary }]
82
- panel_instance.expect :render, true
83
-
84
- panel context: :primary, with: panel_class
85
-
86
- panel_class.verify
87
- panel_instance.verify
88
- end
89
10
  end
90
11
  end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ module Booties
4
+ class BadgeHelperTest < ActionView::TestCase
5
+ test '#badge renders span tag with badge class' do
6
+ expected = '<span class="badge">content</span>'
7
+ assert_equal expected, badge('content')
8
+ end
9
+
10
+ test '#badge passes miscellaneous options through to #content_tag' do
11
+ expected = '<span class="badge" id="foo">content</span>'
12
+ assert_equal expected, badge('content', id: 'foo')
13
+ end
14
+
15
+ test '#badge merges optional classes with badge class' do
16
+ expected = '<span class="badge foo">content</span>'
17
+ assert_equal expected, badge('content', class: 'foo')
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ require 'test_helper'
2
+
3
+ module Booties
4
+ class ButtonHelperTest < ActionView::TestCase
5
+ test '#btn_link_to renders link with btn classes' do
6
+ expected = link_to 'Foo', '/foo', class: 'btn btn-default'
7
+ assert_equal expected, btn_link_to('Foo', '/foo')
8
+ end
9
+
10
+ test '#btn_link_to context can be overridden' do
11
+ expected = link_to 'Foo', '/foo', class: 'btn btn-primary'
12
+ assert_equal expected, btn_link_to('Foo', '/foo', context: :primary)
13
+ end
14
+
15
+ test '#btn_link_to passes extra as html options to #link_to' do
16
+ expected = link_to 'Foo', '/foo', class: 'btn btn-default btn-xs', method: :delete
17
+ assert_equal expected, btn_link_to('Foo', '/foo', class: 'btn-xs', method: :delete)
18
+ end
19
+
20
+ test '#btn_link_to with a block' do
21
+ expected = link_to 'Foo', '/foo', class: 'btn btn-default btn-xs'
22
+ assert_equal expected, btn_link_to('/foo', class: 'btn-xs') { 'Foo' }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+ module Booties
4
+ class FlagHelperTest < ActionView::TestCase
5
+ test '#flag renders span tag with label classes' do
6
+ expected = '<span class="label label-default">content</span>'
7
+ assert_equal expected, flag('content')
8
+ end
9
+
10
+ test '#flag accepts a custom context' do
11
+ expected = '<span class="label label-primary">content</span>'
12
+ assert_equal expected, flag('content', context: :primary)
13
+ end
14
+
15
+ test '#flag passes miscellaneous options through to #content_tag' do
16
+ expected = '<span class="label label-default" id="foo">content</span>'
17
+ assert_equal expected, flag('content', id: 'foo')
18
+ end
19
+
20
+ test '#flag accepts content as a block' do
21
+ expected = '<span class="label label-default">content</span>'
22
+ assert_equal expected, flag { 'content' }
23
+ end
24
+
25
+ test '#flag merges optional classes with label classes' do
26
+ expected = '<span class="label label-default foo">content</span>'
27
+ assert_equal expected, flag('content', class: 'foo')
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+ require 'minitest/mock'
3
+
4
+ module Booties
5
+ class ModalHelperTest < ActionView::TestCase
6
+ test '#modal instantiates a new Modal and calls render' do
7
+ modal_class = Minitest::Mock.new
8
+ modal_instance = Minitest::Mock.new
9
+
10
+ modal_class.expect :new, modal_instance, [self, id: 'foo', fade: true]
11
+ modal_instance.expect :render, true
12
+
13
+ modal 'foo', with: modal_class
14
+
15
+ modal_class.verify
16
+ modal_instance.verify
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+ require 'minitest/mock'
3
+
4
+ module Booties
5
+ class PanelHelperTest < ActionView::TestCase
6
+ test '#panel instantiates a new Panel and calls render' do
7
+ panel_class = Minitest::Mock.new
8
+ panel_instance = Minitest::Mock.new
9
+
10
+ panel_class.expect :new, panel_instance, [self, {}]
11
+ panel_instance.expect :render, true
12
+
13
+ panel with: panel_class
14
+
15
+ panel_class.verify
16
+ panel_instance.verify
17
+ end
18
+
19
+ test '#panel instantiates a new Panel with the given context' do
20
+ panel_class = Minitest::Mock.new
21
+ panel_instance = Minitest::Mock.new
22
+
23
+ panel_class.expect :new, panel_instance, [self, { context: :primary }]
24
+ panel_instance.expect :render, true
25
+
26
+ panel context: :primary, with: panel_class
27
+
28
+ panel_class.verify
29
+ panel_instance.verify
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,48 @@
1
+ require 'test_helper'
2
+
3
+ module Booties
4
+ class TooltipHelperTest < ActionView::TestCase
5
+ test '#tooltip renders span tag with given title' do
6
+ expected = content_tag :span, 'baz',
7
+ data: { toggle: 'tooltip' }, title: 'foo bar'
8
+
9
+ assert_equal expected, tooltip(title: 'foo bar') { 'baz' }
10
+ end
11
+
12
+ test '#tooltip with bottom placement' do
13
+ expected = content_tag :span, 'baz',
14
+ data: { toggle: 'tooltip', placement: 'bottom' }, title: 'foo bar'
15
+
16
+ assert_equal expected, tooltip(title: 'foo bar', placement: :bottom) { 'baz' }
17
+ end
18
+
19
+ test '#tooltip with right placement' do
20
+ expected = content_tag :span, 'baz',
21
+ data: { toggle: 'tooltip', placement: 'right' }, title: 'foo bar'
22
+
23
+ assert_equal expected, tooltip(title: 'foo bar', placement: :right) { 'baz' }
24
+ end
25
+
26
+ test '#tooltip with left placement' do
27
+ expected = content_tag :span, 'baz',
28
+ data: { toggle: 'tooltip', placement: 'left' }, title: 'foo bar'
29
+
30
+ assert_equal expected, tooltip(title: 'foo bar', placement: :left) { 'baz' }
31
+ end
32
+
33
+ test '#tooltip with unrecognized placement' do
34
+ e = assert_raises ArgumentError do
35
+ tooltip(title: 'foo bar', placement: :bogus) {}
36
+ end
37
+ assert_equal 'invalid placement: :bogus, valid placements are: :top, :bottom, :right, :left',
38
+ e.message
39
+ end
40
+
41
+ test '#tooltip accepts additional html attributes' do
42
+ expected = content_tag :span, 'baz',
43
+ data: { toggle: 'tooltip' }, title: 'foo', class: 'bar'
44
+
45
+ assert_equal expected, tooltip(title: 'foo', class: 'bar') { 'baz' }
46
+ end
47
+ end
48
+ end
@@ -9,7 +9,7 @@ class StubView
9
9
 
10
10
  def content_tag(tag, content, options = nil, &block)
11
11
  options, content = content, capture(&block) if options.nil?
12
- "<#{tag} #{attributes options}>#{content}</#{tag}>"
12
+ "<#{[tag, *attributes(options)].join ' '}>#{content}</#{tag}>"
13
13
  end
14
14
 
15
15
  def raw(content)
@@ -25,12 +25,12 @@ class StubView
25
25
 
26
26
  def attributes(prefix = nil, **attrs)
27
27
  prefix = "#{prefix}-" if prefix
28
- attrs.map { |key, value|
28
+ attrs.reject { |_, value| value.nil? }.flat_map do |key, value|
29
29
  if Hash === value
30
30
  attributes key, value
31
31
  else
32
- "#{prefix}#{key}=\"#{Array(value).compact.join(' ')}\""
32
+ %Q{#{prefix}#{key}="#{Array(value).compact.join(' ')}"}
33
33
  end
34
- }.join ' '
34
+ end
35
35
  end
36
36
  end
@@ -9,7 +9,7 @@ require 'pry'
9
9
  require 'minitest/focus'
10
10
  require 'minitest/reporters'
11
11
 
12
- Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new
12
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
13
13
 
14
14
  # Filter out Minitest backtrace while allowing backtrace from other libraries
15
15
  # to be shown.
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Parker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-15 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.3
19
+ version: '4.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.3
26
+ version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: appraisal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: minitest
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -93,17 +107,24 @@ files:
93
107
  - app/assets/stylesheets/booties/application.css
94
108
  - app/controllers/booties/application_controller.rb
95
109
  - app/helpers/booties/application_helper.rb
110
+ - app/helpers/booties/badge_helper.rb
111
+ - app/helpers/booties/button_helper.rb
112
+ - app/helpers/booties/flag_helper.rb
113
+ - app/helpers/booties/modal_helper.rb
114
+ - app/helpers/booties/panel_helper.rb
115
+ - app/helpers/booties/tooltip_helper.rb
96
116
  - app/views/layouts/booties/application.html.erb
97
117
  - config/routes.rb
98
118
  - lib/booties.rb
99
119
  - lib/booties/engine.rb
100
120
  - lib/booties/modal.rb
101
121
  - lib/booties/panel.rb
122
+ - lib/booties/utils.rb
102
123
  - lib/booties/version.rb
103
- - lib/booties_test.rb
104
124
  - lib/tasks/booties_tasks.rake
105
125
  - test/booties/modal_test.rb
106
126
  - test/booties/panel_test.rb
127
+ - test/booties/utils_test.rb
107
128
  - test/dummy/README.rdoc
108
129
  - test/dummy/Rakefile
109
130
  - test/dummy/app/assets/javascripts/application.js
@@ -116,9 +137,11 @@ files:
116
137
  - test/dummy/app/helpers/home_helper.rb
117
138
  - test/dummy/app/views/home/badge.html.erb
118
139
  - test/dummy/app/views/home/breadcrumbs.html.erb
140
+ - test/dummy/app/views/home/button.html.erb
119
141
  - test/dummy/app/views/home/flag.html.erb
120
142
  - test/dummy/app/views/home/modal.html.erb
121
143
  - test/dummy/app/views/home/panel.html.erb
144
+ - test/dummy/app/views/home/tooltip.html.erb
122
145
  - test/dummy/app/views/layouts/application.html.erb
123
146
  - test/dummy/bin/bundle
124
147
  - test/dummy/bin/rails
@@ -151,6 +174,12 @@ files:
151
174
  - test/dummy/public/favicon.ico
152
175
  - test/dummy/test/controllers/home_controller_test.rb
153
176
  - test/helpers/booties/application_helper_test.rb
177
+ - test/helpers/booties/badge_helper_test.rb
178
+ - test/helpers/booties/button_helper_test.rb
179
+ - test/helpers/booties/flag_helper_test.rb
180
+ - test/helpers/booties/modal_helper_test.rb
181
+ - test/helpers/booties/panel_helper_test.rb
182
+ - test/helpers/booties/tooltip_helper_test.rb
154
183
  - test/integration/navigation_test.rb
155
184
  - test/stub_view.rb
156
185
  - test/test_helper.rb
@@ -181,6 +210,7 @@ summary: Rails view helpers for Twitter Bootstrap.
181
210
  test_files:
182
211
  - test/booties/modal_test.rb
183
212
  - test/booties/panel_test.rb
213
+ - test/booties/utils_test.rb
184
214
  - test/dummy/app/assets/javascripts/application.js
185
215
  - test/dummy/app/assets/javascripts/home.js
186
216
  - test/dummy/app/assets/stylesheets/application.css
@@ -191,9 +221,11 @@ test_files:
191
221
  - test/dummy/app/helpers/home_helper.rb
192
222
  - test/dummy/app/views/home/badge.html.erb
193
223
  - test/dummy/app/views/home/breadcrumbs.html.erb
224
+ - test/dummy/app/views/home/button.html.erb
194
225
  - test/dummy/app/views/home/flag.html.erb
195
226
  - test/dummy/app/views/home/modal.html.erb
196
227
  - test/dummy/app/views/home/panel.html.erb
228
+ - test/dummy/app/views/home/tooltip.html.erb
197
229
  - test/dummy/app/views/layouts/application.html.erb
198
230
  - test/dummy/bin/bundle
199
231
  - test/dummy/bin/rails
@@ -228,6 +260,12 @@ test_files:
228
260
  - test/dummy/README.rdoc
229
261
  - test/dummy/test/controllers/home_controller_test.rb
230
262
  - test/helpers/booties/application_helper_test.rb
263
+ - test/helpers/booties/badge_helper_test.rb
264
+ - test/helpers/booties/button_helper_test.rb
265
+ - test/helpers/booties/flag_helper_test.rb
266
+ - test/helpers/booties/modal_helper_test.rb
267
+ - test/helpers/booties/panel_helper_test.rb
268
+ - test/helpers/booties/tooltip_helper_test.rb
231
269
  - test/integration/navigation_test.rb
232
270
  - test/stub_view.rb
233
271
  - test/test_helper.rb