heartwood 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +28 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +4 -0
  8. data/Rakefile +20 -0
  9. data/app/controllers/cambium/base_controller.rb +3 -0
  10. data/app/models/concerns/idx.rb +28 -0
  11. data/app/models/concerns/image_cropper.rb +24 -0
  12. data/app/models/concerns/publishable.rb +57 -0
  13. data/app/models/concerns/slug.rb +56 -0
  14. data/app/models/concerns/tags.rb +33 -0
  15. data/bin/rails +12 -0
  16. data/config/routes.rb +2 -0
  17. data/heartwood.gemspec +43 -0
  18. data/lib/generators/cambium/app_generator.rb +205 -0
  19. data/lib/generators/cambium/controller_generator.rb +81 -0
  20. data/lib/generators/cambium/gemfile_generator.rb +36 -0
  21. data/lib/generators/cambium/install_generator.rb +19 -0
  22. data/lib/generators/cambium/user_generator.rb +40 -0
  23. data/lib/generators/helpers/_autoloader.rb +12 -0
  24. data/lib/generators/helpers/generators_helper.rb +235 -0
  25. data/lib/generators/templates/Gemfile.erb +78 -0
  26. data/lib/generators/templates/app/assets/javascripts/application.js.coffee +24 -0
  27. data/lib/generators/templates/app/assets/javascripts/routers/router.js.coffee +23 -0
  28. data/lib/generators/templates/app/assets/javascripts/templates/.keep +0 -0
  29. data/lib/generators/templates/app/assets/javascripts/views/default_helpers.js.coffee +16 -0
  30. data/lib/generators/templates/app/assets/stylesheets/admin/admin.scss +3 -0
  31. data/lib/generators/templates/app/assets/stylesheets/application.scss +9 -0
  32. data/lib/generators/templates/app/controllers/admin/controller.rb.erb +2 -0
  33. data/lib/generators/templates/app/controllers/application_controller.rb +11 -0
  34. data/lib/generators/templates/app/models/user.rb +14 -0
  35. data/lib/generators/templates/app/views/application/_status.html.erb +3 -0
  36. data/lib/generators/templates/app/views/home/index.html.erb +7 -0
  37. data/lib/generators/templates/app/views/layouts/application.html.erb +24 -0
  38. data/lib/generators/templates/config/application.rb +17 -0
  39. data/lib/generators/templates/config/initializers/_hash.rb +23 -0
  40. data/lib/generators/templates/config/initializers/_settings.rb +18 -0
  41. data/lib/generators/templates/config/initializers/assets.rb +3 -0
  42. data/lib/generators/templates/config/initializers/heartwood.rb +25 -0
  43. data/lib/generators/templates/config/private.yml +16 -0
  44. data/lib/generators/templates/config/routes.rb +54 -0
  45. data/lib/generators/templates/config/settings.yml +16 -0
  46. data/lib/generators/templates/db/seeds.rb +25 -0
  47. data/lib/generators/templates/gitignore +30 -0
  48. data/lib/heartwood/configuration.rb +29 -0
  49. data/lib/heartwood/engine.rb +28 -0
  50. data/lib/heartwood/support/array.rb +9 -0
  51. data/lib/heartwood/support/false_class.rb +9 -0
  52. data/lib/heartwood/support/fixnum.rb +13 -0
  53. data/lib/heartwood/support/float.rb +5 -0
  54. data/lib/heartwood/support/hash.rb +22 -0
  55. data/lib/heartwood/support/nil_class.rb +19 -0
  56. data/lib/heartwood/support/string.rb +28 -0
  57. data/lib/heartwood/support/true_class.rb +9 -0
  58. data/lib/heartwood/version.rb +3 -0
  59. data/lib/heartwood.rb +11 -0
  60. data/lib/help/heartwood_prereqs.txt +13 -0
  61. data/lib/help/pg_search_post_install.txt +13 -0
  62. data/lib/tasks/db.rake +22 -0
  63. data/lib/tasks/rename.rake +28 -0
  64. data/spec/dummy/README.rdoc +28 -0
  65. data/spec/dummy/Rakefile +6 -0
  66. data/spec/dummy/app/assets/images/.keep +0 -0
  67. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  68. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  69. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  70. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  71. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  72. data/spec/dummy/app/mailers/.keep +0 -0
  73. data/spec/dummy/app/models/.keep +0 -0
  74. data/spec/dummy/app/models/concerns/.keep +0 -0
  75. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  76. data/spec/dummy/bin/bundle +3 -0
  77. data/spec/dummy/bin/rails +4 -0
  78. data/spec/dummy/bin/rake +4 -0
  79. data/spec/dummy/bin/setup +29 -0
  80. data/spec/dummy/config/application.rb +32 -0
  81. data/spec/dummy/config/boot.rb +5 -0
  82. data/spec/dummy/config/database.yml +25 -0
  83. data/spec/dummy/config/environment.rb +5 -0
  84. data/spec/dummy/config/environments/development.rb +41 -0
  85. data/spec/dummy/config/environments/production.rb +79 -0
  86. data/spec/dummy/config/environments/test.rb +42 -0
  87. data/spec/dummy/config/initializers/assets.rb +11 -0
  88. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  89. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  90. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  91. data/spec/dummy/config/initializers/inflections.rb +16 -0
  92. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  93. data/spec/dummy/config/initializers/session_store.rb +3 -0
  94. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  95. data/spec/dummy/config/locales/en.yml +23 -0
  96. data/spec/dummy/config/routes.rb +4 -0
  97. data/spec/dummy/config/secrets.yml +22 -0
  98. data/spec/dummy/config.ru +4 -0
  99. data/spec/dummy/db/development.sqlite3 +0 -0
  100. data/spec/dummy/db/heartwood_development.sqlite3 +0 -0
  101. data/spec/dummy/db/heartwood_test.sqlite3 +0 -0
  102. data/spec/dummy/db/schema.rb +15 -0
  103. data/spec/dummy/db/test.sqlite3 +0 -0
  104. data/spec/dummy/lib/assets/.keep +0 -0
  105. data/spec/dummy/log/.keep +0 -0
  106. data/spec/dummy/log/development.log +78 -0
  107. data/spec/dummy/log/test.log +3050 -0
  108. data/spec/dummy/public/404.html +67 -0
  109. data/spec/dummy/public/422.html +67 -0
  110. data/spec/dummy/public/500.html +66 -0
  111. data/spec/dummy/public/favicon.ico +0 -0
  112. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1i/1ii3yPGPbB0S_BkYiwVDC7qlKvhKF5P0zr7QiaTpgV4.cache +0 -0
  113. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
  114. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7k/7kqdQ5LCh-fs6HP4CUqWvk9w7HRuj6ZT_zkC-hUUMHU.cache +0 -0
  115. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8M/8Mpbgok-UsQPhrJQKqd6hVtQogD8YuU6GMn-2KVhC3E.cache +1 -0
  116. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Au/AuOTcA4Uen3sMQjy8Mi6nooP_8gMgvlFsjqr8mHpMIs.cache +0 -0
  117. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/FG/FGeBOdRSmza-XfWb8ERFQydMrExKmdlz2_eksYO3y4Q.cache +1 -0
  118. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/MB/MBqa7cQSBGYszhtbC7r7yiDA0gjwriFrAaNiQnMbfFw.cache +1 -0
  119. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ML/MLT6NKtdybeBwpm6H1d7XzkomTyZnMge5E8EEQkhtrc.cache +1 -0
  120. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
  121. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/R2/R2IjUuzOFtsZdvjOQOrasVwjaCegvj-lE6jkTQFL9xs.cache +1 -0
  122. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/WB/WB2XiMJ4O7--cvm29FJ4zeUyMpU15sqdYtfduF0YeT0.cache +1 -0
  123. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YT/YTDOaZ9qOx03chcaLrJy-Ch0Rtn4Nik102vwxZ2a-k8.cache +1 -0
  124. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aB/aBAdNO31MRRIPsReAdfHmtSFswygiBIFctx6fBhTTdc.cache +0 -0
  125. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fK/fKCgrNQR1G7Gf6VTItx7NTaKXquuw-ufNT5nGlxvBV4.cache +0 -0
  126. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -0
  127. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hr/hrKDaC8EYPX0veGxFTXgYt7IynAdYyeBjYjzcPazQkk.cache +1 -0
  128. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/i4/i4-E3GFC6rOjx1w5H9W14IbdPm4ouzkqixHmsK27kmo.cache +0 -0
  129. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jE/jEmEy4r1QfD5kzXcHSPcAaAgBwet1M0ZIWQuzyT9TXw.cache +0 -0
  130. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/l7/l7FREFh3W4tfuo0mF7DdkXKth9VT4R2hiiiq0KS4xpI.cache +1 -0
  131. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/o8/o8getMbwHiM68k4uUk4shsyjKnDbV_hmifAWyvO-E50.cache +1 -0
  132. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -0
  133. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wA/wAjBFweHcRdsYa4zx9mayhvC0RDVqaI5gM0LcoCv7a4.cache +1 -0
  134. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xW/xWmlGxKNxc1ViyjTyokcbCu6WjNIGDIqPVPXsBwdveA.cache +1 -0
  135. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zP/zPn9M5I_yf8ko0-lpbDwTWjG6wpRvXkA77hDUPzAFZ8.cache +0 -0
  136. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zd/zd90ZPTG89ScoQQ_PzPAAe2669wzpdyZuzn7qmr9e3s.cache +0 -0
  137. data/spec/lib/support/array_spec.rb +14 -0
  138. data/spec/lib/support/false_class_spec.rb +17 -0
  139. data/spec/lib/support/fixnum_spec.rb +23 -0
  140. data/spec/lib/support/float_spec.rb +18 -0
  141. data/spec/lib/support/hash_spec.rb +21 -0
  142. data/spec/lib/support/nil_class_spec.rb +23 -0
  143. data/spec/lib/support/string_spec.rb +44 -0
  144. data/spec/lib/support/true_class_spec.rb +17 -0
  145. data/spec/rails_helper.rb +183 -0
  146. data/spec/spec_helper.rb +99 -0
  147. data/vendor/assets/javascripts/backbone.js +1920 -0
  148. data/vendor/assets/javascripts/modernizr.js +4 -0
  149. data/vendor/assets/javascripts/underscore.js +1548 -0
  150. data/vendor/assets/stylesheets/normalize.scss +406 -0
  151. metadata +425 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1 @@
