booties 0.1.0 → 0.2.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.
Files changed (123) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +172 -0
  3. data/Rakefile +5 -4
  4. data/app/controllers/booties/application_controller.rb +4 -1
  5. data/app/helpers/booties/application_helper.rb +3 -26
  6. data/app/helpers/booties/badge_helper.rb +6 -3
  7. data/app/helpers/booties/breadcrumb_helper.rb +29 -0
  8. data/app/helpers/booties/button_helper.rb +10 -8
  9. data/app/helpers/booties/dropdown_helper.rb +71 -0
  10. data/app/helpers/booties/flag_helper.rb +7 -4
  11. data/app/helpers/booties/modal_helper.rb +4 -1
  12. data/app/helpers/booties/panel_helper.rb +3 -1
  13. data/app/helpers/booties/popover_helper.rb +28 -19
  14. data/app/helpers/booties/tooltip_helper.rb +12 -8
  15. data/config/routes.rb +2 -0
  16. data/lib/booties.rb +3 -1
  17. data/lib/booties/engine.rb +7 -1
  18. data/lib/booties/modal.rb +13 -12
  19. data/lib/booties/panel.rb +21 -18
  20. data/lib/booties/utils.rb +8 -10
  21. data/lib/booties/version.rb +3 -1
  22. data/lib/tasks/booties_tasks.rake +2 -0
  23. data/test/dummy/Rakefile +1 -1
  24. data/test/dummy/app/assets/javascripts/application.js +0 -13
  25. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  26. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  27. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  28. data/test/dummy/app/controllers/application_controller.rb +0 -4
  29. data/test/dummy/app/controllers/samples_controller.rb +28 -0
  30. data/test/dummy/app/jobs/application_job.rb +2 -0
  31. data/test/dummy/app/views/layouts/application.html.erb +9 -11
  32. data/test/dummy/app/views/samples/badges.html.erb +2 -0
  33. data/test/dummy/app/views/{home → samples}/breadcrumbs.html.erb +2 -1
  34. data/test/dummy/app/views/samples/buttons.html.erb +2 -0
  35. data/test/dummy/app/views/samples/dropdowns.html.erb +6 -0
  36. data/test/dummy/app/views/samples/flags.html.erb +2 -0
  37. data/test/dummy/app/views/samples/modals.html.erb +12 -0
  38. data/test/dummy/app/views/samples/panels.html.erb +14 -0
  39. data/test/dummy/app/views/samples/popovers.html.erb +9 -0
  40. data/test/dummy/app/views/samples/tooltips.html.erb +3 -0
  41. data/test/dummy/bin/bundle +1 -1
  42. data/test/dummy/bin/rails +1 -1
  43. data/test/dummy/bin/setup +17 -13
  44. data/test/dummy/bin/update +28 -0
  45. data/test/dummy/config.ru +2 -1
  46. data/test/dummy/config/application.rb +13 -12
  47. data/test/dummy/config/boot.rb +2 -2
  48. data/test/dummy/config/environment.rb +1 -1
  49. data/test/dummy/config/environments/development.rb +24 -16
  50. data/test/dummy/config/environments/production.rb +23 -28
  51. data/test/dummy/config/environments/test.rb +5 -11
  52. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  53. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  54. data/test/dummy/config/initializers/cookies_serializer.rb +2 -0
  55. data/test/dummy/config/initializers/wrap_parameters.rb +6 -1
  56. data/test/dummy/config/locales/en.yml +10 -0
  57. data/test/dummy/config/puma.rb +34 -0
  58. data/test/dummy/config/routes.rb +16 -8
  59. data/test/dummy/config/spring.rb +6 -0
  60. data/test/dummy/log/test.log +11202 -19551
  61. data/test/dummy/public/404.html +6 -6
  62. data/test/dummy/public/422.html +6 -6
  63. data/test/dummy/public/500.html +6 -6
  64. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  65. data/test/dummy/public/apple-touch-icon.png +0 -0
  66. data/test/dummy/tmp/cache/assets/sprockets/v3.0/33/33EUCQBNqL6TOaGyMFn9wz2v39pHMJ4LOUUFUteIHHM.cache +1 -0
  67. data/test/dummy/tmp/cache/assets/sprockets/v3.0/3N/3NnKgR2TsTI1qCXKZpts0uJzp2dRJcoYp3nnFU6YE4o.cache +2 -0
  68. data/test/dummy/tmp/cache/assets/sprockets/v3.0/7Q/7Q2gtOOyCVPFrfYz4KjmXJsM_m8Yra4MjgsQmfVGxZY.cache +1 -0
  69. data/test/dummy/tmp/cache/assets/sprockets/v3.0/8c/8cROjTzeZZQaOFNLPKGuMtXO7EHxNfiEa72qt65UoF4.cache +1 -0
  70. data/test/dummy/tmp/cache/assets/sprockets/v3.0/F6/F6RhC2MbCvVanNZZe44hqlJNKAdIrH4NUzRxj5N2_EQ.cache +1 -0
  71. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Fc/FcMeZRcfG4LrhIhl3xrAg3EhSZInU4efHmUrjIs4keE.cache +0 -0
  72. data/test/dummy/tmp/cache/assets/sprockets/v3.0/H3/H3dfPRbxbWIB6dQXrQ6xA9nDJqy4dOq1ujslocGVY9U.cache +1 -0
  73. data/test/dummy/tmp/cache/assets/sprockets/v3.0/LK/LKisVDbQmzgRQKdFoNH5tRbTr72CrlM_2q7MZczv2Pg.cache +1 -0
  74. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Mj/MjwYGG9GkHD1fwwH2bg66EBYl3zCA_mqeDF9otey4-U.cache +3 -0
  75. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Pc/Pce9HMZhc6XmsNfLUN84Enw7mySJ7ZYzys9mXmCVXqA.cache +0 -0
  76. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Po/PoftKmjB8lzW06EMKeru1CsqVtULc0MsiTysT2JNqvU.cache +0 -0
  77. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Su/SuILTE3Es0N_r-36Ddu2E6h49WcwH_-RsZyG4SPwKFQ.cache +0 -0
  78. data/test/dummy/tmp/cache/assets/sprockets/v3.0/cJ/cJG59MHf0x4qJKYES0pa0nLpOFpFF7YwrrvIVKIixyA.cache +0 -0
  79. data/test/dummy/tmp/cache/assets/sprockets/v3.0/fw/fwPYklzExHPpgeuv53ew_8OIpJVRyaHj2Jtj2JP9j5A.cache +0 -0
  80. data/test/dummy/tmp/cache/assets/sprockets/v3.0/jc/jc_TR7ZZTSFDDRKdgc-KnZskUESr2rLOqcYZej83LvU.cache +0 -0
  81. data/test/dummy/tmp/cache/assets/sprockets/v3.0/rV/rVy4-idUuK0Va9FLw3G8pYeZFwJAwmvs_bQcbq6_Cd0.cache +1 -0
  82. data/test/dummy/tmp/cache/assets/sprockets/v3.0/rY/rYyeRvy3oIuNfWeDhoriNlAlVjN4Wg4A3_9_OTDFin4.cache +1 -0
  83. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tY/tYFbDrMNElXwgmisit50aNXJvRU2zlIFk5g-EJ1CQTc.cache +0 -0
  84. data/test/helpers/booties/badge_helper_test.rb +7 -5
  85. data/test/helpers/booties/breadcrumb_helper_test.rb +13 -0
  86. data/test/helpers/booties/button_helper_test.rb +14 -12
  87. data/test/helpers/booties/dropdown_helper_test.rb +43 -0
  88. data/test/helpers/booties/flag_helper_test.rb +7 -5
  89. data/test/helpers/booties/modal_helper_test.rb +9 -7
  90. data/test/helpers/booties/panel_helper_test.rb +4 -2
  91. data/test/helpers/booties/popover_helper_test.rb +33 -42
  92. data/test/helpers/booties/tooltip_helper_test.rb +19 -40
  93. data/test/integration/samples_test.rb +103 -0
  94. data/test/lib/booties/modal_test.rb +193 -0
  95. data/test/{booties → lib/booties}/panel_test.rb +40 -22
  96. data/test/lib/booties/utils_test.rb +41 -0
  97. data/test/stub_view.rb +14 -7
  98. data/test/test_helper.rb +10 -11
  99. metadata +124 -98
  100. data/app/assets/javascripts/booties/application.js +0 -13
  101. data/app/assets/stylesheets/booties/application.css +0 -15
  102. data/test/booties/modal_test.rb +0 -170
  103. data/test/booties/utils_test.rb +0 -26
  104. data/test/dummy/README.rdoc +0 -28
  105. data/test/dummy/app/assets/javascripts/home.js +0 -2
  106. data/test/dummy/app/assets/stylesheets/home.css +0 -4
  107. data/test/dummy/app/controllers/home_controller.rb +0 -25
  108. data/test/dummy/app/helpers/home_helper.rb +0 -2
  109. data/test/dummy/app/views/home/badge.html.erb +0 -3
  110. data/test/dummy/app/views/home/button.html.erb +0 -2
  111. data/test/dummy/app/views/home/flag.html.erb +0 -5
  112. data/test/dummy/app/views/home/modal.html.erb +0 -16
  113. data/test/dummy/app/views/home/panel.html.erb +0 -25
  114. data/test/dummy/app/views/home/popover.html.erb +0 -7
  115. data/test/dummy/app/views/home/tooltip.html.erb +0 -7
  116. data/test/dummy/config/initializers/assets.rb +0 -11
  117. data/test/dummy/config/initializers/session_store.rb +0 -3
  118. data/test/dummy/config/locales/booties.yml +0 -4
  119. data/test/dummy/config/secrets.yml +0 -22
  120. data/test/dummy/log/development.log +0 -420
  121. data/test/dummy/test/controllers/home_controller_test.rb +0 -108
  122. data/test/helpers/booties/application_helper_test.rb +0 -11
  123. data/test/integration/navigation_test.rb +0 -9
