kuroko2 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 (338) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +15 -0
  4. data/Rakefile +26 -0
  5. data/app/assets/images/kuroko2/avatar.png +0 -0
  6. data/app/assets/images/kuroko2/kuroko-logo-horizontal.png +0 -0
  7. data/app/assets/javascripts/kuroko2/application.js +28 -0
  8. data/app/assets/javascripts/kuroko2/bootstrap.js +2363 -0
  9. data/app/assets/javascripts/kuroko2/definition_linker.js +20 -0
  10. data/app/assets/javascripts/kuroko2/instance_linker.js +10 -0
  11. data/app/assets/javascripts/kuroko2/job_definition_stats.js +67 -0
  12. data/app/assets/javascripts/kuroko2/job_definitions.js +79 -0
  13. data/app/assets/javascripts/kuroko2/job_instances.js +88 -0
  14. data/app/assets/javascripts/kuroko2/job_timelines.js.coffee +24 -0
  15. data/app/assets/javascripts/kuroko2/narrow_job_definitions.js +30 -0
  16. data/app/assets/stylesheets/kuroko2/admin-lte.css +3402 -0
  17. data/app/assets/stylesheets/kuroko2/application.scss +86 -0
  18. data/app/assets/stylesheets/kuroko2/bootstrap.css +6799 -0
  19. data/app/assets/stylesheets/kuroko2/fonts.scss +1 -0
  20. data/app/assets/stylesheets/kuroko2/job_definitions.scss +19 -0
  21. data/app/assets/stylesheets/kuroko2/users.scss +7 -0
  22. data/app/controllers/kuroko2/api/application_controller.rb +49 -0
  23. data/app/controllers/kuroko2/api/job_instances_controller.rb +46 -0
  24. data/app/controllers/kuroko2/api/stats_controller.rb +28 -0
  25. data/app/controllers/kuroko2/application_controller.rb +43 -0
  26. data/app/controllers/kuroko2/dashboard_controller.rb +27 -0
  27. data/app/controllers/kuroko2/execution_logs_controller.rb +19 -0
  28. data/app/controllers/kuroko2/executions_controller.rb +28 -0
  29. data/app/controllers/kuroko2/job_definition_stats_controller.rb +54 -0
  30. data/app/controllers/kuroko2/job_definitions_controller.rb +100 -0
  31. data/app/controllers/kuroko2/job_instances_controller.rb +87 -0
  32. data/app/controllers/kuroko2/job_schedules_controller.rb +39 -0
  33. data/app/controllers/kuroko2/job_suspend_schedules_controller.rb +38 -0
  34. data/app/controllers/kuroko2/job_timelines_controller.rb +56 -0
  35. data/app/controllers/kuroko2/logs_controller.rb +15 -0
  36. data/app/controllers/kuroko2/sessions_controller.rb +32 -0
  37. data/app/controllers/kuroko2/stars_controller.rb +30 -0
  38. data/app/controllers/kuroko2/tokens_controller.rb +47 -0
  39. data/app/controllers/kuroko2/users_controller.rb +62 -0
  40. data/app/controllers/kuroko2/workers_controller.rb +5 -0
  41. data/app/errors/http/bad_request.rb +4 -0
  42. data/app/errors/http/forbidden.rb +4 -0
  43. data/app/errors/http/unauthorized.rb +4 -0
  44. data/app/helpers/kuroko2/application_helper.rb +8 -0
  45. data/app/helpers/kuroko2/dashboard_helper.rb +4 -0
  46. data/app/helpers/kuroko2/executions_helper.rb +4 -0
  47. data/app/helpers/kuroko2/job_definitions_helper.rb +38 -0
  48. data/app/helpers/kuroko2/job_instances_helper.rb +71 -0
  49. data/app/helpers/kuroko2/job_schedules_helper.rb +4 -0
  50. data/app/helpers/kuroko2/logs_helper.rb +4 -0
  51. data/app/helpers/kuroko2/sessions_helper.rb +4 -0
  52. data/app/helpers/kuroko2/stars_helper.rb +4 -0
  53. data/app/helpers/kuroko2/tokens_helper.rb +4 -0
  54. data/app/helpers/kuroko2/users_helper.rb +4 -0
  55. data/app/helpers/kuroko2/workers_helper.rb +4 -0
  56. data/app/jobs/kuroko2/application_job.rb +4 -0
  57. data/app/mailers/kuroko2/application_mailer.rb +6 -0
  58. data/app/mailers/kuroko2/notifications.rb +63 -0
  59. data/app/models/concerns/kuroko2/table_name_customizable.rb +16 -0
  60. data/app/models/kuroko2/admin_assignment.rb +6 -0
  61. data/app/models/kuroko2/api/application_resource.rb +10 -0
  62. data/app/models/kuroko2/api/job_instance_resource.rb +7 -0
  63. data/app/models/kuroko2/application_record.rb +5 -0
  64. data/app/models/kuroko2/execution.rb +55 -0
  65. data/app/models/kuroko2/job_definition.rb +147 -0
  66. data/app/models/kuroko2/job_definition_tag.rb +6 -0
  67. data/app/models/kuroko2/job_instance.rb +118 -0
  68. data/app/models/kuroko2/job_schedule.rb +93 -0
  69. data/app/models/kuroko2/job_suspend_schedule.rb +35 -0
  70. data/app/models/kuroko2/log.rb +3 -0
  71. data/app/models/kuroko2/memory_consumption_log.rb +49 -0
  72. data/app/models/kuroko2/memory_expectancy.rb +21 -0
  73. data/app/models/kuroko2/process_signal.rb +14 -0
  74. data/app/models/kuroko2/star.rb +6 -0
  75. data/app/models/kuroko2/tag.rb +8 -0
  76. data/app/models/kuroko2/tick.rb +12 -0
  77. data/app/models/kuroko2/token.rb +101 -0
  78. data/app/models/kuroko2/user.rb +48 -0
  79. data/app/models/kuroko2/worker.rb +12 -0
  80. data/app/views/kaminari/history/_paginator.html.slim +15 -0
  81. data/app/views/kaminari/list/_paginator.html.slim +17 -0
  82. data/app/views/kuroko2/dashboard/_taglist.html.slim +13 -0
  83. data/app/views/kuroko2/dashboard/index.html.slim +49 -0
  84. data/app/views/kuroko2/execution_logs/index.json.jbuilder +16 -0
  85. data/app/views/kuroko2/executions/index.html.slim +35 -0
  86. data/app/views/kuroko2/job_definition_stats/execution_time.json.jbuilder +13 -0
  87. data/app/views/kuroko2/job_definition_stats/index.html.slim +48 -0
  88. data/app/views/kuroko2/job_definition_stats/memory.json.jbuilder +10 -0
  89. data/app/views/kuroko2/job_definitions/_alert.html.slim +7 -0
  90. data/app/views/kuroko2/job_definitions/_form.html.slim +93 -0
  91. data/app/views/kuroko2/job_definitions/_list.html.slim +26 -0
  92. data/app/views/kuroko2/job_definitions/_search_results.html.slim +51 -0
  93. data/app/views/kuroko2/job_definitions/_taglist.html.slim +13 -0
  94. data/app/views/kuroko2/job_definitions/edit.html.slim +15 -0
  95. data/app/views/kuroko2/job_definitions/index.html.slim +11 -0
  96. data/app/views/kuroko2/job_definitions/new.html.slim +12 -0
  97. data/app/views/kuroko2/job_definitions/show.html.slim +90 -0
  98. data/app/views/kuroko2/job_instances/_instance.html.slim +42 -0
  99. data/app/views/kuroko2/job_instances/index.html.slim +58 -0
  100. data/app/views/kuroko2/job_instances/show.html.slim +19 -0
  101. data/app/views/kuroko2/job_instances/working.html.slim +37 -0
  102. data/app/views/kuroko2/job_schedules/index.html.slim +32 -0
  103. data/app/views/kuroko2/job_suspend_schedules/index.html.slim +27 -0
  104. data/app/views/kuroko2/job_timelines/dataset.json.jbuilder +11 -0
  105. data/app/views/kuroko2/job_timelines/index.html.slim +31 -0
  106. data/app/views/kuroko2/kaminari/history/_paginator.html.slim +15 -0
  107. data/app/views/kuroko2/kaminari/list/_paginator.html.slim +17 -0
  108. data/app/views/kuroko2/layouts/application.html.slim +68 -0
  109. data/app/views/kuroko2/logs/index.html.slim +33 -0
  110. data/app/views/kuroko2/notifications/executor_not_assigned.text.erb +22 -0
  111. data/app/views/kuroko2/notifications/job_failure.html.slim +21 -0
  112. data/app/views/kuroko2/notifications/job_failure.text.erb +18 -0
  113. data/app/views/kuroko2/notifications/notify_long_elapsed_time.text.erb +9 -0
  114. data/app/views/kuroko2/notifications/process_absence.text.erb +22 -0
  115. data/app/views/kuroko2/notifications/remind_failure.html.slim +21 -0
  116. data/app/views/kuroko2/notifications/remind_failure.text.erb +10 -0
  117. data/app/views/kuroko2/sessions/new.html.slim +20 -0
  118. data/app/views/kuroko2/tokens/index.html.slim +42 -0
  119. data/app/views/kuroko2/users/index.html.slim +55 -0
  120. data/app/views/kuroko2/users/show.html.slim +76 -0
  121. data/app/views/kuroko2/workers/index.html.slim +40 -0
  122. data/app/views/layouts/kuroko2/application.html.slim +72 -0
  123. data/app/views/layouts/mailer.html.erb +13 -0
  124. data/app/views/layouts/mailer.text.erb +1 -0
  125. data/bin/cleanup_old_instances.rb +9 -0
  126. data/bin/remind_failure.rb +5 -0
  127. data/config/initializers/000_kuroko2.rb +16 -0
  128. data/config/initializers/assets.rb +9 -0
  129. data/config/initializers/garage.rb +2 -0
  130. data/config/initializers/kaminari_config.rb +3 -0
  131. data/config/initializers/omniauth.rb +5 -0
  132. data/config/locales/en.yml +28 -0
  133. data/config/routes.rb +54 -0
  134. data/db/migrate/001_create_job_definitions.rb +22 -0
  135. data/db/migrate/002_create_job_instances.rb +17 -0
  136. data/db/migrate/003_create_job_schedules.rb +14 -0
  137. data/db/migrate/004_create_ticks.rb +7 -0
  138. data/db/migrate/005_create_logs.rb +13 -0
  139. data/db/migrate/006_create_tokens.rb +21 -0
  140. data/db/migrate/007_create_executions.rb +26 -0
  141. data/db/migrate/008_create_process_signals.rb +15 -0
  142. data/db/migrate/009_create_users.rb +20 -0
  143. data/db/migrate/010_create_admin_assignments.rb +12 -0
  144. data/db/migrate/011_create_stars.rb +12 -0
  145. data/db/migrate/012_create_workers.rb +15 -0
  146. data/db/migrate/018_create_job_definition_tags.rb +13 -0
  147. data/db/migrate/019_create_tags.rb +11 -0
  148. data/db/migrate/021_create_memory_expectancies.rb +17 -0
  149. data/db/migrate/025_create_job_suspend_schedules.rb +12 -0
  150. data/lib/kuroko2/command/executor.rb +62 -0
  151. data/lib/kuroko2/command/kill.rb +24 -0
  152. data/lib/kuroko2/command/monitor.rb +109 -0
  153. data/lib/kuroko2/command/shell.rb +163 -0
  154. data/lib/kuroko2/configuration.rb +19 -0
  155. data/lib/kuroko2/engine.rb +59 -0
  156. data/lib/kuroko2/execution_logger/cloud_watch_logs.rb +92 -0
  157. data/lib/kuroko2/execution_logger/void.rb +13 -0
  158. data/lib/kuroko2/execution_logger.rb +20 -0
  159. data/lib/kuroko2/memory_sampler.rb +50 -0
  160. data/lib/kuroko2/return_to_validator.rb +14 -0
  161. data/lib/kuroko2/servers/base.rb +30 -0
  162. data/lib/kuroko2/servers/command_executor.rb +27 -0
  163. data/lib/kuroko2/servers/job_scheduler.rb +25 -0
  164. data/lib/kuroko2/servers/workflow_processor.rb +25 -0
  165. data/lib/kuroko2/util/logger.rb +19 -0
  166. data/lib/kuroko2/util/rails_logger_formatter.rb +9 -0
  167. data/lib/kuroko2/version.rb +3 -0
  168. data/lib/kuroko2/workflow/assertion_error.rb +6 -0
  169. data/lib/kuroko2/workflow/engine.rb +141 -0
  170. data/lib/kuroko2/workflow/engine_error.rb +6 -0
  171. data/lib/kuroko2/workflow/node.rb +124 -0
  172. data/lib/kuroko2/workflow/notifier/concerns/chat_message_builder.rb +39 -0
  173. data/lib/kuroko2/workflow/notifier/hipchat.rb +88 -0
  174. data/lib/kuroko2/workflow/notifier/mail.rb +44 -0
  175. data/lib/kuroko2/workflow/notifier/slack.rb +121 -0
  176. data/lib/kuroko2/workflow/notifier.rb +31 -0
  177. data/lib/kuroko2/workflow/processor.rb +40 -0
  178. data/lib/kuroko2/workflow/scheduler.rb +42 -0
  179. data/lib/kuroko2/workflow/script_parser.rb +66 -0
  180. data/lib/kuroko2/workflow/shell_scanner.rb +34 -0
  181. data/lib/kuroko2/workflow/syntax_error.rb +6 -0
  182. data/lib/kuroko2/workflow/task/auto_skip_error.rb +20 -0
  183. data/lib/kuroko2/workflow/task/base.rb +32 -0
  184. data/lib/kuroko2/workflow/task/env.rb +45 -0
  185. data/lib/kuroko2/workflow/task/execute.rb +128 -0
  186. data/lib/kuroko2/workflow/task/expected_time.rb +9 -0
  187. data/lib/kuroko2/workflow/task/fork.rb +45 -0
  188. data/lib/kuroko2/workflow/task/kuroko_runner.rb +24 -0
  189. data/lib/kuroko2/workflow/task/noop.rb +13 -0
  190. data/lib/kuroko2/workflow/task/queue.rb +27 -0
  191. data/lib/kuroko2/workflow/task/rails_env.rb +24 -0
  192. data/lib/kuroko2/workflow/task/sequence.rb +13 -0
  193. data/lib/kuroko2/workflow/task/sleep.rb +29 -0
  194. data/lib/kuroko2/workflow/task/sub_process.rb +53 -0
  195. data/lib/kuroko2/workflow/task/time_base.rb +44 -0
  196. data/lib/kuroko2/workflow/task/timeout.rb +9 -0
  197. data/lib/kuroko2/workflow/task/wait.rb +143 -0
  198. data/lib/kuroko2.rb +26 -0
  199. data/lib/tasks/kuroko2_tasks.rake +4 -0
  200. data/spec/command/kill_spec.rb +20 -0
  201. data/spec/command/monitor_spec.rb +68 -0
  202. data/spec/command/shell_spec.rb +87 -0
  203. data/spec/controllers/dashboard_controller_spec.rb +5 -0
  204. data/spec/controllers/executions_controller_spec.rb +23 -0
  205. data/spec/controllers/job_definition_stats_controller_spec.rb +95 -0
  206. data/spec/controllers/job_definitions_controller_spec.rb +89 -0
  207. data/spec/controllers/job_instances_controller_spec.rb +62 -0
  208. data/spec/controllers/job_schedules_controller_spec.rb +39 -0
  209. data/spec/controllers/job_suspend_schedules_controller_spec.rb +39 -0
  210. data/spec/controllers/job_timelines_controller_spec.rb +114 -0
  211. data/spec/controllers/logs_controller_spec.rb +5 -0
  212. data/spec/controllers/sessions_controller_spec.rb +58 -0
  213. data/spec/controllers/stars_controller_spec.rb +28 -0
  214. data/spec/controllers/tokens_controller_spec.rb +5 -0
  215. data/spec/controllers/users_controller_spec.rb +51 -0
  216. data/spec/controllers/workers_controller_spec.rb +5 -0
  217. data/spec/dummy/Rakefile +6 -0
  218. data/spec/dummy/app/assets/config/manifest.js +5 -0
  219. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  220. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  221. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  222. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  223. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  224. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  225. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  226. data/spec/dummy/app/jobs/application_job.rb +2 -0
  227. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  228. data/spec/dummy/app/models/application_record.rb +3 -0
  229. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  230. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  231. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  232. data/spec/dummy/bin/bundle +3 -0
  233. data/spec/dummy/bin/rails +4 -0
  234. data/spec/dummy/bin/rake +4 -0
  235. data/spec/dummy/bin/setup +34 -0
  236. data/spec/dummy/bin/update +29 -0
  237. data/spec/dummy/config/application.rb +25 -0
  238. data/spec/dummy/config/boot.rb +3 -0
  239. data/spec/dummy/config/cable.yml +9 -0
  240. data/spec/dummy/config/database.yml +29 -0
  241. data/spec/dummy/config/environment.rb +5 -0
  242. data/spec/dummy/config/environments/development.rb +54 -0
  243. data/spec/dummy/config/environments/production.rb +86 -0
  244. data/spec/dummy/config/environments/test.rb +42 -0
  245. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
  246. data/spec/dummy/config/initializers/assets.rb +11 -0
  247. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  248. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  249. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  250. data/spec/dummy/config/initializers/inflections.rb +16 -0
  251. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  252. data/spec/dummy/config/initializers/new_framework_defaults.rb +23 -0
  253. data/spec/dummy/config/initializers/session_store.rb +3 -0
  254. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  255. data/spec/dummy/config/kuroko2.yml +35 -0
  256. data/spec/dummy/config/locales/en.yml +23 -0
  257. data/spec/dummy/config/puma.rb +47 -0
  258. data/spec/dummy/config/routes.rb +3 -0
  259. data/spec/dummy/config/secrets.yml +22 -0
  260. data/spec/dummy/config/spring.rb +6 -0
  261. data/spec/dummy/config.ru +5 -0
  262. data/spec/dummy/db/schema.rb +217 -0
  263. data/spec/dummy/lib/dummy_extention.rb +14 -0
  264. data/spec/dummy/lib/kuroko2/workflow/task/custom_task1.rb +13 -0
  265. data/spec/dummy/public/404.html +67 -0
  266. data/spec/dummy/public/422.html +67 -0
  267. data/spec/dummy/public/500.html +66 -0
  268. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  269. data/spec/dummy/public/apple-touch-icon.png +0 -0
  270. data/spec/dummy/public/favicon.ico +0 -0
  271. data/spec/execution_logger/cloud_watch_logs_spec.rb +95 -0
  272. data/spec/factories/execution_factory.rb +13 -0
  273. data/spec/factories/job_definition_factory.rb +21 -0
  274. data/spec/factories/job_instance_factory.rb +4 -0
  275. data/spec/factories/job_schedule_factory.rb +10 -0
  276. data/spec/factories/job_suspend_schedule_factory.rb +8 -0
  277. data/spec/factories/memory_expectancy_factory.rb +5 -0
  278. data/spec/factories/process_signal_factory.rb +4 -0
  279. data/spec/factories/star_factory.rb +4 -0
  280. data/spec/factories/tick_factory.rb +4 -0
  281. data/spec/factories/token_factory.rb +10 -0
  282. data/spec/factories/user_factory.rb +11 -0
  283. data/spec/factories/worker_factory.rb +8 -0
  284. data/spec/features/dashborad_spec.rb +82 -0
  285. data/spec/features/job_definition_spec.rb +74 -0
  286. data/spec/features/job_instance_spec.rb +94 -0
  287. data/spec/features/sign_in_and_out_spec.rb +17 -0
  288. data/spec/features/users_spec.rb +90 -0
  289. data/spec/features/workers_spec.rb +44 -0
  290. data/spec/helpers/executions_helper_spec.rb +4 -0
  291. data/spec/helpers/job_definition_helper_spec.rb +42 -0
  292. data/spec/helpers/job_schedules_helper_spec.rb +4 -0
  293. data/spec/helpers/logs_helper_spec.rb +4 -0
  294. data/spec/helpers/tokens_helper_spec.rb +4 -0
  295. data/spec/helpers/users_helper_spec.rb +4 -0
  296. data/spec/helpers/workers_helper_spec.rb +4 -0
  297. data/spec/mailers/notifications_spec.rb +54 -0
  298. data/spec/memory_sampler_spec.rb +11 -0
  299. data/spec/models/admin_assignment_spec.rb +4 -0
  300. data/spec/models/execution_spec.rb +26 -0
  301. data/spec/models/job_definition_spec.rb +163 -0
  302. data/spec/models/job_instance_spec.rb +115 -0
  303. data/spec/models/job_schedule_spec.rb +121 -0
  304. data/spec/models/job_suspend_schedule_spec.rb +32 -0
  305. data/spec/models/memory_consumption_log_spec.rb +50 -0
  306. data/spec/models/memory_expectancy_spec.rb +26 -0
  307. data/spec/models/star_spec.rb +4 -0
  308. data/spec/models/tick_spec.rb +23 -0
  309. data/spec/models/token_spec.rb +54 -0
  310. data/spec/models/user_spec.rb +17 -0
  311. data/spec/models/worker_spec.rb +5 -0
  312. data/spec/rails_helper.rb +81 -0
  313. data/spec/requests/api/job_instances_spec.rb +96 -0
  314. data/spec/requests/api/stats_spec.rb +45 -0
  315. data/spec/return_to_validator_spec.rb +28 -0
  316. data/spec/settings_spec.rb +10 -0
  317. data/spec/spec_helper.rb +49 -0
  318. data/spec/support/feature_sign_in_helper.rb +31 -0
  319. data/spec/support/sign_in_helper.rb +5 -0
  320. data/spec/support/wait_for_ajax.rb +11 -0
  321. data/spec/workflow/engine_spec.rb +241 -0
  322. data/spec/workflow/node_spec.rb +62 -0
  323. data/spec/workflow/notifier/hipchat_spec.rb +117 -0
  324. data/spec/workflow/notifier/mail_spec.rb +86 -0
  325. data/spec/workflow/notifier/slack_spec.rb +110 -0
  326. data/spec/workflow/script_parser_spec.rb +119 -0
  327. data/spec/workflow/shell_scanner_spec.rb +47 -0
  328. data/spec/workflow/task/auto_skip_error_spec.rb +35 -0
  329. data/spec/workflow/task/env_spec.rb +47 -0
  330. data/spec/workflow/task/execute_spec.rb +127 -0
  331. data/spec/workflow/task/expected_time_spec.rb +52 -0
  332. data/spec/workflow/task/fork_spec.rb +30 -0
  333. data/spec/workflow/task/queue_spec.rb +45 -0
  334. data/spec/workflow/task/rails_env_spec.rb +30 -0
  335. data/spec/workflow/task/sleep_spec.rb +22 -0
  336. data/spec/workflow/task/sub_process_spec.rb +32 -0
  337. data/spec/workflow/task/wait_spec.rb +162 -0
  338. metadata +1038 -0
