engineyard-serverside 2.8.0.pre4 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (308) hide show
  1. checksums.yaml +13 -5
  2. data/features/hook/running-a-deploy-hook.feature +277 -0
  3. data/features/hook/step_definitions/running-a-deploy-hook-steps.rb +200 -0
  4. data/features/step_definitions/command_steps.rb +8 -0
  5. data/features/step_definitions/version_steps.rb +5 -0
  6. data/features/support/env.rb +63 -0
  7. data/features/support/error_codes.rb +17 -0
  8. data/features/support/fs_helpers.rb +82 -0
  9. data/features/support/output_helpers.rb +7 -0
  10. data/features/support/runner.rb +41 -0
  11. data/features/version.feature +7 -0
  12. data/lib/engineyard-serverside/cli/app.rb +6 -0
  13. data/lib/engineyard-serverside/configuration.rb +3 -3
  14. data/lib/engineyard-serverside/deploy.rb +2 -1
  15. data/lib/engineyard-serverside/propagator.rb +1 -1
  16. data/lib/engineyard-serverside/shell.rb +38 -10
  17. data/lib/engineyard-serverside/version.rb +1 -1
  18. data/lib/engineyard-serverside.rb +2 -5
  19. data/spec/engineyard-serverside/callbacks/collection/combined_spec.rb +232 -0
  20. data/spec/engineyard-serverside/callbacks/collection/deploy_hooks_spec.rb +170 -0
  21. data/spec/engineyard-serverside/callbacks/collection/service_hooks/collection_spec.rb +171 -0
  22. data/spec/engineyard-serverside/callbacks/collection/service_hooks/combined_spec.rb +174 -0
  23. data/spec/engineyard-serverside/callbacks/collection/service_hooks_spec.rb +31 -0
  24. data/spec/engineyard-serverside/callbacks/collection_spec.rb +49 -0
  25. data/spec/engineyard-serverside/callbacks/distributor/remote_spec.rb +135 -0
  26. data/spec/engineyard-serverside/callbacks/distributor/viability_filter_spec.rb +208 -0
  27. data/spec/engineyard-serverside/callbacks/distributor_spec.rb +43 -0
  28. data/spec/engineyard-serverside/callbacks/executor/executable_spec.rb +386 -0
  29. data/spec/engineyard-serverside/callbacks/executor/ruby/context_spec.rb +538 -0
  30. data/spec/engineyard-serverside/callbacks/executor/ruby/executor_spec.rb +313 -0
  31. data/spec/engineyard-serverside/callbacks/executor/ruby_spec.rb +35 -0
  32. data/spec/engineyard-serverside/callbacks/executor_spec.rb +45 -0
  33. data/spec/engineyard-serverside/callbacks_spec.rb +31 -0
  34. data/spec/engineyard-serverside/cli/workflows/base_spec.rb +237 -0
  35. data/spec/engineyard-serverside/cli/workflows/calling_deploy_hooks_spec.rb +65 -0
  36. data/spec/engineyard-serverside/cli/workflows/deploying_applications_spec.rb +61 -0
  37. data/spec/engineyard-serverside/cli/workflows/disabling_maintenance_spec.rb +61 -0
  38. data/spec/engineyard-serverside/cli/workflows/enabling_maintenance_spec.rb +61 -0
  39. data/spec/engineyard-serverside/cli/workflows/helpers_spec.rb +64 -0
  40. data/spec/engineyard-serverside/cli/workflows/rolling_back_applications_spec.rb +61 -0
  41. data/spec/engineyard-serverside/cli/workflows/showing_maintenance_status_spec.rb +60 -0
  42. data/spec/engineyard-serverside/cli/workflows_spec.rb +87 -0
  43. data/spec/engineyard-serverside/dependency_manager/base_spec.rb +139 -0
  44. data/spec/engineyard-serverside/paths_spec.rb +820 -0
  45. data/spec/engineyard-serverside/propagator_spec.rb +56 -0
  46. data/spec/engineyard-serverside/server_spec.rb +390 -0
  47. data/spec/engineyard-serverside/shell/helpers_spec.rb +98 -0
  48. data/spec/engineyard-serverside/shell/yieldio_spec.rb +33 -0
  49. data/spec/engineyard-serverside/shell_spec.rb +543 -0
  50. data/spec/engineyard-serverside/slug/distributor_spec.rb +199 -0
  51. data/spec/engineyard-serverside/slug/enabler_spec.rb +191 -0
  52. data/spec/engineyard-serverside/slug/failure_handler_spec.rb +114 -0
  53. data/spec/engineyard-serverside/slug/finalizer_spec.rb +191 -0
  54. data/spec/engineyard-serverside/slug/generator_spec.rb +82 -0
  55. data/spec/engineyard-serverside/slug/migrator_spec.rb +137 -0
  56. data/spec/engineyard-serverside/slug/restarter_spec.rb +226 -0
  57. data/spec/engineyard-serverside/slug/source/updater_spec.rb +710 -0
  58. data/spec/engineyard-serverside/slug/source_spec.rb +40 -0
  59. data/spec/engineyard-serverside/source_spec.rb +171 -0
  60. data/spec/railway_spec.rb +130 -0
  61. data/spec/result/failure_spec.rb +113 -0
  62. data/spec/result/success_spec.rb +109 -0
  63. data/spec/result_spec.rb +23 -0
  64. data/spec/spec_helper.rb +3 -349
  65. metadata +189 -490
  66. data/lib/vendor/json_pure/COPYING +0 -57
  67. data/lib/vendor/json_pure/GPL +0 -340
  68. data/lib/vendor/json_pure/README.rdoc +0 -358
  69. data/lib/vendor/json_pure/VERSION +0 -1
  70. data/lib/vendor/json_pure/lib/json/add/bigdecimal.rb +0 -28
  71. data/lib/vendor/json_pure/lib/json/add/complex.rb +0 -22
  72. data/lib/vendor/json_pure/lib/json/add/core.rb +0 -11
  73. data/lib/vendor/json_pure/lib/json/add/date.rb +0 -34
  74. data/lib/vendor/json_pure/lib/json/add/date_time.rb +0 -48
  75. data/lib/vendor/json_pure/lib/json/add/exception.rb +0 -31
  76. data/lib/vendor/json_pure/lib/json/add/ostruct.rb +0 -31
  77. data/lib/vendor/json_pure/lib/json/add/range.rb +0 -29
  78. data/lib/vendor/json_pure/lib/json/add/rational.rb +0 -22
  79. data/lib/vendor/json_pure/lib/json/add/regexp.rb +0 -30
  80. data/lib/vendor/json_pure/lib/json/add/struct.rb +0 -30
  81. data/lib/vendor/json_pure/lib/json/add/symbol.rb +0 -25
  82. data/lib/vendor/json_pure/lib/json/add/time.rb +0 -38
  83. data/lib/vendor/json_pure/lib/json/common.rb +0 -484
  84. data/lib/vendor/json_pure/lib/json/ext.rb +0 -21
  85. data/lib/vendor/json_pure/lib/json/generic_object.rb +0 -70
  86. data/lib/vendor/json_pure/lib/json/pure/generator.rb +0 -522
  87. data/lib/vendor/json_pure/lib/json/pure/parser.rb +0 -359
  88. data/lib/vendor/json_pure/lib/json/pure.rb +0 -21
  89. data/lib/vendor/json_pure/lib/json/version.rb +0 -8
  90. data/lib/vendor/json_pure/lib/json.rb +0 -62
  91. data/lib/vendor/multi_json/CHANGELOG.md +0 -121
  92. data/lib/vendor/multi_json/CONTRIBUTING.md +0 -46
  93. data/lib/vendor/multi_json/Gemfile +0 -31
  94. data/lib/vendor/multi_json/LICENSE.md +0 -20
  95. data/lib/vendor/multi_json/README.md +0 -105
  96. data/lib/vendor/multi_json/Rakefile +0 -12
  97. data/lib/vendor/multi_json/lib/multi_json/adapters/gson.rb +0 -20
  98. data/lib/vendor/multi_json/lib/multi_json/adapters/json_common.rb +0 -35
  99. data/lib/vendor/multi_json/lib/multi_json/adapters/json_gem.rb +0 -12
  100. data/lib/vendor/multi_json/lib/multi_json/adapters/json_pure.rb +0 -12
  101. data/lib/vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb +0 -35
  102. data/lib/vendor/multi_json/lib/multi_json/adapters/oj.rb +0 -29
  103. data/lib/vendor/multi_json/lib/multi_json/adapters/ok_json.rb +0 -58
  104. data/lib/vendor/multi_json/lib/multi_json/adapters/yajl.rb +0 -20
  105. data/lib/vendor/multi_json/lib/multi_json/vendor/okjson.rb +0 -602
  106. data/lib/vendor/multi_json/lib/multi_json/version.rb +0 -3
  107. data/lib/vendor/multi_json/lib/multi_json.rb +0 -137
  108. data/lib/vendor/multi_json/spec/adapter_shared_example.rb +0 -162
  109. data/lib/vendor/multi_json/spec/helper.rb +0 -45
  110. data/lib/vendor/multi_json/spec/json_common_shared_example.rb +0 -36
  111. data/lib/vendor/multi_json/spec/multi_json_spec.rb +0 -151
  112. data/spec/archive_deploy_spec.rb +0 -53
  113. data/spec/basic_deploy_spec.rb +0 -26
  114. data/spec/bundler_deploy_spec.rb +0 -160
  115. data/spec/configuration_spec.rb +0 -206
  116. data/spec/custom_deploy_spec.rb +0 -128
  117. data/spec/deploy_hook_spec.rb +0 -378
  118. data/spec/deprecation_spec.rb +0 -23
  119. data/spec/ey_yml_customized_deploy_spec.rb +0 -99
  120. data/spec/fixtures/gitrepo.tar.gz +0 -0
  121. data/spec/fixtures/invalid_hook.rb +0 -1
  122. data/spec/fixtures/lockfiles/0.9-no-bundler +0 -111
  123. data/spec/fixtures/lockfiles/0.9-with-bundler +0 -117
  124. data/spec/fixtures/lockfiles/1.0-no-bundler +0 -54
  125. data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +0 -162
  126. data/spec/fixtures/lockfiles/1.0.18-do_mysql +0 -88
  127. data/spec/fixtures/lockfiles/1.0.18-do_postgres +0 -79
  128. data/spec/fixtures/lockfiles/1.0.18-mysql +0 -43
  129. data/spec/fixtures/lockfiles/1.0.18-mysql2 +0 -43
  130. data/spec/fixtures/lockfiles/1.0.18-pg +0 -43
  131. data/spec/fixtures/lockfiles/1.0.6-no-bundler +0 -51
  132. data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +0 -52
  133. data/spec/fixtures/lockfiles/1.0.6-with-bundler +0 -52
  134. data/spec/fixtures/lockfiles/1.15.1-no-bundler +0 -51
  135. data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +0 -112
  136. data/spec/fixtures/lockfiles/not-a-lockfile +0 -1
  137. data/spec/fixtures/repos/assets_detected/Gemfile +0 -5
  138. data/spec/fixtures/repos/assets_detected/Gemfile.lock +0 -88
  139. data/spec/fixtures/repos/assets_detected/README +0 -1
  140. data/spec/fixtures/repos/assets_detected/Rakefile +0 -5
  141. data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
  142. data/spec/fixtures/repos/assets_detected/config/application.rb +0 -5
  143. data/spec/fixtures/repos/assets_detected/config/ey.yml +0 -3
  144. data/spec/fixtures/repos/assets_disabled/Gemfile +0 -5
  145. data/spec/fixtures/repos/assets_disabled/Gemfile.lock +0 -88
  146. data/spec/fixtures/repos/assets_disabled/README +0 -1
  147. data/spec/fixtures/repos/assets_disabled/Rakefile +0 -6
  148. data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
  149. data/spec/fixtures/repos/assets_disabled/config/application.rb +0 -5
  150. data/spec/fixtures/repos/assets_disabled/config/ey.yml +0 -3
  151. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +0 -5
  152. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +0 -88
  153. data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +0 -1
  154. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +0 -6
  155. data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
  156. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +0 -5
  157. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +0 -5
  158. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +0 -5
  159. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +0 -88
  160. data/spec/fixtures/repos/assets_disabled_utf8/README +0 -3
  161. data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +0 -5
  162. data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
  163. data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +0 -7
  164. data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +0 -3
  165. data/spec/fixtures/repos/assets_enabled_all/Gemfile +0 -5
  166. data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +0 -88
  167. data/spec/fixtures/repos/assets_enabled_all/README +0 -1
  168. data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
  169. data/spec/fixtures/repos/assets_enabled_all/config/application.rb +0 -5
  170. data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +0 -6
  171. data/spec/fixtures/repos/assets_enabled_all/script/assets +0 -5
  172. data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +0 -1
  173. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +0 -3
  174. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +0 -10
  175. data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +0 -1
  176. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +0 -8
  177. data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +0 -4
  178. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +0 -5
  179. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +0 -88
  180. data/spec/fixtures/repos/assets_enabled_util_only/README +0 -1
  181. data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +0 -6
  182. data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
  183. data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +0 -5
  184. data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +0 -6
  185. data/spec/fixtures/repos/assets_error/Gemfile +0 -5
  186. data/spec/fixtures/repos/assets_error/Gemfile.lock +0 -88
  187. data/spec/fixtures/repos/assets_error/README +0 -1
  188. data/spec/fixtures/repos/assets_error/Rakefile +0 -4
  189. data/spec/fixtures/repos/assets_error/app/assets/empty +0 -0
  190. data/spec/fixtures/repos/assets_error/config/application.rb +0 -5
  191. data/spec/fixtures/repos/assets_error/config/ey.yml +0 -4
  192. data/spec/fixtures/repos/assets_in_hook/Gemfile +0 -5
  193. data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +0 -88
  194. data/spec/fixtures/repos/assets_in_hook/README +0 -2
  195. data/spec/fixtures/repos/assets_in_hook/Rakefile +0 -5
  196. data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
  197. data/spec/fixtures/repos/assets_in_hook/config/application.rb +0 -5
  198. data/spec/fixtures/repos/assets_in_hook/config/ey.yml +0 -3
  199. data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +0 -2
  200. data/spec/fixtures/repos/bundle_fails/Gemfile +0 -1
  201. data/spec/fixtures/repos/bundle_fails/README +0 -1
  202. data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +0 -1
  203. data/spec/fixtures/repos/bundler_disabled/Gemfile +0 -4
  204. data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +0 -12
  205. data/spec/fixtures/repos/bundler_disabled/README +0 -1
  206. data/spec/fixtures/repos/bundler_disabled/config/ey.yml +0 -2
  207. data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +0 -1
  208. data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +0 -1
  209. data/spec/fixtures/repos/bundler_old/Gemfile +0 -5
  210. data/spec/fixtures/repos/bundler_old/Gemfile.lock +0 -15
  211. data/spec/fixtures/repos/bundler_old/README +0 -1
  212. data/spec/fixtures/repos/default/Gemfile +0 -4
  213. data/spec/fixtures/repos/default/Gemfile.lock +0 -12
  214. data/spec/fixtures/repos/default/README +0 -5
  215. data/spec/fixtures/repos/default/ey.yml +0 -3
  216. data/spec/fixtures/repos/executable_hooks/README +0 -1
  217. data/spec/fixtures/repos/executable_hooks/deploy/before_restart +0 -72
  218. data/spec/fixtures/repos/executable_hooks_not_executable/README +0 -3
  219. data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +0 -3
  220. data/spec/fixtures/repos/ey_yml/Gemfile +0 -4
  221. data/spec/fixtures/repos/ey_yml/Gemfile.lock +0 -12
  222. data/spec/fixtures/repos/ey_yml/README +0 -1
  223. data/spec/fixtures/repos/ey_yml/config/ey.yml +0 -18
  224. data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +0 -6
  225. data/spec/fixtures/repos/ey_yml_alt/Gemfile +0 -4
  226. data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +0 -12
  227. data/spec/fixtures/repos/ey_yml_alt/README +0 -1
  228. data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +0 -6
  229. data/spec/fixtures/repos/ey_yml_alt/ey.yml +0 -12
  230. data/spec/fixtures/repos/hook_fails/README +0 -1
  231. data/spec/fixtures/repos/hook_fails/deploy/before_deploy.rb +0 -1
  232. data/spec/fixtures/repos/hooks/README +0 -1
  233. data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +0 -1
  234. data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +0 -1
  235. data/spec/fixtures/repos/hooks/deploy/after_deploy.rb +0 -1
  236. data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +0 -1
  237. data/spec/fixtures/repos/hooks/deploy/after_restart.rb +0 -1
  238. data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +0 -1
  239. data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +0 -1
  240. data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +0 -1
  241. data/spec/fixtures/repos/hooks/deploy/before_deploy.rb +0 -1
  242. data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +0 -1
  243. data/spec/fixtures/repos/hooks/deploy/before_restart.rb +0 -1
  244. data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +0 -1
  245. data/spec/fixtures/repos/multi_dep_manager/README +0 -1
  246. data/spec/fixtures/repos/multi_dep_manager/composer.json +0 -5
  247. data/spec/fixtures/repos/multi_dep_manager/composer.lock +0 -462
  248. data/spec/fixtures/repos/multi_dep_manager/package.json +0 -7
  249. data/spec/fixtures/repos/multi_dep_manager/public/index.php +0 -4
  250. data/spec/fixtures/repos/no_ey_config/Gemfile +0 -3
  251. data/spec/fixtures/repos/no_ey_config/Gemfile.lock +0 -10
  252. data/spec/fixtures/repos/no_ey_config/README +0 -1
  253. data/spec/fixtures/repos/no_ey_config/ey.yml +0 -3
  254. data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile +0 -3
  255. data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile.lock +0 -10
  256. data/spec/fixtures/repos/no_ey_config_no_warning/README +0 -1
  257. data/spec/fixtures/repos/no_ey_config_no_warning/ey.yml +0 -5
  258. data/spec/fixtures/repos/no_gemfile_lock/Gemfile +0 -4
  259. data/spec/fixtures/repos/no_gemfile_lock/README +0 -1
  260. data/spec/fixtures/repos/no_gemfile_lock/ey.yml +0 -3
  261. data/spec/fixtures/repos/nodejs/README +0 -1
  262. data/spec/fixtures/repos/nodejs/package.json +0 -7
  263. data/spec/fixtures/repos/not_bundled/README +0 -1
  264. data/spec/fixtures/repos/npm_disabled/README +0 -1
  265. data/spec/fixtures/repos/npm_disabled/config/ey.yml +0 -2
  266. data/spec/fixtures/repos/npm_disabled/package.json +0 -7
  267. data/spec/fixtures/repos/php_composer_disabled/README +0 -1
  268. data/spec/fixtures/repos/php_composer_disabled/composer.json +0 -5
  269. data/spec/fixtures/repos/php_composer_disabled/composer.lock +0 -462
  270. data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +0 -2
  271. data/spec/fixtures/repos/php_composer_disabled/public/index.php +0 -4
  272. data/spec/fixtures/repos/php_composer_lock/README +0 -1
  273. data/spec/fixtures/repos/php_composer_lock/composer.json +0 -5
  274. data/spec/fixtures/repos/php_composer_lock/composer.lock +0 -462
  275. data/spec/fixtures/repos/php_composer_lock/public/index.php +0 -4
  276. data/spec/fixtures/repos/php_no_composer_lock/README +0 -1
  277. data/spec/fixtures/repos/php_no_composer_lock/composer.json +0 -21
  278. data/spec/fixtures/repos/php_no_composer_lock/public/index.php +0 -4
  279. data/spec/fixtures/repos/public_system/Gemfile +0 -4
  280. data/spec/fixtures/repos/public_system/Gemfile.lock +0 -12
  281. data/spec/fixtures/repos/public_system/README +0 -5
  282. data/spec/fixtures/repos/public_system/ey.yml +0 -3
  283. data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +0 -3
  284. data/spec/fixtures/repos/sqlite3/Gemfile +0 -4
  285. data/spec/fixtures/repos/sqlite3/Gemfile.lock +0 -89
  286. data/spec/fixtures/repos/sqlite3/README +0 -1
  287. data/spec/fixtures/retwisj.war +0 -0
  288. data/spec/fixtures/valid_hook.rb +0 -1
  289. data/spec/git_strategy_spec.rb +0 -34
  290. data/spec/lockfile_parser_spec.rb +0 -126
  291. data/spec/maintenance_spec.rb +0 -44
  292. data/spec/multi_dependency_manager_spec.rb +0 -25
  293. data/spec/nodejs_deploy_spec.rb +0 -30
  294. data/spec/php_deploy_spec.rb +0 -81
  295. data/spec/platform_configure_spec.rb +0 -61
  296. data/spec/rails31_deploy_spec.rb +0 -172
  297. data/spec/restart_spec.rb +0 -43
  298. data/spec/rollback_spec.rb +0 -87
  299. data/spec/server_spec.rb +0 -70
  300. data/spec/services_deploy_spec.rb +0 -165
  301. data/spec/shell_spec.rb +0 -57
  302. data/spec/source/archive_spec.rb +0 -33
  303. data/spec/source/git_spec.rb +0 -44
  304. data/spec/sqlite3_deploy_spec.rb +0 -38
  305. data/spec/support/integration.rb +0 -103
  306. data/spec/support/source_doubles.rb +0 -28
  307. data/spec/support/timecop.rb +0 -5
  308. data/spec/symlink_spec.rb +0 -15
