capistrano 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -5
  3. data/.rubocop.yml +49 -0
  4. data/.travis.yml +5 -4
  5. data/CHANGELOG.md +72 -9
  6. data/CONTRIBUTING.md +61 -93
  7. data/DEVELOPMENT.md +122 -0
  8. data/Gemfile +2 -2
  9. data/LICENSE.txt +1 -1
  10. data/README.md +121 -43
  11. data/RELEASING.md +16 -0
  12. data/Rakefile +4 -1
  13. data/bin/cap +1 -1
  14. data/capistrano.gemspec +16 -21
  15. data/features/doctor.feature +11 -0
  16. data/features/step_definitions/assertions.rb +17 -17
  17. data/features/step_definitions/cap_commands.rb +0 -1
  18. data/features/step_definitions/setup.rb +12 -8
  19. data/features/support/env.rb +5 -5
  20. data/features/support/remote_command_helpers.rb +8 -6
  21. data/features/support/vagrant_helpers.rb +5 -4
  22. data/issue_template.md +21 -0
  23. data/lib/Capfile +5 -1
  24. data/lib/capistrano/all.rb +9 -10
  25. data/lib/capistrano/application.rb +36 -26
  26. data/lib/capistrano/configuration.rb +56 -41
  27. data/lib/capistrano/configuration/empty_filter.rb +9 -0
  28. data/lib/capistrano/configuration/filter.rb +18 -47
  29. data/lib/capistrano/configuration/host_filter.rb +30 -0
  30. data/lib/capistrano/configuration/null_filter.rb +9 -0
  31. data/lib/capistrano/configuration/plugin_installer.rb +33 -0
  32. data/lib/capistrano/configuration/question.rb +10 -7
  33. data/lib/capistrano/configuration/role_filter.rb +30 -0
  34. data/lib/capistrano/configuration/server.rb +22 -23
  35. data/lib/capistrano/configuration/servers.rb +6 -7
  36. data/lib/capistrano/configuration/variables.rb +136 -0
  37. data/lib/capistrano/defaults.rb +13 -3
  38. data/lib/capistrano/deploy.rb +1 -1
  39. data/lib/capistrano/doctor.rb +5 -0
  40. data/lib/capistrano/doctor/environment_doctor.rb +19 -0
  41. data/lib/capistrano/doctor/gems_doctor.rb +45 -0
  42. data/lib/capistrano/doctor/output_helpers.rb +79 -0
  43. data/lib/capistrano/doctor/variables_doctor.rb +66 -0
  44. data/lib/capistrano/dotfile.rb +1 -2
  45. data/lib/capistrano/dsl.rb +12 -14
  46. data/lib/capistrano/dsl/env.rb +11 -42
  47. data/lib/capistrano/dsl/paths.rb +12 -13
  48. data/lib/capistrano/dsl/stages.rb +2 -4
  49. data/lib/capistrano/dsl/task_enhancements.rb +5 -7
  50. data/lib/capistrano/framework.rb +1 -1
  51. data/lib/capistrano/git.rb +17 -9
  52. data/lib/capistrano/hg.rb +4 -4
  53. data/lib/capistrano/i18n.rb +24 -24
  54. data/lib/capistrano/immutable_task.rb +29 -0
  55. data/lib/capistrano/install.rb +1 -1
  56. data/lib/capistrano/plugin.rb +95 -0
  57. data/lib/capistrano/scm.rb +7 -20
  58. data/lib/capistrano/setup.rb +19 -5
  59. data/lib/capistrano/svn.rb +9 -5
  60. data/lib/capistrano/tasks/console.rake +4 -8
  61. data/lib/capistrano/tasks/deploy.rake +75 -62
  62. data/lib/capistrano/tasks/doctor.rake +19 -0
  63. data/lib/capistrano/tasks/framework.rake +13 -14
  64. data/lib/capistrano/tasks/git.rake +10 -11
  65. data/lib/capistrano/tasks/hg.rake +7 -7
  66. data/lib/capistrano/tasks/install.rake +14 -15
  67. data/lib/capistrano/tasks/svn.rake +7 -7
  68. data/lib/capistrano/templates/Capfile +3 -3
  69. data/lib/capistrano/templates/deploy.rb.erb +6 -5
  70. data/lib/capistrano/upload_task.rb +1 -1
  71. data/lib/capistrano/version.rb +1 -1
  72. data/lib/capistrano/version_validator.rb +4 -6
  73. data/spec/integration/dsl_spec.rb +286 -239
  74. data/spec/integration_spec_helper.rb +3 -5
  75. data/spec/lib/capistrano/application_spec.rb +22 -14
  76. data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
  77. data/spec/lib/capistrano/configuration/filter_spec.rb +82 -84
  78. data/spec/lib/capistrano/configuration/host_filter_spec.rb +61 -0
  79. data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
  80. data/spec/lib/capistrano/configuration/question_spec.rb +12 -16
  81. data/spec/lib/capistrano/configuration/role_filter_spec.rb +64 -0
  82. data/spec/lib/capistrano/configuration/server_spec.rb +102 -110
  83. data/spec/lib/capistrano/configuration/servers_spec.rb +124 -141
  84. data/spec/lib/capistrano/configuration_spec.rb +150 -61
  85. data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
  86. data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +61 -0
  87. data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
  88. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +79 -0
  89. data/spec/lib/capistrano/dsl/paths_spec.rb +58 -50
  90. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +62 -32
  91. data/spec/lib/capistrano/dsl_spec.rb +6 -8
  92. data/spec/lib/capistrano/git_spec.rb +35 -7
  93. data/spec/lib/capistrano/hg_spec.rb +14 -5
  94. data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
  95. data/spec/lib/capistrano/plugin_spec.rb +84 -0
  96. data/spec/lib/capistrano/scm_spec.rb +6 -7
  97. data/spec/lib/capistrano/svn_spec.rb +40 -14
  98. data/spec/lib/capistrano/upload_task_spec.rb +7 -7
  99. data/spec/lib/capistrano/version_validator_spec.rb +37 -45
  100. data/spec/lib/capistrano_spec.rb +2 -3
  101. data/spec/spec_helper.rb +8 -8
  102. data/spec/support/Vagrantfile +9 -10
  103. data/spec/support/tasks/database.rake +3 -3
  104. data/spec/support/tasks/fail.rake +4 -3
  105. data/spec/support/tasks/failed.rake +2 -2
  106. data/spec/support/tasks/plugin.rake +6 -0
  107. data/spec/support/tasks/root.rake +4 -4
  108. data/spec/support/test_app.rb +31 -30
  109. metadata +93 -14
