capistrano 3.4.1 → 3.5.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.
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
@@ -0,0 +1,47 @@
1
+ require "spec_helper"
2
+ require "capistrano/doctor/output_helpers"
3
+
4
+ module Capistrano
5
+ module Doctor
6
+ describe OutputHelpers do
7
+ include OutputHelpers
8
+
9
+ # Force color for the purpose of these tests
10
+ before { ENV.stubs(:[]).with("SSHKIT_COLOR").returns("1") }
11
+
12
+ it "prints titles in blue with newlines and without indentation" do
13
+ expect { title("Hello!") }.to\
14
+ output("\e[0;34;49m\nHello!\n\e[0m\n").to_stdout
15
+ end
16
+
17
+ it "prints warnings in yellow with 4-space indentation" do
18
+ expect { warning("Yikes!") }.to\
19
+ output(" \e[0;33;49mYikes!\e[0m\n").to_stdout
20
+ end
21
+
22
+ it "overrides puts to indent 4 spaces per line" do
23
+ expect { puts("one\ntwo") }.to output(" one\n two\n").to_stdout
24
+ end
25
+
26
+ it "formats tables with indent, aligned columns and per-row color" do
27
+ data = [
28
+ ["one", ".", "1"],
29
+ ["two", "..", "2"],
30
+ ["three", "...", "3"]
31
+ ]
32
+ block = proc do |record, row|
33
+ row.yellow if record.first == "two"
34
+ row << record[0]
35
+ row << record[1]
36
+ row << record[2]
37
+ end
38
+ expected_output = <<-OUT
39
+ one . 1
40
+ \e[0;33;49mtwo .. 2\e[0m
41
+ three ... 3
42
+ OUT
43
+ expect { table(data, &block) }.to output(expected_output).to_stdout
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,79 @@
1
+ require "spec_helper"
2
+ require "capistrano/doctor/variables_doctor"
3
+
4
+ module Capistrano
5
+ module Doctor
6
+ describe VariablesDoctor do
7
+ include Capistrano::DSL
8
+
9
+ let(:doc) { VariablesDoctor.new }
10
+
11
+ before do
12
+ set :branch, "master"
13
+ set :pty, false
14
+
15
+ env.variables.untrusted! do
16
+ set :application, "my_app"
17
+ set :repo_url, ".git"
18
+ set :copy_strategy, :scp
19
+ set :custom_setting, "hello"
20
+ ask :secret
21
+ end
22
+
23
+ fetch :custom_setting
24
+ end
25
+
26
+ after { Capistrano::Configuration.reset! }
27
+
28
+ it "prints using 4-space indentation" do
29
+ expect { doc.call }.to output(/^ {4}/).to_stdout
30
+ end
31
+
32
+ it "prints variable names and values" do
33
+ expect { doc.call }.to output(/:branch\s+"master"$/).to_stdout
34
+ expect { doc.call }.to output(/:pty\s+false$/).to_stdout
35
+ expect { doc.call }.to output(/:application\s+"my_app"$/).to_stdout
36
+ expect { doc.call }.to output(/:repo_url\s+".git"$/).to_stdout
37
+ expect { doc.call }.to output(/:copy_strategy\s+:scp$/).to_stdout
38
+ expect { doc.call }.to output(/:custom_setting\s+"hello"$/).to_stdout
39
+ end
40
+
41
+ it "prints unanswered question variable as <ask>" do
42
+ expect { doc.call }.to output(/:secret\s+<ask>$/).to_stdout
43
+ end
44
+
45
+ it "prints warning for unrecognized variable" do
46
+ expect { doc.call }.to \
47
+ output(/:copy_strategy is not a recognized Capistrano setting/)\
48
+ .to_stdout
49
+ end
50
+
51
+ it "does not print warning for unrecognized variable that is fetched" do
52
+ expect { doc.call }.not_to \
53
+ output(/:custom_setting is not a recognized Capistrano setting/)\
54
+ .to_stdout
55
+ end
56
+
57
+ describe "Rake" do
58
+ before do
59
+ load File.expand_path("../../../../../lib/capistrano/doctor.rb",
60
+ __FILE__)
61
+ end
62
+
63
+ after do
64
+ Rake::Task.clear
65
+ end
66
+
67
+ it "has an doctor:variables task that calls VariablesDoctor" do
68
+ VariablesDoctor.any_instance.expects(:call)
69
+ Rake::Task["doctor:variables"].invoke
70
+ end
71
+
72
+ it "has a doctor task that depends on doctor:variables" do
73
+ expect(Rake::Task["doctor"].prerequisites).to \
74
+ include("doctor:variables")
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,16 +1,15 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Capistrano::DSL::Paths do
4
-
5
4
  let(:dsl) { Class.new.extend Capistrano::DSL }
6
- let(:parent) { Pathname.new('/var/shared') }
5
+ let(:parent) { Pathname.new("/var/shared") }
7
6
  let(:paths) { Class.new.extend Capistrano::DSL::Paths }
8
7
 
9
8
  let(:linked_dirs) { %w{log public/system} }
10
- let(:linked_files) { %w{config/database.yml log/my.log} }
9
+ let(:linked_files) { %w{config/database.yml log/my.log log/access.log} }
11
10
 
12
11
  before do
13
- dsl.set(:deploy_to, '/var/www')
12
+ dsl.set(:deploy_to, "/var/www")
14
13
  end
15
14
 
16
15
  describe '#linked_dirs' do
@@ -20,12 +19,14 @@ describe Capistrano::DSL::Paths do
20
19
  paths.expects(:fetch).with(:linked_dirs).returns(linked_dirs)
21
20
  end
22
21
 
23
- it 'returns the full pathnames' do
24
- expect(subject).to eq [Pathname.new('/var/shared/log'), Pathname.new('/var/shared/public/system')]
22
+ it "returns the full pathnames" do
23
+ expect(subject).to eq [
24
+ Pathname.new("/var/shared/log"),
25
+ Pathname.new("/var/shared/public/system")
26
+ ]
25
27
  end
26
28
  end
27
29
 
28
-
29
30
  describe '#linked_files' do
30
31
  subject { paths.linked_files(parent) }
31
32
 
@@ -33,8 +34,12 @@ describe Capistrano::DSL::Paths do
33
34
  paths.expects(:fetch).with(:linked_files).returns(linked_files)
34
35
  end
35
36
 
36
- it 'returns the full pathnames' do
37
- expect(subject).to eq [Pathname.new('/var/shared/config/database.yml'), Pathname.new('/var/shared/log/my.log')]
37
+ it "returns the full pathnames" do
38
+ expect(subject).to eq [
39
+ Pathname.new("/var/shared/config/database.yml"),
40
+ Pathname.new("/var/shared/log/my.log"),
41
+ Pathname.new("/var/shared/log/access.log")
42
+ ]
38
43
  end
39
44
  end
40
45
 
@@ -45,8 +50,11 @@ describe Capistrano::DSL::Paths do
45
50
  paths.expects(:fetch).with(:linked_files).returns(linked_files)
46
51
  end
47
52
 
48
- it 'returns the full paths names of the parent dirs' do
49
- expect(subject).to eq [Pathname.new('/var/shared/config'), Pathname.new('/var/shared/log')]
53
+ it "returns the full paths names of the parent dirs" do
54
+ expect(subject).to eq [
55
+ Pathname.new("/var/shared/config"),
56
+ Pathname.new("/var/shared/log")
57
+ ]
50
58
  end
51
59
  end
52
60
 
@@ -57,32 +65,34 @@ describe Capistrano::DSL::Paths do
57
65
  paths.expects(:fetch).with(:linked_dirs).returns(linked_dirs)
58
66
  end
59
67
 
60
- it 'returns the full paths names of the parent dirs' do
61
- expect(subject).to eq [Pathname.new('/var/shared'), Pathname.new('/var/shared/public')]
68
+ it "returns the full paths names of the parent dirs" do
69
+ expect(subject).to eq [
70
+ Pathname.new("/var/shared"),
71
+ Pathname.new("/var/shared/public")
72
+ ]
62
73
  end
63
74
  end
64
75
 
65
76
  describe '#release path' do
66
-
67
77
  subject { dsl.release_path }
68
78
 
69
- context 'where no release path has been set' do
79
+ context "where no release path has been set" do
70
80
  before do
71
81
  dsl.delete(:release_path)
72
82
  end
73
83
 
74
- it 'returns the `current_path` value' do
75
- expect(subject.to_s).to eq '/var/www/current'
84
+ it "returns the `current_path` value" do
85
+ expect(subject.to_s).to eq "/var/www/current"
76
86
  end
77
87
  end
78
88
 
79
- context 'where the release path has been set' do
89
+ context "where the release path has been set" do
80
90
  before do
81
- dsl.set(:release_path,'/var/www/release_path')
91
+ dsl.set(:release_path, "/var/www/release_path")
82
92
  end
83
93
 
84
- it 'returns the set `release_path` value' do
85
- expect(subject.to_s).to eq '/var/www/release_path'
94
+ it "returns the set `release_path` value" do
95
+ expect(subject.to_s).to eq "/var/www/release_path"
86
96
  end
87
97
  end
88
98
  end
@@ -91,24 +101,24 @@ describe Capistrano::DSL::Paths do
91
101
  let(:now) { Time.parse("Oct 21 16:29:00 2015") }
92
102
  subject { dsl.release_path }
93
103
 
94
- context 'without a timestamp' do
104
+ context "without a timestamp" do
95
105
  before do
96
106
  dsl.env.expects(:timestamp).returns(now)
97
107
  dsl.set_release_path
98
108
  end
99
109
 
100
- it 'returns the release path with the current env timestamp' do
101
- expect(subject.to_s).to eq '/var/www/releases/20151021162900'
110
+ it "returns the release path with the current env timestamp" do
111
+ expect(subject.to_s).to eq "/var/www/releases/20151021162900"
102
112
  end
103
113
  end
104
114
 
105
- context 'with a timestamp' do
115
+ context "with a timestamp" do
106
116
  before do
107
- dsl.set_release_path('timestamp')
117
+ dsl.set_release_path("timestamp")
108
118
  end
109
119
 
110
- it 'returns the release path with the timestamp' do
111
- expect(subject.to_s).to eq '/var/www/releases/timestamp'
120
+ it "returns the release path with the timestamp" do
121
+ expect(subject.to_s).to eq "/var/www/releases/timestamp"
112
122
  end
113
123
  end
114
124
  end
@@ -116,23 +126,23 @@ describe Capistrano::DSL::Paths do
116
126
  describe '#deploy_config_path' do
117
127
  subject { dsl.deploy_config_path.to_s }
118
128
 
119
- context 'when not specified' do
129
+ context "when not specified" do
120
130
  before do
121
131
  dsl.delete(:deploy_config_path)
122
132
  end
123
133
 
124
134
  it 'returns "config/deploy.rb"' do
125
- expect(subject).to eq 'config/deploy.rb'
135
+ expect(subject).to eq "config/deploy.rb"
126
136
  end
127
137
  end
128
138
 
129
- context 'when the variable :deploy_config_path is set' do
139
+ context "when the variable :deploy_config_path is set" do
130
140
  before do
131
- dsl.set(:deploy_config_path, 'my/custom/path.rb')
141
+ dsl.set(:deploy_config_path, "my/custom/path.rb")
132
142
  end
133
143
 
134
- it 'returns the custom path' do
135
- expect(subject).to eq 'my/custom/path.rb'
144
+ it "returns the custom path" do
145
+ expect(subject).to eq "my/custom/path.rb"
136
146
  end
137
147
  end
138
148
  end
@@ -140,24 +150,23 @@ describe Capistrano::DSL::Paths do
140
150
  describe '#stage_config_path' do
141
151
  subject { dsl.stage_config_path.to_s }
142
152
 
143
- context 'when not specified' do
144
-
153
+ context "when not specified" do
145
154
  before do
146
155
  dsl.delete(:stage_config_path)
147
156
  end
148
157
 
149
158
  it 'returns "config/deploy"' do
150
- expect(subject).to eq 'config/deploy'
159
+ expect(subject).to eq "config/deploy"
151
160
  end
152
161
  end
153
162
 
154
- context 'when the variable :stage_config_path is set' do
163
+ context "when the variable :stage_config_path is set" do
155
164
  before do
156
- dsl.set(:stage_config_path, 'my/custom/path')
165
+ dsl.set(:stage_config_path, "my/custom/path")
157
166
  end
158
167
 
159
- it 'returns the custom path' do
160
- expect(subject).to eq 'my/custom/path'
168
+ it "returns the custom path" do
169
+ expect(subject).to eq "my/custom/path"
161
170
  end
162
171
  end
163
172
  end
@@ -165,25 +174,24 @@ describe Capistrano::DSL::Paths do
165
174
  describe '#repo_path' do
166
175
  subject { dsl.repo_path.to_s }
167
176
 
168
- context 'when not specified' do
169
-
177
+ context "when not specified" do
170
178
  before do
171
179
  dsl.delete(:repo_path)
172
180
  end
173
181
 
174
182
  it 'returns the default #{deploy_to}/repo' do
175
- dsl.set(:deploy_to, '/var/www')
176
- expect(subject).to eq '/var/www/repo'
183
+ dsl.set(:deploy_to, "/var/www")
184
+ expect(subject).to eq "/var/www/repo"
177
185
  end
178
186
  end
179
187
 
180
- context 'when the variable :repo_path is set' do
188
+ context "when the variable :repo_path is set" do
181
189
  before do
182
- dsl.set(:repo_path, 'my/custom/path')
190
+ dsl.set(:repo_path, "my/custom/path")
183
191
  end
184
192
 
185
- it 'returns the custom path' do
186
- expect(subject).to eq 'my/custom/path'
193
+ it "returns the custom path" do
194
+ expect(subject).to eq "my/custom/path"
187
195
  end
188
196
  end
189
197
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Capistrano
4
4
  class DummyTaskEnhancements
@@ -8,8 +8,7 @@ module Capistrano
8
8
  describe TaskEnhancements do
9
9
  let(:task_enhancements) { DummyTaskEnhancements.new }
10
10
 
11
- describe 'ordering' do
12
-
11
+ describe "ordering" do
13
12
  after do
14
13
  task.clear
15
14
  before_task.clear
@@ -19,68 +18,99 @@ module Capistrano
19
18
 
20
19
  let(:order) { [] }
21
20
  let!(:task) do
22
- Rake::Task.define_task('task', [:order]) do |t, args|
23
- args['order'].push 'task'
21
+ Rake::Task.define_task("task", [:order]) do |_t, args|
22
+ args["order"].push "task"
24
23
  end
25
24
  end
26
25
 
27
26
  let!(:before_task) do
28
- Rake::Task.define_task('before_task') do
29
- order.push 'before_task'
27
+ Rake::Task.define_task("before_task") do
28
+ order.push "before_task"
30
29
  end
31
30
  end
32
31
 
33
32
  let!(:after_task) do
34
- Rake::Task.define_task('after_task') do
35
- order.push 'after_task'
33
+ Rake::Task.define_task("after_task") do
34
+ order.push "after_task"
36
35
  end
37
36
  end
38
37
 
39
- it 'invokes in proper order if define after than before' do
40
- task_enhancements.after('task', 'after_task')
41
- task_enhancements.before('task', 'before_task')
38
+ it "invokes in proper order if define after than before" do
39
+ task_enhancements.after("task", "after_task")
40
+ task_enhancements.before("task", "before_task")
42
41
 
43
- Rake::Task['task'].invoke order
42
+ Rake::Task["task"].invoke order
44
43
 
45
- expect(order).to eq(['before_task', 'task', 'after_task'])
44
+ expect(order).to eq(%w(before_task task after_task))
46
45
  end
47
46
 
48
- it 'invokes in proper order if define before than after' do
49
- task_enhancements.before('task', 'before_task')
50
- task_enhancements.after('task', 'after_task')
47
+ it "invokes in proper order if define before than after" do
48
+ task_enhancements.before("task", "before_task")
49
+ task_enhancements.after("task", "after_task")
51
50
 
52
- Rake::Task['task'].invoke order
51
+ Rake::Task["task"].invoke order
53
52
 
54
- expect(order).to eq(['before_task', 'task', 'after_task'])
53
+ expect(order).to eq(%w(before_task task after_task))
55
54
  end
56
55
 
57
- it 'invokes in proper order and with arguments and block' do
58
- task_enhancements.after('task', 'after_task_custom', :order) do |t, args|
59
- order.push 'after_task'
56
+ it "invokes in proper order when referring to as-yet undefined tasks" do
57
+ task_enhancements.after("task", "not_loaded_task")
58
+
59
+ Rake::Task.define_task("not_loaded_task") do
60
+ order.push "not_loaded_task"
60
61
  end
61
62
 
62
- task_enhancements.before('task', 'before_task_custom', :order) do |t, args|
63
- order.push 'before_task'
63
+ Rake::Task["task"].invoke order
64
+
65
+ expect(order).to eq(%w(task not_loaded_task))
66
+ end
67
+
68
+ it "invokes in proper order and with arguments and block" do
69
+ task_enhancements.after("task", "after_task_custom", :order) do |_t, _args|
70
+ order.push "after_task"
64
71
  end
65
72
 
66
- Rake::Task['task'].invoke(order)
73
+ task_enhancements.before("task", "before_task_custom", :order) do |_t, _args|
74
+ order.push "before_task"
75
+ end
67
76
 
68
- expect(order).to eq(['before_task', 'task', 'after_task'])
77
+ Rake::Task["task"].invoke(order)
78
+
79
+ expect(order).to eq(%w(before_task task after_task))
69
80
  end
70
81
 
82
+ it "invokes using the correct namespace when defined within a namespace" do
83
+ Rake.application.in_namespace("namespace") do
84
+ Rake::Task.define_task("task") do |t|
85
+ order.push(t.name)
86
+ end
87
+ task_enhancements.before("task", "before_task", :order) do |t|
88
+ order.push(t.name)
89
+ end
90
+ task_enhancements.after("task", "after_task", :order) do |t|
91
+ order.push(t.name)
92
+ end
93
+ end
94
+
95
+ Rake::Task["namespace:task"].invoke
96
+
97
+ expect(order).to eq(
98
+ ["namespace:before_task", "namespace:task", "namespace:after_task"]
99
+ )
100
+ end
71
101
  end
72
102
 
73
- describe 'remote_file' do
74
- subject(:remote_file) { task_enhancements.remote_file('source' => 'destination') }
103
+ describe "remote_file" do
104
+ subject(:remote_file) { task_enhancements.remote_file("source" => "destination") }
75
105
 
76
- it { expect(remote_file.name).to eq('source') }
106
+ it { expect(remote_file.name).to eq("source") }
77
107
  it { is_expected.to be_a(Capistrano::UploadTask) }
78
108
 
79
- describe 'namespaced' do
109
+ describe "namespaced" do
80
110
  let(:app) { Rake.application }
81
- around { |ex| app.in_namespace('namespace', &ex) }
111
+ around { |ex| app.in_namespace("namespace", &ex) }
82
112
 
83
- it { expect(remote_file.name).to eq('source') }
113
+ it { expect(remote_file.name).to eq("source") }
84
114
  it { is_expected.to be_a(Capistrano::UploadTask) }
85
115
  end
86
116
  end