capistrano 3.0.0.pre13 → 3.0.0.pre14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c30b25d97cfa811596b16d276fb221d0ea55ac9a
4
- data.tar.gz: 2fcf56587e9193ed85b61e822fcd73bf7ecf4809
3
+ metadata.gz: 8d396873548e6dd9e20c1853f741bc8808e7a529
4
+ data.tar.gz: 24aa535d127498013298938e5effb7e38bd26fbb
5
5
  SHA512:
6
- metadata.gz: 589c4f870e7f58a316ed3f5cad74b3febbcc3c4ededb3dfb30decdee293c09030c2f75f4f180c9e504bd2825d32d5b452c08c94a77d9c31eca281686ae658b19
7
- data.tar.gz: 20f0cc7c0cad5561b3e9bad0e048d63c6912f4ef5b12a5cac05625090fc99640125f4254be236bcdd46e8f0831c83813ff6572181d6c739e37755c97599829f9
6
+ metadata.gz: 828006f69722330dcfbf09833922f0547a00fde78bd2d59948b4ebd59b139afa779f69c87e7d69e22e1fff7e9377d84484594dc5edaa544919a644c39d9d9338
7
+ data.tar.gz: 8cfb03d51c92cac8ab9c6bd8cd7ba4d3416731de893927db8ab1b0117e5478af71c4e9256aaea8350a7cf23f663432ae1f7b1b19b5cad80e10890a607bb4c245
@@ -2,6 +2,17 @@
2
2
 
3
3
  Reverse Chronological Order:
4
4
 
5
+ ## `3.0.0.pre14`
6
+
7
+ * Thanks to numerous contributors, in particular (@teohm) for a series of improvements.
8
+
9
+ ## `3.0.0.pre13`
10
+
11
+ * Fixed typos in the Capfile. (@teohm)
12
+ * Allow setting SSH options globally. (@korin)
13
+ * Change the flow (and hooks) see http://www.capistranorb.com/documentation/getting-started/flow/ for more information. Requires min SSHKit 0.0.34 (@teohm)
14
+ * Fix sorting releases in lexicographical order (@teohm)
15
+
5
16
  ## `3.0.0.pre12`
6
17
 
7
18
  * `capistrano/bundler` now runs bundle on all roles, this addresses the same
data/README.md CHANGED
@@ -135,6 +135,22 @@ end
135
135
 
136
136
  Perfect, who needs telephones.
137
137
 
138
+
139
+ ## Running local tasks
140
+
141
+ Local tasks can be run by replacing `on` with `run_locally`
142
+
143
+ ``` ruby
144
+ desc "Notify service of deployment"
145
+ task :notify do
146
+ run_locally do
147
+ with rails_env: :development do
148
+ rake 'service:notify'
149
+ end
150
+ end
151
+ end
152
+ ```
153
+
138
154
  ## Console
139
155
 
140
156
  **Note:** Here be dragons. The console is very immature, but it's much more
@@ -196,6 +212,7 @@ The following variables are settable:
196
212
  | `:repo_url` | The URL of your Git repository | file://, https://, or ssh:// are all supported |
197
213
  | `:git_https_username` | The (optional) username for accessing your Git repostory over HTTPS | if this is an SSH connection, this setting will have no effect. |
198
214
  | `:git_https_password` | The (optional) password for accessing your Git repostory over HTTPS | if this is an SSH connection, this setting will have no effect. |
215
+ | `:tmp_dir` | The (optional) temp directory that will be used (default: /tmp) | if you have a shared web host, this setting may need to be set (i.e. /home/user/tmp/capistrano). |
199
216
 
200
217
  ## SSHKit
201
218
 
@@ -17,6 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
+ gem.post_install_message = "If you're updating Capistrano from 2.x.x, we recommend you to read the upgrade guide: http://www.capistranorb.com/documentation/upgrading/"
21
+
20
22
  #gem.signing_key = '/Volumes/SD Card/leehambley-private_key.pem'
21
23
  #gem.cert_chain = ['capistrano-public_cert.pem', 'leehambley-public_cert.pem']