@@ -1,19 +1,18 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Capistrano
4
-
5
4
  describe VersionValidator do
6
5
  let(:validator) { VersionValidator.new(version) }
7
6
  let(:version) { stub }
8
7
 
9
8
  describe '#new' do
10
- it 'takes a version' do
9
+ it "takes a version" do
11
10
  expect(validator)
12
11
  end
13
12
  end
14
13
 
15
14
  describe '#verify' do
16
- let(:current_version) { '3.0.1' }
15
+ let(:current_version) { "3.0.1" }
17
16
 
18
17
  subject { validator.verify }
19
18
 
@@ -21,83 +20,76 @@ module Capistrano
21
20
  validator.stubs(:current_version).returns(current_version)
22
21
  end
23
22
 
24
- context 'with exact version' do
25
- context 'valid' do
26
- let(:version) { '3.0.1' }
23
+ context "with exact version" do
24
+ context "valid" do
25
+ let(:version) { "3.0.1" }
27
26
  it { expect(subject).to be_truthy }
28
27
  end
29
28
 
30
- context 'invalid - lower' do
31
- let(:version) { '3.0.0' }
29
+ context "invalid - lower" do
30
+ let(:version) { "3.0.0" }
32
31
 
33
- it 'fails' do
34
- expect { subject }.to raise_error
32
+ it "fails" do
33
+ expect { subject }.to raise_error(RuntimeError)
35
34
  end
36
35
  end
37
36
 
38
- context 'invalid - higher' do
39
- let(:version) { '3.0.2' }
37
+ context "invalid - higher" do
38
+ let(:version) { "3.0.2" }
40
39
 
41
- it 'fails' do
42
- expect { subject }.to raise_error
40
+ it "fails" do
41
+ expect { subject }.to raise_error(RuntimeError)
43
42
  end
44
43
  end
45
-
46
44
  end
47
45
 
48
- context 'with optimistic versioning' do
49
- context 'valid' do
50
- let(:version) { '>= 3.0.0' }
46
+ context "with optimistic versioning" do
47
+ context "valid" do
48
+ let(:version) { ">= 3.0.0" }
51
49
  it { expect(subject).to be_truthy }