1
+ "%Ѱč@�����6H�uZoX�Z�gbh0W��V
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=174367a6be49d14b34ec51a173273fa667ff99918d8e995307291288bcff82d2:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&id=5b3b59701a233520fe0608a5e25732138c840244fa13a662e807199dd4291266:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&id=6107521d3a6100e5530debc2966c20beda7f346ff34a865bb92217e6b18ffee4:ET
@@ -0,0 +1 @@
1
+ "%�W\�yho9S���ƫ˥��)|�~���(���
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=38d69380cbdef7464d644972745e31927b4393d5440a319751458aa120371aba:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=74cf88b9fb6e80c4b260e8cc953a448070c5c54c7061ed5735e3f42147a07b12:ET
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=4a9d9c9d6765525a4a1a5ca9d841640750efb1f06c66f815b0578696cfde6d57:ET
@@ -0,0 +1 @@
1
+ "%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
@@ -0,0 +1 @@
1
+ "%ց"�����!���>����S<wq�Ff]>�Aj
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=b12950c4b29cc8e3d7151ab35eac77b45a9daaec6c668b39fd97e304a8554355:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=b6a37d95bf57997458faf69e12eb2b8b163f6ed090e8e7849388cd7203604a1e:ET
@@ -0,0 +1,14 @@
1
+ require 'rails_helper'
2
+
3
+ describe Array do
4
+
5
+ describe '#average' do
6
+ it 'returns nil when there are no items' do
7
+ expect([].average).to eq(nil)
8
+ end
9
+ it 'returns the average' do
10
+ expect([1, 2, 3].average).to eq(2.0)
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails_helper'
2
+
3
+ describe FalseClass do
4
+
5
+ describe '#to_i' do
6
+ it 'returns 0' do
7
+ expect(false.to_i).to eq(0)
8
+ end
9
+ end
10
+
11
+ describe '#to_bool' do
12
+ it 'returns false' do
13
+ expect(false.to_bool).to eq(false)
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,23 @@
1
+ require 'rails_helper'
2
+
3
+ describe Fixnum do
4
+
5
+ describe '#nearest_half' do
6
+ it 'returns a float of itself' do
7
+ expect(1.nearest_half).to eq(1.0)
8
+ end
9
+ end
10
+
11
+ describe '#to_bool' do
12
+ it 'returns true for 1' do
13
+ expect(1.to_bool).to eq(true)
14
+ end
15
+ it 'returns false for 0' do
16
+ expect(0.to_bool).to eq(false)
17
+ end
18
+ it 'raises an error for all other numbers' do
19
+ expect { 2.to_bool }.to raise_error(ArgumentError)
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,18 @@
1
+ require 'rails_helper'
2
+
3
+ describe Float do
4
+
5
+ describe '#nearest_half' do
6
+ it 'rounds to the nearest half' do
7
+ expect(0.24.nearest_half).to eq(0.0)
8
+ expect(0.26.nearest_half).to eq(0.5)
9
+ expect(0.74.nearest_half).to eq(0.5)
10
+ expect(0.76.nearest_half).to eq(1.0)
11
+ end
12
+ it 'rounds up when equally between' do
13
+ expect(0.25.nearest_half).to eq(0.5)
14
+ expect(0.75.nearest_half).to eq(1.0)
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,21 @@
1
+ require 'rails_helper'
2
+
3
+ describe Hash do
4
+
5
+ describe '#to_ostruct' do
6
+ it 'returns an OpenStruct object' do
7
+ expect({}.to_ostruct).to eq(OpenStruct.new)
8
+ end
9
+ it 'returns a recursive OpenStruct' do
10
+ hash = { :a => '1', :b => 2, :c => [3, 4, 5], :d => { :e => '6' } }
11
+ ostruct = OpenStruct.new(
12
+ :a => '1',
13
+ :b => 2,
14
+ :c => [3, 4, 5],
15
+ :d => OpenStruct.new(:e => '6')
16
+ )
17
+ expect(hash.to_ostruct).to eq(ostruct)
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,23 @@
1
+ require 'rails_helper'
2
+
3
+ describe NilClass do
4
+
5
+ describe '#+' do
6
+ it 'can be added to a string' do
7
+ expect(nil + 'hello').to eq('hello')
8
+ end
9
+ it 'can be added to an integer' do
10
+ expect(nil + 1).to eq(1)
11
+ end
12
+ it 'can be added to a float' do
13
+ expect(nil + 1.5).to eq(1.5)
14
+ end
15
+ end
16
+
17
+ describe '#to_bool' do
18
+ it 'returns false' do
19
+ expect(nil.to_bool).to eq(false)
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,44 @@
1
+ require 'rails_helper'
2
+
3
+ describe String do
4
+
5
+ describe '#to_bool' do
6
+ it 'returns true for truly strings' do
7
+ %w{true t yes y 1}.each { |str| expect(str.to_bool).to eq(true) }
8
+ end
9
+ it 'returns false for falsey strings' do
10
+ %w{false f no n 0}.each { |str| expect(str.to_bool).to eq(false) }
11
+ end
12
+ it 'raises an error for all other strings' do
13
+ expect { 'balls'.to_bool }.to raise_error(ArgumentError)
14
+ end
15
+ end
16
+
17
+ describe '#possessive' do
18
+ it 'adds an apostrophe when ending in s' do
19
+ expect('Davis'.possessive).to eq("Davis'")
20
+ end
21
+ it 'adds an apostrophe-S when not ending in s' do
22
+ expect('Sean'.possessive).to eq("Sean's")
23
+ end
24
+ end
25
+
26
+ describe '#paragraphs' do
27
+ it 'breaks on newlines' do
28
+ txt = "I\nAnd Love\nAnd You"
29
+ expect(txt.paragraphs).to eq(['I', 'And Love', 'And You'])
30
+ end
31
+ it 'removes extra newlines' do
32
+ txt = "I\n\nAnd Love\n\nAnd You"
33
+ expect(txt.paragraphs).to eq(['I', 'And Love', 'And You'])
34
+ end
35
+ end
36
+
37
+ describe '#sentences' do
38
+ it 'breaks on periods, exclamation marks, and question marks' do
39
+ txt = "I? And, Love. And You! And Us"
40
+ expect(txt.sentences).to eq(['I?', 'And, Love.', 'And You!', 'And Us'])
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails_helper'
2
+
3
+ describe TrueClass do
4
+
5
+ describe '#to_i' do
6
+ it 'returns 1' do
7
+ expect(true.to_i).to eq(1)
8
+ end
9
+ end
10
+
11
+ describe '#to_bool' do
12
+ it 'returns true' do
13
+ expect(true.to_bool).to eq(true)
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,183 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ # Prevent database truncation if the environment is production
5
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
6
+ require 'spec_helper'
7
+ require 'rspec/rails'
8
+
9
+ # Add additional requires below this line. Rails is not loaded until this point!
10
+
11
+ # Add additional requires below this line. Rails is not loaded until this point!
12
+ require 'capybara/rspec'
13
+ require 'capybara/rails'
14
+ require 'capybara-screenshot/rspec'
15
+ require 'capybara/poltergeist'
16
+ require 'database_cleaner'
17
+ require 'factory_girl'
18
+
19
+ Capybara.javascript_driver = :poltergeist
20
+
21
+ # Requires supporting ruby files with custom matchers and macros, etc, in
22
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
23
+ # run as spec files by default. This means that files in spec/support that end
24
+ # in _spec.rb will both be required and run as specs, causing the specs to be
25
+ # run twice. It is recommended that you do not name files matching this glob to
26
+ # end with _spec.rb. You can configure this pattern with the --pattern
27
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
28
+ #
29
+ # The following line is provided for convenience purposes. It has the downside
30
+ # of increasing the boot-up time by auto-requiring all files in the support
31
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
32
+ # require only the support files necessary.
33
+ #
34
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
35
+
36
+ # Checks for pending migration and applies them before tests are run.
37
+ # If you are not using ActiveRecord, you can remove this line.
38
+ ActiveRecord::Migration.maintain_test_schema!
39
+
40
+ RSpec.configure do |config|
41
+
42
+ config.filter_run :focus => true
43
+ config.run_all_when_everything_filtered = true
44
+
45
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
46
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
47
+
48
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
49
+ # examples within a transaction, remove the following line or assign false
50
+ # instead of true.
51
+ config.use_transactional_fixtures = false
52
+
53
+ # RSpec Rails can automatically mix in different behaviours to your tests
54
+ # based on their file location, for example enabling you to call `get` and
55
+ # `post` in specs under `spec/controllers`.
56
+ #
57
+ # You can disable this behaviour by removing the line below, and instead
58
+ # explicitly tag your specs with their type, e.g.:
59
+ #
60
+ # RSpec.describe UsersController, :type => :controller do
61
+ # # ...
62
+ # end
63
+ #
64
+ # The different available types are documented in the features, such as in
65
+ # https://relishapp.com/rspec/rspec-rails/docs
66
+ config.infer_spec_type_from_file_location!
67
+
68
+ # Filter lines from Rails gems in backtraces.
69
+ config.filter_rails_from_backtrace!
70
+ # arbitrary gems may also be filtered via:
71
+ # config.filter_gems_from_backtrace("gem name")
72
+
73
+ Capybara.default_max_wait_time = 10
74
+
75
+ Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
76
+ "#{example.description.gsub(' ', '-').gsub(/^.*\/spec\//,'')}"
77
+ end
78
+
79
+ # Precompile assets before running suite.
80
+ # config.before(:suite) do
81
+ # unless ARGV.any? {|e| e =~ /guard-rspec/ } || ENV['RSPEC_SKIP_ASSETS'].present?
82
+ # STDOUT.write "Precompiling assets..."
83
+ # require 'rake'
84
+ # Rails.application.load_tasks
85
+ # Rake::Task['assets:precompile'].invoke
86
+ # STDOUT.puts " done."
87
+ # Time.now.to_s
88
+ # end
89
+ # end
90
+
91
+ # config.after(:suite) do
92
+ # unless ARGV.any? {|e| e =~ /guard-rspec/ }
93
+ # FileUtils.rm_r(Rails.root.join('public','assets'))
94
+ # end
95
+ # end
96
+
97
+ config.before(:suite) do
98
+ %w(png html).each do |x|
99
+ Dir.glob("#{Rails.root}/tmp/capybara/*.#{x}").each { |f| FileUtils.rm(f) }
100
+ end
101
+ # Warden.test_mode!
102
+ if config.use_transactional_fixtures?
103
+ raise(<<-MSG)
104
+ Delete line `config.use_transactional_fixtures = true` from rails_helper.rb
105
+ (or set it to false) to prevent uncommitted transactions being used in
106
+ JavaScript-dependent specs.
107
+ During testing, the app-under-test that the browser driver connects to
108
+ uses a different database connection to the database connection used by
109
+ the spec. The app's database connection would not be able to access
110
+ uncommitted transaction data setup over the spec's database connection.
111
+ MSG
112
+ end
113
+ DatabaseCleaner.clean_with(:truncation)
114
+ end
115
+
116
+ config.before(:each) do
117
+ DatabaseCleaner.strategy = :transaction
118
+ end
119
+
120
+ config.before(:each, type: :feature) do
121
+ # :rack_test driver's Rack app under test shares database connection
122
+ # with the specs, so continue to use transaction strategy for speed.
123
+ driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test
124
+
125
+ if !driver_shares_db_connection_with_specs
126
+ # Driver is probably for an external browser with an app
127
+ # under test that does *not* share a database connection with the
128
+ # specs, so use truncation strategy.
129
+ DatabaseCleaner.strategy = :truncation
130
+ end
131
+ end
132
+
133
+ config.before(:each) do
134
+ DatabaseCleaner.start
135
+ ActionMailer::Base.deliveries = []
136
+ @fixture_path = "#{Rails.root}/spec/fixtures"
137
+ end
138
+
139
+ config.append_after(:each) do
140
+ DatabaseCleaner.clean
141
+ # Warden.test_reset!
142
+ end
143
+
144
+ config.after(:each, type: :feature) do
145
+ wait_for_requests_complete # if example.metadata[:type] == :feature
146
+ end
147
+
148
+ # config.include Devise::Test::ControllerHelpers, :type => :controller
149
+ config.include FactoryGirl::Syntax::Methods
150
+ # config.include FeatureHelpers, :type => :feature
151
+ # config.include ControllerHelpers, :type => :controller
152
+ # config.include TestHelpers
153
+ end
154
+
155
+ def wait_for_requests_complete
156
+ stop_client
157
+ RackRequestBlocker.block_requests!
158
+ wait_for('pending AJAX requests complete') do
159
+ RackRequestBlocker.num_active_requests == 0
160
+ end
161
+ ensure
162
+ RackRequestBlocker.allow_requests!
163
+ end
164
+
165
+ # Navigate away from the current page which will prevent any new requests from being started
166
+ def stop_client
167
+ page.execute_script %Q{
168
+ window.location = "about:blank";
169
+ }
170
+ end
171
+
172
+ # Waits until the passed block returns true
173
+ def wait_for(condition_name, max_wait_time: 30, polling_interval: 0.01)
174
+ wait_until = Time.now + max_wait_time.seconds
175
+ while true
176
+ return if yield
177
+ if Time.now > wait_until
178
+ raise "Condition not met: #{condition_name}"
179
+ else
180
+ sleep(polling_interval)
181
+ end
182
+ end
183
+ end