capistrano 3.0.0.pre14 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -0
  3. data/README.md +1 -1
  4. data/bin/cap +1 -1
  5. data/capistrano.gemspec +3 -0
  6. data/features/deploy.feature +52 -0
  7. data/features/installation.feature +16 -0
  8. data/features/remote_file_task.feature +14 -0
  9. data/features/step_definitions/assertions.rb +90 -0
  10. data/features/step_definitions/cap_commands.rb +8 -0
  11. data/features/step_definitions/setup.rb +25 -0
  12. data/features/support/env.rb +12 -0
  13. data/features/support/remote_command_helpers.rb +20 -0
  14. data/lib/Capfile +1 -0
  15. data/lib/capistrano.rb +0 -14
  16. data/lib/capistrano/all.rb +16 -0
  17. data/lib/capistrano/application.rb +1 -10
  18. data/lib/capistrano/configuration.rb +4 -0
  19. data/lib/capistrano/configuration/server.rb +44 -6
  20. data/lib/capistrano/configuration/servers.rb +14 -51
  21. data/lib/capistrano/configuration/servers/role_filter.rb +86 -0
  22. data/lib/capistrano/defaults.rb +0 -8
  23. data/lib/capistrano/dsl.rb +1 -1
  24. data/lib/capistrano/dsl/env.rb +6 -2
  25. data/lib/capistrano/dsl/paths.rb +7 -4
  26. data/lib/capistrano/dsl/task_enhancements.rb +38 -0
  27. data/lib/capistrano/hg.rb +1 -0
  28. data/lib/capistrano/i18n.rb +1 -1
  29. data/lib/capistrano/setup.rb +7 -3
  30. data/lib/capistrano/tasks/deploy.rake +39 -9
  31. data/lib/capistrano/tasks/framework.rake +0 -2
  32. data/lib/capistrano/tasks/git.rake +3 -6
  33. data/lib/capistrano/tasks/hg.rake +39 -0
  34. data/lib/capistrano/templates/Capfile +2 -23
  35. data/lib/capistrano/templates/deploy.rb.erb +23 -0
  36. data/lib/capistrano/templates/stage.rb.erb +1 -1
  37. data/lib/capistrano/version.rb +1 -1
  38. data/spec/integration/dsl_spec.rb +71 -0
  39. data/spec/lib/capistrano/configuration/server_spec.rb +69 -0
  40. data/spec/lib/capistrano/configuration/servers/role_filter_spec.rb +140 -0
  41. data/spec/lib/capistrano/configuration/servers_spec.rb +46 -9
  42. data/spec/lib/capistrano/configuration_spec.rb +11 -0
  43. data/spec/spec_helper.rb +1 -2
  44. data/spec/support/.gitignore +1 -0
  45. data/spec/support/Vagrantfile +13 -0
  46. data/spec/support/tasks/database.cap +11 -0
  47. data/spec/support/test_app.rb +55 -6
  48. metadata +74 -16
  49. data/lib/capistrano/bundler.rb +0 -1
  50. data/lib/capistrano/tasks/bundler.rake +0 -13
  51. data/spec/integration/deploy_finalize_spec.rb +0 -34
  52. data/spec/integration/deploy_finished_spec.rb +0 -36
  53. data/spec/integration/deploy_started_spec.rb +0 -74
  54. data/spec/integration/deploy_update_spec.rb +0 -45
  55. data/spec/integration/installation_spec.rb +0 -76
@@ -62,6 +62,17 @@ module Capistrano
62
62
  end
63
63
  end
64
64
 
65
+ describe 'deleting' do
66
+ before do
67
+ config.set(:key, :value)
68
+ end
69
+
70
+ it 'deletes the value' do
71
+ config.delete(:key)
72
+ expect(config.fetch(:key)).to be_nil
73
+ end
74
+ end
75
+
65
76
  describe 'asking' do
66
77
  let(:question) { stub }
67
78
 
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'capistrano/all'
3
4
  require 'rspec'
