crazy-yard 3.2.2

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 (93) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +19 -0
  3. data/README.md +438 -0
  4. data/bin/ey +9 -0
  5. data/lib/engineyard.rb +9 -0
  6. data/lib/engineyard/cli.rb +816 -0
  7. data/lib/engineyard/cli/api.rb +98 -0
  8. data/lib/engineyard/cli/recipes.rb +129 -0
  9. data/lib/engineyard/cli/ui.rb +275 -0
  10. data/lib/engineyard/cli/web.rb +85 -0
  11. data/lib/engineyard/config.rb +158 -0
  12. data/lib/engineyard/deploy_config.rb +65 -0
  13. data/lib/engineyard/deploy_config/ref.rb +56 -0
  14. data/lib/engineyard/error.rb +82 -0
  15. data/lib/engineyard/eyrc.rb +59 -0
  16. data/lib/engineyard/repo.rb +105 -0
  17. data/lib/engineyard/serverside_runner.rb +159 -0
  18. data/lib/engineyard/templates.rb +6 -0
  19. data/lib/engineyard/templates/ey.yml.erb +196 -0
  20. data/lib/engineyard/templates/ey_yml.rb +119 -0
  21. data/lib/engineyard/thor.rb +215 -0
  22. data/lib/engineyard/version.rb +4 -0
  23. data/lib/vendor/thor/Gemfile +15 -0
  24. data/lib/vendor/thor/LICENSE.md +20 -0
  25. data/lib/vendor/thor/README.md +35 -0
  26. data/lib/vendor/thor/lib/thor.rb +473 -0
  27. data/lib/vendor/thor/lib/thor/actions.rb +318 -0
  28. data/lib/vendor/thor/lib/thor/actions/create_file.rb +105 -0
  29. data/lib/vendor/thor/lib/thor/actions/create_link.rb +60 -0
  30. data/lib/vendor/thor/lib/thor/actions/directory.rb +119 -0
  31. data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +137 -0
  32. data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +314 -0
  33. data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
  34. data/lib/vendor/thor/lib/thor/base.rb +652 -0
  35. data/lib/vendor/thor/lib/thor/command.rb +136 -0
  36. data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +80 -0
  37. data/lib/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
  38. data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +100 -0
  39. data/lib/vendor/thor/lib/thor/error.rb +28 -0
  40. data/lib/vendor/thor/lib/thor/group.rb +282 -0
  41. data/lib/vendor/thor/lib/thor/invocation.rb +172 -0
  42. data/lib/vendor/thor/lib/thor/parser.rb +4 -0
  43. data/lib/vendor/thor/lib/thor/parser/argument.rb +74 -0
  44. data/lib/vendor/thor/lib/thor/parser/arguments.rb +171 -0
  45. data/lib/vendor/thor/lib/thor/parser/option.rb +121 -0
  46. data/lib/vendor/thor/lib/thor/parser/options.rb +218 -0
  47. data/lib/vendor/thor/lib/thor/rake_compat.rb +72 -0
  48. data/lib/vendor/thor/lib/thor/runner.rb +322 -0
  49. data/lib/vendor/thor/lib/thor/shell.rb +88 -0
  50. data/lib/vendor/thor/lib/thor/shell/basic.rb +393 -0
  51. data/lib/vendor/thor/lib/thor/shell/color.rb +148 -0
  52. data/lib/vendor/thor/lib/thor/shell/html.rb +127 -0
  53. data/lib/vendor/thor/lib/thor/util.rb +270 -0
  54. data/lib/vendor/thor/lib/thor/version.rb +3 -0
  55. data/lib/vendor/thor/thor.gemspec +24 -0
  56. data/spec/engineyard/cli/api_spec.rb +50 -0
  57. data/spec/engineyard/cli_spec.rb +28 -0
  58. data/spec/engineyard/config_spec.rb +61 -0
  59. data/spec/engineyard/deploy_config_spec.rb +194 -0
  60. data/spec/engineyard/eyrc_spec.rb +76 -0
  61. data/spec/engineyard/repo_spec.rb +83 -0
  62. data/spec/engineyard_spec.rb +7 -0
  63. data/spec/ey/console_spec.rb +57 -0
  64. data/spec/ey/deploy_spec.rb +435 -0
  65. data/spec/ey/ey_spec.rb +23 -0
  66. data/spec/ey/init_spec.rb +123 -0
  67. data/spec/ey/list_environments_spec.rb +120 -0
  68. data/spec/ey/login_spec.rb +33 -0
  69. data/spec/ey/logout_spec.rb +24 -0
  70. data/spec/ey/logs_spec.rb +36 -0
  71. data/spec/ey/rebuild_spec.rb +18 -0
  72. data/spec/ey/recipes/apply_spec.rb +29 -0
  73. data/spec/ey/recipes/download_spec.rb +43 -0
  74. data/spec/ey/recipes/upload_spec.rb +99 -0
  75. data/spec/ey/rollback_spec.rb +73 -0
  76. data/spec/ey/scp_spec.rb +176 -0
  77. data/spec/ey/servers_spec.rb +209 -0
  78. data/spec/ey/ssh_spec.rb +273 -0
  79. data/spec/ey/status_spec.rb +45 -0
  80. data/spec/ey/timeout_deploy_spec.rb +18 -0
  81. data/spec/ey/web/disable_spec.rb +21 -0
  82. data/spec/ey/web/enable_spec.rb +26 -0
  83. data/spec/ey/web/restart_spec.rb +21 -0
  84. data/spec/ey/whoami_spec.rb +30 -0
  85. data/spec/spec_helper.rb +84 -0
  86. data/spec/support/bundled_ey +7 -0
  87. data/spec/support/fixture_recipes.tgz +0 -0
  88. data/spec/support/git_repos.rb +115 -0
  89. data/spec/support/helpers.rb +330 -0
  90. data/spec/support/matchers.rb +16 -0
  91. data/spec/support/ruby_ext.rb +13 -0
  92. data/spec/support/shared_behavior.rb +278 -0
  93. metadata +411 -0
@@ -0,0 +1,273 @@
1
+ require 'spec_helper'
2
+
3
+ print_my_args_ssh = "#!/bin/sh\necho ssh $*"
4
+
5
+ shared_examples_for "running ey ssh" do
6
+ given "integration"
7
+
8
+ def extra_ey_options
9
+ ssh_cmd = <<-RUBY
10
+ #!#{`which ruby`}
11
+ require "rubygems"
12
+ require "escape"
13
+ puts "ssh \#{Escape.shell_command(ARGV)}"
14
+ RUBY
15
+ {:prepend_to_path => {'ssh' => ssh_cmd}}
16
+ end
17
+ end
18
+
19
+ shared_examples_for "running ey ssh for select role" do
20
+ given "integration"
21
+
22
+ def extra_ey_options
23
+ {:prepend_to_path => {'ssh' => "#!/bin/sh\necho ssh $*"}}
24
+ end
25
+
26
+ def command_to_run(opts)
27
+ cmd = ["ssh", opts[:ssh_command]].compact + (@ssh_flag || [])
28
+ cmd << "--environment" << opts[:environment] if opts[:environment]
29
+ cmd << "--shell" << opts[:shell] if opts[:shell]
30
+ cmd << "--no-shell" if opts[:no_shell]
31
+ cmd << "--quiet" if opts[:quiet]
32
+ cmd
33
+ end
34
+
35
+ it "runs the command on the right servers" do
36
+ login_scenario "one app, one environment"
37
+ ey command_to_run(:ssh_command => "ls", :environment => 'giblets', :verbose => true)
38
+ @hosts.each do |host|
39
+ expect(@raw_ssh_commands.select do |command|
40
+ command =~ /^ssh turkey@#{host}.+ ls$/
41
+ end).not_to be_empty
42
+ end
43
+ expect(@raw_ssh_commands.select do |command|
44
+ command =~ /^ssh turkey.+ ls$/
45
+ end.count).to eq(@hosts.count)
46
+ end
47
+
48
+ it "is quiet" do
49
+ login_scenario "one app, one environment"
50
+ ey command_to_run(:ssh_command => "ls", :environment => 'giblets', :quiet => true)
51
+ expect(@out).to match(/ssh.*ls/)
52
+ expect(@out).not_to match(/Loading application data/)
53
+ end
54
+
55
+ it "runs in bash by default" do
56
+ login_scenario "one app, one environment"
57
+ ey command_to_run(:ssh_command => "ls", :environment => 'giblets')
58
+ expect(@out).to match(/ssh.*bash -lc ls/)
59
+ end
60
+
61
+ it "excludes shell with --no-shell" do
62
+ login_scenario "one app, one environment"
63
+ ey command_to_run(:ssh_command => "ls", :environment => 'giblets', :no_shell => true)
64
+ expect(@out).not_to match(/bash/)
65
+ expect(@out).to match(/ssh.*ls/)
66
+ end
67
+
68
+ it "accepts an alternate shell" do
69
+ login_scenario "one app, one environment"
70
+ ey command_to_run(:ssh_command => "ls", :environment => 'giblets', :shell => 'zsh')
71
+ expect(@out).to match(/ssh.*zsh -lc ls/)
72
+ end
73
+
74
+ it "raises an error when there are no matching hosts" do
75
+ login_scenario "one app, one environment, no instances"
76
+ ey command_to_run({:ssh_command => "ls", :environment => 'giblets', :verbose => true}), :expect_failure => true
77
+ end
78
+
79
+ it "responds correctly when there is no command" do
80
+ if @hosts.count != 1
81
+ login_scenario "one app, one environment"
82
+ ey command_to_run({:environment => 'giblets', :verbose => true}), :expect_failure => true
83
+ end
84
+ end
85
+ end
86
+
87
+ describe "ey ssh" do
88
+ include_examples "running ey ssh"
89
+
90
+ before(:all) do
91
+ login_scenario "one app, many environments"
92
+ end
93
+
94
+ it "complains if it has no app master" do
95
+ ey %w[ssh -e bakon], :expect_failure => true
96
+ expect(@err).to match(/'bakon' does not have any matching instances/)
97
+ end
98
+
99
+ end
100
+
101
+ describe "ey ssh with an ambiguous git repo" do
102
+ include_examples "running ey ssh"
103
+ def command_to_run(_) %w[ssh ls] end
104
+ include_examples "it requires an unambiguous git repo"
105
+ end
106
+
107
+ describe "ey ssh without a command" do
108
+ include_examples "running ey ssh"
109
+
110
+ def command_to_run(opts)
111
+ cmd = ["ssh"]
112
+ cmd << "--environment" << opts[:environment] if opts[:environment]
113
+ cmd << "--account" << opts[:account] if opts[:account]
114
+ cmd
115
+ end
116
+
117
+ def verify_ran(scenario)
118
+ ssh_target = scenario[:ssh_username] + '@' + scenario[:master_hostname]
119
+ expect(@raw_ssh_commands).to eq(["ssh #{ssh_target}"])
120
+ end
121
+
122
+ include_examples "it takes an environment name and an account name"
123
+ end
124
+
125
+ describe "ey ssh with a command" do
126
+ include_examples "running ey ssh"
127
+
128
+ def command_to_run(opts)
129
+ cmd = %w[ssh ls]
130
+ cmd << "--environment" << opts[:environment] if opts[:environment]
131
+ cmd << "--account" << opts[:account] if opts[:account]
132
+ cmd << "--shell" << opts[:shell] if opts[:shell]
133
+ cmd << "--no-shell" if opts[:no_shell]
134
+ cmd
135
+ end
136
+
137
+ def verify_ran(scenario)
138
+ ssh_target = scenario[:ssh_username] + '@' + scenario[:master_hostname]
139
+ expect(@raw_ssh_commands).to eq(["ssh #{ssh_target} 'bash -lc ls'"])
140
+ end
141
+
142
+ include_examples "it takes an environment name and an account name"
143
+ end
144
+
145
+ describe "ey ssh with a command that fails" do
146
+ given "integration"
147
+
148
+ def extra_ey_options
149
+ ssh_cmd = "false" # fail immediately
150
+ {:prepend_to_path => {'ssh' => ssh_cmd}}
151
+ end
152
+
153
+ def command_to_run(opts)
154
+ cmd = %w[ssh ls]
155
+ cmd << "--environment" << opts[:environment] if opts[:environment]
156
+ cmd << "--account" << opts[:account] if opts[:account]
157
+ cmd << "--shell" << opts[:shell] if opts[:shell]
158
+ cmd << "--no-shell" if opts[:no_shell]
159
+ cmd
160
+ end
161
+
162
+ it "fails just like the ssh command fails" do
163
+ login_scenario "one app, one environment"
164
+ ey command_to_run({:ssh_command => "ls", :environment => 'giblets', :verbose => true}), :expect_failure => true
165
+ end
166
+ end
167
+
168
+ describe "ey ssh with a multi-part command" do
169
+ include_examples "running ey ssh"
170
+
171
+ def command_to_run(opts)
172
+ cmd = ['ssh', 'echo "echo"']
173
+ cmd << "--environment" << opts[:environment] if opts[:environment]
174
+ cmd << "--account" << opts[:account] if opts[:account]
175
+ cmd << "--shell" << opts[:shell] if opts[:shell]
176
+ cmd << "--no-shell" if opts[:no_shell]
177
+ cmd
178
+ end
179
+
180
+ def verify_ran(scenario)
181
+ ssh_target = scenario[:ssh_username] + '@' + scenario[:master_hostname]
182
+ expect(@raw_ssh_commands).to eq(["ssh #{ssh_target} 'bash -lc '\\''echo \"echo\"'\\'"])
183
+ end
184
+
185
+ include_examples "it takes an environment name and an account name"
186
+ end
187
+
188
+ describe "ey ssh --all" do
189
+ before do
190
+ @ssh_flag = %w[--all]
191
+ @hosts = %w(app_hostname
192
+ app_master_hostname
193
+ util_fluffy_hostname
194
+ util_rocky_hostname
195
+ db_master_hostname
196
+ db_slave_1_hostname
197
+ db_slave_2_hostname)
198
+ end
199
+
200
+ include_examples "running ey ssh"
201
+ include_examples "running ey ssh for select role"
202
+ end
203
+
204
+ describe "ey ssh --app-servers" do
205
+ before do
206
+ @ssh_flag = %w[--app-servers]
207
+ @hosts = %w(app_hostname app_master_hostname)
208
+ end
209
+
210
+ include_examples "running ey ssh"
211
+ include_examples "running ey ssh for select role"
212
+ end
213
+
214
+ describe "ey ssh --db-master" do
215
+ before do
216
+ @ssh_flag = %w[--db-master]
217
+ @hosts = %w(db_master_hostname)
218
+ end
219
+
220
+ include_examples "running ey ssh"
221
+ include_examples "running ey ssh for select role"
222
+ end
223
+
224
+ describe "ey ssh --db-slaves" do
225
+ before do
226
+ @ssh_flag = %w[--db-slaves]
227
+ @hosts = %w(db_slave_1_hostname db_slave_2_hostname)
228
+ end
229
+
230
+ include_examples "running ey ssh"
231
+ include_examples "running ey ssh for select role"
232
+ end
233
+
234
+ describe "ey ssh --db-servers" do
235
+ before do
236
+ @ssh_flag = %w[--db-servers]
237
+ @hosts = %w(db_master_hostname db_slave_1_hostname db_slave_2_hostname)
238
+ end
239
+
240
+ include_examples "running ey ssh"
241
+ include_examples "running ey ssh for select role"
242
+ end
243
+
244
+ describe "ey ssh --utilities" do
245
+ before do
246
+ @ssh_flag = %w[--utilities]
247
+ @hosts = %w(util_fluffy_hostname util_rocky_hostname)
248
+ end
249
+
250
+ include_examples "running ey ssh"
251
+ include_examples "running ey ssh for select role"
252
+ end
253
+
254
+ describe "ey ssh --utilities fluffy" do
255
+ before do
256
+ @ssh_flag = %w[--utilities fluffy]
257
+ @hosts = %w(util_fluffy_hostname)
258
+ end
259
+
260
+ include_examples "running ey ssh"
261
+ include_examples "running ey ssh for select role"
262
+ end
263
+
264
+ describe "ey ssh --utilities fluffy rocky" do
265
+ before do
266
+ @ssh_flag = %w[--utilities fluffy rocky]
267
+ @hosts = %w(util_fluffy_hostname util_rocky_hostname)
268
+ end
269
+
270
+ include_examples "running ey ssh"
271
+ include_examples "running ey ssh for select role"
272
+ end
273
+
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey environments" do
4
+
5
+ given "integration"
6
+
7
+ before(:all) do
8
+ login_scenario "one app, many environments"
9
+ end
10
+
11
+ it "tells you it's never been deployed" do
12
+ fast_failing_ey %w[status -e giblets]
13
+ expect(@err).to match(/Application rails232app has not been deployed on giblets./)
14
+ end
15
+
16
+ it "outputs the status of the deployment" do
17
+ fast_ey %w[deploy -e giblets --ref HEAD --no-migrate]
18
+ fast_ey %w[status -e giblets]
19
+ expect(@out).to match(/Application:\s+rails232app/)
20
+ expect(@out).to match(/Environment:\s+giblets/)
21
+ expect(@out).to match(/Ref:\s+HEAD/)
22
+ expect(@out).to match(/Resolved Ref:\s+resolved-HEAD/)
23
+ expect(@out).to match(/Commit:\s+[a-f0-9]{40}/)
24
+ expect(@out).to match(/Migrate:\s+false/)
25
+ expect(@out).to match(/Deployed by:\s+One App Many Envs/)
26
+ expect(@out).to match(/Started at:/)
27
+ expect(@out).to match(/Finished at:/)
28
+ expect(@out).to match(/Deployment was successful/)
29
+ end
30
+
31
+ it "quiets almost all of the output with --quiet" do
32
+ fast_ey %w[deploy -e giblets --ref HEAD --no-migrate]
33
+ fast_ey %w[status -e giblets -q]
34
+ expect(@out).not_to match(/Application:\s+rails232app/)
35
+ expect(@out).not_to match(/Environment:\s+giblets/)
36
+ expect(@out).not_to match(/Ref:\s+HEAD/)
37
+ expect(@out).not_to match(/Resolved Ref:\s+resolved-HEAD/)
38
+ expect(@out).not_to match(/Commit:\s+[a-f0-9]{40}/)
39
+ expect(@out).not_to match(/Migrate:\s+false/)
40
+ expect(@out).not_to match(/Deployed by:\s+One App Many Envs/)
41
+ expect(@out).not_to match(/Started at:/)
42
+ expect(@out).not_to match(/Finished at:/)
43
+ expect(@out).to match(/Deployment was successful/)
44
+ end
45
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey timeout-deploy" do
4
+ given "integration"
5
+
6
+ it "timeouts the last deployment" do
7
+ login_scenario "Stuck Deployment"
8
+ fast_ey %w[timeout-deploy]
9
+ expect(@out).to match(/Marking last deployment failed.../)
10
+ expect(@out).to match(/Finished at:\s+\w+/)
11
+ end
12
+
13
+ it "complains when there is no stuck deployment" do
14
+ login_scenario "one app, one environment"
15
+ fast_failing_ey ["timeout-deploy"]
16
+ expect(@err).to include(%|No unfinished deployment was found for main / rails232app / giblets.|)
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey web disable" do
4
+ given "integration"
5
+
6
+ def command_to_run(opts)
7
+ cmd = %w[web disable]
8
+ cmd << "-e" << opts[:environment] if opts[:environment]
9
+ cmd << "-a" << opts[:app] if opts[:app]
10
+ cmd << "-c" << opts[:account] if opts[:account]
11
+ cmd << "--verbose" if opts[:verbose]
12
+ cmd
13
+ end
14
+
15
+ def verify_ran(scenario)
16
+ expect(@ssh_commands).to have_command_like(/engineyard-serverside.*enable_maintenance.*--app #{scenario[:application]}/)
17
+ end
18
+
19
+ include_examples "it takes an environment name and an app name and an account name"
20
+ include_examples "it invokes engineyard-serverside"
21
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey web enable" do
4
+ given "integration"
5
+
6
+ def command_to_run(opts)
7
+ cmd = %w[web enable]
8
+ cmd << "-e" << opts[:environment] if opts[:environment]
9
+ cmd << "-a" << opts[:app] if opts[:app]
10
+ cmd << "-c" << opts[:account] if opts[:account]
11
+ cmd << "--verbose" if opts[:verbose]
12
+ cmd
13
+ end
14
+
15
+ def verify_ran(scenario)
16
+ expect(@ssh_commands).to have_command_like(/engineyard-serverside.*disable_maintenance.*--app #{scenario[:application]}/)
17
+ end
18
+
19
+ include_examples "it takes an environment name and an app name and an account name"
20
+ include_examples "it invokes engineyard-serverside"
21
+
22
+ it "fails when given a bad option" do
23
+ ey %w[web enable --lots --of --bogus --options], :expect_failure => true
24
+ expect(@err).to include("Unknown switches")
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey web restart" do
4
+ given "integration"
5
+
6
+ def command_to_run(opts)
7
+ cmd = %w[web restart]
8
+ cmd << "-e" << opts[:environment] if opts[:environment]
9
+ cmd << "-a" << opts[:app] if opts[:app]
10
+ cmd << "-c" << opts[:account] if opts[:account]
11
+ cmd << "--verbose" if opts[:verbose]
12
+ cmd
13
+ end
14
+
15
+ def verify_ran(scenario)
16
+ expect(@ssh_commands).to have_command_like(/engineyard-serverside.*restart.*--app #{scenario[:application]}/)
17
+ end
18
+
19
+ include_examples "it takes an environment name and an app name and an account name"
20
+ include_examples "it invokes engineyard-serverside"
21
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey whoami" do
4
+ given "integration"
5
+
6
+ context "logged in" do
7
+ before { login_scenario 'empty' }
8
+ it "outputs the currently logged in user" do
9
+ ey %w[whoami]
10
+ expect(@out).to include("User Name (#{scenario_email})")
11
+ end
12
+ end
13
+
14
+ context "not logged in" do
15
+ it "prompts for authentication before outputting the logged in user" do
16
+ api_scenario 'empty'
17
+
18
+ ey(%w[whoami], :hide_err => true) do |input|
19
+ input.puts(scenario_email)
20
+ input.puts(scenario_password)
21
+ end
22
+
23
+ expect(@out).to include("We need to fetch your API token; please log in.")
24
+ expect(@out).to include("Email:")
25
+ expect(@out).to include("Password:")
26
+
27
+ expect(@out).to include("User Name (#{scenario_email})")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,84 @@
1
+ if self.class.const_defined?(:EY_ROOT)
2
+ raise "don't require the spec helper twice!"
3
+ end
4
+
5
+ if ENV['COVERAGE']
6
+ require 'simplecov'
7
+ SimpleCov.start
8
+ end
9
+
10
+ EY_ROOT = File.expand_path("../..", __FILE__)
11
+ require 'rubygems'
12
+ require 'bundler/setup'
13
+ require 'escape'
14
+ require 'net/ssh'
15
+
16
+ # Bundled gems
17
+ require 'fakeweb'
18
+ require 'fakeweb_matcher'
19
+
20
+ require 'multi_json'
21
+
22
+ # Engineyard gem
23
+ $LOAD_PATH.unshift(File.join(EY_ROOT, "lib"))
24
+ require 'engineyard'
25
+
26
+ require 'engineyard-cloud-client/test'
27
+
28
+ # Spec stuff
29
+ require 'rspec'
30
+ require 'tmpdir'
31
+ require 'yaml'
32
+ require 'pp'
33
+
34
+ Dir[File.join(EY_ROOT,'/spec/support/*.rb')].each do |helper|
35
+ require helper
36
+ end
37
+
38
+ TMPDIR = Pathname.new(__FILE__).dirname.parent.join('tmp')
39
+
40
+ RSpec.configure do |config|
41
+ config.treat_symbols_as_metadata_keys_with_true_values = true
42
+ config.run_all_when_everything_filtered = true
43
+
44
+ config.include SpecHelpers
45
+ config.include SpecHelpers::IntegrationHelpers
46
+
47
+ config.extend SpecHelpers::GitRepoHelpers
48
+ config.extend SpecHelpers::Given
49
+
50
+ def clean_tmpdir
51
+ TMPDIR.rmtree if TMPDIR.exist?
52
+ end
53
+
54
+ # Cleaning the tmpdir has to happen outside of the test cycle because git repos
55
+ # last longer than the before/after :all test block in order to speed up specs.
56
+ config.before(:suite) { clean_tmpdir }
57
+ config.after(:suite) { clean_tmpdir }
58
+
59
+ config.before(:all) do
60
+ clean_eyrc
61
+ FakeWeb.allow_net_connect = false
62
+ ENV["CLOUD_URL"] = nil
63
+ ENV["NO_SSH"] = "true"
64
+ end
65
+
66
+ config.after(:all) do
67
+ clean_eyrc
68
+ end
69
+
70
+ end
71
+
72
+ shared_examples_for "integration" do
73
+ use_git_repo('default')
74
+
75
+ before(:all) do
76
+ FakeWeb.allow_net_connect = true
77
+ ENV['CLOUD_URL'] = EY::CloudClient::Test::FakeAwsm.uri
78
+ end
79
+
80
+ after(:all) do
81
+ ENV.delete('CLOUD_URL')
82
+ FakeWeb.allow_net_connect = false
83
+ end
84
+ end