52
50
  end
53
51
 
54
- context 'invalid - lower' do
55
- let(:version) { '<= 2.0.0' }
52
+ context "invalid - lower" do
53
+ let(:version) { "<= 2.0.0" }
56
54
 
57
- it 'fails' do
58
- expect { subject }.to raise_error
55
+ it "fails" do
56
+ expect { subject }.to raise_error(RuntimeError)
59
57
  end
60
58
  end
61
59
  end
62
60
 
63
-
64
-
65
- context 'with pessimistic versioning' do
66
- context '2 decimal places' do
67
- context 'valid' do
68
- let(:version) { '~> 3.0.0' }
61
+ context "with pessimistic versioning" do
62
+ context "2 decimal places" do
63
+ context "valid" do
64
+ let(:version) { "~> 3.0.0" }
69
65
  it { expect(subject).to be_truthy }
70
66
  end
71
67
 
72
- context 'invalid' do
73
- let(:version) { '~> 3.1.0' }
68
+ context "invalid" do
69
+ let(:version) { "~> 3.1.0" }
74
70
 
75
- it 'fails' do
76
- expect { subject }.to raise_error
71
+ it "fails" do
72
+ expect { subject }.to raise_error(RuntimeError)
77
73
  end
78
74
  end
79
75
  end
80
76
 
81
- context '1 decimal place' do
82
- let(:current_version) { '3.5.0' }
77
+ context "1 decimal place" do
78
+ let(:current_version) { "3.5.0" }
83
79
 
84
- context 'valid' do
85
- let(:version) { '~> 3.1' }
80
+ context "valid" do
81
+ let(:version) { "~> 3.1" }
86
82
  it { expect(subject).to be_truthy }
87
83
  end
88
84
 
89
- context 'invalid' do
90
- let(:version) { '~> 3.6' }
91
- it 'fails' do
92
- expect { subject }.to raise_error
85
+ context "invalid" do
86
+ let(:version) { "~> 3.6" }
87
+ it "fails" do
88
+ expect { subject }.to raise_error(RuntimeError)
93
89
  end
94
90
  end
95
91
  end
96
-
97
92
  end
98
-
99
93
  end
100
-
101
94
  end
102
-
103
95
  end
@@ -1,8 +1,7 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Capistrano
4
-
5
4
  describe Application do
6
- let(:app) { Application.new }
5
+ let(:app) { Application.new }
7
6
  end
8
7
  end
@@ -1,16 +1,16 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'capistrano/all'
4
- require 'rspec'
5
- require 'mocha/api'
6
- require 'time'
3
+ require "capistrano/all"
4
+ require "rspec"
5
+ require "mocha/api"
6
+ require "time"
7
7
 
8
8
  # Requires supporting files with custom matchers and macros, etc,
9
9
  # in ./support/ and its subdirectories.
10
- Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each {|f| require f}
10
+ Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each { |f| require f }
11
11
 
12
12
  RSpec.configure do |config|
13
- config.raise_errors_for_deprecations!
13
+ config.raise_errors_for_deprecations!
14
14
  config.mock_framework = :mocha
15
- config.order = 'random'
15
+ config.order = "random"
16
16
  end
@@ -1,20 +1,19 @@
1
- require 'open-uri'
1
+ require "open-uri"
2
2
 
3
3
  Vagrant.configure("2") do |config|
4
-
5
4
  config.ssh.insert_key = false
6
5
 
7
6
  [:app].each_with_index do |role, i|
8
- config.vm.define(role, primary: true) do |config|
9
- config.vm.define role
10
- config.vm.box = 'hashicorp/precise64'
11
- config.vm.network "forwarded_port", guest: 22, host: "222#{i}".to_i
12
- config.vm.provision :shell, inline: 'sudo apt-get -y install git-core'
7
+ config.vm.define(role, primary: true) do |primary|
8
+ primary.vm.define role
9
+ primary.vm.box = "hashicorp/precise64"
10
+ primary.vm.network "forwarded_port", guest: 22, host: "222#{i}".to_i
11
+ primary.vm.provision :shell, inline: "sudo apt-get -y install git-core"
13
12
 
14
- vagrantkey = open("https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub", "r",&:read)
13
+ vagrantkey = open("https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub", "r", &:read)
15
14
 
16
- config.vm.provision :shell,
17
- inline: <<-INLINE
15
+ primary.vm.provision :shell,
16
+ inline: <<-INLINE
18
17
  install -d -m 700 /root/.ssh
