engineyard-serverside 1.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 (220) hide show
  1. data/LICENSE +19 -0
  2. data/bin/engineyard-serverside +10 -0
  3. data/lib/engineyard-serverside.rb +49 -0
  4. data/lib/engineyard-serverside/bundle_installer.rb +4 -0
  5. data/lib/engineyard-serverside/cli.rb +146 -0
  6. data/lib/engineyard-serverside/configuration.rb +130 -0
  7. data/lib/engineyard-serverside/default_maintenance_page.html +29 -0
  8. data/lib/engineyard-serverside/deploy.rb +321 -0
  9. data/lib/engineyard-serverside/deploy_hook.rb +80 -0
  10. data/lib/engineyard-serverside/lockfile_parser.rb +55 -0
  11. data/lib/engineyard-serverside/logged_output.rb +78 -0
  12. data/lib/engineyard-serverside/server.rb +70 -0
  13. data/lib/engineyard-serverside/strategies/git.rb +136 -0
  14. data/lib/engineyard-serverside/task.rb +62 -0
  15. data/lib/engineyard-serverside/version.rb +3 -0
  16. data/lib/vendor/dataflow/HISTORY +52 -0
  17. data/lib/vendor/dataflow/LICENSE +19 -0
  18. data/lib/vendor/dataflow/README.textile +290 -0
  19. data/lib/vendor/dataflow/Rakefile +36 -0
  20. data/lib/vendor/dataflow/dataflow.rb +120 -0
  21. data/lib/vendor/dataflow/dataflow/actor.rb +22 -0
  22. data/lib/vendor/dataflow/dataflow/equality.rb +28 -0
  23. data/lib/vendor/dataflow/dataflow/future_queue.rb +24 -0
  24. data/lib/vendor/dataflow/dataflow/port.rb +54 -0
  25. data/lib/vendor/dataflow/examples/barrier.rb +9 -0
  26. data/lib/vendor/dataflow/examples/data_driven.rb +17 -0
  27. data/lib/vendor/dataflow/examples/dataflow_http_gets.rb +13 -0
  28. data/lib/vendor/dataflow/examples/flow.rb +20 -0
  29. data/lib/vendor/dataflow/examples/future_http_gets.rb +12 -0
  30. data/lib/vendor/dataflow/examples/future_queue.rb +11 -0
  31. data/lib/vendor/dataflow/examples/instance_variables.rb +15 -0
  32. data/lib/vendor/dataflow/examples/laziness.rb +9 -0
  33. data/lib/vendor/dataflow/examples/local_variables.rb +11 -0
  34. data/lib/vendor/dataflow/examples/messages.rb +26 -0
  35. data/lib/vendor/dataflow/examples/port_http_gets.rb +13 -0
  36. data/lib/vendor/dataflow/examples/port_send.rb +10 -0
  37. data/lib/vendor/dataflow/examples/ring.rb +21 -0
  38. data/lib/vendor/dataflow/spec/actor_spec.rb +28 -0
  39. data/lib/vendor/dataflow/spec/anonymous_variables_spec.rb +21 -0
  40. data/lib/vendor/dataflow/spec/barrier_spec.rb +25 -0
  41. data/lib/vendor/dataflow/spec/by_need_spec.rb +55 -0
  42. data/lib/vendor/dataflow/spec/dataflow_spec.rb +151 -0
  43. data/lib/vendor/dataflow/spec/equality_spec.rb +40 -0
  44. data/lib/vendor/dataflow/spec/flow_spec.rb +25 -0
  45. data/lib/vendor/dataflow/spec/forker_spec.rb +28 -0
  46. data/lib/vendor/dataflow/spec/future_queue_spec.rb +31 -0
  47. data/lib/vendor/dataflow/spec/inspect_spec.rb +19 -0
  48. data/lib/vendor/dataflow/spec/need_later_spec.rb +12 -0
  49. data/lib/vendor/dataflow/spec/port_spec.rb +26 -0
  50. data/lib/vendor/dataflow/spec/spec.opts +1 -0
  51. data/lib/vendor/dataflow/spec/spec_helper.rb +10 -0
  52. data/lib/vendor/escape/Readme +21 -0
  53. data/lib/vendor/escape/doc_include/template/qualitysmith.rb +631 -0
  54. data/lib/vendor/escape/lib/escape.rb +247 -0
  55. data/lib/vendor/json_pure/CHANGES +166 -0
  56. data/lib/vendor/json_pure/COPYING +58 -0
  57. data/lib/vendor/json_pure/GPL +340 -0
  58. data/lib/vendor/json_pure/README +358 -0
  59. data/lib/vendor/json_pure/Rakefile +292 -0
  60. data/lib/vendor/json_pure/TODO +1 -0
  61. data/lib/vendor/json_pure/VERSION +1 -0
  62. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
  63. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
  64. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
  65. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
  66. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
  67. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
  68. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
  69. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
  70. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
  71. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
  72. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
  73. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
  74. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
  75. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
  76. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
  77. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
  78. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
  79. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
  80. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
  81. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
  82. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
  83. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
  84. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
  85. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
  86. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
  87. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
  88. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
  89. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
  90. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
  91. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
  92. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
  93. data/lib/vendor/json_pure/benchmarks/generator2_benchmark.rb +222 -0
  94. data/lib/vendor/json_pure/benchmarks/generator_benchmark.rb +224 -0
  95. data/lib/vendor/json_pure/benchmarks/ohai.json +1216 -0
  96. data/lib/vendor/json_pure/benchmarks/ohai.ruby +1 -0
  97. data/lib/vendor/json_pure/benchmarks/parser2_benchmark.rb +251 -0
  98. data/lib/vendor/json_pure/benchmarks/parser_benchmark.rb +259 -0
  99. data/lib/vendor/json_pure/bin/edit_json.rb +9 -0
  100. data/lib/vendor/json_pure/bin/prettify_json.rb +75 -0
  101. data/lib/vendor/json_pure/data/example.json +1 -0
  102. data/lib/vendor/json_pure/data/index.html +38 -0
  103. data/lib/vendor/json_pure/data/prototype.js +4184 -0
  104. data/lib/vendor/json_pure/ext/json/ext/generator/extconf.rb +16 -0
  105. data/lib/vendor/json_pure/ext/json/ext/generator/generator.c +1323 -0
  106. data/lib/vendor/json_pure/ext/json/ext/generator/generator.h +170 -0
  107. data/lib/vendor/json_pure/ext/json/ext/parser/extconf.rb +15 -0
  108. data/lib/vendor/json_pure/ext/json/ext/parser/parser.c +1935 -0
  109. data/lib/vendor/json_pure/ext/json/ext/parser/parser.h +71 -0
  110. data/lib/vendor/json_pure/ext/json/ext/parser/parser.rl +792 -0
  111. data/lib/vendor/json_pure/install.rb +26 -0
  112. data/lib/vendor/json_pure/lib/json.rb +10 -0
  113. data/lib/vendor/json_pure/lib/json/Array.xpm +21 -0
  114. data/lib/vendor/json_pure/lib/json/FalseClass.xpm +21 -0
  115. data/lib/vendor/json_pure/lib/json/Hash.xpm +21 -0
  116. data/lib/vendor/json_pure/lib/json/Key.xpm +73 -0
  117. data/lib/vendor/json_pure/lib/json/NilClass.xpm +21 -0
  118. data/lib/vendor/json_pure/lib/json/Numeric.xpm +28 -0
  119. data/lib/vendor/json_pure/lib/json/String.xpm +96 -0
  120. data/lib/vendor/json_pure/lib/json/TrueClass.xpm +21 -0
  121. data/lib/vendor/json_pure/lib/json/add/core.rb +148 -0
  122. data/lib/vendor/json_pure/lib/json/add/rails.rb +58 -0
  123. data/lib/vendor/json_pure/lib/json/common.rb +397 -0
  124. data/lib/vendor/json_pure/lib/json/editor.rb +1371 -0
  125. data/lib/vendor/json_pure/lib/json/ext.rb +15 -0
  126. data/lib/vendor/json_pure/lib/json/json.xpm +1499 -0
  127. data/lib/vendor/json_pure/lib/json/pure.rb +77 -0
  128. data/lib/vendor/json_pure/lib/json/pure/generator.rb +452 -0
  129. data/lib/vendor/json_pure/lib/json/pure/parser.rb +307 -0
  130. data/lib/vendor/json_pure/lib/json/version.rb +8 -0
  131. data/lib/vendor/json_pure/tests/fixtures/fail1.json +1 -0
  132. data/lib/vendor/json_pure/tests/fixtures/fail10.json +1 -0
  133. data/lib/vendor/json_pure/tests/fixtures/fail11.json +1 -0
  134. data/lib/vendor/json_pure/tests/fixtures/fail12.json +1 -0
  135. data/lib/vendor/json_pure/tests/fixtures/fail13.json +1 -0
  136. data/lib/vendor/json_pure/tests/fixtures/fail14.json +1 -0
  137. data/lib/vendor/json_pure/tests/fixtures/fail18.json +1 -0
  138. data/lib/vendor/json_pure/tests/fixtures/fail19.json +1 -0
  139. data/lib/vendor/json_pure/tests/fixtures/fail2.json +1 -0
  140. data/lib/vendor/json_pure/tests/fixtures/fail20.json +1 -0
  141. data/lib/vendor/json_pure/tests/fixtures/fail21.json +1 -0
  142. data/lib/vendor/json_pure/tests/fixtures/fail22.json +1 -0
  143. data/lib/vendor/json_pure/tests/fixtures/fail23.json +1 -0
  144. data/lib/vendor/json_pure/tests/fixtures/fail24.json +1 -0
  145. data/lib/vendor/json_pure/tests/fixtures/fail25.json +1 -0
  146. data/lib/vendor/json_pure/tests/fixtures/fail27.json +2 -0
  147. data/lib/vendor/json_pure/tests/fixtures/fail28.json +2 -0
  148. data/lib/vendor/json_pure/tests/fixtures/fail3.json +1 -0
  149. data/lib/vendor/json_pure/tests/fixtures/fail4.json +1 -0
  150. data/lib/vendor/json_pure/tests/fixtures/fail5.json +1 -0
  151. data/lib/vendor/json_pure/tests/fixtures/fail6.json +1 -0
  152. data/lib/vendor/json_pure/tests/fixtures/fail7.json +1 -0
  153. data/lib/vendor/json_pure/tests/fixtures/fail8.json +1 -0
  154. data/lib/vendor/json_pure/tests/fixtures/fail9.json +1 -0
  155. data/lib/vendor/json_pure/tests/fixtures/pass1.json +56 -0
  156. data/lib/vendor/json_pure/tests/fixtures/pass15.json +1 -0
  157. data/lib/vendor/json_pure/tests/fixtures/pass16.json +1 -0
  158. data/lib/vendor/json_pure/tests/fixtures/pass17.json +1 -0
  159. data/lib/vendor/json_pure/tests/fixtures/pass2.json +1 -0
  160. data/lib/vendor/json_pure/tests/fixtures/pass26.json +1 -0
  161. data/lib/vendor/json_pure/tests/fixtures/pass3.json +6 -0
  162. data/lib/vendor/json_pure/tests/test_json.rb +361 -0
  163. data/lib/vendor/json_pure/tests/test_json_addition.rb +162 -0
  164. data/lib/vendor/json_pure/tests/test_json_encoding.rb +68 -0
  165. data/lib/vendor/json_pure/tests/test_json_fixtures.rb +34 -0
  166. data/lib/vendor/json_pure/tests/test_json_generate.rb +122 -0
  167. data/lib/vendor/json_pure/tests/test_json_rails.rb +144 -0
  168. data/lib/vendor/json_pure/tests/test_json_unicode.rb +76 -0
  169. data/lib/vendor/json_pure/tools/fuzz.rb +139 -0
  170. data/lib/vendor/json_pure/tools/server.rb +61 -0
  171. data/lib/vendor/open4/lib/open4.rb +403 -0
  172. data/lib/vendor/thor/CHANGELOG.rdoc +89 -0
  173. data/lib/vendor/thor/LICENSE +20 -0
  174. data/lib/vendor/thor/README.rdoc +297 -0
  175. data/lib/vendor/thor/Thorfile +69 -0
  176. data/lib/vendor/thor/bin/rake2thor +86 -0
  177. data/lib/vendor/thor/bin/thor +6 -0
  178. data/lib/vendor/thor/lib/thor.rb +244 -0
  179. data/lib/vendor/thor/lib/thor/actions.rb +275 -0
  180. data/lib/vendor/thor/lib/thor/actions/create_file.rb +103 -0
  181. data/lib/vendor/thor/lib/thor/actions/directory.rb +91 -0
  182. data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +134 -0
  183. data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +223 -0
  184. data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +104 -0
  185. data/lib/vendor/thor/lib/thor/base.rb +540 -0
  186. data/lib/vendor/thor/lib/thor/core_ext/file_binary_read.rb +9 -0
  187. data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  188. data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +100 -0
  189. data/lib/vendor/thor/lib/thor/error.rb +30 -0
  190. data/lib/vendor/thor/lib/thor/group.rb +271 -0
  191. data/lib/vendor/thor/lib/thor/invocation.rb +180 -0
  192. data/lib/vendor/thor/lib/thor/parser.rb +4 -0
  193. data/lib/vendor/thor/lib/thor/parser/argument.rb +67 -0
  194. data/lib/vendor/thor/lib/thor/parser/arguments.rb +150 -0
  195. data/lib/vendor/thor/lib/thor/parser/option.rb +128 -0
  196. data/lib/vendor/thor/lib/thor/parser/options.rb +169 -0
  197. data/lib/vendor/thor/lib/thor/rake_compat.rb +66 -0
  198. data/lib/vendor/thor/lib/thor/runner.rb +314 -0
  199. data/lib/vendor/thor/lib/thor/shell.rb +83 -0
  200. data/lib/vendor/thor/lib/thor/shell/basic.rb +239 -0
  201. data/lib/vendor/thor/lib/thor/shell/color.rb +108 -0
  202. data/lib/vendor/thor/lib/thor/task.rb +102 -0
  203. data/lib/vendor/thor/lib/thor/util.rb +230 -0
  204. data/lib/vendor/thor/lib/thor/version.rb +3 -0
  205. data/lib/vendor/thor/thor.gemspec +120 -0
  206. data/spec/custom_deploy_spec.rb +95 -0
  207. data/spec/deploy_hook_spec.rb +211 -0
  208. data/spec/fixtures/gitrepo.tar.gz +0 -0
  209. data/spec/fixtures/gitrepo/foo +0 -0
  210. data/spec/fixtures/invalid_hook.rb +1 -0
  211. data/spec/fixtures/valid_hook.rb +1 -0
  212. data/spec/git_strategy_spec.rb +22 -0
  213. data/spec/lockfile_parser_spec.rb +30 -0
  214. data/spec/spec_helper.rb +37 -0
  215. data/spec/support/lockfiles/0.9-no-bundler +111 -0
  216. data/spec/support/lockfiles/0.9-with-bundler +117 -0
  217. data/spec/support/lockfiles/1.0-no-bundler +54 -0
  218. data/spec/support/lockfiles/1.0.0.rc.1-with-bundler +162 -0
  219. data/spec/support/lockfiles/not-a-lockfile +10 -0
  220. metadata +279 -0