4
- require 'capistrano'
5
5
  require 'mocha/api'
6
6
 
7
7
  # Requires supporting files with custom matchers and macros, etc,
@@ -12,5 +12,4 @@ RSpec.configure do |config|
12
12
  config.treat_symbols_as_metadata_keys_with_true_values = true
13
13
  config.mock_framework = :mocha
14
14
  config.order = 'random'
15
- config.filter_run_excluding :slow
16
15
  end
@@ -0,0 +1 @@
1
+ .vagrant
@@ -0,0 +1,13 @@
1
+ Vagrant::Config.run do |config|
2
+
3
+ [:app].each_with_index do |role, i|
4
+ config.vm.define(role, primary: true) do |config|
5
+ config.vm.box = role
6
+ config.vm.box = 'precise64'
7
+ config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
8
+ config.vm.forward_port 22, "222#{i}".to_i
9
+ config.vm.provision :shell, inline: 'yes | sudo apt-get install git-core'
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,11 @@
1
+ namespace :deploy do
2
+ namespace :check do
3
+ task :linked_files => 'config/database.yml'
4
+ end
5
+ end
6
+
7
+ remote_file 'config/database.yml' => '/tmp/database.yml', roles: :all
8
+
9
+ file '/tmp/database.yml' do |t|
10
+ sh "touch #{t.name}"
11
+ end
@@ -1,10 +1,39 @@
1
1
  require 'fileutils'
2
2
  module TestApp
3
+ extend self
4
+
5
+ def install
6
+ install_test_app_with(default_config)
7
+ end
8
+
9
+ def default_config
10
+ %{
11
+ set :stage, :#{stage}
12
+ set :deploy_to, '#{deploy_to}'
13
+ set :repo_url, 'git://github.com/capistrano/capistrano.git'
14
+ set :branch, 'v3'
15
+ set :ssh_options, { keys: "\#{ENV['HOME']}/.vagrant.d/insecure_private_key" }
16
+ server 'vagrant@localhost:2220', roles: %w{web app}
17
+ set :linked_files, #{linked_files}
18
+ set :linked_dirs, #{linked_dirs}
19
+ }
20
+ end
21
+
22
+ def linked_files
23
+ %w{config/database.yml}
24
+ end
25
+
26
+ def linked_file
27
+ shared_path.join(linked_files.first)
28
+ end
29
+
30
+ def linked_dirs
31
+ %w{bin log public/system vendor/bundle}
32
+ end
33
+
3
34
  def create_test_app
4
- [test_app_path, deploy_to].each do |path|
5
- FileUtils.rm_rf(path)
6
- FileUtils.mkdir(path)
7
- end
35
+ FileUtils.rm_rf(test_app_path)
36
+ FileUtils.mkdir(test_app_path)
8
37
 
9
38
  File.open(gemfile, 'w+') do |file|
10
39
  file.write "gem 'capistrano', path: '#{path_to_cap}'"
@@ -56,7 +85,7 @@ module TestApp
56
85
  end
57
86
 
58
87
  def deploy_to
59
- Pathname.new('/tmp/test_app/deploy_to')
88
+ Pathname.new('/home/vagrant/var/www/deploy')
60
89
  end
61
90
 
62
91
  def shared_path
@@ -72,7 +101,15 @@ module TestApp
72
101
  end
73
102
 
74
103
  def release_path
75
- releases_path.join(Dir.entries(releases_path).last)
104
+ releases_path.join(timestamp)
105
+ end
106
+
107
+ def timestamp
108
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
109
+ end
110
+
111
+ def repo_path
112
+ deploy_to.join('repo')
76
113
  end
77
114
 
78
115
  def path_to_cap
@@ -83,7 +120,19 @@ module TestApp
83
120
  test_app_path.join('Gemfile')
84
121
  end
85
122
 
123
+ def capfile
124
+ test_app_path.join('Capfile')
125
+ end
126
+
86
127
  def current_user
87
128
  `whoami`.chomp
