kawara 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.
Files changed (190) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +13 -0
  4. data/Rakefile +26 -0
  5. data/app/assets/javascripts/kawara/application.js +13 -0
  6. data/app/assets/stylesheets/kawara/application.css +15 -0
  7. data/app/controllers/kawara/application_controller.rb +5 -0
  8. data/app/controllers/kawara/articles_controller.rb +9 -0
  9. data/app/helpers/kawara/application_helper.rb +4 -0
  10. data/app/models/kawara/article.rb +25 -0
  11. data/app/models/kawara/article_image.rb +10 -0
  12. data/app/models/kawara/articles_meta_tag.rb +10 -0
  13. data/app/models/kawara/articles_tag.rb +10 -0
  14. data/app/models/kawara/category.rb +11 -0
  15. data/app/models/kawara/meta_tag.rb +9 -0
  16. data/app/models/kawara/tag.rb +9 -0
  17. data/app/views/kawara/articles/show.html.erb +13 -0
  18. data/app/views/layouts/kawara/application.html.erb +14 -0
  19. data/config/routes.rb +3 -0
  20. data/db/migrate/20160310230220_create_kawara_categories.rb +18 -0
  21. data/db/migrate/20160311072058_create_kawara_articles.rb +17 -0
  22. data/db/migrate/20160312220950_create_kawara_article_images.rb +13 -0
  23. data/db/migrate/20160315075716_create_kawara_tags.rb +12 -0
  24. data/db/migrate/20160315075948_create_kawara_articles_tags.rb +13 -0
  25. data/db/migrate/20160316132735_create_kawara_meta_tags.rb +12 -0
  26. data/db/migrate/20160316132838_create_kawara_articles_meta_tags.rb +13 -0
  27. data/lib/kawara/config.rb +29 -0
  28. data/lib/kawara/engine.rb +10 -0
  29. data/lib/kawara/version.rb +3 -0
  30. data/lib/kawara.rb +23 -0
  31. data/lib/tasks/kawara_tasks.rake +4 -0
  32. data/spec/controllers/kawara/articles_controller_spec.rb +30 -0
  33. data/spec/dummy/README.rdoc +28 -0
  34. data/spec/dummy/Rakefile +6 -0
  35. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  36. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  37. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  38. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  39. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  40. data/spec/dummy/bin/bundle +3 -0
  41. data/spec/dummy/bin/rails +4 -0
  42. data/spec/dummy/bin/rake +4 -0
  43. data/spec/dummy/bin/setup +29 -0
  44. data/spec/dummy/config/application.rb +32 -0
  45. data/spec/dummy/config/boot.rb +5 -0
  46. data/spec/dummy/config/database.yml +25 -0
  47. data/spec/dummy/config/environment.rb +5 -0
  48. data/spec/dummy/config/environments/development.rb +41 -0
  49. data/spec/dummy/config/environments/production.rb +79 -0
  50. data/spec/dummy/config/environments/test.rb +42 -0
  51. data/spec/dummy/config/initializers/assets.rb +11 -0
  52. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  53. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  54. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  55. data/spec/dummy/config/initializers/inflections.rb +16 -0
  56. data/spec/dummy/config/initializers/kawara.rb +8 -0
  57. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  58. data/spec/dummy/config/initializers/session_store.rb +3 -0
  59. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  60. data/spec/dummy/config/locales/en.yml +23 -0
  61. data/spec/dummy/config/routes.rb +4 -0
  62. data/spec/dummy/config/secrets.yml +22 -0
  63. data/spec/dummy/config.ru +4 -0
  64. data/spec/dummy/db/development.sqlite3 +0 -0
  65. data/spec/dummy/db/schema.rb +95 -0
  66. data/spec/dummy/db/test.sqlite3 +0 -0
  67. data/spec/dummy/log/development.log +3490 -0
  68. data/spec/dummy/log/test.log +7247 -0
  69. data/spec/dummy/public/404.html +67 -0
  70. data/spec/dummy/public/422.html +67 -0
  71. data/spec/dummy/public/500.html +66 -0
  72. data/spec/dummy/public/favicon.ico +0 -0
  73. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-GHY4pUmIod7aFXzqiTB1085VcN7QqLUq3uKh9EyrW8.cache +0 -0
  74. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-MYVNIBlzheOKmpCnc9D2lhtkhIcEl4YwZM7XVXAOF4.cache +0 -0
  75. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-OglIj6GGRix52-_kOnIVr-BwJbzu-ASbJx1VoScAVA.cache +1 -0
  76. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1KP7a1QwrH3OAbTdpgJVWZ0-pxpa1fcODRFqDcBPhUg.cache +1 -0
  77. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3QTcI6uIGbaXXd09o7ImhAbo_NMT_RVGZZ0Bqql2u2k.cache +1 -0
  78. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
  79. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5dNmmgZ1z1sZdMLOMqiQQKpTpkTo6o8fHrx7n-0oJPU.cache +1 -0
  80. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5zn7WE2Kf-W7nsLvyC8E0_bzAsEpuUALNf6MZpQBsog.cache +1 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/676ThQEFcacaWo-V6PAFKr8T6A9RnuC46Q2B8s-ZjOs.cache +1 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/6mmWcXQAa85jlxLZcRu37akpBv0H2agU6St8MtfaS04.cache +0 -0
  83. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7slj08lcqeYVz-2P5YaSO9ZHEW7CoCftIHZ54iOD14Y.cache +1 -0
  84. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/AZf7bqxGe7Q_hy-HImkMdMRShpV1rKoUXSs4KTmpcmM.cache +1 -0
  85. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/BXTz6VGNtrwaaqk-HVXmXiA7tsik9l-SBXnuHU9Y_No.cache +0 -0
  86. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DCUVKuoBkhtoc6-kTiPWpboN5KkmMDn0XD4bIwd3Pjw.cache +1 -0
  87. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DqxZQhVYt_gM_0UrN5DpmgxGqC3qDn0O9LmuOhDFkm4.cache +0 -0
  88. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/G_xLPRR5cXDCXz3k7QOjF82bKq4nUtLYQlo4VmyKzzM.cache +0 -0
  89. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/HHxaySpp8drvBDtjBOIn4Qbo3lmxQkEaERFOCi_oL9c.cache +1 -0
  90. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/IIes6cNhw2ZV5ruwsoW_WsNBDshI7wY5cmAKgEuTEo0.cache +1 -0
  91. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/JbBqfMFb60VtkrLmiRjXi08z1Y_IzK0hGW0M6rcCrhs.cache +0 -0
  92. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/KmBYHfUKVA9jOPzGx_HHUPtub6yUWtYEatrmy0BO9Xk.cache +0 -0
  93. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/L4n6mOM9s98jDFmv8P54gK08bltUvbeXih_O0z5MrH8.cache +0 -0
  94. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
  95. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/QKxtFPqtZSrBGyy42s3xwoeZ0yazHJvdS6CE7YkgMfc.cache +0 -0
  96. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/R29movm_aMSMs876ETYLiw7MyD3HXJKGU5am0ZWq4LU.cache +0 -0
  97. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/T7rBAlcrHhDGbxQGhznnSSOznpnuwtwRCn-pRBYTfXM.cache +1 -0
  98. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Vaxm8cKAFWFVkcBzzBwkJmMhl-NQyGLF8d9KyznXjWQ.cache +1 -0
  99. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/VlqA2Tp7L959ZnXZJ2F19ar_HaXlQFJaWm9aMW_dVaQ.cache +0 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/WEH9nXReGdSirA6-snq-NBZkvf5FXO1RmeX9Kxja_i8.cache +0 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/XUflKWMWOFmlUyxTWKB2Zu0DezUpfyxW6cyfUi2KLBg.cache +0 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YofvP9QAum93ypgWBKJonzhcZ2_PNe5JUf4SRF5RZ1U.cache +0 -0
  103. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_NlyaoV8oLEkDCn2fcAmyFno2KEhUnYtr5DRh9U15TQ.cache +1 -0
  104. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_cnDeuQV-P0jn-ZulURi6V3V85VuZAKxKr13-tzpJXg.cache +0 -0
  105. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aWHOBdA9G2l8rYoQFtX2KKlFA0_SvBQ72InA5a2VHRM.cache +0 -0
  106. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/b3eAB8l1iR3asS5hAxdwJKnSr9-822hw-kz_tuFuwII.cache +1 -0
  107. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/b_bbg7jg6iMQIo1v_HbRrIb_VFSPc4iBSmrY-ZE0FS0.cache +0 -0
  108. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dLkUM4Y-LoV1RrTjpa1z779CL_2UhLTCsOWXYqJ8cks.cache +1 -0
  109. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fMOP7mUWS6i3djD4kGHlw5lhClI1WAiI_w7FRS7Uauw.cache +0 -0
  110. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/h6mA3Cyu37w7LeutyDNHxX3I9GP7AUOsJPOaRoipXOQ.cache +0 -0
  111. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -0
  112. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hsNnsC_Cc4Tfp-iL7U3GwR1Ex-7FNPC_H5Y2DLoaau4.cache +1 -0
  113. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iLck0HdkY5V2wTkVW8Gz94GhsWU-2ZPi6CmRzr2Khc8.cache +0 -0
  114. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/im1Ue8etCIJlpp6W1_oHnMC6ssHZItygtXEzI0CDcog.cache +1 -0
  115. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jujnkdX8lDF1tdJW-X4_C0x_zb9G7PbjVwarzJjRHJ8.cache +0 -0
  116. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/kBNj9LEVDLqOQPcQ7ZpnhzNamFSkZwTeVwXKHiI7Yr8.cache +1 -0
  117. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mFSbefoakcnHeK0qLWpjAKnTqhAFYpqY62C6fdIpkBA.cache +0 -0
  118. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oYtmmKuk57rUOVduym0YSXaybGr3usVwdwBUAmefdHE.cache +1 -0
  119. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/p6C4e7QY0XDBV6j1hSqAEj2v5SwzsRadOpAwkT4EZV0.cache +0 -0
  120. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/p8PjTmao6G3mefh2Iws2vAow2alI3xo_MWxGt1txdwY.cache +0 -0
  121. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -0
  122. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/qPFZ2BUN--wo39yQCaOrQr_rH3EB8CScL3RV7ewS2SM.cache +1 -0
  123. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/qpJFxG0An23sYQA5CC1MCiDiQfT5UUsaF5-TLb_-9-k.cache +1 -0
  124. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/r03yAMij1DlQRoG0EARN71NBVrdAbSITUiHND4BPBzE.cache +0 -0
  125. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/r6v5Cu2CF5dQcp3UQglo2cIxe2eL5Mm3DWicaRwKYsc.cache +1 -0
  126. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/s-LKybje6prnbkcRfpEzkF02FJhVgyRVgvZQFdzZJ_M.cache +0 -0
  127. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/tXes8vdEQhJzM0Fn0w4CHgm1ZIPl51aFjwRju7CW8vs.cache +1 -0
  128. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/w8tmLWOgJTTO3lwqfnkMzpjCrg4gNT1woOJvgfvNkk0.cache +0 -0
  129. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yCEUk2jp5vTkSyXzUbodvK4RLiHEjKrTtu-oA52gnjs.cache +1 -0
  130. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zLxifIlJePLiBHx46lTNZEW59BZcVM0MNCm64s8FxJo.cache +1 -0
  131. data/spec/dummy/tmp/uploads/store/013af6d43bb3551fa0a01cd29dc07b23431930b5623452c0711a86b7e489 +1 -0
  132. data/spec/dummy/tmp/uploads/store/0339840baaa1ab9ce9894bd4041e00114a0aa12d5dbedf13ca0f99cb43ac +1 -0
  133. data/spec/dummy/tmp/uploads/store/0a638b1863fb5e952a2ebfd44c997be887cd2eb98bfb35bf6651a951da56 +1 -0
  134. data/spec/dummy/tmp/uploads/store/0fc11d5fdcf5d0868f2d3369c8c1057aea3b543d31be04f78b21137ad9ed +1 -0
  135. data/spec/dummy/tmp/uploads/store/122800e6cdacfb975b73c766791017d8fec77bf697826e22aa7aa907d955 +1 -0
  136. data/spec/dummy/tmp/uploads/store/23a5e4931ca0d4397b4688da22a7050aeccccb3b923b13abf4883d508fa2 +1 -0
  137. data/spec/dummy/tmp/uploads/store/2eccfeb1e4b56771a5771eee05577a0b0b3e4d8a6dbb1fcaede36ab135dd +1 -0
  138. data/spec/dummy/tmp/uploads/store/3110cba76b1ecdd6fe3e6ed6e29b1b18a03011bfc46fbd0fa9e91d8d1d1d +1 -0
  139. data/spec/dummy/tmp/uploads/store/337030b57341d1f1a90c7cb1f98d853e48f4a9f31bebc35ac24743f03967 +1 -0
  140. data/spec/dummy/tmp/uploads/store/3f3f95a6b2bd7f04d95a086d807c908b32fc363184482993ef1aea6980e7 +1 -0
  141. data/spec/dummy/tmp/uploads/store/433e1cff4bd65cb1e120a1a50d224173b45e2afc411be9d0d7e0bfbeeb8b +1 -0
  142. data/spec/dummy/tmp/uploads/store/4bd35b09dcf4a51d2c342d8725acdb8d83c0ec48006ab243d68209adc75e +1 -0
  143. data/spec/dummy/tmp/uploads/store/5845bd84cae841b16d430a2995226f89e951d406a50312a264ae0a2a38b9 +1 -0
  144. data/spec/dummy/tmp/uploads/store/58a4fa523400b154fda693194d90841163eb3eeaf7bbb7d760d48cea0a9d +1 -0
  145. data/spec/dummy/tmp/uploads/store/59ee7d66e12f4af9cce18aef8f51e156568bb43cd8493d7ec4c366e83d9a +1 -0
  146. data/spec/dummy/tmp/uploads/store/647dc628a03933f81197cdd5180a85e7b437327b2d44f059253936364356 +1 -0
  147. data/spec/dummy/tmp/uploads/store/6517d67fa347dc15bcdc66abd2b0f5b2bc594ad045837114c9ff153fbb7b +1 -0
  148. data/spec/dummy/tmp/uploads/store/66db2947f50696b190e30fe24a162fda19738cae25187ff6f1b4a4198267 +1 -0
  149. data/spec/dummy/tmp/uploads/store/6bc7da6e76e8c9f08a268f75cd723413f6a1c93dcc53a7741dde4a3e7c66 +1 -0
  150. data/spec/dummy/tmp/uploads/store/779039e6ecd69d19e7902c046cf6c3a5f9315c8df5334b3fb103d5e52df0 +1 -0
  151. data/spec/dummy/tmp/uploads/store/79ebbb49ea728f585ac1d552c687c6e6e63e21a7e984c04361f29712616b +1 -0
  152. data/spec/dummy/tmp/uploads/store/7d883bda5a0e21800d287baeef8e43d5b5393f780c0b6febe3aa37a18b98 +1 -0
  153. data/spec/dummy/tmp/uploads/store/83488b3fecb1f736bc0e6f18b8ce09091d77c74c72929f8e9b13f7e0b339 +1 -0
  154. data/spec/dummy/tmp/uploads/store/87f81b2206257afa9e44de63328f9ffab3adb1310bc65fedf9e568b22f42 +1 -0
  155. data/spec/dummy/tmp/uploads/store/8f1000740668b73a33dd07ab95c845b3473a7c6af14f446d6442523df98c +1 -0
  156. data/spec/dummy/tmp/uploads/store/97fba6b149dde97310735d773cb654975c4d2a45886693d03654b286d5d4 +1 -0
  157. data/spec/dummy/tmp/uploads/store/9a594f4b196ad875fba39c15c49741a449c8836450a781679ce4e9f074ce +1 -0
  158. data/spec/dummy/tmp/uploads/store/b08e0da5725010b809daaf8657b25af53900b38e4bd83e192dd49e6cee16 +1 -0
  159. data/spec/dummy/tmp/uploads/store/b2ed670f04070e8a7708e5c06ec1f9052ed9975fbaa42aec2c0dbfa617aa +1 -0
  160. data/spec/dummy/tmp/uploads/store/c9beb4710f822171201df1f090c41342015629d2dab5b9c4d94ab93c82d1 +1 -0
  161. data/spec/dummy/tmp/uploads/store/cc07ed99bbca4f83dd0b5954b9f1ce9584092bc5c2d05b7e6a92fd4c2e20 +1 -0
  162. data/spec/dummy/tmp/uploads/store/da5afbf24a652dca7390fd4afe5b466999ac0c8f8f1143e8023a4f184f91 +1 -0
  163. data/spec/dummy/tmp/uploads/store/e59f265c25efe736ff455a3faed63d710a21a403a93a1723ebc845438ef0 +1 -0
  164. data/spec/dummy/tmp/uploads/store/e9dd4abf2a9a9c727d864cf471923816cf68d55715a58d0a0496e825b767 +1 -0
  165. data/spec/dummy/tmp/uploads/store/ea4080bdac8b65c0b786a2997cb2a79bef2361e0ffbac573a517c5b979e2 +1 -0
  166. data/spec/dummy/tmp/uploads/store/edaa8c2911d6a2bfc9f4cc5b687887bf67b2aa061fac88426ed83f04eefa +1 -0
  167. data/spec/dummy/tmp/uploads/store/f30311663071fdc59166977a2a20af239c5349268f9725ec033cadfa2976 +1 -0
  168. data/spec/dummy/tmp/uploads/store/fe8c7f9b9c8afedb8a09e7dbe50b1da9db175395104e2e5aaba16cbcb733 +1 -0
  169. data/spec/factories/kawara_article_images.rb +6 -0
  170. data/spec/factories/kawara_articles.rb +17 -0
  171. data/spec/factories/kawara_articles_meta_tags.rb +6 -0
  172. data/spec/factories/kawara_articles_tags.rb +6 -0
  173. data/spec/factories/kawara_categories.rb +5 -0
  174. data/spec/factories/kawara_meta_tags.rb +6 -0
  175. data/spec/factories/kawara_tags.rb +6 -0
  176. data/spec/lib/kawara/config_spec.rb +4 -0
  177. data/spec/models/kawara/article_image_spec.rb +23 -0
  178. data/spec/models/kawara/article_spec.rb +35 -0
  179. data/spec/models/kawara/articles_meta_tag_spec.rb +22 -0
  180. data/spec/models/kawara/articles_tag_spec.rb +22 -0
  181. data/spec/models/kawara/category_spec.rb +13 -0
  182. data/spec/models/kawara/meta_tag_spec.rb +20 -0
  183. data/spec/models/kawara/tag_spec.rb +20 -0
  184. data/spec/rails_helper.rb +58 -0
  185. data/spec/spec_helper.rb +92 -0
  186. data/spec/support/factory_girl.rb +3 -0
  187. data/spec/support/refile.rb +15 -0
  188. data/spec/support/shoulda_matchers.rb +6 -0
  189. data/spec/support/temping.rb +5 -0
  190. metadata +584 -0