@@ -0,0 +1,211 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "the deploy-hook API" do
4
+ before(:each) do
5
+ @hook = EY::DeployHook.new(options)
6
+ @callback_context = EY::DeployHook::CallbackContext.new(@hook.config)
7
+ end
8
+
9
+ def run_hook(options={}, &blk)
10
+ raise ArgumentError unless block_given?
11
+ options.each do |k, v|
12
+ @callback_context.configuration[k] = v
13
+ end
14
+
15
+ # The hooks on the filesystem are run by passing a string to
16
+ # context.instance_eval, not a block. However, using a block
17
+ # should allow us to get the same degree of test coverage and
18
+ # still let us have things like syntax checking work on this spec
19
+ # file.
20
+ @callback_context.instance_eval(&blk)
21
+ end
22
+
23
+ context "#run" do
24
+ it "is available" do
25
+ run_hook { respond_to?(:run) }.should be_true
26
+ end
27
+
28
+ it "runs commands like the shell does" do
29
+ ENV['COUNT'] = 'Chocula'
30
+ File.unlink("/tmp/deploy_hook_spec.the_count") rescue nil
31
+
32
+ run_hook { run("echo $COUNT > /tmp/deploy_hook_spec.the_count") }
33
+
34
+ IO.read("/tmp/deploy_hook_spec.the_count").strip.should == "Chocula"
35
+ end
36
+
37
+ it "returns true/false to indicate the command's success" do
38
+ run_hook { run("true") }.should be_true
39
+ run_hook { run("false") }.should be_false
40
+ end
41
+ end
42
+
43
+ context "#sudo" do
44
+ it "is available" do
45
+ run_hook { respond_to?(:sudo) }.should be_true
46
+ end
47
+
48
+ it "runs things with sudo" do
49
+ @callback_context.should_receive(:system).with("sudo sh -l -c 'do it as root'").and_return(true)
50
+
51
+ run_hook { sudo("do it as root") }
52
+ end
53
+ end
54
+
55
+ context "capistrano-ish methods" do
56
+ it "has them" do
57
+ run_hook { respond_to?(:latest_release) }.should be_true
58
+ run_hook { respond_to?(:previous_release) }.should be_true
59
+ run_hook { respond_to?(:all_releases) }.should be_true
60
+ run_hook { respond_to?(:current_path) }.should be_true
61
+ run_hook { respond_to?(:shared_path) }.should be_true
62
+ run_hook { respond_to?(:release_dir) }.should be_true
63
+ run_hook { respond_to?(:release_path) }.should be_true
64
+ end
65
+ end
66
+
67
+ context "the @node ivar" do
68
+ before(:each) do
69
+ EY.dna_json = {
70
+ 'instance_role' => 'solo',
71
+ 'applications' => {
72
+ 'myapp' => {
73
+ 'type' => 'rails',
74
+ 'branch' => 'master',
75
+ }
76
+ }
77
+ }.to_json
78
+ end
79
+
80
+ it "is available" do
81
+ run_hook { @node.nil? }.should be_false
82
+ end
83
+
84
+ it "has indifferent access" do
85
+ run_hook { @node[:instance_role] }.should == 'solo'
86
+ run_hook { @node['instance_role'] }.should == 'solo'
87
+ end
88
+
89
+ it "has deep indifferent access" do
90
+ run_hook { @node['applications']['myapp']['type'] }.should == 'rails'
91
+ run_hook { @node[:applications]['myapp'][:type] }.should == 'rails'
92
+ run_hook { @node[:applications][:myapp][:type] }.should == 'rails'
93
+ end
94
+ end
95
+
96
+ context "the @configuration ivar" do
97
+ it "is available" do
98
+ run_hook { @configuration.nil? }.should be_false
99
+ end
100
+
101
+ it "has the configuration in it" do
102
+ run_hook('bert' => 'ernie') { @configuration.bert }.should == 'ernie'
103
+ end
104
+
105
+ it "can be accessed with method calls, with [:symbols], or ['strings']" do
106
+ run_hook('bert' => 'ernie') { @configuration.bert }.should == 'ernie'
107
+ run_hook('bert' => 'ernie') { @configuration[:bert] }.should == 'ernie'
108
+ run_hook('bert' => 'ernie') { @configuration['bert'] }.should == 'ernie'
109
+ end
110
+
111
+ [:repository_cache,
112
+ :release_path,
113
+ :branch,
114
+ :shared_path,
115
+ :deploy_to,
116
+ :user,
117
+ :revision,
118
+ :environment].each do |attribute|
119
+ it "has the #{attribute.inspect} attribute for compatibility with chef-deploy" do
120
+ run_hook { @configuration.has_key?(attribute) }.should be_true
121
+ end
122
+ end
123
+ end
124
+
125
+ context "has methods to run code only on certain instances" do
126
+ def scenarios
127
+ [
128
+ {:instance_role => 'solo'},
129
+ {:instance_role => 'app_master'},
130
+ {:instance_role => 'app'},
131
+ {:instance_role => 'db_master'},
132
+ {:instance_role => 'db_slave'},
133
+ {:instance_role => 'util', :name => "alpha"},
134
+ {:instance_role => 'util', :name => "beta"},
135
+ {:instance_role => 'util', :name => "gamma"},
136
+ ]
137
+ end
138
+
139
+ def where_code_runs_with(method, *args)
140
+ scenarios.map do |s|
141
+ @callback_context.configuration[:current_role] = s[:instance_role]
142
+ @callback_context.configuration[:current_name] = s[:name]
143
+
144
+ if run_hook { send(method, *args) { 'ran!'} } == 'ran!'
145
+ result = s[:instance_role]
146
+ result << "_#{s[:name]}" if s[:name]
147
+ result
148
+ end
149
+ end.compact
150
+ end
151
+
152
+ it "#on_app_master runs on app masters and solos" do
153
+ where_code_runs_with(:on_app_master).should == %w(solo app_master)
154
+ end
155
+
156
+ it "#on_app_servers runs on app masters, app slaves, and solos" do
157
+ where_code_runs_with(:on_app_servers).should == %w(solo app_master app)
158
+ end
159
+
160
+ it "#on_db_master runs on DB masters and solos" do
161
+ where_code_runs_with(:on_db_master).should == %w(solo db_master)
162
+ end
163
+
164
+ it "#on_db_slaves runs on DB slaves only (not solos or masters)" do
165
+ where_code_runs_with(:on_db_slaves).should == %w(db_slave)
166
+ end
167
+
168
+ it "#on_db_servers runs on DB masters, DB slaves, and solos" do
169
+ where_code_runs_with(:on_db_servers).should == %w(solo db_master db_slave)
170
+ end
171
+
172
+ it "#on_app_servers_and_utilities does what it says on the tin" do
173
+ where_code_runs_with(:on_app_servers_and_utilities).should ==
174
+ %w(solo app_master app util_alpha util_beta util_gamma)
175
+ end
176
+
177
+ it "#on_utilities() runs on all utility instances" do
178
+ where_code_runs_with(:on_utilities).should ==
179
+ %w(util_alpha util_beta util_gamma)
180
+ end
181
+
182
+ it "#on_utilities('sometype') runs on only utilities of type 'sometype'" do
183
+ where_code_runs_with(:on_utilities, 'alpha').should == %w(util_alpha)
184
+ end
185
+
186
+ it "#on_utilities('type1', 'type2') runs on utilities of both types" do
187
+ where_code_runs_with(:on_utilities, 'alpha', 'beta').should ==
188
+ %w(util_alpha util_beta)
189
+ end
190
+
191
+ it "#on_utilities can be invoked with (['a', 'b']) or ('a', 'b')" do
192
+ where_code_runs_with(:on_utilities, %w[alpha beta]).should ==
193
+ where_code_runs_with(:on_utilities, 'alpha', 'beta')
194
+ end
195
+
196
+ end
197
+
198
+ context "#syntax_error" do
199
+ it "returns nil for hook files containing valid Ruby syntax" do
200
+ hook_path = File.expand_path('../fixtures/valid_hook.rb', __FILE__)
201
+ @hook.syntax_error(hook_path).should be_nil
202
+ end
203
+
204
+ it "returns a brief problem description for hook files containing valid Ruby syntax" do
205
+ hook_path = File.expand_path('../fixtures/invalid_hook.rb', __FILE__)
206
+ desc = "spec/fixtures/invalid_hook.rb:1: syntax error, unexpected '^'"
207
+ match = /\A.*#{Regexp.escape desc}\Z/
208
+ @hook.syntax_error(hook_path).should =~ match
209
+ end
210
+ end
211
+ end
Binary file
File without changes
@@ -0,0 +1 @@
1
+ ^^^invalid ruby^^^
@@ -0,0 +1 @@
1
+ run("true")
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "the git deploy strategy" do
4
+ subject do
5
+ EY::Strategies::Git.new(:repo => File.expand_path("../fixtures/gitrepo/.git", __FILE__),
6
+ :repository_cache => File.expand_path("../fixtures/gitrepo", __FILE__),
7
+ :ref => "master"
8
+ )
9
+ end
10
+
11
+ before { subject.checkout }
12
+
13
+ it "#checkout returns true for branches that exist" do
14
+ subject.opts[:ref] = "somebranch"
15
+ subject.checkout.should be_true
16
+ end
17
+
18
+ it "#checkout returns false for branches that do not exist" do
19
+ subject.opts[:ref] = "notabranch"
20
+ subject.checkout.should be_false
21
+ end
22
+ end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "the bundler version retrieved from the lockfile" do
4
+ def get_version(file)
5
+ full_path = File.expand_path("../support/lockfiles/#{file}", __FILE__)
6
+ config = EY::Deploy::Configuration.new('deploy_to' => 'dontcare')
7
+ EY::DeployBase.new(config).get_bundler_installer(full_path).version
8
+ end
9
+
10
+ it "returns the default version for an 0.9 lockfile without a bundler dependency" do
11
+ get_version('0.9-no-bundler').should == EY::DeployBase::DEFAULT_09_BUNDLER
12
+ end
13
+
14
+ it "gets the version from an 0.9 lockfile with a bundler dependency" do
15
+ get_version('0.9-with-bundler').should == '0.9.24'
16
+ end
17
+
18
+ it "returns the default version for a 1.0 lockfile without a bundler dependency" do
19
+ get_version('1.0-no-bundler').should == EY::DeployBase::DEFAULT_10_BUNDLER
20
+ end
21
+
22
+ it "gets the version from a 1.0.0.rc.1 lockfile w/dependency on 1.0.0.rc.1" do
23
+ # This is a real, customer-generated lockfile
24
+ get_version('1.0.0.rc.1-with-bundler').should == '1.0.0.rc.1'
25
+ end
26
+
27
+ it "raises an error if it can't parse the file" do
28
+ lambda { get_version('not-a-lockfile') }.should raise_error
29
+ end
30
+ end
@@ -0,0 +1,37 @@
1
+ $LOAD_PATH.push File.expand_path("../lib", File.dirname(__FILE__))
2
+
3
+ Bundler.require :default, :test
4
+ require 'pp'
5
+ require 'engineyard-serverside'
6
+
7
+ module EY
8
+ def self.dna_json=(j)
9
+ @dna_json = j;
10
+ @node = nil
11
+ j
12
+ end
13
+
14
+ module LoggedOutput
15
+ def info(_) end
16
+
17
+ def logged_system(cmd)
18
+ system("#{cmd} 2>/dev/null")
19
+ end
20
+ end
21
+
22
+ class Strategies::Git
23
+ def short_log_message(_) "" end
24
+ end
25
+ end
26
+
27
+ FIXTURES_DIR = File.expand_path("../fixtures", __FILE__)
28
+ GITREPO_DIR = "#{FIXTURES_DIR}/gitrepo"
29
+
30
+ FileUtils.rm_rf GITREPO_DIR if File.exists? GITREPO_DIR
31
+ Kernel.system "tar xzf #{GITREPO_DIR}.tar.gz -C #{FIXTURES_DIR}"
32
+
33
+ Spec::Runner.configure do |config|
34
+ config.before(:all) do
35
+ EY.dna_json = {}.to_json
36
+ end
37
+ end
@@ -0,0 +1,111 @@
1
+ ---
2
+ dependencies:
3
+ ruby-debug:
4
+ group:
5
+ - :test
6
+ version: ">= 0"
7
+ fakeweb:
8
+ group:
9
+ - :test
10
+ version: ">= 0"
11
+ termios:
12
+ group:
13
+ - :default
14
+ version: ">= 0"
15
+ fakefs:
16
+ group:
17
+ - :test
18
+ version: ">= 0"
19
+ highline:
20
+ group:
21
+ - :default
22
+ version: ~> 1.5.2
23
+ rake:
24
+ group:
25
+ - :test
26
+ version: ">= 0"
27
+ realweb:
28
+ group:
29
+ - :test
30
+ version: ~> 0.1.6
31
+ escape:
32
+ group:
33
+ - :default
34
+ version: ~> 0.0.4
35
+ thor:
36
+ group:
37
+ - :default
38
+ version: ~> 0.13.6
39
+ rspec:
40
+ group:
41
+ - :test
42
+ version: ">= 0"
43
+ require:
44
+ - spec
45
+ sinatra:
46
+ group:
47
+ - :test
48
+ version: ">= 0"
49
+ json:
50
+ group:
51
+ - :default
52
+ version: ~> 1.4.0
53
+ rest-client:
54
+ group:
55
+ - :default
56
+ version: ~> 1.4
57
+ require:
58
+ - rest_client
59
+ fakeweb-matcher:
60
+ group:
61
+ - :test
62
+ version: ">= 0"
63
+ open4:
64
+ group:
65
+ - :test
66
+ version: ">= 0"
67
+ specs:
68
+ - rake:
69
+ version: 0.8.7
70
+ - columnize:
71
+ version: 0.3.1
72
+ - escape:
73
+ version: 0.0.4
74
+ - fakefs:
75
+ version: 0.2.1
76
+ - fakeweb:
77
+ version: 1.2.8
78
+ - rspec:
79
+ version: 1.3.0
80
+ - fakeweb-matcher:
81
+ version: 1.1.0
82
+ - highline:
83
+ version: 1.5.2
84
+ - json:
85
+ version: 1.4.3
86
+ - linecache:
87
+ version: "0.43"
88
+ - mime-types:
89
+ version: "1.16"
90
+ - open4:
91
+ version: 1.0.1
92
+ - rack:
93
+ version: 1.2.1
94
+ - realweb:
95
+ version: 0.1.6
96
+ - rest-client:
97
+ version: 1.5.1
98
+ - ruby-debug-base:
99
+ version: 0.10.3
100
+ - ruby-debug:
101
+ version: 0.10.3
102
+ - sinatra:
103
+ version: "1.0"
104
+ - termios:
105
+ version: 0.9.4
106
+ - thor:
107
+ version: 0.13.6
108
+ hash: fbfa26af5a1ec9a59367fdd0ea866373166d06f0
109
+ sources:
110
+ - Rubygems:
111
+ uri: http://gemcutter.org
@@ -0,0 +1,117 @@
1
+ ---
2
+ dependencies:
3
+ ruby-debug:
4
+ group:
5
+ - :test
6
+ version: ">= 0"
7
+ fakeweb:
8
+ group:
9
+ - :test
10
+ version: ">= 0"
11
+ termios:
12
+ group:
13
+ - :default
14
+ version: ">= 0"
15
+ fakefs:
16
+ group:
17
+ - :test
18
+ version: ">= 0"
19
+ highline:
20
+ group:
21
+ - :default
22
+ version: ~> 1.5.2
23
+ rake:
24
+ group:
25
+ - :test
26
+ version: ">= 0"
27
+ realweb:
28
+ group:
29
+ - :test
30
+ version: ~> 0.1.6
31
+ escape:
32
+ group:
33
+ - :default
34
+ version: ~> 0.0.4
35
+ thor:
36
+ group:
37
+ - :default
38
+ version: ~> 0.13.6
39
+ rspec:
40
+ group:
41
+ - :test
42
+ version: ">= 0"
43
+ require:
44
+ - spec
45
+ sinatra:
46
+ group:
47
+ - :test
48
+ version: ">= 0"
49
+ json:
50
+ group:
51
+ - :default
52
+ version: ~> 1.4.0
53
+ rest-client:
54
+ group:
55
+ - :default
56
+ version: ~> 1.4
57
+ require:
58
+ - rest_client
59
+ bundler:
60
+ group:
61
+ - :test
62
+ version: ">= 0"
63
+ fakeweb-matcher:
64
+ group:
65
+ - :test
66
+ version: ">= 0"
67
+ open4:
68
+ group:
69
+ - :test
70
+ version: ">= 0"
71
+ specs:
72
+ - rake:
73
+ version: 0.8.7
74
+ - bundler:
75
+ version: 0.9.24
76
+ - columnize:
77
+ version: 0.3.1
78
+ - escape:
79
+ version: 0.0.4
80
+ - fakefs:
81
+ version: 0.2.1
82
+ - fakeweb:
83
+ version: 1.2.8
84
+ - rspec:
85
+ version: 1.3.0
86
+ - fakeweb-matcher:
87
+ version: 1.1.0
88
+ - highline:
89
+ version: 1.5.2
90
+ - json:
91
+ version: 1.4.3
92
+ - linecache:
93
+ version: "0.43"
94
+ - mime-types:
95
+ version: "1.16"
96
+ - open4:
97
+ version: 1.0.1
98
+ - rack:
99
+ version: 1.2.1
100
+ - realweb:
101
+ version: 0.1.6
102
+ - rest-client:
103
+ version: 1.5.1
104
+ - ruby-debug-base:
105
+ version: 0.10.3
106
+ - ruby-debug:
107
+ version: 0.10.3
108
+ - sinatra:
109
+ version: "1.0"
110
+ - termios:
111
+ version: 0.9.4
112
+ - thor:
113
+ version: 0.13.6
114
+ hash: fbfa26af5a1ec9a59367fdd0ea866373166d06f0
115
+ sources:
116
+ - Rubygems:
117
+ uri: http://gemcutter.org