engineyard-serverside-adapter 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzQ0Mzk3ZTIyMjc5NzcyY2YyNTU5MDg4NjI5YzhlNDQyYjRkNjNiOQ==
4
+ YjY3NzdlMzA1N2I0NmZhYjg1MmFkY2I2ZGM4NDJjYTY5OTJiNzI4Zg==
5
5
  data.tar.gz: !binary |-
6
- MGEzZDk5NzlkZDkzMWRjOTk2YWIwZTVmM2U4NDBmNjFkMWJjNTBhNQ==
6
+ NTBlOTYyN2VlMjFmNzM3ZmFkNTdmMzU5MGNmYjk0YjI0OTI4ZWE4MQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZDM2ODRjOWMwMzdkMGEyMTEzNTI4OGY5YzExMzhhOWQyODIwYjE2ODZmYzNi
10
- ZTg3NWZmMzIxOTM5YjA2NmE1NjUzMDc2N2YzYWMyYzMwOWNmYzY0MjdjZjVl
11
- YzRkZGJkNWZjY2U1ZjE4MjNhZTMxMTI5MGJiMmM0MDg5OGVjMDc=
9
+ MzU4MzAxMmY3YTQ4ZWZkMzhmNmMyNjVlMTYzODMxZTIyNjExNjVhN2Q2ZWNm
10
+ MDgyNDRmZDI4Mjc5MDI4M2IyYTZmMGM5MTkzNjdlNTkwYmM0Y2JmZWRkNjY0
11
+ ODI5OWJlMmI4ZGVlNDEwMzVhN2FhODU4ZjllN2MzZjc4ZjRiYTU=
12
12
  data.tar.gz: !binary |-
13
- YWU5NzM5YzA1Y2ZiYzljYzcyYzk3NmQ3NzhkMmQ5YTNkNzE1Yzk4NTIzOTJk
14
- ZDcwOGIzMmI0ODQ0ZDE4OWYwYjRmYzNkNjExNDM0ZThkNjA5ZmM5OWVmMWUx
15
- YzAwOGQ1ODYzZTY2YzliMGQzOTFjZGNmY2M1ZjFmYTljMGE0ZGY=
13
+ NmY1Yjk5NWY0MjIzMzUwMzQxNjg2OTJmZDEwNTk3YTgxYTE1NDNkZmE5NjQ3
14
+ ZDcxYmFmMjA4YTAwZGQxODZiYzliNTAyNDMzMzE2YTg2NTA5ZGFjZmE1MmI0
15
+ NDBmYjg5NTcxYjk5NWE0NTlhNjE1ZTllNTM1ZTdjNDcyZWEyNWQ=
@@ -0,0 +1,9 @@
1
+ # ChangeLog
2
+
3
+ ## NEXT
4
+
5
+ *
6
+
7
+ ## v2.2.0 (2013-09-30)
8
+
9
+ * Require serverside_version for all commands.
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'rspec/core/rake_task'
2
+ require 'date'
3
+
2
4
  RSpec::Core::RakeTask.new(:spec) do |t|
3
5
  t.rspec_opts = ['-cfs']
4
6
  end
@@ -9,12 +11,22 @@ task :release do
9
11
  puts "Adapter DOES NOT bump serverside automatically anymore."
10
12
  puts "Please reference the serverside_version in the client."
11
13
  puts
14
+
12
15
  new_version = remove_pre
16
+ write_version new_version
17
+ release_changelog(new_version)
13
18
 
