capistrano 2.8.0 → 3.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.docker/Dockerfile +7 -0
- data/.docker/ssh_key_rsa +49 -0
- data/.docker/ssh_key_rsa.pub +1 -0
- data/.docker/ubuntu_setup.sh +23 -0
- data/.github/issue_template.md +19 -0
- data/.github/pull_request_template.md +22 -0
- data/.github/release-drafter.yml +25 -0
- data/.github/workflows/ci.yml +80 -0
- data/.github/workflows/release-drafter.yml +18 -0
- data/.gitignore +23 -8
- data/.rubocop.yml +62 -0
- data/CHANGELOG.md +1 -0
- data/CONTRIBUTING.md +63 -0
- data/DEVELOPMENT.md +112 -0
- data/Gemfile +42 -9
- data/LICENSE.txt +21 -0
- data/README.md +221 -0
- data/RELEASING.md +17 -0
- data/Rakefile +17 -8
- data/UPGRADING-3.7.md +86 -0
- data/bin/cap +2 -3
- data/bin/capify +7 -89
- data/capistrano.gemspec +29 -43
- data/docker-compose.yml +8 -0
- data/features/configuration.feature +28 -0
- data/features/deploy.feature +92 -0
- data/features/deploy_failure.feature +17 -0
- data/features/doctor.feature +11 -0
- data/features/installation.feature +21 -0
- data/features/sshconnect.feature +11 -0
- data/features/stage_failure.feature +9 -0
- data/features/step_definitions/assertions.rb +162 -0
- data/features/step_definitions/cap_commands.rb +21 -0
- data/features/step_definitions/setup.rb +91 -0
- data/features/subdirectory.feature +9 -0
- data/features/support/docker_gateway.rb +53 -0
- data/features/support/env.rb +1 -0
- data/features/support/remote_command_helpers.rb +29 -0
- data/features/support/remote_ssh_helpers.rb +33 -0
- data/lib/Capfile +3 -0
- data/lib/capistrano/all.rb +17 -0
- data/lib/capistrano/application.rb +153 -0
- data/lib/capistrano/configuration/empty_filter.rb +9 -0
- data/lib/capistrano/configuration/filter.rb +26 -0
- data/lib/capistrano/configuration/host_filter.rb +29 -0
- data/lib/capistrano/configuration/null_filter.rb +9 -0
- data/lib/capistrano/configuration/plugin_installer.rb +51 -0
- data/lib/capistrano/configuration/question.rb +76 -0
- data/lib/capistrano/configuration/role_filter.rb +29 -0
- data/lib/capistrano/configuration/scm_resolver.rb +149 -0
- data/lib/capistrano/configuration/server.rb +137 -0
- data/lib/capistrano/configuration/servers.rb +56 -96
- data/lib/capistrano/configuration/validated_variables.rb +110 -0
- data/lib/capistrano/configuration/variables.rb +79 -94
- data/lib/capistrano/configuration.rb +178 -33
- data/lib/capistrano/console.rb +1 -0
- data/lib/capistrano/defaults.rb +36 -0
- data/lib/capistrano/deploy.rb +3 -0
- data/lib/capistrano/doctor/environment_doctor.rb +19 -0
- data/lib/capistrano/doctor/gems_doctor.rb +45 -0
- data/lib/capistrano/doctor/output_helpers.rb +79 -0
- data/lib/capistrano/doctor/servers_doctor.rb +105 -0
- data/lib/capistrano/doctor/variables_doctor.rb +74 -0
- data/lib/capistrano/doctor.rb +6 -0
- data/lib/capistrano/dotfile.rb +2 -0
- data/lib/capistrano/dsl/env.rb +43 -0
- data/lib/capistrano/dsl/paths.rb +89 -0
- data/lib/capistrano/dsl/stages.rb +31 -0
- data/lib/capistrano/dsl/task_enhancements.rb +61 -0
- data/lib/capistrano/dsl.rb +95 -0
- data/lib/capistrano/framework.rb +2 -0
- data/lib/capistrano/i18n.rb +46 -0
- data/lib/capistrano/immutable_task.rb +30 -0
- data/lib/capistrano/install.rb +1 -0
- data/lib/capistrano/plugin.rb +95 -0
- data/lib/capistrano/proc_helpers.rb +13 -0
- data/lib/capistrano/scm/git.rb +105 -0
- data/lib/capistrano/scm/hg.rb +55 -0
- data/lib/capistrano/scm/plugin.rb +13 -0
- data/lib/capistrano/scm/svn.rb +56 -0
- data/lib/capistrano/scm/tasks/git.rake +84 -0
- data/lib/capistrano/scm/tasks/hg.rake +53 -0
- data/lib/capistrano/scm/tasks/svn.rake +53 -0
- data/lib/capistrano/scm.rb +115 -0
- data/lib/capistrano/setup.rb +36 -0
- data/lib/capistrano/tasks/console.rake +25 -0
- data/lib/capistrano/tasks/deploy.rake +280 -0
- data/lib/capistrano/tasks/doctor.rake +24 -0
- data/lib/capistrano/tasks/framework.rake +67 -0
- data/lib/capistrano/tasks/install.rake +41 -0
- data/lib/capistrano/templates/Capfile +38 -0
- data/lib/capistrano/templates/deploy.rb.erb +39 -0
- data/lib/capistrano/templates/stage.rb.erb +61 -0
- data/lib/capistrano/upload_task.rb +9 -0
- data/lib/capistrano/version.rb +1 -14
- data/lib/capistrano/version_validator.rb +32 -0
- data/lib/capistrano.rb +0 -3
- data/spec/integration/dsl_spec.rb +632 -0
- data/spec/integration_spec_helper.rb +5 -0
- data/spec/lib/capistrano/application_spec.rb +60 -0
- data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/filter_spec.rb +109 -0
- data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
- data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
- data/spec/lib/capistrano/configuration/question_spec.rb +92 -0
- data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
- data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +56 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +309 -0
- data/spec/lib/capistrano/configuration/servers_spec.rb +331 -0
- data/spec/lib/capistrano/configuration_spec.rb +357 -0
- data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
- data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
- data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
- data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
- data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +228 -0
- data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +108 -0
- data/spec/lib/capistrano/dsl_spec.rb +125 -0
- data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
- data/spec/lib/capistrano/plugin_spec.rb +84 -0
- data/spec/lib/capistrano/scm/git_spec.rb +194 -0
- data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
- data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
- data/spec/lib/capistrano/scm_spec.rb +103 -0
- data/spec/lib/capistrano/upload_task_spec.rb +19 -0
- data/spec/lib/capistrano/version_validator_spec.rb +118 -0
- data/spec/lib/capistrano_spec.rb +7 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/matchers.rb +5 -0
- data/spec/support/tasks/database.rake +11 -0
- data/spec/support/tasks/fail.rake +8 -0
- data/spec/support/tasks/failed.rake +5 -0
- data/spec/support/tasks/plugin.rake +6 -0
- data/spec/support/tasks/root.rake +11 -0
- data/spec/support/test_app.rb +205 -0
- metadata +234 -208
- data/.rvmrc +0 -1
- data/CHANGELOG +0 -954
- data/README.mdown +0 -76
- data/lib/capistrano/callback.rb +0 -45
- data/lib/capistrano/cli/execute.rb +0 -85
- data/lib/capistrano/cli/help.rb +0 -125
- data/lib/capistrano/cli/help.txt +0 -81
- data/lib/capistrano/cli/options.rb +0 -243
- data/lib/capistrano/cli/ui.rb +0 -40
- data/lib/capistrano/cli.rb +0 -47
- data/lib/capistrano/command.rb +0 -286
- data/lib/capistrano/configuration/actions/file_transfer.rb +0 -51
- data/lib/capistrano/configuration/actions/inspect.rb +0 -46
- data/lib/capistrano/configuration/actions/invocation.rb +0 -298
- data/lib/capistrano/configuration/callbacks.rb +0 -148
- data/lib/capistrano/configuration/connections.rb +0 -230
- data/lib/capistrano/configuration/execution.rb +0 -143
- data/lib/capistrano/configuration/loading.rb +0 -197
- data/lib/capistrano/configuration/namespaces.rb +0 -197
- data/lib/capistrano/configuration/roles.rb +0 -73
- data/lib/capistrano/errors.rb +0 -19
- data/lib/capistrano/ext/string.rb +0 -5
- data/lib/capistrano/extensions.rb +0 -57
- data/lib/capistrano/logger.rb +0 -59
- data/lib/capistrano/processable.rb +0 -53
- data/lib/capistrano/recipes/compat.rb +0 -32
- data/lib/capistrano/recipes/deploy/assets.rb +0 -57
- data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
- data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -111
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
- data/lib/capistrano/recipes/deploy/scm/base.rb +0 -196
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
- data/lib/capistrano/recipes/deploy/scm/git.rb +0 -282
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
- data/lib/capistrano/recipes/deploy/scm/none.rb +0 -44
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -138
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
- data/lib/capistrano/recipes/deploy/scm.rb +0 -19
- data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -88
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -224
- data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
- data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
- data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/recipes/deploy.rb +0 -568
- data/lib/capistrano/recipes/standard.rb +0 -37
- data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/role.rb +0 -102
- data/lib/capistrano/server_definition.rb +0 -56
- data/lib/capistrano/shell.rb +0 -260
- data/lib/capistrano/ssh.rb +0 -101
- data/lib/capistrano/task_definition.rb +0 -75
- data/lib/capistrano/transfer.rb +0 -216
- data/rvmrc.sample +0 -1
- data/test/cli/execute_test.rb +0 -132
- data/test/cli/help_test.rb +0 -165
- data/test/cli/options_test.rb +0 -329
- data/test/cli/ui_test.rb +0 -28
- data/test/cli_test.rb +0 -17
- data/test/command_test.rb +0 -289
- data/test/configuration/actions/file_transfer_test.rb +0 -61
- data/test/configuration/actions/inspect_test.rb +0 -65
- data/test/configuration/actions/invocation_test.rb +0 -247
- data/test/configuration/callbacks_test.rb +0 -220
- data/test/configuration/connections_test.rb +0 -420
- data/test/configuration/execution_test.rb +0 -175
- data/test/configuration/loading_test.rb +0 -132
- data/test/configuration/namespace_dsl_test.rb +0 -311
- data/test/configuration/roles_test.rb +0 -144
- data/test/configuration/servers_test.rb +0 -183
- data/test/configuration/variables_test.rb +0 -190
- data/test/configuration_test.rb +0 -88
- data/test/deploy/local_dependency_test.rb +0 -76
- data/test/deploy/remote_dependency_test.rb +0 -135
- data/test/deploy/scm/accurev_test.rb +0 -23
- data/test/deploy/scm/base_test.rb +0 -55
- data/test/deploy/scm/bzr_test.rb +0 -51
- data/test/deploy/scm/darcs_test.rb +0 -37
- data/test/deploy/scm/git_test.rb +0 -184
- data/test/deploy/scm/mercurial_test.rb +0 -134
- data/test/deploy/scm/none_test.rb +0 -35
- data/test/deploy/scm/subversion_test.rb +0 -32
- data/test/deploy/strategy/copy_test.rb +0 -321
- data/test/extensions_test.rb +0 -69
- data/test/fixtures/cli_integration.rb +0 -5
- data/test/fixtures/config.rb +0 -5
- data/test/fixtures/custom.rb +0 -3
- data/test/logger_test.rb +0 -123
- data/test/recipes_test.rb +0 -25
- data/test/role_test.rb +0 -11
- data/test/server_definition_test.rb +0 -121
- data/test/shell_test.rb +0 -90
- data/test/ssh_test.rb +0 -113
- data/test/task_definition_test.rb +0 -116
- data/test/transfer_test.rb +0 -160
- data/test/utils.rb +0 -37
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Capistrano
|
|
4
|
+
class Configuration
|
|
5
|
+
describe EmptyFilter do
|
|
6
|
+
subject(:empty_filter) { EmptyFilter.new }
|
|
7
|
+
|
|
8
|
+
describe "#filter" do
|
|
9
|
+
let(:servers) { mock("servers") }
|
|
10
|
+
|
|
11
|
+
it "returns an empty array" do
|
|
12
|
+
expect(empty_filter.filter(servers)).to eq([])
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Capistrano
|
|
4
|
+
class Configuration
|
|
5
|
+
describe Filter do
|
|
6
|
+
let(:available) do
|
|
7
|
+
[
|
|
8
|
+
Server.new("server1").add_roles(%i(web db)),
|
|
9
|
+
Server.new("server2").add_role(:web),
|
|
10
|
+
Server.new("server3").add_role(:redis),
|
|
11
|
+
Server.new("server4").add_role(:db),
|
|
12
|
+
Server.new("server5").add_role(:stageweb)
|
|
13
|
+
]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "#new" do
|
|
17
|
+
it "won't create an invalid type of filter" do
|
|
18
|
+
expect do
|
|
19
|
+
Filter.new(:zarg)
|
|
20
|
+
end.to raise_error RuntimeError
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "with type :host" do
|
|
24
|
+
context "and no values" do
|
|
25
|
+
it "creates an EmptyFilter strategy" do
|
|
26
|
+
expect(Filter.new(:host).instance_variable_get(:@strategy)).to be_a(EmptyFilter)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "and :all" do
|
|
31
|
+
it "creates an NullFilter strategy" do
|
|
32
|
+
expect(Filter.new(:host, :all).instance_variable_get(:@strategy)).to be_a(NullFilter)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "and [:all]" do
|
|
37
|
+
it "creates an NullFilter strategy" do
|
|
38
|
+
expect(Filter.new(:host, [:all]).instance_variable_get(:@strategy)).to be_a(NullFilter)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context "and [:all]" do
|
|
43
|
+
it "creates an NullFilter strategy" do
|
|
44
|
+
expect(Filter.new(:host, "all").instance_variable_get(:@strategy)).to be_a(NullFilter)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context "with type :role" do
|
|
50
|
+
context "and no values" do
|
|
51
|
+
it "creates an EmptyFilter strategy" do
|
|
52
|
+
expect(Filter.new(:role).instance_variable_get(:@strategy)).to be_a(EmptyFilter)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context "and :all" do
|
|
57
|
+
it "creates an NullFilter strategy" do
|
|
58
|
+
expect(Filter.new(:role, :all).instance_variable_get(:@strategy)).to be_a(NullFilter)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context "and [:all]" do
|
|
63
|
+
it "creates an NullFilter strategy" do
|
|
64
|
+
expect(Filter.new(:role, [:all]).instance_variable_get(:@strategy)).to be_a(NullFilter)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "and [:all]" do
|
|
69
|
+
it "creates an NullFilter strategy" do
|
|
70
|
+
expect(Filter.new(:role, "all").instance_variable_get(:@strategy)).to be_a(NullFilter)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe "#filter" do
|
|
77
|
+
let(:strategy) { filter.instance_variable_get(:@strategy) }
|
|
78
|
+
let(:results) { mock("result") }
|
|
79
|
+
|
|
80
|
+
shared_examples "it calls #filter on its strategy" do
|
|
81
|
+
it "calls #filter on its strategy" do
|
|
82
|
+
strategy.expects(:filter).with(available).returns(results)
|
|
83
|
+
expect(filter.filter(available)).to eq(results)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
context "for an empty filter" do
|
|
88
|
+
let(:filter) { Filter.new(:role) }
|
|
89
|
+
it_behaves_like "it calls #filter on its strategy"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context "for a null filter" do
|
|
93
|
+
let(:filter) { Filter.new(:role, :all) }
|
|
94
|
+
it_behaves_like "it calls #filter on its strategy"
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
context "for a role filter" do
|
|
98
|
+
let(:filter) { Filter.new(:role, "web") }
|
|
99
|
+
it_behaves_like "it calls #filter on its strategy"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
context "for a host filter" do
|
|
103
|
+
let(:filter) { Filter.new(:host, "server1") }
|
|
104
|
+
it_behaves_like "it calls #filter on its strategy"
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Capistrano
|
|
4
|
+
class Configuration
|
|
5
|
+
describe HostFilter do
|
|
6
|
+
subject(:host_filter) { HostFilter.new(values) }
|
|
7
|
+
|
|
8
|
+
let(:available) do
|
|
9
|
+
[Server.new("server1"),
|
|
10
|
+
Server.new("server2"),
|
|
11
|
+
Server.new("server3"),
|
|
12
|
+
Server.new("server4"),
|
|
13
|
+
Server.new("server10")]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
shared_examples "it filters hosts correctly" do |expected|
|
|
17
|
+
it "filters correctly" do
|
|
18
|
+
set = host_filter.filter(available)
|
|
19
|
+
expect(set.map(&:hostname)).to eq(expected)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "#filter" do
|
|
24
|
+
context "with a string" do
|
|
25
|
+
let(:values) { "server1" }
|
|
26
|
+
it_behaves_like "it filters hosts correctly", %w{server1}
|
|
27
|
+
|
|
28
|
+
context "and a single server" do
|
|
29
|
+
let(:available) { Server.new("server1") }
|
|
30
|
+
it_behaves_like "it filters hosts correctly", %w{server1}
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "with a comma separated string" do
|
|
35
|
+
let(:values) { "server1,server10" }
|
|
36
|
+
it_behaves_like "it filters hosts correctly", %w{server1 server10}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context "with an array of strings" do
|
|
40
|
+
let(:values) { %w{server1 server3} }
|
|
41
|
+
it_behaves_like "it filters hosts correctly", %w{server1 server3}
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context "with mixed splittable and unsplittable strings" do
|
|
45
|
+
let(:values) { %w{server1 server2,server3} }
|
|
46
|
+
it_behaves_like "it filters hosts correctly", %w{server1 server2 server3}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context "with a regexp" do
|
|
50
|
+
let(:values) { "server[13]$" }
|
|
51
|
+
it_behaves_like "it filters hosts correctly", %w{server1 server3}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context "with a regexp with line boundaries" do
|
|
55
|
+
let(:values) { "^server" }
|
|
56
|
+
it_behaves_like "it filters hosts correctly", %w{server1 server2 server3 server4 server10}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context "with a regexp with a comma" do
|
|
60
|
+
let(:values) { 'server\d{1,3}$' }
|
|
61
|
+
it_behaves_like "it filters hosts correctly", %w{server1 server2 server3 server4 server10}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context "without number" do
|
|
65
|
+
let(:values) { "server" }
|
|
66
|
+
it_behaves_like "it filters hosts correctly", %w{}
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Capistrano
|
|
4
|
+
class Configuration
|
|
5
|
+
describe NullFilter do
|
|
6
|
+
subject(:null_filter) { NullFilter.new }
|
|
7
|
+
|
|
8
|
+
describe "#filter" do
|
|
9
|
+
let(:servers) { mock("servers") }
|
|
10
|
+
|
|
11
|
+
it "returns the servers passed in as arguments" do
|
|
12
|
+
expect(null_filter.filter(servers)).to eq(servers)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "capistrano/plugin"
|
|
3
|
+
require "capistrano/scm/plugin"
|
|
4
|
+
|
|
5
|
+
module Capistrano
|
|
6
|
+
class Configuration
|
|
7
|
+
class ExamplePlugin < Capistrano::Plugin
|
|
8
|
+
def set_defaults
|
|
9
|
+
set_if_empty :example_variable, "foo"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def define_tasks
|
|
13
|
+
task :example
|
|
14
|
+
task :example_prerequisite
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def register_hooks
|
|
18
|
+
before :example, :example_prerequisite
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class ExampleSCMPlugin < Capistrano::SCM::Plugin
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe PluginInstaller do
|
|
26
|
+
include Capistrano::DSL
|
|
27
|
+
|
|
28
|
+
let(:installer) { PluginInstaller.new }
|
|
29
|
+
let(:options) { {} }
|
|
30
|
+
let(:plugin) { ExamplePlugin.new }
|
|
31
|
+
|
|
32
|
+
before do
|
|
33
|
+
installer.install(plugin, **options)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
after do
|
|
37
|
+
Rake::Task.clear
|
|
38
|
+
Capistrano::Configuration.reset!
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context "installing plugin" do
|
|
42
|
+
it "defines tasks" do
|
|
43
|
+
expect(Rake::Task[:example]).to_not be_nil
|
|
44
|
+
expect(Rake::Task[:example_prerequisite]).to_not be_nil
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "registers hooks" do
|
|
48
|
+
task = Rake::Task[:example]
|
|
49
|
+
expect(task.prerequisites).to eq([:example_prerequisite])
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "sets defaults when load:defaults is invoked", capture_io: true do
|
|
53
|
+
expect(fetch(:example_variable)).to be_nil
|
|
54
|
+
invoke "load:defaults"
|
|
55
|
+
expect(fetch(:example_variable)).to eq("foo")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "doesn't say an SCM is installed" do
|
|
59
|
+
expect(installer.scm_installed?).to be_falsey
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context "installing plugin class" do
|
|
64
|
+
let(:plugin) { ExamplePlugin }
|
|
65
|
+
|
|
66
|
+
it "defines tasks" do
|
|
67
|
+
expect(Rake::Task[:example]).to_not be_nil
|
|
68
|
+
expect(Rake::Task[:example_prerequisite]).to_not be_nil
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
context "installing plugin without hooks" do
|
|
73
|
+
let(:options) { { load_hooks: false } }
|
|
74
|
+
|
|
75
|
+
it "doesn't register hooks" do
|
|
76
|
+
task = Rake::Task[:example]
|
|
77
|
+
expect(task.prerequisites).to be_empty
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context "installing plugin and loading immediately" do
|
|
82
|
+
let(:options) { { load_immediately: true } }
|
|
83
|
+
|
|
84
|
+
it "sets defaults immediately" do
|
|
85
|
+
expect(fetch(:example_variable)).to eq("foo")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
context "installing an SCM plugin" do
|
|
90
|
+
let(:plugin) { ExampleSCMPlugin }
|
|
91
|
+
|
|
92
|
+
it "says an SCM is installed" do
|
|
93
|
+
expect(installer.scm_installed?).to be_truthy
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Capistrano
|
|
4
|
+
class Configuration
|
|
5
|
+
describe Question do
|
|
6
|
+
let(:question) { Question.new(key, default, stdin: stdin) }
|
|
7
|
+
let(:question_without_echo) { Question.new(key, default, echo: false, stdin: stdin) }
|
|
8
|
+
let(:question_without_default) { Question.new(key, nil, stdin: stdin) }
|
|
9
|
+
let(:question_prompt) { Question.new(key, default, stdin: stdin, prompt: "Your favorite branch") }
|
|
10
|
+
let(:question_prompt_without_default) { Question.new(key, nil, stdin: stdin, prompt: "Your favorite branch") }
|
|
11
|
+
let(:default) { :default }
|
|
12
|
+
let(:key) { :branch }
|
|
13
|
+
let(:stdin) { stub(tty?: true) }
|
|
14
|
+
|
|
15
|
+
describe ".new" do
|
|
16
|
+
it "takes a key, default, options" do
|
|
17
|
+
question
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "#call" do
|
|
22
|
+
context "value is entered" do
|
|
23
|
+
let(:branch) { "branch" }
|
|
24
|
+
|
|
25
|
+
it "returns the echoed value" do
|
|
26
|
+
$stdout.expects(:print).with("Please enter branch (default): ")
|
|
27
|
+
stdin.expects(:gets).returns(branch)
|
|
28
|
+
stdin.expects(:noecho).never
|
|
29
|
+
|
|
30
|
+
expect(question.call).to eq(branch)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "returns the value but does not echo it" do
|
|
34
|
+
$stdout.expects(:print).with("Please enter branch (default): ")
|
|
35
|
+
stdin.expects(:noecho).returns(branch)
|
|
36
|
+
$stdout.expects(:print).with("\n")
|
|
37
|
+
|
|
38
|
+
expect(question_without_echo.call).to eq(branch)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "returns the value but has no default between parenthesis" do
|
|
42
|
+
$stdout.expects(:print).with("Please enter branch: ")
|
|
43
|
+
stdin.expects(:gets).returns(branch)
|
|
44
|
+
stdin.expects(:noecho).never
|
|
45
|
+
|
|
46
|
+
expect(question_without_default.call).to eq(branch)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "uses prompt and returns the value" do
|
|
50
|
+
$stdout.expects(:print).with("Your favorite branch (default): ")
|
|
51
|
+
stdin.expects(:gets).returns(branch)
|
|
52
|
+
stdin.expects(:noecho).never
|
|
53
|
+
|
|
54
|
+
expect(question_prompt.call).to eq(branch)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "uses prompt and returns the value but has no default between parenthesis" do
|
|
58
|
+
$stdout.expects(:print).with("Your favorite branch: ")
|
|
59
|
+
stdin.expects(:gets).returns(branch)
|
|
60
|
+
stdin.expects(:noecho).never
|
|
61
|
+
|
|
62
|
+
expect(question_prompt_without_default.call).to eq(branch)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context "value is not entered" do
|
|
67
|
+
let(:branch) { default }
|
|
68
|
+
|
|
69
|
+
before do
|
|
70
|
+
$stdout.expects(:print).with("Please enter branch (default): ")
|
|
71
|
+
stdin.expects(:gets).returns("")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "returns the default as the value" do
|
|
75
|
+
expect(question.call).to eq(branch)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context "tty unavailable", capture_io: true do
|
|
80
|
+
before do
|
|
81
|
+
stdin.expects(:gets).never
|
|
82
|
+
stdin.expects(:tty?).returns(false)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "returns the default as the value" do
|
|
86
|
+
expect(question.call).to eq(default)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Capistrano
|
|
4
|
+
class Configuration
|
|
5
|
+
describe RoleFilter do
|
|
6
|
+
subject(:role_filter) { RoleFilter.new(values) }
|
|
7
|
+
|
|
8
|
+
let(:available) do
|
|
9
|
+
[
|
|
10
|
+
Server.new("server1").add_roles(%i(web db)),
|
|
11
|
+
Server.new("server2").add_role(:web),
|
|
12
|
+
Server.new("server3").add_role(:redis),
|
|
13
|
+
Server.new("server4").add_role(:db),
|
|
14
|
+
Server.new("server5").add_role(:stageweb),
|
|
15
|
+
Server.new("server6").add_role(:"db.new")
|
|
16
|
+
]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
shared_examples "it filters roles correctly" do |expected_size, expected|
|
|
20
|
+
it "filters correctly" do
|
|
21
|
+
set = role_filter.filter(available)
|
|
22
|
+
expect(set.size).to eq(expected_size)
|
|
23
|
+
expect(set.map(&:hostname)).to eq(expected)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "#filter" do
|
|
28
|
+
context "with a single role string" do
|
|
29
|
+
let(:values) { "web" }
|
|
30
|
+
it_behaves_like "it filters roles correctly", 2, %w{server1 server2}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "with a single role" do
|
|
34
|
+
let(:values) { [:web] }
|
|
35
|
+
it_behaves_like "it filters roles correctly", 2, %w{server1 server2}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "with multiple roles in a string" do
|
|
39
|
+
let(:values) { "web,db" }
|
|
40
|
+
it_behaves_like "it filters roles correctly", 3, %w{server1 server2 server4}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context "with multiple roles" do
|
|
44
|
+
let(:values) { %i(web db) }
|
|
45
|
+
it_behaves_like "it filters roles correctly", 3, %w{server1 server2 server4}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
context "with a regex" do
|
|
49
|
+
let(:values) { /red/ }
|
|
50
|
+
it_behaves_like "it filters roles correctly", 1, %w{server3}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context "with a regex string" do
|
|
54
|
+
let(:values) { "/red|web/" }
|
|
55
|
+
it_behaves_like "it filters roles correctly", 4, %w{server1 server2 server3 server5}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context "with both a string and regex" do
|
|
59
|
+
let(:values) { "db,/red/" }
|
|
60
|
+
it_behaves_like "it filters roles correctly", 3, %w{server1 server3 server4}
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context "with a dot wildcard" do
|
|
64
|
+
let(:values) { "db.*" }
|
|
65
|
+
it_behaves_like "it filters roles correctly", 0, %w{}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "with a dot" do
|
|
69
|
+
let(:values) { "db.new" }
|
|
70
|
+
it_behaves_like "it filters roles correctly", 1, %w{server6}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
context "with a dot wildcard regex" do
|
|
74
|
+
let(:values) { "/db.*/" }
|
|
75
|
+
it_behaves_like "it filters roles correctly", 3, %w{server1 server4 server6}
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "capistrano/scm"
|
|
3
|
+
|
|
4
|
+
module Capistrano
|
|
5
|
+
class Configuration
|
|
6
|
+
describe SCMResolver do
|
|
7
|
+
include Capistrano::DSL
|
|
8
|
+
|
|
9
|
+
let(:resolver) { SCMResolver.new }
|
|
10
|
+
|
|
11
|
+
before do
|
|
12
|
+
Rake::Task.define_task("deploy:check")
|
|
13
|
+
Rake::Task.define_task("deploy:new_release_path")
|
|
14
|
+
Rake::Task.define_task("deploy:set_current_revision")
|
|
15
|
+
Rake::Task.define_task("deploy:set_current_revision_time")
|
|
16
|
+
set :scm, SCMResolver::DEFAULT_GIT
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
after do
|
|
20
|
+
Rake::Task.clear
|
|
21
|
+
Capistrano::Configuration.reset!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "default scm, no plugin installed" do
|
|
25
|
+
it "emits a warning" do
|
|
26
|
+
expect { resolver.resolve }.to output(/will not load the git scm/i).to_stderr
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "activates the git scm", capture_io: true do
|
|
30
|
+
resolver.resolve
|
|
31
|
+
expect(Rake::Task["git:wrapper"]).not_to be_nil
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "sets :scm to :git", capture_io: true do
|
|
35
|
+
resolver.resolve
|
|
36
|
+
expect(fetch(:scm)).to eq(:git)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "default scm, git plugin installed" do
|
|
41
|
+
before do
|
|
42
|
+
install_plugin Capistrano::SCM::Git
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "emits no warning" do
|
|
46
|
+
expect { resolver.resolve }.not_to output.to_stderr
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "deletes :scm" do
|
|
50
|
+
resolver.resolve
|
|
51
|
+
expect(fetch(:scm)).to be_nil
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|