88
129
  end
130
+
131
+ def task_dir
132
+ test_app_path.join('lib/capistrano/tasks')
133
+ end
134
+
135
+ def copy_task_to_test_app(source)
136
+ FileUtils.cp(source, task_dir)
137
+ end
89
138
  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.pre14
4
+ version: 3.0.0
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-08-03 00:00:00.000000000 Z
12
+ date: 2013-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sshkit
@@ -81,6 +81,48 @@ dependencies:
81
81
  - - '>='
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: vagrant
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 1.0.7
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: 1.0.7
98
+ - !ruby/object:Gem::Dependency
99
+ name: kuroko
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: cucumber
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
84
126
  description: Capistrano is a utility and framework for executing commands in parallel
85
127
  on multiple remote machines, via SSH.
86
128
  email:
@@ -102,14 +144,23 @@ files:
102
144
  - bin/capify
103
145
  - capistrano-public_cert.pem
104
146
  - capistrano.gemspec
147
+ - features/deploy.feature
148
+ - features/installation.feature
149
+ - features/remote_file_task.feature
150
+ - features/step_definitions/assertions.rb
151
+ - features/step_definitions/cap_commands.rb
152
+ - features/step_definitions/setup.rb
153
+ - features/support/env.rb
154
+ - features/support/remote_command_helpers.rb
105
155
  - lib/Capfile
106
156
  - lib/capistrano.rb
157
+ - lib/capistrano/all.rb
107
158
  - lib/capistrano/application.rb
108
- - lib/capistrano/bundler.rb
109
159
  - lib/capistrano/configuration.rb
110
160
  - lib/capistrano/configuration/question.rb
111
161
  - lib/capistrano/configuration/server.rb
112
162
  - lib/capistrano/configuration/servers.rb
163
+ - lib/capistrano/configuration/servers/role_filter.rb
113
164
  - lib/capistrano/console.rb
114
165
  - lib/capistrano/defaults.rb
115
166
  - lib/capistrano/deploy.rb
@@ -120,30 +171,27 @@ files:
120
171
  - lib/capistrano/dsl/stages.rb
121
172
  - lib/capistrano/dsl/task_enhancements.rb
122
173
  - lib/capistrano/git.rb
174
+ - lib/capistrano/hg.rb
123
175
  - lib/capistrano/i18n.rb
124
176
  - lib/capistrano/install.rb
125
177
  - lib/capistrano/setup.rb
126
- - lib/capistrano/tasks/bundler.rake
127
178
  - lib/capistrano/tasks/console.rake
128
179
  - lib/capistrano/tasks/deploy.rake
129
180
  - lib/capistrano/tasks/framework.rake
130
181
  - lib/capistrano/tasks/git.rake
182
+ - lib/capistrano/tasks/hg.rake
131
183
  - lib/capistrano/tasks/install.rake
132
184
  - lib/capistrano/templates/Capfile
133
185
  - lib/capistrano/templates/deploy.rb.erb
134
186
  - lib/capistrano/templates/stage.rb.erb
135
187
  - lib/capistrano/version.rb
136
188
  - lib/capistrano/version_validator.rb
137
- - spec/integration/deploy_finalize_spec.rb
138
- - spec/integration/deploy_finished_spec.rb
139
- - spec/integration/deploy_started_spec.rb
140
- - spec/integration/deploy_update_spec.rb
141
189
  - spec/integration/dsl_spec.rb
142
- - spec/integration/installation_spec.rb
143
190
  - spec/integration_spec_helper.rb
144
191
  - spec/lib/capistrano/application_spec.rb
145
192
  - spec/lib/capistrano/configuration/question_spec.rb
146
193
  - spec/lib/capistrano/configuration/server_spec.rb
194
+ - spec/lib/capistrano/configuration/servers/role_filter_spec.rb
147
195
  - spec/lib/capistrano/configuration/servers_spec.rb
148
196
  - spec/lib/capistrano/configuration_spec.rb