22
24
 
@@ -4,6 +4,7 @@ require 'sshkit'
4
4
  Rake.application.options.trace = true
5
5
 
6
6
  require 'capistrano/version'
7
+ require 'capistrano/version_validator'
7
8
  require 'capistrano/i18n'
8
9
  require 'capistrano/dsl'
9
10
  require 'capistrano/application'
@@ -13,7 +13,7 @@ module Capistrano
13
13
  end
14
14
 
15
15
  def sort_options(options)
16
- options.push(version)
16
+ options.push(version,dry_run)
17
17
  super
18
18
  end
19
19
 
@@ -22,6 +22,14 @@ module Capistrano
22
22
  super
23
23
  end
24
24
 
25
+ def top_level_tasks
26
+ if tasks_without_stage_dependency.include?(@top_level_tasks.first)
27
+ @top_level_tasks
28
+ else
29
+ @top_level_tasks.unshift('deploy:ensure_stage')
30
+ end
31
+ end
32
+
25
33
  private
26
34
 
27
35
  # allows the `cap install` task to load without a capfile
@@ -29,6 +37,15 @@ module Capistrano
29
37
  File.expand_path(File.join(File.dirname(__FILE__),'..','Capfile'))
30
38
  end
31
39
 
40
+ def tasks_without_stage_dependency
41
+ defined_stages = Dir['config/deploy/*.rb'].map { |f| File.basename(f, '.rb') }
42
+ defined_stages + default_tasks
43
+ end
44
+
45
+ def default_tasks
46
+ %w{install}
47
+ end
48
+
32
49
  def version
33
50
  ['--version', '-V',
34
51
  "Display the program version.",
@@ -38,6 +55,15 @@ module Capistrano
38
55
  }
39
56
  ]
40
57
  end
58
+
59
+ def dry_run
60
+ ['--dry-run', '-n',
61
+ "Do a dry run without executing actions",
62
+ lambda { |value|
63
+ Configuration.env.set(:sshkit_backend, SSHKit::Backend::Printer)
64
+ }
65
+ ]
66
+ end
41
67
  end
42
68
 
43
69
  end
@@ -56,9 +56,11 @@ module Capistrano
56
56
  sshkit.format = fetch(:format)
57
57
  sshkit.output_verbosity = fetch(:log_level)
58
58
  sshkit.default_env = fetch(:default_env)
59
+ sshkit.backend = fetch(:sshkit_backend, SSHKit::Backend::Netssh)
59
60
  sshkit.backend.configure do |backend|
60
61
  backend.pty = fetch(:pty)
61
62
  backend.connection_timeout = fetch(:connection_timeout)
63
+ backend.ssh_options = fetch(:ssh_options) if fetch(:ssh_options)
62
64
  end
63
65
  end
64
66
  end
@@ -35,6 +35,12 @@ module Capistrano
35
35
  @properties ||= Properties.new
36
36
  end
37
37
 
38
+ def netssh_options_with_options
39
+ @netssh_options ||= netssh_options_without_options.merge( fetch(:ssh_options) || {} )
40
+ end
41
+ alias_method :netssh_options_without_options, :netssh_options
42
+ alias_method :netssh_options, :netssh_options_with_options
43
+
38
44
  class Properties
39
45
 
40
46
  def initialize
@@ -1,11 +1,21 @@
1
1
  set :scm, :git
2
2
  set :branch, :master
3
3
  set :deploy_to, "/var/www/#{fetch(:application)}"
4
+ set :tmp_dir, "/tmp"
4
5
 
5
- set :default_environment, {}
6
+ set :default_env, {}
6
7
  set :keep_releases, 5
7
8
 
8
9
  set :format, :pretty
9
10
  set :log_level, :debug
10
11
 
11
12
  set :pty, true
13
+
14
+ namespace :deploy do
15
+ task :ensure_stage do
16
+ unless stage_set?
17
+ puts t(:stage_not_set)
18
+ exit 1
19
+ end
20
+ end
21
+ end
@@ -22,6 +22,10 @@ module Capistrano
22
22
  fetch(:scm)