19
18
  echo -e "#{vagrantkey}" > /root/.ssh/authorized_keys
20
19
  chmod 0600 /root/.ssh/authorized_keys
@@ -1,11 +1,11 @@
1
1
  namespace :deploy do
2
2
  namespace :check do
3
- task :linked_files => 'config/database.yml'
3
+ task linked_files: "config/database.yml"
4
4
  end
5
5
  end
6
6
 
7
- remote_file 'config/database.yml' => '/tmp/database.yml', roles: :all
7
+ remote_file "config/database.yml" => "/tmp/database.yml", :roles => :all
8
8
 
9
- file '/tmp/database.yml' do |t|
9
+ file "/tmp/database.yml" do |t|
10
10
  sh "touch #{t.name}"
11
11
  end
@@ -1,7 +1,8 @@
1
- set :fail, proc { fail }
2
- before 'deploy:starting', :fail do
1
+ set :fail, proc { raise }
2
+ before "deploy:starting", :fail do
3
3
  on roles :all do
4
- execute :touch, shared_path.join('fail')
4
+ execute :mkdir, "-p", shared_path
5
+ execute :touch, shared_path.join("fail")
5
6
  end
6
7
  fetch(:fail)
7
8
  end
@@ -1,5 +1,5 @@
1
- after 'deploy:failed', :failed do
1
+ after "deploy:failed", :custom_failed do
2
2
  on roles :all do
3
- execute :touch, shared_path.join('failed')
3
+ execute :touch, shared_path.join("failed")
4
4
  end
5
5
  end
@@ -0,0 +1,6 @@
1
+ # This rake file is used by plugin_spec.rb.
2
+
3
+ task :plugin_test do
4
+ # Example of invoking a helper method provided by the plugin
5
+ hello
6
+ end
@@ -1,11 +1,11 @@
1
1
  task :am_i_root do
2
2
  on roles(:all) do |host|
3
- host.user = 'root'
4
- ident = capture :id, '-a'
3
+ host.user = "root"
4
+ ident = capture :id, "-a"
5
5
  info "I am #{ident}"
6
6
  end
7
- on roles(:all) do |host|
8
- ident = capture :id, '-a'
7
+ on roles(:all) do |_host|
8
+ ident = capture :id, "-a"
9
9
  info "I am #{ident}"
10
10
  end
11
11
  end
@@ -1,5 +1,6 @@
1
- require 'fileutils'
2
- require 'pathname'
1
+ require "English"
2
+ require "fileutils"
3
+ require "pathname"
3
4
 
4
5
  module TestApp
5
6
  extend self
@@ -9,7 +10,7 @@ module TestApp
9
10
  end
10
11
 
11
12
  def default_config
12
- %{
13
+ <<-CONFIG
13
14
  set :deploy_to, '#{deploy_to}'
14
15
  set :repo_url, 'git://github.com/capistrano/capistrano.git'
15
16
  set :branch, 'master'
@@ -17,7 +18,8 @@ module TestApp
17
18
  server 'vagrant@localhost:2220', roles: %w{web app}
18
19
  set :linked_files, #{linked_files}
19
20
  set :linked_dirs, #{linked_dirs}
20
- }
21
+ set :format_options, log_file: nil
22
+ CONFIG
21
23
  end
22
24
 
23
25
  def linked_files
@@ -29,45 +31,45 @@ module TestApp
29
31
  end
30
32
 
31
33
  def linked_dirs
32
- %w{bin log public/system vendor/bundle}
34
+ %w{bin log public/system}
33
35
  end
34
36
 
35
37
  def create_test_app
36
38
  FileUtils.rm_rf(test_app_path)
37
39
  FileUtils.mkdir(test_app_path)
38
40
 
39
- File.open(gemfile, 'w+') do |file|
41
+ File.open(gemfile, "w+") do |file|
40
42
  file.write "gem 'capistrano', path: '#{path_to_cap}'"
41
43
  end
42
44
 
43
45
  Dir.chdir(test_app_path) do
44
- %x[bundle]
46
+ `bundle`
45
47
  end
46
48
  end
47
49
 
48
50
  def install_test_app_with(config)
49
51
  create_test_app
50
52
  Dir.chdir(test_app_path) do