149
197
  - spec/lib/capistrano/dsl/env_spec.rb
@@ -152,7 +200,10 @@ files:
152
200
  - spec/lib/capistrano/version_validator_spec.rb
153
201
  - spec/lib/capistrano_spec.rb
154
202
  - spec/spec_helper.rb
203
+ - spec/support/.gitignore
204
+ - spec/support/Vagrantfile
155
205
  - spec/support/matchers.rb
206
+ - spec/support/tasks/database.cap
156
207
  - spec/support/test_app.rb
157
208
  homepage: ''
158
209
  licenses: []
@@ -169,9 +220,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
220
  version: '0'
170
221
  required_rubygems_version: !ruby/object:Gem::Requirement
171
222
  requirements:
172
- - - '>'
223
+ - - '>='
173
224
  - !ruby/object:Gem::Version
174
- version: 1.3.1
225
+ version: '0'
175
226
  requirements: []
176
227
  rubyforge_project:
177
228
  rubygems_version: 2.0.3
@@ -179,16 +230,20 @@ signing_key:
179
230
  specification_version: 4
180
231
  summary: Capistrano - Welcome to easy deployment with Ruby over SSH
181
232
  test_files:
182
- - spec/integration/deploy_finalize_spec.rb
183
- - spec/integration/deploy_finished_spec.rb
184
- - spec/integration/deploy_started_spec.rb
185
- - spec/integration/deploy_update_spec.rb
233
+ - features/deploy.feature
234
+ - features/installation.feature
235
+ - features/remote_file_task.feature
236
+ - features/step_definitions/assertions.rb
237
+ - features/step_definitions/cap_commands.rb
238
+ - features/step_definitions/setup.rb
239
+ - features/support/env.rb
240
+ - features/support/remote_command_helpers.rb
186
241
  - spec/integration/dsl_spec.rb
187
- - spec/integration/installation_spec.rb
188
242
  - spec/integration_spec_helper.rb
189
243
  - spec/lib/capistrano/application_spec.rb
190
244
  - spec/lib/capistrano/configuration/question_spec.rb
191
245
  - spec/lib/capistrano/configuration/server_spec.rb
246
+ - spec/lib/capistrano/configuration/servers/role_filter_spec.rb
192
247
  - spec/lib/capistrano/configuration/servers_spec.rb
193
248
  - spec/lib/capistrano/configuration_spec.rb
194
249
  - spec/lib/capistrano/dsl/env_spec.rb
@@ -197,5 +252,8 @@ test_files:
197
252
  - spec/lib/capistrano/version_validator_spec.rb
198
253
  - spec/lib/capistrano_spec.rb
199
254
  - spec/spec_helper.rb
255
+ - spec/support/.gitignore
256
+ - spec/support/Vagrantfile
200
257
  - spec/support/matchers.rb
258
+ - spec/support/tasks/database.cap
201
259
  - spec/support/test_app.rb