14
- run_commands("git tag v#{new_version}",
19
+ run_commands(
20
+ "git add ChangeLog.md #{version_path}",
21
+ "git commit -m 'Bump versions for release #{new_version}'",
15
22
  "gem build engineyard-serverside-adapter.gemspec")
16
23
 
17
- next_pre(new_version)
24
+ write_version next_pre(new_version)
25
+
26
+ run_commands(
27
+ "git add #{version_path}",
28
+ "git commit -m 'Add .pre for next release'",
29
+ "git tag v#{new_version} HEAD^")
18
30
 
19
31
  puts <<-PUSHGEM
20
32
  ## To publish the gem: #########################################################
@@ -36,27 +48,32 @@ def run_commands(*cmds)
36
48
  end
37
49
  end
38
50
 
51
+ def release_changelog(version)
52
+ clog = Pathname.new('ChangeLog.md')
53
+ new_clog = clog.read.sub(/^## NEXT$/, <<-SUB.chomp)
54
+ ## NEXT
55
+
56
+ *
57
+
58
+ ## v#{version} (#{Date.today})
59
+ SUB
60
+ clog.open('w') { |f| f.puts new_clog }
61
+ end
62
+
39
63
  def remove_pre
40
64
  require 'engineyard-serverside-adapter/version'
41
- new_version = Gem::Version.create(EY::Serverside::Adapter::VERSION).release
42
- puts "New version is #{new_version}"
43
- bump(new_version, "Bump to version #{new_version}")
44
- new_version.to_s
65
+ Gem::Version.create(EY::Serverside::Adapter::VERSION).release
45
66
  end
46
67
 
47
68
  def next_pre(version)
48
- digits = version.scan(/(\d+)/).map { |x| x.first.to_i }
69
+ digits = version.to_s.scan(/(\d+)/).map { |x| x.first.to_i }
49
70
  digits[-1] += 1
50
71
  new_version = digits.join('.') + ".pre"
51
- puts "Next version is #{new_version}"
52
- bump(new_version, "Add .pre for next release")
53
72
  end
54
73
 
55
- def bump(new_version, commit_msg)
74
+ def write_version(new_version)
56
75
  contents = version_path.read.sub(/VERSION = "[^"]+"/, %|VERSION = "#{new_version}"|)
76
+ puts "engineyard-serverside-adapter (#{new_version})"
57
77
  version_path.unlink
58
78
  version_path.open('w') { |f| f.write contents }
59
- run_commands(
60
- "git add #{version_path}",
61
- "git commit -m '#{commit_msg}'")
62
79
  end
@@ -1,9 +1,9 @@
1
1
  require 'pathname'
2
+ require 'engineyard-serverside-adapter/version'
2
3
 
3
4
  module EY
4
5
  module Serverside
5
6
  class Adapter
6
- require 'engineyard-serverside-adapter/version'
7
7
  autoload :Action, 'engineyard-serverside-adapter/action'
8
8
  autoload :Arguments, 'engineyard-serverside-adapter/arguments'
9
9
  autoload :Command, 'engineyard-serverside-adapter/command'
@@ -29,7 +29,7 @@ module EY
29
29
 
30
30
  block.call @arguments if block
31
31
 
32
- @serverside_version = Gem::Version.create(@arguments.serverside_version || ENGINEYARD_SERVERSIDE_VERSION.dup)
32
+ @serverside_version = @arguments.serverside_version
33
33
 
34
34
  validate!
35
35
  end
@@ -120,6 +120,10 @@ module EY
120
120
  end
121
121
 
122
122
  def validate!
123
+ unless @serverside_version
124
+ raise ArgumentError, "Required field [serverside_version] not provided."
125
+ end
126
+
123
127
  missing = required_options - given_options
124
128
  unless missing.empty?
125
129
  options_s = missing.map{|option| option.name}.join(', ')
@@ -18,16 +18,9 @@ module EY
18
18
  end
19
19
  end
20
20
 
21
- def self.aliased_attribute(pairs)
22
- pairs.each do |from, to|
23
- alias_method from, to
24
- alias_method :"#{from}=", "#{to}="
25
- end
26
- end
27
-
28
21
  nonempty_attr_accessor :app, :account_name, :archive, :environment_name
29
- nonempty_attr_accessor :framework_env, :git, :ref, :serverside_version, :stack
30
- attr_accessor :config, :migrate, :verbose
22
+ nonempty_attr_accessor :framework_env, :git, :ref, :stack
23
+ attr_accessor :clean, :config, :migrate, :serverside_version, :verbose
31
24
  attr_reader :instances
32
25
  alias repo git # for versions where --repo is required, it is accessed via this alias
33
26
 
@@ -49,8 +42,10 @@ module EY
49
42
  @instances = instances
50
43
  end
51
44
 
52
- # Uses Gem::Version.create to validate the version string
53
45
  def serverside_version=(value)
46
+ if value.nil? || value.to_s.empty?
47
+ raise ArgumentError, "Value for 'serverside_version' must be non-empty."
48
+ end
54
49
  @serverside_version = Gem::Version.create(value.dup) # dup b/c Gem::Version sometimes modifies its argument :(
55
50
  end
56
51
 
@@ -6,6 +6,7 @@ module EY
6
6
  option :app, :string, :required => true
7
7
  option :account_name, :string, :required => true, :version => '>= 2.0.0'
8
8
  option :archive, :string, :version => '>= 2.3.0'
9
+ option :clean, :boolean, :version => '>= 2.3.1'
9
10
  option :config, :json
10
11
  option :environment_name, :string, :required => true, :version => '>= 2.0.0'
11
12
  option :git, :string, :version => '>= 2.3.0'
@@ -1,11 +1,7 @@
1
1
  module EY
2
2
  module Serverside
3
3
  class Adapter
4
- VERSION = "2.1.0"
5
- # For backwards compatibility, the serverside version default will be maintained until 2.1
6
- # It is recommended that you supply a serverside_version to engineyard-serverside-adapter
7
- # rather than relying on the default version here. This default will go away soon.
8
- ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || "2.3.0"
4
+ VERSION = "2.2.0"
9
5
  end
10
6
  end
11
7
  end
@@ -11,6 +11,7 @@ shared_examples_for "a serverside action" do
11
11
  args.ref = 'master'
12
12
  args.git = 'git@github.com:engineyard/engineyard-serverside.git'
13
13
  args.stack = 'nginx_unicorn'
14
+ args.serverside_version = serverside_version
14
15
  args
15
16
  end
16
17
  end
@@ -88,6 +89,7 @@ shared_examples_for "a serverside action" do
88
89
  args.ref = 'master'
89
90
  args.git = 'git@github.com:engineyard/engineyard-serverside.git'
90
91
  args.stack = 'nginx_unicorn'
92
+ args.serverside_version = serverside_version
91
93
  args
92
94
  end
93
95
 
@@ -154,6 +156,7 @@ describe EY::Serverside::Adapter do
154
156
  args.ref = 'master'
155
157
  args.git = 'git@github.com:engineyard/engineyard-serverside.git'
156
158
  args.stack = 'nginx_unicorn'
159
+ args.serverside_version = serverside_version
157
160
  end
158
161
  end
159
162
 
@@ -2,9 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  describe EY::Serverside::Adapter::Arguments do
4
4
  def raises_argument_error(message = nil, &block)
5
- lambda {
5
+ expect {
6
6
  block.call(described_class.new)
7
- }.should raise_error(ArgumentError, message)
7
+ }.to raise_error(ArgumentError, message)
8
8
  end
9
9
 
10
10
  it "raises an ArgumentError immediately when instances is empty" do
@@ -31,4 +31,13 @@ describe EY::Serverside::Adapter::Arguments do
31
31
  end
32
32
  end
33
33
 
34
+ it "raises an ArgumentError immediately when serverside_version is empty" do
35
+ raises_argument_error(/Value for 'serverside_version' must be non-empty/) do |arguments|
36
+ arguments.serverside_version = nil
37
+ end
38
+
39
+ raises_argument_error(/Value for 'serverside_version' must be non-empty/) do |arguments|
40
+ arguments.serverside_version = ''
41
+ end
42
+ end
34
43
  end
@@ -6,6 +6,7 @@ describe EY::Serverside::Adapter::Deploy do
6
6
  it_should_behave_like "it accepts app"
7
7
  it_should_behave_like "it accepts account_name"
8
8
  it_should_behave_like "it accepts archive"
9
+ it_should_behave_like "it accepts clean"
9
10
  it_should_behave_like "it accepts environment_name"
10
11
  it_should_behave_like "it accepts framework_env"
11
12
  it_should_behave_like "it accepts git"
@@ -24,6 +25,7 @@ describe EY::Serverside::Adapter::Deploy do
24
25
  it_should_require :stack
25
26
  it_should_require :ref, %w[1.6.4 2.0.0 2.1.0 2.2.0]
26
27
  it_should_require :git, %w[1.6.4 2.0.0 2.1.0 2.2.0]
28
+ it_should_require :serverside_version
27
29
 
28
30
  it_should_ignore_requirement :environment_name, '1.6.4'
29
31
  it_should_ignore_requirement :account_name, '1.6.4'
@@ -51,7 +53,7 @@ describe EY::Serverside::Adapter::Deploy do
51
53
  arguments.ref = 'master'
52
54
  arguments.git = 'git@github.com:engineyard/engineyard-serverside.git'
53
55
  arguments.stack = "nginx_unicorn"
54
- arguments.serverside_version = '2.3.0'
56
+ arguments.serverside_version = serverside_version
55
57
  block.call arguments if block
56
58
  end
57
59
  last_command(adapter)
@@ -68,7 +70,7 @@ describe EY::Serverside::Adapter::Deploy do
68
70
  arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
69
71
  arguments.migrate = 'rake db:migrate'
70
72
  arguments.stack = "nginx_unicorn"
71
- arguments.serverside_version = '2.3.0'
73
+ arguments.serverside_version = serverside_version
72
74
  block.call arguments if block_given?
73
75
  end
74
76
  last_command(adapter)
@@ -81,7 +83,7 @@ describe EY::Serverside::Adapter::Deploy do
81
83
  it "invokes exactly the right command" do
82
84
  deploy_command.should == [
83
85
  "engineyard-serverside",
84
- "_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
86
+ "_#{serverside_version}_",
85
87
  "deploy",
86
88
  "--account-name ey",
87
89
  "--app rackapp",
@@ -174,16 +176,17 @@ describe EY::Serverside::Adapter::Deploy do
174
176
  context "with git deploy" do
175
177
  let(:command) do
176
178
  adapter = described_class.new do |arguments|
177
- arguments.app = "rackapp"
178
- arguments.environment_name = 'rackapp_production'
179
- arguments.account_name = 'ey'
180
- arguments.framework_env = 'production'
181
- arguments.config = {'a' => 1}
182
- arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
183
- arguments.migrate = 'rake db:migrate'
184
- arguments.ref = 'master'
185
- arguments.git = 'git@github.com:engineyard/engineyard-serverside.git'
186
- arguments.stack = "nginx_unicorn"
179
+ arguments.app = "rackapp"
180
+ arguments.environment_name = 'rackapp_production'
181
+ arguments.account_name = 'ey'
182
+ arguments.framework_env = 'production'
183
+ arguments.config = {'a' => 1}
184
+ arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
185
+ arguments.migrate = 'rake db:migrate'
186
+ arguments.ref = 'master'
187
+ arguments.git = 'git@github.com:engineyard/engineyard-serverside.git'
188
+ arguments.stack = "nginx_unicorn"
189
+ arguments.serverside_version = '2.3.0'
187
190
  end
188
191
  last_command(adapter)
189
192
  end
@@ -191,7 +194,7 @@ describe EY::Serverside::Adapter::Deploy do
191
194
  it "invokes exactly the right command" do
192
195
  command.should == [
193
196
  "engineyard-serverside",
194
- "_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
197
+ "_2.3.0_",
195
198
  "deploy",
196
199
  "--account-name ey",
197
200
  "--app rackapp",
@@ -220,7 +223,7 @@ describe EY::Serverside::Adapter::Deploy do
220
223
  args.migrate = false
221
224
  args.stack = "nginx_unicorn"
222
225
  args.archive = 'https://github.com/engineyard/engineyard-serverside/archive/master.zip'
223
- args.serverside_version = EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION
226
+ args.serverside_version = '2.3.0'
224
227
  end
225
228
 
226
229
  last_command(adapter)
@@ -229,7 +232,7 @@ describe EY::Serverside::Adapter::Deploy do
229
232
  it "invokes exactly the right command" do
230
233
  command.should == [
231
234
  "engineyard-serverside",
232
- "_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
235
+ "_2.3.0_",
233
236
  "deploy",
234
237
  "--account-name ey",
235
238
  "--app rackapp",
@@ -259,6 +262,7 @@ describe EY::Serverside::Adapter::Deploy do
259
262
  arguments.ref = 'master'
260
263
  arguments.git = 'git@github.com:engineyard/engineyard-serverside.git'
261
264
  arguments.stack = "nginx_unicorn"
265
+ arguments.serverside_version = '2.3.0'
262
266
  end
263
267
  last_command(adapter)
264
268
  end
@@ -270,7 +274,7 @@ describe EY::Serverside::Adapter::Deploy do
270
274
  it "invokes exactly the right command" do
271
275
  command.should == [
272
276
  "engineyard-serverside",
273
- "_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
277
+ "_2.3.0_",
274
278
  "deploy",
275
279
  "--account-name ey",
276
280
  "--app rackapp",
@@ -14,6 +14,7 @@ describe EY::Serverside::Adapter::DisableMaintenance do
14
14
  it_should_require :environment_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
15
15
  it_should_require :account_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
16
16
  it_should_require :instances
17
+ it_should_require :serverside_version
17
18
 
18
19
  it_should_ignore_requirement :environment_name, '1.6.4'
19
20
  it_should_ignore_requirement :account_name, '1.6.4'
@@ -24,10 +25,11 @@ describe EY::Serverside::Adapter::DisableMaintenance do
24
25
  context "with valid arguments" do
25
26
  let(:command) do
26
27
  adapter = described_class.new do |arguments|
27
- arguments.app = "rackapp"
28
- arguments.environment_name = "rackapp_production"
29
- arguments.account_name = "ey"
30
- arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
28
+ arguments.app = "rackapp"
29
+ arguments.environment_name = "rackapp_production"
30
+ arguments.account_name = "ey"
31
+ arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
32
+ arguments.serverside_version = serverside_version
31
33
  end
32
34
  last_command(adapter)
33
35
  end
@@ -35,7 +37,7 @@ describe EY::Serverside::Adapter::DisableMaintenance do
35
37
  it "invokes exactly the right command" do
36
38
  command.should == [
37
39
  "engineyard-serverside",
38
- "_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
40
+ "_#{serverside_version}_",
39
41
  "disable_maintenance",
40
42
  "--account-name ey",
41
43
  "--app rackapp",
@@ -14,6 +14,7 @@ describe EY::Serverside::Adapter::EnableMaintenance do
14
14
  it_should_require :environment_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
15
15
  it_should_require :account_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
16
16
  it_should_require :instances
17
+ it_should_require :serverside_version
17
18
 
18
19
  it_should_ignore_requirement :environment_name, '1.6.4'
19
20
  it_should_ignore_requirement :account_name, '1.6.4'
@@ -25,10 +26,11 @@ describe EY::Serverside::Adapter::EnableMaintenance do
25
26
 
26
27
  let(:command) do
27
28
  adapter = described_class.new do |arguments|
28
- arguments.app = "rackapp"
29
- arguments.environment_name = "rackapp_production"
30
- arguments.account_name = "ey"
31
- arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
29
+ arguments.app = "rackapp"
30
+ arguments.environment_name = "rackapp_production"
31
+ arguments.account_name = "ey"
32
+ arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
33
+ arguments.serverside_version = serverside_version
32
34
  end
33
35
  last_command(adapter)
34
36
  end
@@ -36,7 +38,7 @@ describe EY::Serverside::Adapter::EnableMaintenance do
36
38
  it "invokes exactly the right command" do
37
39
  command.should == [
38
40
  "engineyard-serverside",
39
- "_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
41
+ "_#{serverside_version}_",
40
42
  "enable_maintenance",
41
43
  "--account-name ey",
42
44
  "--app rackapp",
@@ -18,6 +18,7 @@ describe EY::Serverside::Adapter::Integrate do
18
18
  it_should_require :stack
19
19
  it_should_require :instances
20
20
  it_should_require :framework_env
21
+ it_should_require :serverside_version
21
22
 
22
23
  it_should_ignore_requirement :environment_name, '1.6.4'
23
24
  it_should_ignore_requirement :account_name, '1.6.4'
@@ -28,12 +29,13 @@ describe EY::Serverside::Adapter::Integrate do
28
29
  context "with valid arguments" do
29
30
  let(:command) do
30
31
  adapter = described_class.new do |arguments|
31
- arguments.app = "rackapp"
32
- arguments.environment_name = "rackapp_production"
33
- arguments.account_name = "ey"
34
- arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
35
- arguments.stack = "nginx_unicorn"
36
- arguments.framework_env = "production"
32
+ arguments.app = "rackapp"
33
+ arguments.environment_name = "rackapp_production"
34
+ arguments.account_name = "ey"
35
+ arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
36
+ arguments.stack = "nginx_unicorn"
37
+ arguments.framework_env = "production"
38
+ arguments.serverside_version = serverside_version
37
39
  end
38
40
  last_command(adapter)
39
41
  end
@@ -41,7 +43,7 @@ describe EY::Serverside::Adapter::Integrate do
41
43
  it "invokes exactly the right command" do
42
44
  command.should == [
43
45
  "engineyard-serverside",
44
- "_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
46
+ "_#{serverside_version}_",
45
47
  "integrate",
46
48
  "--account-name ey",
47
49
  "--app rackapp",
@@ -16,6 +16,7 @@ describe EY::Serverside::Adapter::Restart do
16
16
  it_should_require :account_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
17
17
  it_should_require :instances
18
18
  it_should_require :stack
19
+ it_should_require :serverside_version
19
20
 
20
21
  it_should_ignore_requirement :environment_name, '1.6.4'
21
22
  it_should_ignore_requirement :account_name, '1.6.4'
@@ -26,11 +27,12 @@ describe EY::Serverside::Adapter::Restart do
26
27
  context "with valid arguments" do
27
28
  let(:command) do
28
29
  adapter = described_class.new do |arguments|
29
- arguments.app = "rackapp"
30
- arguments.environment_name = "rackapp_production"
31
- arguments.account_name = "ey"
32
- arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
33
- arguments.stack = "nginx_unicorn"
30
+ arguments.app = "rackapp"
31
+ arguments.environment_name = "rackapp_production"
32
+ arguments.account_name = "ey"
33
+ arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
34
+ arguments.stack = "nginx_unicorn"
35
+ arguments.serverside_version = serverside_version
34
36
  end
35
37
  last_command(adapter)
36
38
  end
@@ -38,7 +40,7 @@ describe EY::Serverside::Adapter::Restart do
38
40
  it "invokes exactly the right command" do
39
41
  command.should == [
40
42
  "engineyard-serverside",
41
- "_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
43
+ "_#{serverside_version}_",
42
44
  "restart",
43
45
  "--account-name ey",
44
46
  "--app rackapp",
@@ -18,6 +18,7 @@ describe EY::Serverside::Adapter::Rollback do
18
18
  it_should_require :framework_env
19
19
  it_should_require :instances
20
20
  it_should_require :stack
21
+ it_should_require :serverside_version
21
22
 
22
23
  it_should_ignore_requirement :environment_name, '1.6.4'
23
24
  it_should_ignore_requirement :account_name, '1.6.4'
@@ -28,13 +29,14 @@ describe EY::Serverside::Adapter::Rollback do
28
29
  context "with valid arguments" do
29
30
  let(:command) do
30
31
  adapter = described_class.new do |arguments|
31
- arguments.app = "rackapp"
32
- arguments.environment_name = "rackapp_production"
33
- arguments.account_name = "ey"
34
- arguments.framework_env = 'production'
35
- arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
36
- arguments.stack = "nginx_unicorn"
37
- arguments.config = {'a' => 1}
32
+ arguments.app = "rackapp"
33
+ arguments.environment_name = "rackapp_production"
34
+ arguments.account_name = "ey"
35
+ arguments.framework_env = 'production'
36
+ arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
37
+ arguments.stack = "nginx_unicorn"
38
+ arguments.config = {'a' => 1}
39
+ arguments.serverside_version = serverside_version
38
40
  end
39
41
  last_command(adapter)
40
42
  end
@@ -46,7 +48,7 @@ describe EY::Serverside::Adapter::Rollback do
46
48
  it "invokes exactly the right command" do
47
49
  command.should == [
48
50
  "engineyard-serverside",
49
- "_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
51
+ "_#{serverside_version}_",
50
52
  "deploy rollback",
51
53
  "--account-name ey",
52
54
  "--app rackapp",
@@ -4,18 +4,30 @@ require 'bundler/setup'
4
4
  require 'engineyard-serverside-adapter'
5
5
  require 'pp'
6
6
 
7
+ begin
8
+ specs = Gem::SpecFetcher.fetcher.fetch(Gem::Dependency.new("engineyard-serverside"))
9
+ ENGINEYARD_SERVERSIDE_VERSION = specs.map {|spec,| spec.version}.sort.last.to_s
10
+ rescue
11
+ ENGINEYARD_SERVERSIDE_VERSION = '2.3.1'
12
+ end
13
+
7
14
  module ArgumentsHelpers
15
+ def serverside_version
16
+ ENGINEYARD_SERVERSIDE_VERSION
17
+ end
18
+
8
19
  def valid_options
9
20
  {
10
- :app => 'rackapp',
11
- :account_name => 'ey',
12
- #:archive => 'https://github.com/engineyard/engineyard-serverside/archive/master.zip',
13
- :environment_name => 'rackapp_production',
14
- :framework_env => 'production',
15
- :git => 'git@github.com:engineyard/engineyard-serverside.git',
16
- :instances => [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}],
17
- :ref => 'master',
18
- :stack => 'nginx_unicorn',
21
+ :app => 'rackapp',
22
+ :account_name => 'ey',
23
+ #:archive => 'https://github.com/engineyard/engineyard-serverside/archive/master.zip',
24
+ :environment_name => 'rackapp_production',
25
+ :framework_env => 'production',
26
+ :git => 'git@github.com:engineyard/engineyard-serverside.git',
27
+ :instances => [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}],
28
+ :ref => 'master',
29
+ :stack => 'nginx_unicorn',
30
+ :serverside_version => serverside_version,
19
31
  }
20
32
  end
21
33
 
@@ -110,14 +122,33 @@ RSpec.configure do |config|
110
122
 
111
123
  # of course, the only way to be sure is to actually run it, but
112
124
  # this gives us regression-proofing
113
- version = EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION
125
+ version = serverside_version
114
126
  escaped_version = version.gsub(/\./, '\\.')
115
127
  installation_command.should == "(gem list engineyard-serverside | grep 'engineyard-serverside ' | egrep -q '#{escaped_version}[,)]') || (sudo sh -c 'cd `mktemp -d` && gem install engineyard-serverside --no-rdoc --no-ri -v #{version}')"
116
128
 
117
129
 
118
130
  installation_command.should =~ /gem list engineyard-serverside/
119
131
  installation_command.should =~ /egrep -q /
120
- installation_command.should =~ /gem install engineyard-serverside.*-v #{Regexp.quote EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}/
132
+ installation_command.should =~ /gem install engineyard-serverside.*-v #{Regexp.quote serverside_version}/
133
+ end
134
+ end
135
+
136
+ shared_examples_for "it accepts clean" do
137
+ context "the --clean arg" do
138
+ it "is present when you set clean to true" do
139
+ adapter = described_class.new(:arguments => arguments_with(:clean => true))
140
+ last_command(adapter).should =~ /--clean/
141
+ end
142
+
143
+ it "is absent when you set clean to false" do
144
+ adapter = described_class.new(:arguments => arguments_with(:clean => false))
145
+ last_command(adapter).should_not =~ /--clean/
146
+ end
147
+
148
+ it "is absent when you omit clean" do
149
+ adapter = described_class.new(:arguments => valid_arguments)
150
+ last_command(adapter).should_not =~ /--clean/
151
+ end
121
152
  end
122
153
  end
123
154
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard-serverside-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Emde
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-03 00:00:00.000000000 Z
12
+ date: 2013-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: escape
@@ -78,6 +78,7 @@ extra_rdoc_files: []
78
78
  files:
79
79
  - .gitignore
80
80
  - .travis.yml
81
+ - ChangeLog.md
81
82
  - Gemfile
82
83
  - Guardfile
83
84
  - LICENSE