23
23
  end
24
24
 
25
+ def sudo(*args)
26
+ execute :sudo, *args
27
+ end
28
+
25
29
  def revision_log_message
26
30
  fetch(:revision_log_message,
27
31
  t(:revision_log_message, branch: fetch(:branch), user: local_user, release: release_timestamp))
@@ -35,6 +39,10 @@ module Capistrano
35
39
  `whoami`
36
40
  end
37
41
 
42
+ def lock(locked_version)
43
+ VersionValidator.new(locked_version).verify
44
+ end
45
+
38
46
  end
39
47
  end
40
48
  self.extend Capistrano::DSL
@@ -9,5 +9,5 @@ namespace :deploy do
9
9
  end
10
10
  end
11
11
 
12
- after 'deploy:update', 'deploy:bundle'
12
+ before 'deploy:updated', 'deploy:bundle'
13
13
  end
@@ -1,16 +1,29 @@
1
1
  namespace :deploy do
2
2
 
3
- task :started do
3
+ task :starting do
4
4
  invoke 'deploy:check'
5
5
  end
6
6
 
7
- task :update do
7
+ task :updating do
8
8
  invoke "#{scm}:create_release"
9
9
  invoke 'deploy:symlink:shared'
10
10
  end
11
11
 
12
- task :finalize do
12
+ task :reverting do
13
+ invoke 'deploy:revert_release'
14
+ end
15
+
16
+ task :publishing do
13
17
  invoke 'deploy:symlink:release'
18
+ invoke 'deploy:restart'
19
+ end
20
+
21
+ task :finishing do
22
+ invoke 'deploy:cleanup'
23
+ end
24
+
25
+ task :finishing_rollback do
26
+ invoke 'deploy:cleanup_rollback'
14
27
  end
15
28
 
16
29
  task :finished do
@@ -81,7 +94,7 @@ namespace :deploy do
81
94
  target = release_path.join(dir)
82
95
  source = shared_path.join(dir)
83
96
  unless test "[ -L #{target} ]"
84
- if test "[ -f #{target} ]"
97
+ if test "[ -d #{target} ]"
85
98
  execute :rm, '-rf', target
86
99
  end
87
100
  execute :ln, '-s', source, target
@@ -123,6 +136,22 @@ namespace :deploy do
123
136
  end
124
137
  end
125
138
 
139
+ desc 'Remove and archive rolled-back release.'
140
+ task :cleanup_rollback do
141
+ on roles(:all) do
142
+ last_release = capture(:ls, '-xr', releases_path).split.first
143
+ last_release_path = releases_path.join(last_release)
144
+ if test "[ `readlink #{current_path}` != #{last_release_path} ]"
145
+ execute :tar, '-czf',
146
+ deploy_path.join("rolled-back-release-#{last_release}.tar.gz"),
147
+ last_release_path
148
+ execute :rm, '-rf', last_release_path
149
+ else
150
+ debug 'Last release is the current release, skip cleanup_rollback.'
151
+ end
152
+ end
153
+ end
154
+
126
155
  desc 'Log details of the deploy'
127
156
  task :log_revision do
128
157
  on roles(:all) do
@@ -132,19 +161,14 @@ namespace :deploy do
132
161
  end
133
162
  end
134
163
 
135
- desc 'Rollback to the last release'
136
- task :rollback do
164
+ desc 'Revert to previous release timestamp'
165
+ task :revert_release do
137
166
  on roles(:all) do
138
167
  last_release = capture(:ls, '-xr', releases_path).split[1]
139
168
  set(:rollback_release_timestamp, last_release)
140
169
  set(:branch, last_release)
141
170
  set(:revision_log_message, rollback_log_message)
142
171
  end
143
-
144
- on roles :app do
145
- %w{check finalize restart finishing finished}.each do |task|
146
- invoke "deploy:#{task}"
147
- end
148
- end
149
172
  end
173
+
150
174
  end
@@ -1,6 +1,6 @@
1
1
  namespace :deploy do
2
2
 