@@ -4,7 +4,7 @@
4
4
  <title>The page you were looking for doesn't exist (404)</title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <style>
7
- body {
7
+ .rails-default-error-page {
8
8
  background-color: #EFEFEF;
9
9
  color: #2E2F30;
10
10
  text-align: center;
@@ -12,13 +12,13 @@
12
12
  margin: 0;
13
13
  }
14
14
 
15
- div.dialog {
15
+ .rails-default-error-page div.dialog {
16
16
  width: 95%;
17
17
  max-width: 33em;
18
18
  margin: 4em auto 0;
19
19
  }
20
20
 
21
- div.dialog > div {
21
+ .rails-default-error-page div.dialog > div {
22
22
  border: 1px solid #CCC;
23
23
  border-right-color: #999;
24
24
  border-left-color: #999;
@@ -31,13 +31,13 @@
31
31
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
32
  }
33
33
 
34
- h1 {
34
+ .rails-default-error-page h1 {
35
35
  font-size: 100%;
36
36
  color: #730E15;
37
37
  line-height: 1.5em;
38
38
  }
39
39
 
40
- div.dialog > p {
40
+ .rails-default-error-page div.dialog > p {
41
41
  margin: 0 0 1em;
42
42
  padding: 1em;
43
43
  background-color: #F7F7F7;
@@ -54,7 +54,7 @@
54
54
  </style>
55
55
  </head>
56
56
 
57
- <body>
57
+ <body class="rails-default-error-page">
58
58
  <!-- This file lives in public/404.html -->
59
59
  <div class="dialog">
60
60
  <div>
@@ -4,7 +4,7 @@
4
4
  <title>The change you wanted was rejected (422)</title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <style>
7
- body {
7
+ .rails-default-error-page {
8
8
  background-color: #EFEFEF;
9
9
  color: #2E2F30;
10
10
  text-align: center;
@@ -12,13 +12,13 @@
12
12
  margin: 0;
13
13
  }
14
14
 
15
- div.dialog {
15
+ .rails-default-error-page div.dialog {
16
16
  width: 95%;
17
17
  max-width: 33em;
18
18
  margin: 4em auto 0;
19
19
  }
20
20
 
21
- div.dialog > div {
21
+ .rails-default-error-page div.dialog > div {
22
22
  border: 1px solid #CCC;
23
23
  border-right-color: #999;
24
24
  border-left-color: #999;
@@ -31,13 +31,13 @@
31
31
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
32
  }
33
33
 
34
- h1 {
34
+ .rails-default-error-page h1 {
35
35
  font-size: 100%;
36
36
  color: #730E15;
37
37
  line-height: 1.5em;
38
38
  }
39
39
 
40
- div.dialog > p {
40
+ .rails-default-error-page div.dialog > p {
41
41
  margin: 0 0 1em;
42
42
  padding: 1em;
43
43
  background-color: #F7F7F7;
@@ -54,7 +54,7 @@
54
54
  </style>
55
55
  </head>
56
56
 
57
- <body>
57
+ <body class="rails-default-error-page">
58
58
  <!-- This file lives in public/422.html -->
59
59
  <div class="dialog">
60
60
  <div>
@@ -4,7 +4,7 @@
4
4
  <title>We're sorry, but something went wrong (500)</title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <style>
7
- body {
7
+ .rails-default-error-page {
8
8
  background-color: #EFEFEF;
9
9
  color: #2E2F30;
10
10
  text-align: center;
@@ -12,13 +12,13 @@
12
12
  margin: 0;
13
13
  }
14
14
 
15
- div.dialog {
15
+ .rails-default-error-page div.dialog {
16
16
  width: 95%;
17
17
  max-width: 33em;
18
18
  margin: 4em auto 0;
19
19
  }
20
20
 
21
- div.dialog > div {
21
+ .rails-default-error-page div.dialog > div {
22
22
  border: 1px solid #CCC;
23
23
  border-right-color: #999;
24
24
  border-left-color: #999;
@@ -31,13 +31,13 @@
31
31
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
32
  }
33
33
 
34
- h1 {
34
+ .rails-default-error-page h1 {
35
35
  font-size: 100%;
36
36
  color: #730E15;
37
37
  line-height: 1.5em;
38
38
  }
39
39
 
40
- div.dialog > p {
40
+ .rails-default-error-page div.dialog > p {
41
41
  margin: 0 0 1em;
42
42
  padding: 1em;
43
43
  background-color: #F7F7F7;
@@ -54,7 +54,7 @@
54
54
  </style>
55
55
  </head>
56
56
 
57
- <body>
57
+ <body class="rails-default-error-page">
58
58
  <!-- This file lives in public/500.html -->
59
59
  <div class="dialog">
60
60
  <div>
File without changes
@@ -0,0 +1 @@
1
+ "%��B�����șo�$'�A�d��L���xR�U
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash} I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Lprocessors:type=application/javascript&file_type=application/javascript;TTI"8file-digest://app/assets/javascripts/application.js;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTF
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&id=b0fc51269f5a30cd9d7d2eedaad00ca3df5f3c117965a2f3e4dc5902767532ae:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=d35a2de9bf475b03ab7c4109821448721454a5376d5a023c0c01d2c156a01760:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=fc04be093b27339a8b66356c446578808c939a7d55357ab837918a04b2f5f07b:ET
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=32f91865827ed99aeefdca6c631796f5dc304dc1e3adacca5062889824f3f995:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=c7508cd7ef462d9c3c1994cd6328c02584cb77120fa393b5a5cc627b2aab2e35:ET
@@ -0,0 +1,3 @@
1
+ [o:Set:
2
+ @hash}
3
+ I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"8file-digest://app/assets/javascripts/application.js;TTF
@@ -0,0 +1 @@
1
+ "%��B�����șo�$'�A�d��L���xR�U
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=01e7326e301a8b006acc71de68fe1d6ba23fe6b3fbf3b69934201f1513015163:ET
@@ -1,28 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  module Booties
4
6
  class BadgeHelperTest < ActionView::TestCase
5
- test '#badge renders span tag with badge class' do
7
+ def test_badge_renders_span_tag_with_badge_class
6
8
  expected = '<span class="badge">content</span>'
7
9
  assert_equal expected, badge('content')
8
10
  end
9
11
 
10
- test '#badge passes miscellaneous options through to #content_tag' do
12
+ def test_badge_passes_miscellaneous_options_through_to_content_tag
11
13
  expected = '<span class="badge" id="foo">content</span>'
12
14
  assert_equal expected, badge('content', id: 'foo')
13
15
  end
14
16
 
15
- test '#badge merges optional classes with badge class' do
17
+ def test_badge_merges_optional_classes_with_badge_class
16
18
  expected = '<span class="badge foo">content</span>'
17
19
  assert_equal expected, badge('content', class: 'foo')
18
20
  end
19
21
 
20
- test '#badge accepts content as a block' do
22
+ def test_badge_accepts_content_as_a_block
21
23
  expected = '<span class="badge" id="foo">Bar</span>'
22
24
  assert_equal expected, badge(id: 'foo') { 'Bar' }
23
25
  end
24
26
 
25
- test '#badge handles nil content when no block is given' do
27
+ def test_badge_handles_nil_content_when_no_block_is_given
26
28
  expected = '<span class="badge"></span>'
27
29
  assert_equal expected, badge(nil)
28
30
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Booties
6
+ class BreadcrumbHelperTest < ActionView::TestCase
7
+ def test_breadcrumbs_renders_ol_tag_with_breadcrumb_class
8
+ expected = '<ol class="breadcrumb"><li class="active">Hi</li></ol>'
9
+ actual = render_breadcrumbs { '<li class="active">Hi</li>'.html_safe }
10
+ assert_dom_equal expected, actual
11
+ end
12
+ end
13
+ end
@@ -1,25 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  module Booties
4
6
  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')
7
+ def test_btn_link_to_renders_link_with_btn_classes
8
+ expected = '<a href="/foo" class="btn btn-default">Foo</a>'
9
+ assert_dom_equal expected, btn_link_to('Foo', '/foo')
8
10
  end
9
11
 
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)
12
+ def test_btn_link_to_context_can_be_overridden
13
+ expected = '<a href="/foo" class="btn btn-primary">Foo</a>'
14
+ assert_dom_equal expected, btn_link_to('Foo', '/foo', context: :primary)
13
15
  end
14
16
 
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)
17
+ def test_btn_link_to_passes_extra_as_html_options_to_link_to
18
+ expected = '<a href="/foo" class="btn btn-default btn-xs" data-method="delete" rel="nofollow">Foo</a>'
19
+ assert_dom_equal expected, btn_link_to('Foo', '/foo', class: 'btn-xs', method: :delete)
18
20
  end
19
21
 
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' }
22
+ def test_btn_link_to_with_a_block
23
+ expected = '<a href="/foo" class="btn btn-default btn-xs">Foo</a>'
24
+ assert_dom_equal expected, btn_link_to('/foo', class: 'btn-xs') { 'Foo' }
23
25
  end
24
26
  end
25
27
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Booties
6
+ class DropdownHelperTest < ActionView::TestCase
7
+ def test_link_to_dropdown_renders_link_with_dropdown_options
8
+ expected = '<a class="dropdown-toggle" data-toggle="dropdown" role="button" href="#">Foo<span class="caret"></span></a>'
9
+ actual = link_to_dropdown { 'Foo' }
10
+ assert_dom_equal expected, actual
11
+ end
12
+
13
+ def test_link_to_dropdown_with_custom_class
14
+ expected = '<a class="foo dropdown-toggle" data-toggle="dropdown" role="button" href="#">Foo<span class="caret"></span></a>'
15
+ actual = link_to_dropdown(class: 'foo') { 'Foo' }
16
+ assert_dom_equal expected, actual
17
+ end
18
+
19
+ def test_button_to_dropdown_renders_button_with_dropdown_options
20
+ expected = '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Foo<span class="caret"></span></button>'
21
+ actual = button_to_dropdown { 'Foo' }
22
+ assert_dom_equal expected, actual
23
+ end
24
+
25
+ def test_button_to_dropdown_with_context
26
+ expected = '<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">Foo<span class="caret"></span></button>'
27
+ actual = button_to_dropdown(context: :primary) { 'Foo' }
28
+ assert_dom_equal expected, actual
29
+ end
30
+
31
+ def test_button_to_dropdown_with_optional_classes
32
+ expected = '<button type="button" class="btn-xs btn btn-default dropdown-toggle" data-toggle="dropdown">Foo<span class="caret"></span></button>'
33
+ actual = button_to_dropdown(class: 'btn-xs') { 'Foo' }
34
+ assert_dom_equal expected, actual
35
+ end
36
+
37
+ def test_dropdown_menu_renders_dropdown_list
38
+ expected = '<ul class="dropdown-menu"><li><a href="#">Foo</a></li></ul>'
39
+ actual = dropdown_menu { content_tag :li, link_to('Foo', '#') }
40
+ assert_dom_equal expected, actual
41
+ end
42
+ end
43
+ end
@@ -1,28 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  module Booties
4
6
  class FlagHelperTest < ActionView::TestCase
5
- test '#flag renders span tag with label classes' do
7
+ def test_flag_renders_span_tag_with_label_classes
6
8
  expected = '<span class="label label-default">content</span>'
7
9
  assert_equal expected, flag('content')
8
10
  end
9
11
 
10
- test '#flag accepts a custom context' do
12
+ def test_flag_accepts_a_custom_context
11
13
  expected = '<span class="label label-primary">content</span>'
12
14
  assert_equal expected, flag('content', context: :primary)
13
15
  end
14
16
 
15
- test '#flag passes miscellaneous options through to #content_tag' do
17
+ def test_flag_passes_miscellaneous_options_through_to_content_tag
16
18
  expected = '<span class="label label-default" id="foo">content</span>'
17
19
  assert_equal expected, flag('content', id: 'foo')
18
20
  end
19
21
 
20
- test '#flag accepts content as a block' do
22
+ def test_flag_accepts_content_as_a_block
21
23
  expected = '<span class="label label-default" id="foo">content</span>'
22
24
  assert_equal expected, flag(id: 'foo') { 'content' }
23
25
  end
24
26
 
25
- test '#flag merges optional classes with label classes' do
27
+ def test_flag_merges_optional_classes_with_label_classes
26
28
  expected = '<span class="label label-default foo">content</span>'
27
29
  assert_equal expected, flag('content', class: 'foo')
28
30
  end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
  require 'minitest/mock'
3
5
 
4
6
  module Booties
5
7
  class ModalHelperTest < ActionView::TestCase
6
- test '#modal instantiates a new Modal and calls render' do
8
+ def test_modal_instantiates_a_new_modal_and_calls_render
7
9
  modal_class = Minitest::Mock.new
8
10
  modal_instance = Minitest::Mock.new
9
11
 
10
12
  modal_class.expect :new, modal_instance,
11
- [self, id: 'foo', fade: true, size: nil]
13
+ [self, id: 'foo', fade: true, size: nil]
12
14
  modal_instance.expect :render, true, [{}]
13
15
 
14
16
  modal 'foo', with: modal_class
@@ -17,12 +19,12 @@ module Booties
17
19
  modal_instance.verify
18
20
  end
19
21
 
20
- test '#modal passes keyword arguments on to Modal constructor' do
22
+ def test_modal_passes_keyword_arguments_on_to_modal_constructor
21
23
  modal_class = Minitest::Mock.new
22
24
  modal_instance = Minitest::Mock.new
23
25
 
24
26
  modal_class.expect :new, modal_instance,
25
- [self, id: 'foo', fade: false, size: :large]
27
+ [self, id: 'foo', fade: false, size: :large]
26
28
  modal_instance.expect :render, true, [{}]
27
29
 
28
30
  modal 'foo', fade: false, size: :large, with: modal_class
@@ -31,14 +33,14 @@ module Booties
31
33
  modal_instance.verify
32
34
  end
33
35
 
34
- test '#modal passes optional arguments on to Modal#render' do
36
+ def test_modal_passes_optional_arguments_on_to_modal_render
35
37
  modal_class = Minitest::Mock.new
36
38
  modal_instance = Minitest::Mock.new
37
39
 
38
40
  modal_class.expect :new, modal_instance,
39
- [self, id: 'foo', fade: true, size: nil]
41
+ [self, id: 'foo', fade: true, size: nil]
40
42
  modal_instance.expect :render, true,
41
- [{ class: 'foo', data: { bar: 'baz' } }]
43
+ [{ class: 'foo', data: { bar: 'baz' } }]
42
44
 
43
45
  modal 'foo', with: modal_class, class: 'foo', data: { bar: 'baz' }
44
46
 
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
  require 'minitest/mock'
3
5
 
4
6
  module Booties
5
7
  class PanelHelperTest < ActionView::TestCase
6
- test '#panel instantiates a new Panel and calls render' do
8
+ def test_panel_instantiates_a_new_panel_and_calls_render
7
9
  panel_class = Minitest::Mock.new
8
10
  panel_instance = Minitest::Mock.new
9
11
 
@@ -16,7 +18,7 @@ module Booties
16
18
  panel_instance.verify
17
19
  end
18
20
 
19
- test '#panel instantiates a new Panel with the given context' do
21
+ def test_panel_instantiates_a_new_panel_with_the_given_context
20
22
  panel_class = Minitest::Mock.new
21
23
  panel_instance = Minitest::Mock.new
22
24
 
@@ -7,17 +7,15 @@ module Booties
7
7
  CONTENT = 'Lorem ipsum dolor sin amet'
8
8
 
9
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)
10
+ expected = '<a role="button" data-toggle="popover" data-content="Lorem ipsum">Link text</a>'
11
+ actual = popover('Link text', content: 'Lorem ipsum')
12
+ assert_dom_equal expected, actual
14
13
  end
15
14
 
16
15
  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' }
16
+ expected = '<a role="button" data-toggle="popover" data-content="Lorem ipsum">Link text</a>'
17
+ actual = popover(content: 'Lorem ipsum') { 'Link text' }
18
+ assert_equal expected, actual
21
19
  end
22
20
 
23
21
  def test_popover_requires_content_argument
@@ -26,53 +24,46 @@ module Booties
26
24
  end
27
25
 
28
26
  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')
27
+ expected = '<a role="button" title="Lorem ipsum" data-toggle="popover" data-content="Lorem ipsum dolor sin amet">Link text</a>'
28
+ actual = popover('Link text', content: 'Lorem ipsum dolor sin amet', title: 'Lorem ipsum')
29
+ assert_dom_equal expected, actual
35
30
  end
36
31
 
37
32
  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)
33
+ expected = '<a role="button" data-toggle="popover" data-content="Lorem ipsum" data-placement="top">Link text</a>'
34
+ actual = popover('Link text', content: 'Lorem ipsum', placement: :top)
35
+ assert_equal expected, actual
43
36
  end
44
37
 
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
38
+ def test_popover_with_trigger
39
+ expected = '<a tabindex="10" role="button" data-toggle="popover" data-content="Lorem ipsum" data-trigger="focus">Link text</a>'
40
+ actual = popover('Link text', content: 'Lorem ipsum', trigger: :focus)
41
+ assert_dom_equal expected, actual
51
42
  end
52
43
 
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)
44
+ def test_popover_with_container
45
+ expected = '<a role="button" data-toggle="popover"' \
46
+ ' data-content="Lorem ipsum" data-container="body">Link text</a>'
47
+ actual = popover('Link text', content: 'Lorem ipsum', container: 'body')
48
+ assert_dom_equal expected, actual
49
+ end
50
+
51
+ def test_popover_with_custom_tabindex
52
+ expected = '<a tabindex="42" role="button" data-toggle="popover" data-content="Lorem ipsum" data-trigger="focus">Link text</a>'
53
+ actual = popover('Link text', content: 'Lorem ipsum', trigger: :focus, tabindex: 42)
54
+ assert_dom_equal expected, actual
59
55
  end
60
56
 
61
57
  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)
58
+ expected = '<button type="button" data-toggle="popover" data-content="Lorem ipsum">Link text</button>'
59
+ actual = popover('Link text', content: 'Lorem ipsum', tag: :button)
60
+ assert_dom_equal expected, actual
67
61
  end
68
62
 
69
63
  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' })
64
+ expected = '<a class="btn btn-default" data-foo="bar" data-toggle="popover" data-content="Lorem ipsum" role="button">Link text</a>'
65
+ actual = popover('Link text', content: 'Lorem ipsum', class: 'btn btn-default', data: { foo: 'bar' })
66
+ assert_dom_equal expected, actual
76
67
  end
77
68
  end
78
69
  end