engineyard 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,9 +25,10 @@ module EY
25
25
  omitted. Furthermore, if a default branch is specified but a different command
26
26
  is supplied the deploy will fail unless --ignore-default-branch is used.
27
27
 
28
- Migrations are run by default with 'rake db:migrate'. A different command can be
29
- specified via --migrate "ruby do_migrations.rb". Migrations can also be skipped
30
- entirely by using --no-migrate.
28
+ Migrations are run based on the 'Migrate?' setting you define in your dashboard
29
+ for the application. If you want to override these settings, a different
30
+ command can be specified via --migrate "ruby do_migrations.rb". Migrations
31
+ can also be skipped entirely by using --no-migrate.
31
32
  DESC
32
33
  method_option :ignore_default_branch, :type => :boolean,
33
34
  :desc => "Force a deploy of the specified branch even if a default is set"
@@ -74,8 +74,8 @@ module EY
74
74
 
75
75
  def print_envs(apps, default_env_name = nil, simple = false)
76
76
  if simple
77
- envs = apps.map{ |a| a.environments }
78
- puts envs.flatten.map{|x| x.name}.uniq
77
+ envs = apps.map{ |app| app.environments.to_a }
78
+ puts envs.flatten.map{|env| env.name }.uniq
79
79
  else
80
80
  apps.each do |app|
81
81
  puts "#{app.name} (#{app.account.name})"
@@ -2,14 +2,28 @@ require 'engineyard/error'
2
2
 
3
3
  module EY
4
4
  module Collection
5
- class Abstract < Array
5
+ class Abstract
6
6
  COLLAB_MESSAGE = <<-MSG
7
7
  \nThis error is due to having access to another account's resources via the collaboration feature.
8
8
  Specify --account ACCOUNT_NAME to resolve this ambiguity.
9
9
  MSG
10
10
 
11
+ include Enumerable
12
+
13
+ def initialize(contents)
14
+ @contents = contents ? contents.dup.flatten : []
15
+ end
16
+
17
+ def each(&block)
18
+ @contents.each(&block)
19
+ end
20
+
21
+ def to_a
22
+ @contents
23
+ end
24
+
11
25
  def named(name, account_name=nil)
12
- candidates = find_all do |x|
26
+ candidates = @contents.find_all do |x|
13
27
  if account_name
14
28
  x.name.downcase == name.downcase && x.account.name.downcase == account_name.downcase
15
29
  else
@@ -33,7 +47,7 @@ Specify --account ACCOUNT_NAME to resolve this ambiguity.
33
47
  private
34
48
 
35
49
  def find_by_unambiguous_substring(name_part)
36
- candidates = find_all{|e| e.name.downcase[name_part.downcase] }
50
+ candidates = @contents.find_all{|e| e.name.downcase[name_part.downcase] }
37
51
  if candidates.size > 1
38
52
  raise ambiguous_error(name_part, candidates.map {|e| e.name})
39
53
  end
@@ -10,7 +10,7 @@ module EY
10
10
  end
11
11
 
12
12
  def self.from_array(*)
13
- Collection::Apps[*super]
13
+ Collection::Apps.new(super)
14
14
  end
15
15
 
16
16
  def sole_environment
@@ -18,7 +18,7 @@ module EY
18
18
  end
19
19
 
20
20
  def self.from_array(*)
21
- Collection::Environments[*super]
21
+ Collection::Environments.new(super)
22
22
  end
23
23
 
24
24
  def logs
@@ -1,3 +1,3 @@
1
1
  module EY
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  end
@@ -12,5 +12,5 @@ describe EY::Collection::Apps do
12
12
  ])
13
13
  end
14
14
 
15
- it_should_behave_like "model collections"
15
+ include_examples "model collections"
16
16
  end
@@ -12,5 +12,5 @@ describe EY::Collection::Environments do
12
12
  ])
13
13
  end
14
14
 
15
- it_should_behave_like "model collections"
15
+ include_examples "model collections"
16
16
  end
@@ -1,12 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "EY::Model::Environment#rebuild" do
4
- given "it has an api"
5
-
6
4
  it "hits the rebuild action in the API" do
7
5
  env = EY::Model::Environment.from_hash({
8
6
  "id" => 46534,
9
- "api" => @api,
7
+ "api" => ey_api,
10
8
  })
11
9
 