3
- desc 'Starting'
3
+ desc 'Start a deployment, make sure server(s) ready.'
4
4
  task :starting do
5
5
  end
6
6
 
@@ -8,37 +8,61 @@ namespace :deploy do
8
8
  task :started do
9
9
  end
10
10
 
11
- desc 'Update'
12
- task :update do
11
+ desc 'Update server(s) by setting up a new release.'
12
+ task :updating do
13
13
  end
14
14
 
15
- desc 'Finalize'
16
- task :finalize do
15
+ desc 'Updated'
16
+ task :updated do
17
17
  end
18
18
 
19
- desc 'Restart'
20
- task :restart do
19
+ desc 'Revert server(s) to previous release.'
20
+ task :reverting do
21
21
  end
22
22
 
23
- desc 'Finishing'
23
+ desc 'Reverted'
24
+ task :reverted do
25
+ end
26
+
27
+ desc 'Publish the release.'
28
+ task :publishing do
29
+ end
30
+
31
+ desc 'Published'
32
+ task :published do
33
+ end
34
+
35
+ desc 'Finish the deployment, clean up server(s).'
24
36
  task :finishing do
25
37
  end
26
38
 
39
+ desc 'Finish the rollback, clean up server(s).'
40
+ task :finishing_rollback do
41
+ end
42
+
27
43
  desc 'Finished'
28
44
  task :finished do
29
45
  end
30
46
 
31
- before :starting, :ensure_stage do
32
- unless stage_set?
33
- puts t(:stage_not_set)
34
- exit 1
47
+ before :starting, :ensure_stage
48
+
49
+ desc 'Rollback to previous release.'
50
+ task :rollback do
51
+ %w{ starting started
52
+ reverting reverted
53
+ publishing published
54
+ finishing_rollback finished }.each do |task|
55
+ invoke "deploy:#{task}"
35
56
  end
36
57
  end
37
58
  end
38
59
 
39
- desc 'Deploy'
60
+ desc 'Deploy a new release.'
40
61
  task :deploy do
41
- %w{starting started update finalize restart finishing finished}.each do |task|
62
+ %w{ starting started
63
+ updating updated
64
+ publishing published
65
+ finishing finished }.each do |task|
42
66
  invoke "deploy:#{task}"
43
67
  end
44
68
  end
@@ -1,15 +1,15 @@
1
1
  namespace :git do
2
2
 
3
3
  git_environmental_variables = {
4
- git_askpass: '/bin/echo',
5
- git_ssh: '/tmp/git-ssh.sh'
4
+ git_askpass: "/bin/echo",
5
+ git_ssh: "#{fetch(:tmp_dir)}/git-ssh.sh"
6
6
  }
7
7
 
8
8
  desc 'Upload the git wrapper script, this script guarantees that we can script git without getting an interactive prompt'
9
9
  task :wrapper do
10
10
  on roles :all do
11
- upload! StringIO.new("#!/bin/sh -e\nexec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no \"$@\"\n"), '/tmp/git-ssh.sh'
12
- execute :chmod, "+x", '/tmp/git-ssh.sh'
11
+ upload! StringIO.new("#!/bin/sh -e\nexec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no \"$@\"\n"), "#{fetch(:tmp_dir)}/git-ssh.sh"
12
+ execute :chmod, "+x", "#{fetch(:tmp_dir)}/git-ssh.sh"
13
13
  end
14
14
  end
15
15
 
@@ -56,7 +56,6 @@ namespace :git do
56
56
  '--depth 1', \
57
57
  '--recursive', \
58
58
  '--no-hardlinks', \
59
- '--', \
60
59
  repo_path, release_path
61
60
  end
62
61
  end
@@ -36,7 +36,7 @@ namespace :deploy do
36
36
  after :restart, :clear_cache do
37
37
  on roles(:web), in: :groups, limit: 3, wait: 10 do
38
38
  # Here we can do anything such as:
39
- # within latest_relese_path do
39
+ # within latest_release_path do
40
40
  # execute :rake, 'cache:clear'
41
41
  # end
42
42
  end