51
- %x[bundle exec cap install STAGES=#{stage}]
53
+ `bundle exec cap install STAGES=#{stage}`
52
54
  end
53
55
  write_local_deploy_file(config)
54
56
  end
55
57
 
56
58
  def write_local_deploy_file(config)
57
- File.open(test_stage_path, 'w') do |file|
59
+ File.open(test_stage_path, "w") do |file|
58
60
  file.write config
59
61
  end
60
62
  end
61
63
 
62
64
  def append_to_deploy_file(config)
63
- File.open(test_stage_path, 'a') do |file|
65
+ File.open(test_stage_path, "a") do |file|
64
66
  file.write config + "\n"
65
67
  end
66
68
  end
67
69
 
68
70
  def prepend_to_capfile(config)
69
71
  current_capfile = File.read(capfile)
70
- File.open(capfile, 'w') do |file|
72
+ File.open(capfile, "w") do |file|
71
73
  file.write config
72
74
  file.write current_capfile
73
75
  end
@@ -78,7 +80,7 @@ module TestApp
78
80
  end
79
81
 
80
82
  def create_shared_file(path)
81
- File.open(shared_path.join(path), 'w')
83
+ File.open(shared_path.join(path), "w")
82
84
  end
83
85
 
84
86
  def cap(task)
@@ -88,37 +90,37 @@ module TestApp
88
90
  def run(command)
89
91
  output = nil
90
92
  Dir.chdir(test_app_path) do
91
- output = %x[#{command}]
93
+ output = `#{command}`
92
94
  end
93
- [$?.success?, output]
95
+ [$CHILD_STATUS.success?, output]
94
96
  end
95
97
 
96
98
  def stage
97
- 'test'
99
+ "test"
98
100
  end
99
101
 
100
102
  def test_stage_path
101
- test_app_path.join('config/deploy/test.rb')
103
+ test_app_path.join("config/deploy/test.rb")
102
104
  end
103
105
 
104
106
  def test_app_path
105
- Pathname.new('/tmp/test_app')
107
+ Pathname.new("/tmp/test_app")
106
108
  end
107
109
 
108
110
  def deploy_to
109
- Pathname.new('/home/vagrant/var/www/deploy')
111
+ Pathname.new("/home/vagrant/var/www/deploy")
110
112
  end
111
113
 
112
114
  def shared_path
113
- deploy_to.join('shared')
115
+ deploy_to.join("shared")
114
116
  end
115
117
 
116
118
  def current_path
117
- deploy_to.join('current')
119
+ deploy_to.join("current")
118
120
  end
119
121
 
120
122
  def releases_path
121
- deploy_to.join('releases')
123
+ deploy_to.join("releases")
122
124
  end
123
125
 
124
126
  def release_path
@@ -130,19 +132,19 @@ module TestApp
130
132
  end
131
133
 
132
134
  def repo_path
133
- deploy_to.join('repo')
135
+ deploy_to.join("repo")
134
136
  end
135
137
 
136
138
  def path_to_cap
137
- File.expand_path('.')
139
+ File.expand_path(".")
138
140
  end
139
141
 
140
142
  def gemfile
141
- test_app_path.join('Gemfile')
143
+ test_app_path.join("Gemfile")
142
144
  end
143
145
 
144
146
  def capfile
145
- test_app_path.join('Capfile')
147
+ test_app_path.join("Capfile")
146
148
  end
147
149
 
148
150
  def current_user
@@ -150,7 +152,7 @@ module TestApp
150
152
  end
151
153
 
152
154
  def task_dir
153
- test_app_path.join('lib/capistrano/tasks')
155
+ test_app_path.join("lib/capistrano/tasks")
154
156
  end
155
157
 
156
158
  def copy_task_to_test_app(source)
@@ -158,20 +160,19 @@ module TestApp
158
160
  end
159
161
 
160
162
  def config_path
161
- test_app_path.join('config')
163
+ test_app_path.join("config")
162
164
  end
163
165
 
164
166
  def move_configuration_to_custom_location(location)
165
167
  prepend_to_capfile(
166
- %{
168
+ <<-CONFIG
167
169
  set :stage_config_path, "app/config/deploy"
168
170
  set :deploy_config_path, "app/config/deploy.rb"
169
- }
171
+ CONFIG
170
172
  )
171
173
 
172
174
  location = test_app_path.join(location)
173
175
  FileUtils.mkdir_p(location)
174
176
  FileUtils.mv(config_path, location)
175
177
  end
176
-
177
178
  end