@@ -0,0 +1,121 @@
1
+ require 'rails_helper'
2
+
3
+ describe Kuroko2::JobSchedule do
4
+
5
+ describe '#valid?' do
6
+ it 'accepts only CRON notation' do
7
+ expect(Kuroko2::JobSchedule.new(cron: '* * * * *')).to be_valid
8
+ expect(Kuroko2::JobSchedule.new(cron: '1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,1-3/5')).to be_valid
9
+ expect(Kuroko2::JobSchedule.new(cron: '* * * *')).not_to be_valid
10
+ end
11
+
12
+ it 'accepts only valid CRON notation' do
13
+ expect(Kuroko2::JobSchedule.new(cron: '5-0 * * * *')).not_to be_valid
14
+ end
15
+ end
16
+
17
+ describe '#next' do
18
+ let(:cron) { '0,15,30,45 10 * * *' }
19
+ let(:definition) { create(:job_definition) }
20
+ let(:schedule) { create(:job_schedule, job_definition: definition, cron: cron) }
21
+ let(:time) { Time.new(2016, 1, 1, 10, 0) }
22
+
23
+ context 'Without suspend_schelule' do
24
+ it 'returns next schedule' do
25
+ expect(schedule.next(time)).to eq(Time.new(2016, 1, 1, 10, 15))
26
+ end
27
+ end
28
+
29
+ context 'With suspend_schelule' do
30
+ before do
31
+ create(:job_suspend_schedule, job_definition: definition, cron: '0-29 10 * * *')
32
+ end
33
+
34
+ it 'skips suspend time range' do
35
+ expect(schedule.next(time)).to eq(Time.new(2016, 1, 1, 10, 30))
36
+ end
37
+ end
38
+
39
+ context 'When suspend schelules covers all schedule' do
40
+ before do
41
+ create(:job_suspend_schedule, job_definition: definition, cron: '0-50 10 * * *')
42
+ end
43
+
44
+ it 'returns nil' do
45
+ expect(schedule.next(time)).to be_nil
46
+ end
47
+ end
48
+
49
+ context 'With invalid date' do
50
+ let(:cron) { '* * 31 2 *' }
51
+ let(:time) { Time.new(2016, 2, 28, 10, 0) }
52
+ xit 'occurs infinit loop (https://github.com/r7kamura/chrono/issues/2)' do
53
+ expect(schedule.next(time)).to eq(Time.new(2016, 1, 1, 10, 15))
54
+ end
55
+ end
56
+ end
57
+
58
+ describe '.launch_scheduled_jobs!' do
59
+ let(:definition) { create(:job_definition) }
60
+ let(:time_from) { Time.new(2016, 1, 1, 9, 50, 0) }
61
+
62
+ before do
63
+ create(:job_schedule, job_definition: definition, cron: '0 10 * * *')
64
+ end
65
+
66
+ context 'Without scheduled time' do
67
+ let(:time_to) { Time.new(2016, 1, 1, 9, 58, 0) }
68
+
69
+ it 'does not launch jobs' do
70
+ expect { Kuroko2::JobSchedule.launch_scheduled_jobs!(time_from, time_to) }.
71
+ not_to change { Kuroko2::JobInstance.count }
72
+ end
73
+ end
74
+
75
+ context 'With scheduled time' do
76
+ let(:time_to) { Time.new(2016, 1, 1, 10, 1, 0) }
77
+
78
+ it 'launches jobs' do
79
+ expect { Kuroko2::JobSchedule.launch_scheduled_jobs!(time_from, time_to) }.
80
+ to change { Kuroko2::JobInstance.count }.from(0).to(1)
81
+ end
82
+
83
+ context 'With suspended option' do
84
+ before do
85
+ definition.update!(suspended: true)
86
+ end
87
+
88
+ it 'does not launch jobs' do
89
+ expect { Kuroko2::JobSchedule.launch_scheduled_jobs!(time_from, time_to) }.
90
+ not_to change { Kuroko2::JobInstance.count }
91
+ end
92
+ end
93
+ end
94
+
95
+ context 'With job_suspend_schedule' do
96
+ before do
97
+ create(:job_schedule, job_definition: definition, cron: '* 10 * * *')
98
+ create(:job_suspend_schedule, cron: '0-30 10 * * *', job_definition: definition)
99
+ end
100
+
101
+ context 'On supended time' do
102
+ let(:time_from) { Time.new(2016, 1, 1, 9, 50, 0) }
103
+ let(:time_to) { Time.new(2016, 1, 1, 10, 1, 0) }
104
+
105
+ it 'does not launch jobs' do
106
+ expect { Kuroko2::JobSchedule.launch_scheduled_jobs!(time_from, time_to) }.
107
+ not_to change { Kuroko2::JobInstance.count }
108
+ end
109
+ end
110
+
111
+ context 'Out of supended time' do
112
+ let(:time_from) { Time.new(2016, 1, 1, 10, 30, 0) }
113
+ let(:time_to) { Time.new(2016, 1, 1, 10, 31, 0) }
114
+ it 'launches jobs' do
115
+ expect { Kuroko2::JobSchedule.launch_scheduled_jobs!(time_from, time_to) }.
116
+ to change { Kuroko2::JobInstance.count }.from(0).to(1)
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,32 @@
1
+ require 'rails_helper'
2
+
3
+ describe Kuroko2::JobSuspendSchedule do
4
+ describe '#valid?' do
5
+ it 'accepts only CRON notation' do
6
+ expect(Kuroko2::JobSuspendSchedule.new(cron: '* * * * *')).to be_valid
7
+ expect(Kuroko2::JobSuspendSchedule.new(cron: '1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,1-3/5')).to be_valid
8
+ expect(Kuroko2::JobSuspendSchedule.new(cron: '* * * *')).not_to be_valid
9
+ end
10
+
11
+ it 'accepts only valid CRON notation' do
12
+ expect(Kuroko2::JobSuspendSchedule.new(cron: '5-0 * * * *')).not_to be_valid
13
+ end
14
+ end
15
+
16
+ describe '#suspend_times' do
17
+ let(:suspend_schedule) { create(:job_suspend_schedule, cron: '* 10 * * *') }
18
+ let(:time_from) { Time.new(2016, 1, 1, 10, 0, 0) }
19
+ let(:time_to) { Time.new(2016, 1, 1, 10, 5, 0) }
20
+
21
+ it 'returns suspend times' do
22
+ expect(suspend_schedule.suspend_times(time_from, time_to)).to eq([
23
+ Time.new(2016, 1, 1, 10, 0, 0),
24
+ Time.new(2016, 1, 1, 10, 1, 0),
25
+ Time.new(2016, 1, 1, 10, 2, 0),
26
+ Time.new(2016, 1, 1, 10, 3, 0),
27
+ Time.new(2016, 1, 1, 10, 4, 0),
28
+ Time.new(2016, 1, 1, 10, 5, 0),
29
+ ])
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,50 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Kuroko2::MemoryConsumptionLog do
4
+ around {|example| Timecop.freeze(Time.now) { example.run } }
5
+
6
+ describe described_class::Interval do
7
+ describe '#reached?' do
8
+ let(:interval) { described_class.new(base, count) }
9
+ let(:base) { Time.now }
10
+
11
+ context 'count = 0 and 2 seconds since' do
12
+ let(:count) { 0 }
13
+ let(:now) { 2.seconds.since.to_time }
14
+ it { expect(interval.reached?(now)).to be_truthy }
15
+ end
16
+
17
+ context 'count = 10 and 2 minutes since' do
18
+ let(:count) { 10 }
19
+ let(:now) { 2.minutes.since.to_time }
20
+ it { expect(interval.reached?(now)).to be_truthy }
21
+ end
22
+
23
+ context 'count = 100 and 31 minutes since' do
24
+ let(:count) { 100 }
25
+ let(:now) { 31.minutes.since.to_time }
26
+ it { expect(interval.reached?(now)).to be_truthy }
27
+ end
28
+ end
29
+
30
+ describe '#next' do
31
+ it 'returns count-up-ed Interval' do
32
+ a = described_class.new(Time.now)
33
+ b = a.next
34
+ expect(b).to be_a(described_class)
35
+
36
+ diff = b.count - a.count
37
+ expect(diff).to eq(1)
38
+ end
39
+ end
40
+
41
+ it 'behaves as certain period interval with #reached? and #next' do
42
+ a = described_class.new(Time.now, 100)
43
+ expect(a.reached?(29.minutes.since.to_time)).to be_falsy
44
+ expect(a.reached?(31.minutes.since.to_time)).to be_truthy
45
+ b = a.next
46
+ expect(b.reached?(59.minutes.since.to_time)).to be_falsy
47
+ expect(b.reached?(61.minutes.since.to_time)).to be_truthy
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,26 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Kuroko2::MemoryExpectancy do
4
+ let!(:definition) { create(:job_definition) }
5
+ let!(:instance) { create(:job_instance, job_definition: definition) }
6
+ let!(:expectancy) { described_class.create!(job_definition: definition) }
7
+
8
+ describe 'memory expectancy calculation' do
9
+ before { (1..10).each {|i| instance.log_memory_consumption(i) } }
10
+
11
+ it 'logs consumptions then calculates expectancy' do
12
+ expect(expectancy.expected_value).to eq(described_class::DEFAULT_VALUE)
13
+ expectancy.calculate!
14
+ expect(expectancy.reload.expected_value).not_to eq(described_class::DEFAULT_VALUE)
15
+ end
16
+ end
17
+
18
+ describe '#calculate!' do
19
+ before { (1..10).each {|i| instance.log_memory_consumption(i) } }
20
+
21
+ it 'uses max consumption value' do
22
+ expectancy.calculate!
23
+ expect(expectancy.expected_value).to eq(10)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ require 'rails_helper'
2
+
3
+ describe Kuroko2::Star do
4
+ end
@@ -0,0 +1,23 @@
1
+ require 'rails_helper'
2
+
3
+ describe Kuroko2::Tick do
4
+ describe '.fetch_then_update' do
5
+ let(:prev_now) { Time.at(123456789) }
6
+ let(:now) { Time.at(1234567890) }
7
+
8
+ context 'without previous tick' do
9
+ it do
10
+ expect(Kuroko2::Tick.fetch_then_update(now)).to eq now
11
+ expect(Kuroko2::Tick.first.at).to eq now
12
+ end
13
+ end
14
+ context 'with previous tick' do
15
+ before { create(:tick, at: prev_now) }
16
+
17
+ it do
18
+ expect(Kuroko2::Tick.fetch_then_update(now)).to eq prev_now
19
+ expect(Kuroko2::Tick.first.at).to eq now
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,54 @@
1
+ require 'rails_helper'
2
+
3
+ describe Kuroko2::Token do
4
+ describe '#cancelable?' do
5
+ context 'without children' do
6
+ context 'working' do
7
+ subject! { create(:token, status: Kuroko2::Token::WORKING) }
8
+
9
+ it { is_expected.not_to be_cancelable }
10
+ end
11
+ context 'finished' do
12
+ subject! { create(:token, status: Kuroko2::Token::FINISHED) }
13
+
14
+ it { is_expected.not_to be_cancelable }
15
+ end
16
+ context 'failure' do
17
+ subject! { create(:token, status: Kuroko2::Token::FAILURE) }
18
+
19
+ it { is_expected.to be_cancelable }
20
+ end
21
+ context 'critical' do
22
+ subject! { create(:token, status: Kuroko2::Token::CRITICAL) }
23
+
24
+ it { is_expected.not_to be_cancelable }
25
+ end
26
+ end
27
+
28
+ context 'with children' do
29
+ subject!(:parent) { create(:token, status: Kuroko2::Token::WORKING) }
30
+
31
+ context 'all children are working' do
32
+ before { create(:token, parent_id: parent.id, status: Kuroko2::Token::WORKING) }
33
+ before { create(:token, parent_id: parent.id, status: Kuroko2::Token::WORKING) }
34
+
35
+ it { is_expected.not_to be_cancelable }
36
+ end
37
+
38
+ context 'working and failrue' do
39
+ before { create(:token, parent_id: parent.id, status: Kuroko2::Token::WORKING) }
40
+ before { create(:token, parent_id: parent.id, status: Kuroko2::Token::FAILURE) }
41
+
42
+ it { is_expected.not_to be_cancelable }
43
+ end
44
+
45
+ context 'finished and failure' do
46
+ before { create(:token, parent_id: parent.id, status: Kuroko2::Token::FINISHED) }
47
+ before { create(:token, parent_id: parent.id, status: Kuroko2::Token::FAILURE) }
48
+
49
+ it { is_expected.to be_cancelable }
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails_helper'
2
+
3
+ describe Kuroko2::User do
4
+ describe '#google_account?' do
5
+ subject { user.google_account? }
6
+
7
+ context 'provider is google_oauth2' do
8
+ let(:user) { create(:user, provider: 'google_oauth2') }
9
+ it { is_expected.to be_truthy }
10
+ end
11
+
12
+ context 'provider is not google_oauth2' do
13
+ let(:user) { create(:user, provider: 'group_email') }
14
+ it { is_expected.to be_falsey }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ require 'rails_helper'
2
+
3
+ describe Kuroko2::Worker do
4
+
5
+ end
@@ -0,0 +1,81 @@
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
+
7
+ require 'spec_helper'
8
+ require 'rspec/rails'
9
+ # Add additional requires below this line. Rails is not loaded until this point!
10
+ require 'factory_girl_rails'
11
+
12
+ require 'timecop'
13
+ Timecop.safe_mode = true
14
+
15
+ require 'webmock/rspec'
16
+ WebMock.disable_net_connect!(allow_localhost: true)
17
+
18
+ require 'capybara/rspec'
19
+ require 'capybara/poltergeist'
20
+ Capybara.javascript_driver = :poltergeist
21
+
22
+ OmniAuth.config.test_mode = true
23
+
24
+ # Requires supporting ruby files with custom matchers and macros, etc, in
25
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
26
+ # run as spec files by default. This means that files in spec/support that end
27
+ # in _spec.rb will both be required and run as specs, causing the specs to be
28
+ # run twice. It is recommended that you do not name files matching this glob to
29
+ # end with _spec.rb. You can configure this pattern with with the --pattern
30
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
31
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
32
+
33
+ # Checks for pending migrations before tests are run.
34
+ # If you are not using ActiveRecord, you can remove this line.
35
+ ActiveRecord::Migration.maintain_test_schema!
36
+
37
+ RSpec.configure do |config|
38
+ config.include FactoryGirl::Syntax::Methods
39
+ config.include SignInHelper, type: :controller
40
+ config.include FeatureSignInHelper, type: :feature
41
+ config.include WaitForAjax, type: :feature
42
+
43
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
44
+ # examples within a transaction, remove the following line or assign false
45
+ # instead of true.
46
+ config.use_transactional_fixtures = false
47
+
48
+ # RSpec Rails can automatically mix in different behaviours to your tests
49
+ # based on their file location, for example enabling you to call `get` and
50
+ # `post` in specs under `spec/controllers`.
51
+ #
52
+ # You can disable this behaviour by removing the line below, and instead
53
+ # explicitly tag your specs with their type, e.g.:
54
+ #
55
+ # RSpec.describe UsersController, :type => :controller do
56
+ # # ...
57
+ # end
58
+ #
59
+ # The different available types are documented in the features, such as in
60
+ # https://relishapp.com/rspec/rspec-rails/docs
61
+ config.infer_spec_type_from_file_location!
62
+
63
+ # Filter lines from Rails gems in backtraces.
64
+ config.filter_rails_from_backtrace!
65
+ # arbitrary gems may also be filtered via:
66
+ # config.filter_gems_from_backtrace("gem name")
67
+
68
+ config.after(:each) do
69
+ Capybara.reset_sessions!
70
+ DatabaseRewinder.clean
71
+ end
72
+
73
+ config.around do |e|
74
+ begin
75
+ original_env = ENV.to_h.dup
76
+ e.run
77
+ ensure
78
+ ENV.replace(original_env)
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,96 @@
1
+ require 'rails_helper'
2
+
3
+ describe 'job_instances' do
4
+ let(:service_name) { :test_client_name }
5
+ let(:secret_key) { 'secret_key' }
6
+ let(:result) { JSON.parse(response.body) }
7
+ let(:env) do
8
+ {
9
+ accept: 'application/json',
10
+ authorization: "Basic #{Base64.encode64("#{service_name}:#{secret_key}")}",
11
+ }
12
+ end
13
+ let(:definition) do
14
+ create(:job_definition, script: 'execute: bundle exec rake test:execute', api_allowed: true)
15
+ end
16
+
17
+ describe 'GET /v1/definitions/:job_definition_name/instances/:job_instance_id' do
18
+ context 'with job_instance working' do
19
+ let(:instance) { create(:job_instance, job_definition: definition, finished_at: nil, error_at: nil, canceled_at: nil) }
20
+
21
+ it 'returns "working" as status' do
22
+ get "/v1/definitions/#{definition.id}/instances/#{instance.id}", params: {}, env: env
23
+ expect(response.status).to eq(200)
24
+ expect(result).to eq({
25
+ 'id' => instance.id,
26
+ 'status' => 'working',
27
+ })
28
+ end
29
+ end
30
+
31
+ context 'with job_instance succeeded' do
32
+ let(:instance) { create(:job_instance, job_definition: definition, finished_at: Time.now, error_at: nil, canceled_at: nil) }
33
+
34
+ it 'returns "success" as status' do
35
+ get "/v1/definitions/#{definition.id}/instances/#{instance.id}", params: {}, env: env
36
+ expect(response.status).to eq(200)
37
+ expect(result).to eq({
38
+ 'id' => instance.id,
39
+ 'status' => 'success',
40
+ })
41
+ end
42
+ end
43
+ end
44
+
45
+ describe 'POST /v1/definitions/:job_definition_name/instances' do
46
+ let(:params) { {} }
47
+
48
+ it 'creates a job_instance' do
49
+ expect {
50
+ post "/v1/definitions/#{definition.id}/instances", params: params, env: env
51
+ }.to change {
52
+ definition.job_instances.count
53
+ }.by(1)
54
+ expect(definition.job_instances.last.script).to eq(definition.script)
55
+ expect(result).to match({
56
+ 'id' => a_kind_of(Integer),
57
+ 'status' => 'working',
58
+ })
59
+ end
60
+
61
+ context 'given env parameter' do
62
+ let(:env_vars) do
63
+ { 'JOB_NAME' => 'TestJob', 'MESSAGE' => %q{["it's a job"]} }
64
+ end
65
+ let(:params) { { env: env_vars } }
66
+
67
+ it 'creates a job_instance with env task' do
68
+ expect {
69
+ post "/v1/definitions/#{definition.id}/instances", params: params, env: env
70
+ }.to change {
71
+ definition.job_instances.count
72
+ }.by(1)
73
+ expect(definition.job_instances.last.script).to eq(<<-SCRIPT.strip_heredoc.rstrip)
74
+ env: JOB_NAME='TestJob'
75
+ env: MESSAGE='["it\\'s a job"]'
76
+ #{definition.script}
77
+ SCRIPT
78
+ end
79
+ end
80
+
81
+ context 'when job_definition is not api_allowed' do
82
+ let(:definition) do
83
+ create(:job_definition, script: 'execute: bundle exec rake test:execute', api_allowed: false)
84
+ end
85
+
86
+ it 'does not create a job_instance' do
87
+ expect {
88
+ post "/v1/definitions/#{definition.id}/instances", params: params, env: env
89
+ }.to_not change {
90
+ definition.job_instances.count
91
+ }
92
+ expect(response.status).to eq(403)
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,45 @@
1
+ require 'rails_helper'
2
+
3
+ describe 'stats api' do
4
+ describe 'GET /v1/stats/instance' do
5
+ before do
6
+ create(:job_instance, job_definition: create(:job_definition))
7
+ create(:job_instance, job_definition: create(:job_definition)).touch(:error_at)
8
+
9
+ get '/v1/stats/instance'
10
+ end
11
+
12
+ it 'returns instance stats json' do
13
+ expect(response.status).to eq(200)
14
+ result = JSON.parse(response.body)
15
+ expect(result).to eq({
16
+ "kuroko2.job_instances.working" => 1,
17
+ "kuroko2.job_instances.error" => 1,
18
+ })
19
+ end
20
+ end
21
+
22
+ describe 'GET /v1/stats/waiting_execution' do
23
+ let!(:worker) { create(:worker) }
24
+
25
+ before do
26
+ create(
27
+ :execution,
28
+ job_definition: create(:job_definition),
29
+ token: create(:token),
30
+ started_at: nil,
31
+ created_at: 4.minutes.ago,
32
+ )
33
+
34
+ get '/v1/stats/waiting_execution'
35
+ end
36
+
37
+ it 'returns waiting execution stats json' do
38
+ expect(response.status).to eq(200)
39
+ result = JSON.parse(response.body)
40
+ expect(result).to eq({
41
+ "kuroko2.executions.waiting.#{worker.queue}" => 1
42
+ })
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,28 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Kuroko2::ReturnToValidator do
4
+ let(:validator) { described_class }
5
+
6
+ describe '.valid?' do
7
+ it 'accepts a valid path' do
8
+ expect(validator).to be_valid('/users/1')
9
+ end
10
+
11
+ it 'rejects absolute URI' do
12
+ expect(validator).to_not be_valid('http://example.net')
13
+ end
14
+
15
+ it 'rejects protocol-relative URI' do
16
+ expect(validator).to_not be_valid('//example.net')
17
+ end
18
+
19
+ it 'rejects non-URI' do
20
+ expect(validator).to_not be_valid(nil)
21
+ expect(validator).to_not be_valid('http:')
22
+ end
23
+
24
+ it 'rejects path starting with @' do
25
+ expect(validator).to_not be_valid('@example.net')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,10 @@
1
+ require 'rails_helper'
2
+
3
+ module Kuroko2
4
+ describe 'Check if settings is loaded' do
5
+ it 'loads custom tasks' do
6
+ expect(Workflow::Node::TASK_REGISTORY).to have_key(:custom_task1)
7
+ expect(Workflow::ScriptParser.new('custom_task1:').parse).to be_a(Workflow::Node)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,49 @@
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
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
44
+ # have no way to turn it off -- the option exists only for backwards
45
+ # compatibility in RSpec 3). It causes shared context metadata to be
46
+ # inherited by the metadata hash of host groups and examples, rather than
47
+ # triggering implicit auto-inclusion in groups with matching metadata.
48
+ config.shared_context_metadata_behavior = :apply_to_host_groups
49
+ end