@@ -1,7 +1,7 @@
1
1
  set :application, 'my app name'
2
2
  set :repo_url, 'git@example.com:me/my_repo.git'
3
3
 
4
- ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
4
+ # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
5
5
 
6
6
  # set :deploy_to, '/var/www/my_app'
7
7
  # set :scm, :git
@@ -13,5 +13,5 @@ ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
13
13
  # set :linked_files, %w{config/database.yml}
14
14
  # set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
15
15
 
16
- # set :default_environment, { path: "/opt/ruby/bin:$PATH" }
16
+ # set :default_env, { path: "/opt/ruby/bin:$PATH" }
17
17
  # set :keep_releases, 5
@@ -17,4 +17,26 @@ role :db, %w{deploy@example.com}
17
17
  # extended properties on the server.
18
18
  server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
19
19
 
20
- # set :rails_env, :<%= stage %>
20
+ # you can set custom ssh options
21
+ # it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
22
+ # you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
23
+ # set it globally
24
+ # set :ssh_options, {
25
+ # keys: %w(/home/rlisowski/.ssh/id_rsa),
26
+ # forward_agent: false,
27
+ # auth_methods: %w(password)
28
+ # }
29
+ # and/or per server
30
+ # server 'example.com',
31
+ # user: 'user_name',
32
+ # roles: %w{web app},
33
+ # ssh_options: {
34
+ # user: 'user_name', # overrides user setting above
35
+ # keys: %w(/home/user_name/.ssh/id_rsa),
36
+ # forward_agent: false,
37
+ # auth_methods: %w(publickey password)
38
+ # # password: 'please use keys'
39
+ # }
40
+ # setting per server overrides global ssh_options
41
+
42
+ # fetch(:default_env).merge!(:rails_env, :<%= stage %>)
@@ -1,3 +1,3 @@
1
1
  module Capistrano
2
- VERSION = "3.0.0.pre13"
2
+ VERSION = "3.0.0.pre14"
3
3
  end
@@ -0,0 +1,37 @@
1
+ module Capistrano
2
+ class VersionValidator
3
+
4
+ def initialize(version)
5
+ @version = version
6
+ end
7
+
8
+ def verify
9
+ if match?
10
+ self
11
+ else
12
+ fail "Capfile locked at #{version}, but #{current_version} is loaded"
13
+ end
14
+ end
15
+
16
+ private
17
+ attr_reader :version
18
+
19
+
20
+ def match?
21
+ available =~ requested
22
+ end
23
+
24
+ def current_version
25
+ VERSION
26
+ end
27
+
28
+ def available
29
+ Gem::Dependency.new('cap', version)
30
+ end
31
+
32
+ def requested
33
+ Gem::Dependency.new('cap', current_version)
34
+ end
35
+
36
+ end
37
+ end
@@ -21,8 +21,8 @@ describe 'cap deploy:finished', slow: true do
21
21
  describe 'log_revision' do
22
22
  before do
23
23
  cap 'deploy:started'
24
- cap 'deploy:update'
25
- cap 'deploy:finalize'
24
+ cap 'deploy:updating'
25
+ cap 'deploy:publishing'
26
26
  cap 'deploy:finished'
27
27
  end
28
28
 
@@ -21,8 +21,8 @@ describe 'cap deploy:finished', slow: true do
21
21
  describe 'symlink' do
22
22
  before do
23
23
  cap 'deploy:started'
24
- cap 'deploy:update'
25
- cap 'deploy:finalize'
24
+ cap 'deploy:updating'
25
+ cap 'deploy:publishing'
26
26
  end
27
27
 
28
28
  describe 'release' do
@@ -1,6 +1,6 @@
1
1
  require 'integration_spec_helper'
2
2
 
3
- describe 'cap deploy:update', slow: true do
3
+ describe 'cap deploy:updating', slow: true do
4
4
  before do
5
5
  install_test_app_with(config)
6
6
  end
@@ -234,6 +234,11 @@ describe Capistrano::DSL do
234
234
  dsl.set(:default_env, default_env)