@@ -1 +0,0 @@
1
- load File.expand_path("../tasks/bundler.rake", __FILE__)
@@ -1,13 +0,0 @@
1
- namespace :deploy do
2
-
3
- desc 'Bundle'
4
- task :bundle do
5
- on roles :all do
6
- within release_path do
7
- execute :bundle, "--gemfile #{release_path}/Gemfile --deployment --binstubs #{shared_path}/bin --path #{shared_path}/bundle --without development test cucumber"
8
- end
9
- end
10
- end
11
-
12
- before 'deploy:updated', 'deploy:bundle'
13
- end
@@ -1,34 +0,0 @@
1
- require 'integration_spec_helper'
2
-
3
- describe 'cap deploy:finished', slow: true do
4
- before do
5
- install_test_app_with(config)
6
- end
7
-
8
- describe 'deploy' do
9
- let(:config) {
10
- %{
11
- set :stage, :#{stage}
12
- set :deploy_to, '#{deploy_to}'
13
- set :repo_url, 'git://github.com/capistrano/capistrano.git'
14
- set :branch, 'v3'
15
- server 'localhost', roles: %w{web app}, user: '#{current_user}'
16
- set :linked_files, %w{config/database.yml}
17
- set :linked_dirs, %w{bin log public/system vendor/bundle}
18
- }
19
- }
20
-
21
- describe 'log_revision' do
22
- before do
23
- cap 'deploy:started'
24
- cap 'deploy:updating'
25
- cap 'deploy:publishing'
26
- cap 'deploy:finished'
27
- end
28
-
29
- it 'writes the log file' do
30
- expect(deploy_to.join('revisions.log')).to be_a_file
31
- end
32
- end
33
- end
34
- end
@@ -1,36 +0,0 @@
1
- require 'integration_spec_helper'
2
-
3
- describe 'cap deploy:finished', slow: true do
4
- before do
5
- install_test_app_with(config)
6
- end
7
-
8
- describe 'deploy' do
9
- let(:config) {
10
- %{
11
- set :stage, :#{stage}
12
- set :deploy_to, '#{deploy_to}'
13
- set :repo_url, 'git://github.com/capistrano/capistrano.git'
14
- set :branch, 'v3'
15
- server 'localhost', roles: %w{web app}, user: '#{current_user}'
16
- set :linked_files, %w{config/database.yml}
17
- set :linked_dirs, %w{bin log public/system vendor/bundle}
18
- }
19
- }
20
-
21
- describe 'symlink' do
22
- before do
23
- cap 'deploy:started'
24
- cap 'deploy:updating'
25
- cap 'deploy:publishing'
26
- end
27
-
28
- describe 'release' do
29
- it 'symlinks the release to `current`' do
30
- expect(File.symlink?(current_path)).to be_true
31
- expect(File.readlink(current_path)).to match /\/tmp\/test_app\/deploy_to\/releases\/\d{14}/
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,74 +0,0 @@
1
- require 'integration_spec_helper'
2
-
3
- describe 'cap deploy:started', slow: true do
4
- before do
5
- install_test_app_with(config)
6
- end
7
-
8
- describe 'deploy:check' do
9
- let(:config) {
10
- %{
11
- set :stage, :#{stage}
12
- set :deploy_to, '#{deploy_to}'
13
- set :repo_url, 'git://github.com/capistrano/capistrano.git'
14
- set :branch, 'v3'
15
- server 'localhost', roles: %w{web app}, user: '#{current_user}'
16
- set :linked_files, %w{config/database.yml}
17
- set :linked_dirs, %w{bin log public/system vendor/bundle}
18
- }
19
- }
20
-
21
- describe 'directories' do
22
- before do
23
- cap 'deploy:check:directories'
24
- end
25
-
26
- it 'ensures the directory structure' do
27
- expect(shared_path).to be_a_directory
28
- expect(releases_path).to be_a_directory
29
- end
30
- end
31
-
32
- describe 'linked_dirs' do
33
- before do
34
- cap 'deploy:check:linked_dirs'
35
- end
36
-
37
- it 'ensure directories to be linked in `shared`' do
38
- [
39
- shared_path.join('bin'),
40
- shared_path.join('log'),
41
- shared_path.join('public/system'),
42
- shared_path.join('vendor/bundle'),
43
- ].each do |dir|
44
- expect(dir).to be_a_directory
45
- end
46
- end
47
- end
48
-
49
- describe 'linked_files' do
50
-
51
- subject { cap 'deploy:check:linked_files' }
52
-
53
- context 'file does not exist' do
54
- it 'fails' do
55
- expect(subject).to match 'config/database.yml does not exist'
56
- end
57
- end
58
-
59
- context 'file exists' do
60
- before do
61
- create_shared_directory('config')
62
- create_shared_file('config/database.yml')
63
- end
64
-
65
- it 'suceeds' do
66
- expect(subject).not_to match 'config/database.yml does not exist'
67
- expect(subject).to match 'successful'
68
- end
69
-
70
- end
71
- end
72
- end
73
- end
74
-