12
10
  FakeWeb.register_uri(
@@ -22,12 +20,10 @@ describe "EY::Model::Environment#rebuild" do
22
20
  end
23
21
 
24
22
  describe "EY::Model::Environment#run_custom_recipes" do
25
- given "it has an api"
26
-
27
23
  it "hits the rebuild action in the API" do
28
24
  env = EY::Model::Environment.from_hash({
29
25
  "id" => 46534,
30
- "api" => @api,
26
+ "api" => ey_api,
31
27
  })
32
28
 
33
29
  FakeWeb.register_uri(
@@ -51,14 +47,12 @@ describe "EY::Model::Environment.from_array" do
51
47
  ]
52
48
 
53
49
  collection = EY::Model::Environment.from_array(api_data)
54
- collection.should be_kind_of(Array)
50
+ collection.should respond_to(:each)
55
51
  collection.should respond_to(:match_one)
56
52
  end
57
53
  end
58
54
 
59
55
  describe "EY::Model::Environment#instances" do
60
- given "it has an api"
61
-
62
56
  it "returns instances" do
63
57
  instance_data = {
64
58
  "id" => "1",
@@ -69,7 +63,7 @@ describe "EY::Model::Environment#instances" do
69
63
 
70
64
  env = EY::Model::Environment.from_hash({
71
65
  "id" => 10291,
72
- "api" => @api,
66
+ "api" => ey_api,
73
67
  "instances" => [instance_data],
74
68
  })
75
69
 
@@ -159,14 +153,14 @@ describe "EY::Model::Environment#migration_command" do
159
153
  @app = EY::Model::App.from_hash({:name => 'fake'})
160
154
  @migrate = EY::Model::Environment.from_hash({
161
155
  "id" => 10291,
162
- "api" => @api,
156
+ "api" => ey_api,
163
157
  'name' => 'migrate',
164
158
  'deployment_configurations' => {'fake' => {'migrate' => {'command' => 'fake db:migrate', 'perform' => true}}}
165
159
  })
166
160
 
167
161
  @no_migrate = EY::Model::Environment.from_hash({
168
162
  "id" => 10291,
169
- "api" => @api,
163
+ "api" => ey_api,
170
164
  'name' => 'no_migrate',
171
165
  'deployment_configurations' => {'fake' => {'migrate' => {'command' => 'fake db:migrate', 'perform' => false}}}
172
166
  })
@@ -1,11 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "EY::Model::Instance#has_app_code?" do
4
-
5
- def have_app_code
6
- simple_matcher("has app code") { |given| given.has_app_code? }
7
- end
8
-
9
4
  it "is true for solos" do
10
5
  EY::Model::Instance.from_hash("role" => "solo").should have_app_code
11
6
  end
@@ -1,14 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe EY::Repo do
4
- before(:all) do
4
+ before(:each) do
5
5
  FakeFS.deactivate!
6
6
  @path = Pathname.new("/tmp/ey-test/.git/")
7
7
  @path.mkpath
8
8
  @r = EY::Repo.new("/tmp/ey-test")
9
9
  end
10
- after(:all) { FakeFS.activate! }
11
- after(:each) { clear_urls }
10
+
11
+ after(:each) do
12
+ clear_urls
13
+ FakeFS.activate!
14
+ end
12
15
 
13
16
  def set_head(head)
14
17
  @path.join("HEAD").open('w') {|f| f.write(head) }
@@ -51,8 +54,8 @@ describe EY::Repo do
51
54
  other_url = "git@github.com:engineyard/engineyard.git"
52
55
  set_url origin_url, "origin"
53
56
  set_url other_url, "other"
54
- @r.should be_has_remote(origin_url)
55
- @r.should be_has_remote(other_url)
57
+ @r.should have_remote(origin_url)
58
+ @r.should have_remote(other_url)
56
59
  end
57
60
  end # url
58
61
 
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe EY::Resolver do
4
- def api
5
- return @api if @api
4
+ def mock_api
5
+ return @mock_api if @mock_api
6
6
  apps = Object.new
7
7
  def apps.named(name, *args)
8
8
  result = EY::Model::App.from_hash(:name => name)
@@ -15,11 +15,11 @@ describe EY::Resolver do
15
15
  result.stub!(:apps => [])
16
16
  result
17
17
  end
18
- @api = mock("api", :apps => apps, :environments => environments)
18
+ @mock_api = mock("api", :apps => apps, :environments => environments)
19
19
  end
20
20
 
21
21
  def resolver
22
- @resolver ||= EY::Resolver.new(api).tap do |r|
22
+ @resolver ||= EY::Resolver.new(mock_api).tap do |r|
23
23
  r.instance_variable_set("@app_deployments", [])
24
24
  end
25
25
  end
@@ -45,13 +45,6 @@ describe EY::Resolver do
45
45
  r
46
46
  end
47
47
 
48
- def resolve_to(expected)
49
- simple_matcher "resolve to" do |(app,environment), _|
50
- app.name.should == expected[:app_name]
51
- environment.name.should == expected[:environment_name]
52
- end
53
- end
54
-
55
48
  describe "#fetch" do
56
49
  it "raises argument error if the conditions are empty" do
57
50
  lambda { resolver.app_and_environment({}) }.should raise_error(ArgumentError)
@@ -43,8 +43,8 @@ describe "ey deploy" do
43
43
  end
44
44
 
45
45
  # common behavior
46
- it_should_behave_like "it takes an environment name and an app name and an account name"
47
- it_should_behave_like "it invokes engineyard-serverside"
46
+ include_examples "it takes an environment name and an app name and an account name"
47
+ include_examples "it invokes engineyard-serverside"
48
48
  end
49
49
 
50
50
  describe "ey deploy" do
@@ -55,7 +55,7 @@ end
55
55
 
56
56
  describe "ey environments with an ambiguous git repo" do
57
57
  given "integration"
58
- it_should_behave_like "it has an ambiguous git repo"
58
+ include_examples "it has an ambiguous git repo"
59
59
 
60
60
  it "lists environments from all apps using the git repo" do
61
61
  ey %w[environments]
data/spec/ey/logs_spec.rb CHANGED
@@ -32,5 +32,5 @@ describe "ey logs" do
32
32
  @out.should match(/Main logs for #{scenario[:environment]}/)
33
33
  end
34
34
 
35
- it_should_behave_like "it takes an environment name and an account name"
35
+ include_examples "it takes an environment name and an account name"
36
36
  end
@@ -14,5 +14,5 @@ describe "ey rebuild" do
14
14
  @out.should =~ /Rebuilding #{scenario[:environment]}/
15
15
  end
16
16
 
17
- it_should_behave_like "it takes an environment name and an account name"
17
+ include_examples "it takes an environment name and an account name"
18
18
  end
@@ -14,7 +14,7 @@ describe "ey recipes apply" do
14
14
  @out.should =~ /Uploaded recipes started for #{scenario[:environment]}/
15
15
  end
16
16
 
17
- it_should_behave_like "it takes an environment name and an account name"
17
+ include_examples "it takes an environment name and an account name"
18
18
 
19
19
  it "fails when given a bad option" do
20
20
  ey %w[web enable --lots --of --bogus --options], :expect_failure => true
@@ -25,5 +25,5 @@ end
25
25
  describe "ey recipes apply with an ambiguous git repo" do
26
26
  given "integration"
27
27
  def command_to_run(_) %w[recipes apply] end
28
- it_should_behave_like "it requires an unambiguous git repo"
28
+ include_examples "it requires an unambiguous git repo"
29
29
  end
@@ -11,7 +11,7 @@ describe "ey recipes download" do
11
11
  after(:each) do
12
12
  # This test creates + destroys the cookbooks/ directory, thus
13
13
  # rendering the git repo unsuitable for reuse.
14
- refresh_git_repo('default')
14
+ EY.refresh_git_repo('default')
15
15
  end
16
16
 
17
17
  def command_to_run(opts)
@@ -26,7 +26,7 @@ describe "ey recipes download" do
26
26
  File.read('cookbooks/README').should == "Remove this file to clone an upstream git repository of cookbooks\n"
27
27
  end
28
28
 
29
- it_should_behave_like "it takes an environment name and an account name"
29
+ include_examples "it takes an environment name and an account name"
30
30
 
31
31
  it "fails when cookbooks/ already exists" do
32
32
  api_scenario "one app, one environment"
@@ -39,5 +39,5 @@ end
39
39
  describe "ey recipes download with an ambiguous git repo" do
40
40
  given "integration"
41
41
  def command_to_run(_) %w[recipes download] end
42
- it_should_behave_like "it requires an unambiguous git repo"
42
+ include_examples "it requires an unambiguous git repo"
43
43
  end
@@ -20,7 +20,7 @@ describe "ey recipes upload" do
20
20
  @out.should =~ %r|Recipes in cookbooks/ uploaded successfully for #{scenario[:environment]}|
21
21
  end
22
22
 
23
- it_should_behave_like "it takes an environment name and an account name"
23
+ include_examples "it takes an environment name and an account name"
24
24
  end
25
25
 
26
26
  describe "ey recipes upload -f recipes.tgz" do
@@ -43,7 +43,7 @@ describe "ey recipes upload -f recipes.tgz" do
43
43
  @out.should =~ %r|Recipes file recipes.tgz uploaded successfully for #{scenario[:environment]}|
44
44
  end
45
45
 
46
- it_should_behave_like "it takes an environment name and an account name"
46
+ include_examples "it takes an environment name and an account name"
47
47
  end
48
48
 
49
49
  describe "ey recipes upload -f with a missing filenamen" do
@@ -66,7 +66,7 @@ end
66
66
  describe "ey recipes upload with an ambiguous git repo" do
67
67
  given "integration"
68
68
  def command_to_run(_) %w[recipes upload] end
69
- it_should_behave_like "it requires an unambiguous git repo"
69
+ include_examples "it requires an unambiguous git repo"
70
70
  end
71
71
 
72
72
  describe "ey recipes upload from a separate cookbooks directory" do
@@ -18,8 +18,8 @@ describe "ey rollback" do
18
18
  @ssh_commands.last.should match(/engineyard-serverside.*deploy rollback.*--app #{scenario[:application]}/)
19
19
  end
20
20
 
21
- it_should_behave_like "it takes an environment name and an app name and an account name"
22
- it_should_behave_like "it invokes engineyard-serverside"
21
+ include_examples "it takes an environment name and an app name and an account name"
22
+ include_examples "it invokes engineyard-serverside"
23
23
 
24
24
  it "passes along the web server stack to engineyard-serverside" do
25
25
  api_scenario "one app, one environment"
data/spec/ey/ssh_spec.rb CHANGED
@@ -4,7 +4,6 @@ print_my_args_ssh = "#!/bin/sh\necho ssh $*"
4
4
 
5
5
  shared_examples_for "running ey ssh" do
6
6
  given "integration"
7
- include Spec::Helpers::SharedIntegrationTestUtils
8
7
 
9
8
  def extra_ey_options
10
9
  ssh_cmd = <<-RUBY
@@ -19,7 +18,6 @@ end
19
18
 
20
19
  shared_examples_for "running ey ssh for select role" do
21
20
  given "integration"
22
- include Spec::Helpers::SharedIntegrationTestUtils
23
21
 
24
22
  def extra_ey_options
25
23
  {:prepend_to_path => {'ssh' => "#!/bin/sh\necho ssh $*"}}
@@ -58,7 +56,7 @@ shared_examples_for "running ey ssh for select role" do
58
56
  end
59
57
 
60
58
  describe "ey ssh" do
61
- it_should_behave_like "running ey ssh"
59
+ include_examples "running ey ssh"
62
60
 
63
61
  before(:all) do
64
62
  api_scenario "one app, many environments"
@@ -72,13 +70,13 @@ describe "ey ssh" do
72
70
  end
73
71
 
74
72
  describe "ey ssh with an ambiguous git repo" do
75
- it_should_behave_like "running ey ssh"
73
+ include_examples "running ey ssh"
76
74
  def command_to_run(_) %w[ssh ls] end
77
- it_should_behave_like "it requires an unambiguous git repo"
75
+ include_examples "it requires an unambiguous git repo"
78
76
  end
79
77
 
80
78
  describe "ey ssh without a command" do
81
- it_should_behave_like "running ey ssh"
79
+ include_examples "running ey ssh"
82
80
 
83
81
  def command_to_run(opts)
84
82
  cmd = ["ssh"]
@@ -92,11 +90,11 @@ describe "ey ssh without a command" do
92
90
  @raw_ssh_commands.should == ["ssh #{ssh_target}"]
93
91
  end
94
92
 
95
- it_should_behave_like "it takes an environment name and an account name"
93
+ include_examples "it takes an environment name and an account name"
96
94
  end
97
95
 
98
96
  describe "ey ssh with a command" do
99
- it_should_behave_like "running ey ssh"
97
+ include_examples "running ey ssh"
100
98
 
101
99
  def command_to_run(opts)
102
100
  cmd = %w[ssh ls]
@@ -110,11 +108,11 @@ describe "ey ssh with a command" do
110
108
  @raw_ssh_commands.should == ["ssh #{ssh_target} ls"]
111
109
  end
112
110
 
113
- it_should_behave_like "it takes an environment name and an account name"
111
+ include_examples "it takes an environment name and an account name"
114
112
  end
115
113
 
116
114
  describe "ey ssh with a multi-part command" do
117
- it_should_behave_like "running ey ssh"
115
+ include_examples "running ey ssh"
118
116
 
119
117
  def command_to_run(opts)
120
118
  cmd = ['ssh', 'echo "echo"']
@@ -128,7 +126,7 @@ describe "ey ssh with a multi-part command" do
128
126
  @raw_ssh_commands.should == ["ssh #{ssh_target} 'echo \"echo\"'"]
129
127
  end
130
128
 
131
- it_should_behave_like "it takes an environment name and an account name"
129
+ include_examples "it takes an environment name and an account name"
132
130
  end
133
131
 
134
132
  describe "ey ssh --all" do
@@ -143,8 +141,8 @@ describe "ey ssh --all" do
143
141
  db_slave_2_hostname)
144
142
  end
145
143
 
146
- it_should_behave_like "running ey ssh"
147
- it_should_behave_like "running ey ssh for select role"
144
+ include_examples "running ey ssh"
145
+ include_examples "running ey ssh for select role"
148
146
  end
149
147
 
150
148
  describe "ey ssh --app-servers" do
@@ -153,8 +151,8 @@ describe "ey ssh --app-servers" do
153
151
  @hosts = %w(app_hostname app_master_hostname)
154
152
  end
155
153
 
156
- it_should_behave_like "running ey ssh"
157
- it_should_behave_like "running ey ssh for select role"
154
+ include_examples "running ey ssh"
155
+ include_examples "running ey ssh for select role"
158
156
  end
159
157
 
160
158
  describe "ey ssh --db-master" do
@@ -163,8 +161,8 @@ describe "ey ssh --db-master" do
163
161
  @hosts = %w(db_master_hostname)
164
162
  end
165
163
 
166
- it_should_behave_like "running ey ssh"
167
- it_should_behave_like "running ey ssh for select role"
164
+ include_examples "running ey ssh"
165
+ include_examples "running ey ssh for select role"
168
166
  end
169
167
 
170
168
  describe "ey ssh --db-slaves" do
@@ -173,8 +171,8 @@ describe "ey ssh --db-slaves" do
173
171
  @hosts = %w(db_slave_1_hostname db_slave_2_hostname)
174
172
  end
175
173
 
176
- it_should_behave_like "running ey ssh"
177
- it_should_behave_like "running ey ssh for select role"
174
+ include_examples "running ey ssh"
175
+ include_examples "running ey ssh for select role"
178
176
  end
179
177
 
180
178
  describe "ey ssh --db-servers" do
@@ -183,8 +181,8 @@ describe "ey ssh --db-servers" do
183
181
  @hosts = %w(db_master_hostname db_slave_1_hostname db_slave_2_hostname)
184
182
  end
185
183
 
186
- it_should_behave_like "running ey ssh"
187
- it_should_behave_like "running ey ssh for select role"
184
+ include_examples "running ey ssh"
185
+ include_examples "running ey ssh for select role"
188
186
  end
189
187
 
190
188
  describe "ey ssh --utilities" do
@@ -193,8 +191,8 @@ describe "ey ssh --utilities" do
193
191
  @hosts = %w(util_fluffy_hostname util_rocky_hostname)
194
192
  end
195
193
 
196
- it_should_behave_like "running ey ssh"
197
- it_should_behave_like "running ey ssh for select role"
194
+ include_examples "running ey ssh"
195
+ include_examples "running ey ssh for select role"
198
196
  end
199
197
 
200
198
  describe "ey ssh --utilities fluffy" do
@@ -203,8 +201,8 @@ describe "ey ssh --utilities fluffy" do
203
201
  @hosts = %w(util_fluffy_hostname)
204
202
  end
205
203
 
206
- it_should_behave_like "running ey ssh"
207
- it_should_behave_like "running ey ssh for select role"
204
+ include_examples "running ey ssh"
205
+ include_examples "running ey ssh for select role"
208
206
  end
209
207
 
210
208
  describe "ey ssh --utilities fluffy rocky" do
@@ -213,7 +211,7 @@ describe "ey ssh --utilities fluffy rocky" do
213
211
  @hosts = %w(util_fluffy_hostname util_rocky_hostname)
214
212
  end
215
213
 
216
- it_should_behave_like "running ey ssh"
217
- it_should_behave_like "running ey ssh for select role"
214
+ include_examples "running ey ssh"
215
+ include_examples "running ey ssh for select role"
218
216
  end
219
217