235
235
  dsl.set(:pty, true)
236
236
  dsl.set(:connection_timeout, 10)
237
+ dsl.set(:ssh_options, {
238
+ keys: %w(/home/user/.ssh/id_rsa),
239
+ forward_agent: false,
240
+ auth_methods: %w(publickey password)
241
+ })
237
242
  dsl.configure_backend
238
243
  end
239
244
 
@@ -256,6 +261,13 @@ describe Capistrano::DSL do
256
261
  it 'sets the backend connection timeout' do
257
262
  expect(backend.connection_timeout).to eq 10
258
263
  end
264
+
265
+ it 'sets the backend ssh_options' do
266
+ expect(backend.ssh_options[:keys]).to eq %w(/home/user/.ssh/id_rsa)
267
+ expect(backend.ssh_options[:forward_agent]).to eq false
268
+ expect(backend.ssh_options[:auth_methods]).to eq %w(publickey password)
269
+ end
270
+
259
271
  end
260
272
 
261
273
  end
@@ -1,6 +1,6 @@
1
1
  require 'integration_spec_helper'
2
2
 
3
- describe 'cap install', slow: true do
3
+ describe 'cap install' do
4
4
 
5
5
  context 'with defaults' do
6
6
  before :all do
@@ -134,6 +134,47 @@ module Capistrano
134
134
  end
135
135
  end
136
136
 
137
+ describe 'assign ssh_options' do
138
+ let(:server) { Server.new('user_name@hostname') }
139
+
140
+ context 'defaults' do
141
+ it 'forward agent' do
142
+ expect(server.netssh_options[:forward_agent]).to eq true
143
+ end
144
+ it 'contains user' do
145
+ expect(server.netssh_options[:user]).to eq 'user_name'
146
+ end
147
+ end
148
+
149
+ context 'custom' do
150
+ let(:properties) do
151
+ { ssh_options: {
152
+ user: 'another_user',
153
+ keys: %w(/home/another_user/.ssh/id_rsa),
154
+ forward_agent: false,
155
+ auth_methods: %w(publickey password) } }
156
+ end
157
+
158
+ before do
159
+ server.with(properties)
160
+ end
161
+
162
+ it 'not forward agent' do
163
+ expect(server.netssh_options[:forward_agent]).to eq false
164
+ end
165
+ it 'contains correct user' do
166
+ expect(server.netssh_options[:user]).to eq 'another_user'
167
+ end
168
+ it 'contains keys' do
169
+ expect(server.netssh_options[:keys]).to eq %w(/home/another_user/.ssh/id_rsa)
170
+ end
171
+ it 'contains auth_methods' do
172
+ expect(server.netssh_options[:auth_methods]).to eq %w(publickey password)
173
+ end
174
+ end
175
+
176
+ end
177
+
137
178
  end
138
179
  end
139
180
  end
@@ -6,6 +6,7 @@ module Capistrano
6
6
  include DSL
7
7
  end
8
8
 
9
+ # see also - spec/integration/dsl_spec.rb
9
10
  describe DSL do
10
11
  let(:dsl) { DummyDSL.new }
11
12
 
@@ -47,5 +48,16 @@ module Capistrano
47
48
  it { should be_false }
48
49
  end
49
50
  end
51
+
52
+ describe '#sudo' do
53
+
54
+ before do
55
+ dsl.expects(:execute).with(:sudo, :my, :command)
56
+ end
57
+
58
+ it 'prepends sudo, delegates to execute' do
59
+ dsl.sudo(:my, :command)
60
+ end
61
+ end
50
62
  end