@@ -0,0 +1,35 @@
1
+ require 'rails_helper'
2
+
3
+ module Kawara
4
+ RSpec.describe Article, type: :model do
5
+ describe 'associations' do
6
+ it { should belong_to(:category) }
7
+ it { should have_many(:images) }
8
+ it { should have_many(:articles_tags) }
9
+ it { should have_many(:tags) }
10
+ end
11
+
12
+ describe '#find_from_published' do
13
+ subject { Kawara::Article.find_from_published(article.id) }
14
+
15
+ let(:draft_article) { create :draft_article }
16
+ let(:published_article) { create :published_article }
17
+
18
+ context 'when there are no published articles' do
19
+ let(:article) { draft_article }
20
+ it { expect{subject}.to raise_error(ActiveRecord::RecordNotFound) }
21
+ end
22
+
23
+ context 'when there are published article' do
24
+ let(:article) { published_article }
25
+ it { is_expected.to eq published_article }
26
+ end
27
+ end
28
+
29
+ describe '#html_content' do
30
+ let(:article) { build :draft_article }
31
+ subject { article.html_content }
32
+ it { is_expected.to eq "<h1 id=\"content-header\">Content Header</h1>\n" }
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ require 'rails_helper'
2
+
3
+ module Kawara
4
+ RSpec.describe ArticlesMetaTag, type: :model do
5
+
6
+ describe 'associations' do
7
+ it { should belong_to(:article) }
8
+ it { should belong_to(:meta_tag) }
9
+ end
10
+
11
+ describe 'validations' do
12
+ it { should validate_presence_of(:article) }
13
+ it { should validate_presence_of(:meta_tag) }
14
+ end
15
+
16
+ describe 'counter cache' do
17
+ subject { create :kawara_articles_meta_tag, meta_tag: meta_tag }
18
+ let(:meta_tag) { create :kawara_meta_tag }
19
+ it { expect{subject}.to change{meta_tag.articles_count}.from(nil).to(1) }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'rails_helper'
2
+
3
+ module Kawara
4
+ RSpec.describe ArticlesTag, type: :model do
5
+
6
+ describe 'associations' do
7
+ it { should belong_to(:article) }
8
+ it { should belong_to(:tag) }
9
+ end
10
+
11
+ describe 'validations' do
12
+ it { should validate_presence_of(:article) }
13
+ it { should validate_presence_of(:tag) }
14
+ end
15
+
16
+ describe 'counter cache' do
17
+ subject { create :kawara_articles_tag, tag: tag }
18
+ let(:tag) { create :kawara_tag }
19
+ it { expect{subject}.to change{tag.articles_count}.from(nil).to(1) }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails_helper'
2
+
3
+ module Kawara
4
+ RSpec.describe Category, type: :model do
5
+ describe 'associations' do
6
+ it { should have_many(:articles) }
7
+ end
8
+
9
+ describe 'validations' do
10
+ it { should validate_presence_of(:name) }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ module Kawara
4
+ RSpec.describe MetaTag, type: :model do
5
+
6
+ describe 'associations' do
7
+ it { should have_many(:articles_meta_tags) }
8
+ it { should have_many(:articles) }
9
+ end
10
+
11
+ describe 'validations' do
12
+ it { should validate_presence_of(:name) }
13
+
14
+ describe 'uniqueness' do
15
+ subject { build :kawara_meta_tag }
16
+ it { should validate_uniqueness_of(:name) }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ module Kawara
4
+ RSpec.describe Tag, type: :model do
5
+
6
+ describe 'associations' do
7
+ it { should have_many(:articles_tags) }
8
+ it { should have_many(:articles) }
9
+ end
10
+
11
+ describe 'validations' do
12
+ it { should validate_presence_of(:name) }
13
+
14
+ describe 'uniqueness' do
15
+ subject { build :kawara_tag }
16
+ it { should validate_uniqueness_of(:name) }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,58 @@
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', __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
+ # Add additional requires below this line. Rails is not loaded until this point!
9
+ require 'factory_girl_rails'
10
+ require 'ammeter/init'
11
+ require 'temping'
12
+ require 'shoulda/matchers'
13
+
14
+ # Requires supporting ruby files with custom matchers and macros, etc, in
15
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
16
+ # run as spec files by default. This means that files in spec/support that end
17
+ # in _spec.rb will both be required and run as specs, causing the specs to be
18
+ # run twice. It is recommended that you do not name files matching this glob to
19
+ # end with _spec.rb. You can configure this pattern with the --pattern
20
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
21
+ #
22
+ # The following line is provided for convenience purposes. It has the downside
23
+ # of increasing the boot-up time by auto-requiring all files in the support
24
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
25
+ # require only the support files necessary.
26
+ #
27
+ Dir[Rails.root.join('../support/**/*.rb')].each { |f| require f }
28
+
29
+ # Checks for pending migration and applies them before tests are run.
30
+ # If you are not using ActiveRecord, you can remove this line.
31
+ ActiveRecord::Migration.maintain_test_schema!
32
+
33
+ RSpec.configure do |config|
34
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
35
+ # examples within a transaction, remove the following line or assign false
36
+ # instead of true.
37
+ config.use_transactional_fixtures = true
38
+
39
+ # RSpec Rails can automatically mix in different behaviours to your tests
40
+ # based on their file location, for example enabling you to call `get` and
41
+ # `post` in specs under `spec/controllers`.
42
+ #
43
+ # You can disable this behaviour by removing the line below, and instead
44
+ # explicitly tag your specs with their type, e.g.:
45
+ #
46
+ # RSpec.describe UsersController, :type => :controller do
47
+ # # ...
48
+ # end
49
+ #
50
+ # The different available types are documented in the features, such as in
51
+ # https://relishapp.com/rspec/rspec-rails/docs
52
+ config.infer_spec_type_from_file_location!
53
+
54
+ # Filter lines from Rails gems in backtraces.
55
+ config.filter_rails_from_backtrace!
56
+ # arbitrary gems may also be filtered via:
57
+ # config.filter_gems_from_backtrace("gem name")
58
+ end
@@ -0,0 +1,92 @@
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # Run specs in random order to surface order dependencies. If you find an
44
+ # order dependency and want to debug it, you can fix the order by providing
45
+ # the seed, which is printed after each run.
46
+ # --seed 1234
47
+ config.order = :random
48
+
49
+ # The settings below are suggested to provide a good initial experience
50
+ # with RSpec, but feel free to customize to your heart's content.
51
+ =begin
52
+ # These two settings work together to allow you to limit a spec run
53
+ # to individual examples or groups you care about by tagging them with
54
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
55
+ # get run.
56
+ config.filter_run :focus
57
+ config.run_all_when_everything_filtered = true
58
+
59
+ # Allows RSpec to persist some state between runs in order to support
60
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
61
+ # you configure your source control system to ignore this file.
62
+ config.example_status_persistence_file_path = "spec/examples.txt"
63
+
64
+ # Limits the available syntax to the non-monkey patched syntax that is
65
+ # recommended. For more details, see:
66
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
67
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
68
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
69
+ config.disable_monkey_patching!
70
+
71
+ # Many RSpec users commonly either run the entire suite or an individual
72
+ # file, and it's useful to allow more verbose output when running an
73
+ # individual spec file.
74
+ if config.files_to_run.one?
75
+ # Use the documentation formatter for detailed output,
76
+ # unless a formatter has already been configured
77
+ # (e.g. via a command-line flag).
78
+ config.default_formatter = 'doc'
79
+ end
80
+
81
+ # Print the 10 slowest examples and example groups at the
82
+ # end of the spec run, to help surface which specs are running
83
+ # particularly slow.
84
+ config.profile_examples = 10
85
+
86
+ # Seed global randomization in this process using the `--seed` CLI option.
87
+ # Setting this allows you to use `--seed` to deterministically reproduce
88
+ # test failures related to randomization by passing the same `--seed` value
89
+ # as the one that triggered the failure.
90
+ Kernel.srand config.seed
91
+ =end
92
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
@@ -0,0 +1,15 @@
1
+ # https://github.com/refile/refile/blob/49efe827717bca12f31c5f3a4f6973509a46508e/lib/refile/file_double.rb
2
+
3
+ module Refile
4
+ class FileDouble
5
+ attr_reader :original_filename, :content_type
6
+ def initialize(data, name = nil, content_type: nil)
7
+ @io = StringIO.new(data)
8
+ @original_filename = name
9
+ @content_type = content_type
10
+ end
11
+
12
+ extend Forwardable
13
+ def_delegators :@io, :read, :rewind, :size, :eof?, :close
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ Shoulda::Matchers.configure do |config|
2
+ config.integrate do |with|
3
+ with.test_framework :rspec
4
+ with.library :rails
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.after do
3
+ Temping.teardown
4
+ end
5
+ end