@@ -0,0 +1,543 @@
1
+ require 'spec_helper'
2
+ require 'timecop'
3
+
4
+ require 'engineyard-serverside/shell'
5
+
6
+ module EY
7
+ module Serverside
8
+
9
+ describe Shell do
10
+ let(:logger) {Object.new}
11
+ let(:start_time) {nil}
12
+ let(:verbose) {nil}
13
+ let(:stdout) {nil}
14
+ let(:stderr) {nil}
15
+ let(:log_path) {'fake.log'}
16
+ let(:options) {
17
+ {
18
+ :start_time => start_time,
19
+ :verbose => verbose,
20
+ :stdout => stdout,
21
+ :stderr => stderr,
22
+ :log_path => log_path
23
+ }
24
+ }
25
+
26
+ let(:now_is_the_time) {Time.local(2020, 02, 14, 13, 0, 0)}
27
+ let(:log_pathname) {Object.new}
28
+ let(:logger) {Object.new}
29
+ let(:formatter) {Object.new}
30
+
31
+ let(:shell) {described_class.new(options)}
32
+
33
+ before(:each) do
34
+ # STub out the logfile to keep from leaving file system artifacts
35
+ allow(Pathname).to receive(:new).with(log_path).and_return(log_pathname)
36
+ allow(log_pathname).to receive(:exist?).and_return(false)
37
+ allow(log_pathname).to receive(:unlink)
38
+ allow(log_pathname).to receive(:to_s).and_return(log_path)
39
+
40
+ # Stub out the actual logger for the same reason
41
+ allow(Logger).to receive(:new).and_return(logger)
42
+ allow(logger).to receive(:formatter=)
43
+ allow(logger).to receive(:level=)
44
+ allow(logger).to receive(:info)
45
+ allow(logger).to receive(:fatal)
46
+ allow(logger).to receive(:error)
47
+ allow(logger).to receive(:debug)
48
+ allow(logger).to receive(:unknown)
49
+
50
+ # So, Object has a private #warn method, so we have to get crafty to stub it.
51
+ # Also, this is dirty as all heck.
52
+ logger.instance_eval do
53
+ def warn(*args)
54
+ end
55
+ end
56
+
57
+ # Let's go ahead and make sure we can predict the time, too.
58
+ Timecop.freeze(now_is_the_time)
59
+ end
60
+
61
+ after(:each) do
62
+ Timecop.return
63
+ end
64
+
65
+ describe '.new' do
66
+ let(:result) {shell}
67
+
68
+ it 'sets the log level to DEBUG' do
69
+ expect(logger).to receive(:level=).with(Logger::DEBUG)
70
+
71
+ result
72
+ end
73
+
74
+ context 'when a start time is provided' do
75
+ let(:start_time) {now_is_the_time + 3600}
76
+
77
+ it 'formats log messages based on that start time' do
78
+ expect(EY::Serverside::Shell::Formatter).
79
+ to receive(:new).
80
+ with($stdout, $stderr, start_time, verbose).
81
+ and_call_original
82
+
83
+ result
84
+ end
85
+ end
86
+
87
+ context 'when no start time is provided' do
88
+ it 'formats log messages based on the current time' do
89
+ expect(EY::Serverside::Shell::Formatter).
90
+ to receive(:new).
91
+ with($stdout, $stderr, now_is_the_time, verbose).
92
+ and_return(formatter)
93
+
94
+ expect(logger).to receive(:formatter=).with(formatter)
95
+
96
+ result
97
+ end
98
+ end
99
+
100
+ context 'when verbosity is requested' do
101
+ let(:verbose) {true}
102
+
103
+ it 'formats log messages verbosely' do
104
+ expect(EY::Serverside::Shell::Formatter).
105
+ to receive(:new).
106
+ with($stdout, $stderr, now_is_the_time, true).
107
+ and_return(formatter)
108
+
109
+ expect(logger).to receive(:formatter=).with(formatter)
110
+
111
+ result
112
+ end
113
+ end
114
+
115
+ context 'when verobisty is disabled' do
116
+ let(:verbose) {false}
117
+
118
+ it 'does not use verbose formatting for logs' do
119
+ expect(EY::Serverside::Shell::Formatter).
120
+ to receive(:new).
121
+ with($stdout, $stderr, now_is_the_time, false).
122
+ and_return(formatter)
123
+
124
+ expect(logger).to receive(:formatter=).with(formatter)
125
+
126
+ result
127
+ end
128
+ end
129
+
130
+ context 'when no verbosity preference is provided' do
131
+ it 'does not use verbose formatting for logs' do
132
+ expect(EY::Serverside::Shell::Formatter).
133
+ to receive(:new).
134
+ with($stdout, $stderr, now_is_the_time, nil).
135
+ and_return(formatter)
136
+
137
+ expect(logger).to receive(:formatter=).with(formatter)
138
+
139
+ result
140
+ end
141
+ end
142
+
143
+ context 'when the provided log path exists' do
144
+ before(:each) do
145
+ allow(log_pathname).to receive(:exist?).and_return(true)
146
+ end
147
+
148
+ it 'unlinks the log file' do
149
+ expect(log_pathname).to receive(:unlink)
150
+
151
+ result
152
+ end
153
+ end
154
+
155
+ context 'when the provided log path does not exist' do
156
+ it 'does not unlink the log file' do
157
+ expect(log_pathname).not_to receive(:unlink)
158
+
159
+ result
160
+ end
161
+ end
162
+
163
+ context 'when stdout is provided' do
164
+ let(:stdout) {Object.new}
165
+
166
+ it 'passes the provided stdout to the formatter' do
167
+ expect(EY::Serverside::Shell::Formatter).
168
+ to receive(:new).
169
+ with(stdout, $stderr, now_is_the_time, verbose).
170
+ and_return(formatter)
171
+
172
+ expect(logger).to receive(:formatter=).with(formatter)
173
+
174
+ result
175
+ end
176
+ end
177
+
178
+ context 'when stdout is not provided' do
179
+ it 'passes the real stdout to the formatter' do
180
+ expect(EY::Serverside::Shell::Formatter).
181
+ to receive(:new).
182
+ with($stdout, $stderr, now_is_the_time, verbose).
183
+ and_return(formatter)
184
+
185
+ expect(logger).to receive(:formatter=).with(formatter)
186
+
187
+ result
188
+ end
189
+ end
190
+
191
+ context 'when stderr is provided' do
192
+ let(:stderr) {Object.new}
193
+
194
+ it 'passes the provided stderr to the formatter' do
195
+ expect(EY::Serverside::Shell::Formatter).
196
+ to receive(:new).
197
+ with($stdout, stderr, now_is_the_time, verbose).
198
+ and_return(formatter)
199
+
200
+ expect(logger).to receive(:formatter=).with(formatter)
201
+
202
+ result
203
+ end
204
+ end
205
+
206
+ context 'when stderr is not provided' do
207
+ it 'passes the real stderr to the formatter' do
208
+ expect(EY::Serverside::Shell::Formatter).
209
+ to receive(:new).
210
+ with($stdout, $stderr, now_is_the_time, verbose).
211
+ and_return(formatter)
212
+
213
+ expect(logger).to receive(:formatter=).with(formatter)
214
+
215
+ result
216
+ end
217
+ end
218
+ end
219
+
220
+ describe '#logger' do
221
+ let(:result) {shell.logger}
222
+
223
+ it 'is the logger created during initilization' do
224
+ expect(result).to eql(logger)
225
+ end
226
+ end
227
+
228
+ describe '#start_time' do
229
+ let(:result) {shell.start_time}
230
+
231
+ context 'when a start time was provided during initialization' do
232
+ let(:start_time) {now_is_the_time + 7200}
233
+
234
+ it 'is the initilized start time' do
235
+ expect(result).to eql(start_time)
236
+ end
237
+ end
238
+
239
+ context 'when no start time was provided during initialization' do
240
+ it 'is the current time as of initialization' do
241
+ expect(result).to eql(now_is_the_time)
242
+ end
243
+ end
244
+ end
245
+
246
+ describe '#verbose?' do
247
+ let(:result) {shell.verbose?}
248
+
249
+ context 'when verbosity was enabled during initialization' do
250
+ let(:verbose) {true}
251
+
252
+ it 'is true' do
253
+ expect(result).to be_truthy
254
+ end
255
+ end
256
+
257
+ context 'when verbosity was disabled during initialization' do
258
+ let(:verbose) {false}
259
+
260
+ it 'is false' do
261
+ expect(result).to be_falsey
262
+ end
263
+ end
264
+
265
+ context 'when verbosity was not provided at initialization' do
266
+ it 'is false' do
267
+ expect(result).to be_falsey
268
+ end
269
+ end
270
+ end
271
+
272
+ describe '#status' do
273
+ let(:msg) {'some message'}
274
+ let(:gsubbed) {'gsubbed'}
275
+ let(:result) {shell.status(msg)}
276
+
277
+ before(:each) do
278
+ allow(msg).to receive(:gsub).and_return(gsubbed)
279
+ end
280
+
281
+ # This example literally cannot come up in ruby-1.8.7, as the `Encoding` module
282
+ # `String#force_encoding` method totally aren't a thing until ruby-1.9.3
283
+ if RUBY_VERSION >= "1.9.3"
284
+ context 'when the message supports forced encoding' do
285
+ before(:each) do
286
+ allow(msg).to receive(:force_encoding)
287
+ end
288
+
289
+ it 'forces the encoding to UTF-8' do
290
+ expect(msg).to receive(:force_encoding).with(::Encoding::UTF_8)
291
+
292
+ result
293
+ end
294
+ end
295
+ end
296
+
297
+ it 'puts the status prefix at the beginning of each line in the message' do
298
+ expect(msg).
299
+ to receive(:gsub).
300
+ with(described_class::BOL, described_class::STATUS_PREFIX).
301
+ and_return(gsubbed)
302
+
303
+ result
304
+ end
305
+
306
+ it 'logs the modified message as an info line' do
307
+ expect(logger).to receive(:info).with(gsubbed)
308
+
309
+ result
310
+ end
311
+ end
312
+
313
+ describe '#substatus' do
314
+ let(:msg) {'some message'}
315
+ let(:gsubbed) {'gsubbed'}
316
+ let(:result) {shell.substatus(msg)}
317
+
318
+ before(:each) do
319
+ allow(msg).to receive(:gsub).and_return(gsubbed)
320
+ end
321
+
322
+ it 'adds the substatus prefix to the beginning of each line in the message' do
323
+ expect(msg).
324
+ to receive(:gsub).
325
+ with(described_class::BOL, described_class::SUBSTATUS_PREFIX).
326
+ and_return(gsubbed)
327
+
328
+ result
329
+ end
330
+
331
+ it 'logs the modified message as a debug line' do
332
+ expect(logger).to receive(:debug).with(gsubbed)
333
+
334
+ result
335
+ end
336
+ end
337
+
338
+ describe '#fatal' do
339
+ let(:msg) {'finish him!'}
340
+ let(:result) {shell.fatal(msg)}
341
+
342
+ it 'forwards the call to the logger after decorating the message' do
343
+ expect(logger).to receive(:fatal).with("FATAL: #{msg}")
344
+
345
+ result
346
+ end
347
+ end
348
+
349
+ describe '#error' do
350
+ let(:msg) {'you do not know the way'}
351
+ let(:result) {shell.error(msg)}
352
+
353
+ it 'forwards the call to the logger after decorating the message' do
354
+ expect(logger).to receive(:error).with("ERROR: #{msg}")
355
+
356
+ result
357
+ end
358
+ end
359
+
360
+ describe '#warning' do
361
+ let(:msg) {'she knew that her life had passed her by'}
362
+ let(:result) {shell.warning(msg)}
363
+
364
+ it 'forwards the call to the logger after decorating the message' do
365
+ expect(logger).to receive(:warn).with("WARNING: #{msg}")
366
+
367
+ result
368
+ end
369
+ end
370
+
371
+ describe '#warn' do
372
+ let(:msg) {'watch out for that tree'}
373
+ let(:result) {shell.warn(msg)}
374
+
375
+ it 'forwards the call to the logger after decorating the message' do
376
+ expect(logger).to receive(:warn).with("WARNING: #{msg}")
377
+
378
+ result
379
+ end
380
+ end
381
+
382
+ describe '#notice' do
383
+ let(:msg) {'of intent'}
384
+ let(:result) {shell.notice(msg)}
385
+
386
+ it 'warns unmodified via the logger' do
387
+ expect(logger).to receive(:warn).with(msg)
388
+
389
+ result
390
+ end
391
+ end
392
+
393
+ describe '#info' do
394
+ let(:msg) {'rmation'}
395
+ let(:result) {shell.info(msg)}
396
+
397
+ it 'forwards the call to the logger unmodified' do
398
+ expect(logger).to receive(:info).with(msg)
399
+
400
+ result
401
+ end
402
+ end
403
+
404
+ describe '#debug' do
405
+ let(:msg) {'a buggy bug on a bug made of bugs'}
406
+ let(:result) {shell.debug(msg)}
407
+
408
+ it 'forwards the call to the logger unmodified' do
409
+ expect(logger).to receive(:debug).with(msg)
410
+
411
+ result
412
+ end
413
+ end
414
+
415
+ describe '#unknown' do
416
+ let(:msg) {'soldier'}
417
+ let(:result) {shell.unknown(msg)}
418
+
419
+ it 'forwards the call to the logger unmodified' do
420
+ expect(logger).to receive(:unknown).with(msg)
421
+
422
+ result
423
+ end
424
+ end
425
+
426
+ describe '#command_show' do
427
+ let(:cmd) {'some command'}
428
+ let(:continued) {'continued command'}
429
+ let(:prefixed) {'prefixed continued command'}
430
+ let(:result) {shell.command_show(cmd)}
431
+
432
+ before(:each) do
433
+ allow(cmd).to receive(:gsub).and_return(continued)
434
+ allow(continued).to receive(:sub).and_return(prefixed)
435
+ end
436
+
437
+ it 'adds the command continue decoration to each line of the message' do
438
+ expect(cmd).
439
+ to receive(:gsub).
440
+ with(described_class::BOL, described_class::CMD_CONTINUE).
441
+ and_return(continued)
442
+
443
+ result
444
+ end
445
+
446
+ it 'replaces the first command continue decoration with a command prefix' do
447
+ expect(continued).
448
+ to receive(:sub).
449
+ with(described_class::CMD_CONTINUE, described_class::CMD_PREFIX).
450
+ and_return(prefixed)
451
+
452
+ result
453
+ end
454
+
455
+ it 'logs the decorated message as a debug line via the logger' do
456
+ expect(logger).to receive(:debug).with(prefixed)
457
+
458
+ result
459
+ end
460
+ end
461
+
462
+ describe '#comand_out' do
463
+ let(:msg) {'some message'}
464
+ let(:indented) {'indented message'}
465
+ let(:result) {shell.command_out(msg)}
466
+
467
+ before(:each) do
468
+ allow(msg).to receive(:gsub).and_return(indented)
469
+ end
470
+
471
+ it 'indents each line of the message' do
472
+ expect(msg).
473
+ to receive(:gsub).
474
+ with(described_class::BOL, described_class::CMD_INDENT).
475
+ and_return(indented)
476
+
477
+ result
478
+ end
479
+
480
+ it 'logs the indented message as a debug line via the logger' do
481
+ expect(logger).to receive(:debug).with(indented)
482
+
483
+ result
484
+ end
485
+ end
486
+
487
+ describe '#command_err' do
488
+ let(:msg) {'some message'}
489
+ let(:indented) {'indented message'}
490
+ let(:result) {shell.command_err(msg)}
491
+
492
+ before(:each) do
493
+ allow(msg).to receive(:gsub).and_return(indented)
494
+ end
495
+
496
+ it 'indents each line of the message' do
497
+ expect(msg).
498
+ to receive(:gsub).
499
+ with(described_class::BOL, described_class::CMD_INDENT).
500
+ and_return(indented)
501
+
502
+ result
503
+ end
504
+
505
+ it 'logs the indented message as an unknown line via the logger' do
506
+ expect(logger).to receive(:unknown).with(indented)
507
+
508
+ result
509
+ end
510
+ end
511
+
512
+ describe '#logged_system' do
513
+ let(:cmd) {Object.new}
514
+ let(:spawn_result) {Object.new}
515
+ let(:result) {shell.logged_system(cmd)}
516
+
517
+ it 'spawns the command, passing the shell to the spawner' do
518
+ expect(EY::Serverside::Spawner).
519
+ to receive(:run).
520
+ with(cmd, shell, nil).
521
+ and_return(spawn_result)
522
+
523
+ expect(result).to eql(spawn_result)
524
+ end
525
+
526
+ context 'when a server is passed in' do
527
+ let(:server) {Object.new}
528
+ let(:result) {shell.logged_system(cmd, server)}
529
+
530
+ it 'passes the server along as well' do
531
+ expect(EY::Serverside::Spawner).
532
+ to receive(:run).
533
+ with(cmd, shell, server).
534
+ and_return(spawn_result)
535
+
536
+ expect(result).to eql(spawn_result)
537
+ end
538
+ end
539
+ end
540
+ end
541
+
542
+ end
543
+ end