51
63
  end
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ module Capistrano
4
+
5
+ describe VersionValidator do
6
+ let(:validator) { VersionValidator.new(version) }
7
+ let(:version) { stub }
8
+
9
+ describe '#new' do
10
+ it 'takes a version' do
11
+ expect(validator)
12
+ end
13
+ end
14
+
15
+ describe '#verify' do
16
+ let(:current_version) { '3.0.1' }
17
+
18
+ subject { validator.verify }
19
+
20
+ before do
21
+ validator.stubs(:current_version).returns(current_version)
22
+ end
23
+
24
+ context 'with exact version' do
25
+ context 'valid' do
26
+ let(:version) { '3.0.1' }
27
+ it { should be_true }
28
+ end
29
+
30
+ context 'invalid - lower' do
31
+ let(:version) { '3.0.0' }
32
+
33
+ it 'fails' do
34
+ expect { subject }.to raise_error
35
+ end
36
+ end
37
+
38
+ context 'invalid - higher' do
39
+ let(:version) { '3.0.2' }
40
+
41
+ it 'fails' do
42
+ expect { subject }.to raise_error
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ context 'with optimistic versioning' do
49
+ context 'valid' do
50
+ let(:version) { '>= 3.0.0' }
51
+ it { should be_true }
52
+ end
53
+
54
+ context 'invalid - lower' do
55
+ let(:version) { '<= 2.0.0' }
56
+
57
+ it 'fails' do
58
+ expect { subject }.to raise_error
59
+ end
60
+ end
61
+ end
62
+
63
+
64
+
65
+ context 'with pessimistic versioning' do
66
+ context '2 decimal places' do
67
+ context 'valid' do
68
+ let(:version) { '~> 3.0.0' }
69
+ it { should be_true }
70
+ end
71
+
72
+ context 'invalid' do
73
+ let(:version) { '~> 3.1.0' }
74
+
75
+ it 'fails' do
76
+ expect { subject }.to raise_error
77
+ end
78
+ end
79
+ end
80
+
81
+ context '1 decimal place' do
82
+ let(:current_version) { '3.5.0' }
83
+
84
+ context 'valid' do
85
+ let(:version) { '~> 3.1' }
86
+ it { should be_true }
87
+ end
88
+
89
+ context 'invalid' do
90
+ let(:version) { '~> 3.6' }
91
+ it 'fails' do
92
+ expect { subject }.to raise_error
93
+ end
94
+ end
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+
101
+ end
102
+
103
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre13
4
+ version: 3.0.0.pre14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Clements
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-10 00:00:00.000000000 Z
12
+ date: 2013-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sshkit
@@ -133,6 +133,7 @@ files:
133
133
  - lib/capistrano/templates/deploy.rb.erb
134
134
  - lib/capistrano/templates/stage.rb.erb
135
135
  - lib/capistrano/version.rb
136
+ - lib/capistrano/version_validator.rb
136
137
  - spec/integration/deploy_finalize_spec.rb
137
138
  - spec/integration/deploy_finished_spec.rb
138
139
  - spec/integration/deploy_started_spec.rb
@@ -148,6 +149,7 @@ files:
148
149
  - spec/lib/capistrano/dsl/env_spec.rb
149
150
  - spec/lib/capistrano/dsl/paths_spec.rb
150
151
  - spec/lib/capistrano/dsl_spec.rb
152
+ - spec/lib/capistrano/version_validator_spec.rb
151
153
  - spec/lib/capistrano_spec.rb
152
154
  - spec/spec_helper.rb
153
155
  - spec/support/matchers.rb
@@ -155,7 +157,8 @@ files:
155
157
  homepage: ''
156
158
  licenses: []
157
159
  metadata: {}
158
- post_install_message:
160
+ post_install_message: 'If you''re updating Capistrano from 2.x.x, we recommend you
161
+ to read the upgrade guide: http://www.capistranorb.com/documentation/upgrading/'
159
162
  rdoc_options: []
160
163
  require_paths:
161
164
  - lib
@@ -191,8 +194,8 @@ test_files:
191
194
  - spec/lib/capistrano/dsl/env_spec.rb
192
195
  - spec/lib/capistrano/dsl/paths_spec.rb
193
196
  - spec/lib/capistrano/dsl_spec.rb
197
+ - spec/lib/capistrano/version_validator_spec.rb
194
198
  - spec/lib/capistrano_spec.rb
195
199
  - spec/spec_helper.rb
196
200
  - spec/support/matchers.rb
197
201
  - spec/support/test_app.rb
198
- has_rdoc: