cape 1.6.2 → 1.7.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.
- data/Gemfile +7 -6
- data/Guardfile +29 -10
- data/History.markdown +4 -0
- data/README.markdown +38 -9
- data/Rakefile +35 -8
- data/features/dsl/each_rake_task/{without_arguments.feature → unqualified.feature} +16 -37
- data/features/dsl/each_rake_task/{with_defined_namespace_argument.feature → with_defined_namespace.feature} +2 -13
- data/features/dsl/each_rake_task/{with_defined_task_argument.feature → with_defined_task.feature} +2 -6
- data/features/dsl/each_rake_task/with_undefined_task_or_namespace.feature +24 -0
- data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace.feature +2 -2
- data/features/dsl/mirror_rake_tasks/{without_arguments.feature → unqualified.feature} +15 -11
- data/features/dsl/mirror_rake_tasks/with_cd.feature +63 -0
- data/features/dsl/mirror_rake_tasks/with_cd_and_environment_variables.feature +27 -0
- data/features/dsl/mirror_rake_tasks/{with_defined_namespace_argument.feature → with_defined_namespace.feature} +6 -8
- data/features/dsl/mirror_rake_tasks/{with_defined_task_argument.feature → with_defined_task.feature} +4 -4
- data/features/dsl/mirror_rake_tasks/{with_defined_task_argument_and_environment_variables.feature → with_defined_task_and_cd.feature} +8 -8
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_cd_and_environment_variables.feature +46 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_environment_variables.feature +92 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename.feature +47 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_cd.feature +49 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_cd_and_environment_variables.feature +52 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_environment_variables.feature +50 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options.feature +49 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options_and_cd.feature +51 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options_and_cd_and_environment_variables.feature +54 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options_and_environment_variables.feature +52 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options.feature +53 -6
- data/features/dsl/mirror_rake_tasks/{with_defined_task_and_valid_options_arguments_and_environment_variables.feature → with_defined_task_and_valid_options_and_cd.feature} +10 -8
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_and_cd_and_environment_variables.feature +48 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_and_environment_variables.feature +98 -0
- data/features/dsl/mirror_rake_tasks/with_environment_variables.feature +61 -4
- data/features/dsl/mirror_rake_tasks/with_rename.feature +27 -0
- data/features/dsl/mirror_rake_tasks/with_rename_and_cd.feature +28 -0
- data/features/dsl/mirror_rake_tasks/with_rename_and_cd_and_environment_variables.feature +30 -0
- data/features/dsl/mirror_rake_tasks/with_rename_and_environment_variables.feature +29 -0
- data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options.feature +28 -0
- data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options_and_cd.feature +29 -0
- data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options_and_cd_and_environment_variables.feature +31 -0
- data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options_and_environment_variables.feature +30 -0
- data/features/dsl/mirror_rake_tasks/{with_undefined_argument.feature → with_undefined_task_or_namespace.feature} +3 -4
- data/features/dsl/mirror_rake_tasks/with_valid_options.feature +46 -0
- data/features/dsl/mirror_rake_tasks/{with_valid_options_argument.feature → with_valid_options_and_cd.feature} +7 -5
- data/features/dsl/mirror_rake_tasks/with_valid_options_and_cd_and_environment_variables.feature +28 -0
- data/features/dsl/mirror_rake_tasks/with_valid_options_and_environment_variables.feature +51 -0
- data/features/dsl/rake_executable.feature +2 -2
- data/features/step_definitions.rb +40 -0
- data/lib/cape.rb +2 -0
- data/lib/cape/capistrano.rb +59 -32
- data/lib/cape/capistrano_deprecated.rb +165 -0
- data/lib/cape/core_ext.rb +2 -0
- data/lib/cape/deprecation.rb +12 -0
- data/lib/cape/deprecation/base.rb +59 -0
- data/lib/cape/deprecation/capistrano_deprecated_define_rake_wrapper.rb +168 -0
- data/lib/cape/deprecation/dsl_deprecated_mirror_rake_tasks.rb +145 -0
- data/lib/cape/dsl.rb +49 -60
- data/lib/cape/dsl_deprecated.rb +157 -0
- data/lib/cape/hash_list.rb +2 -0
- data/lib/cape/recipe_definition.rb +103 -0
- data/lib/cape/recipe_definition_deprecated.rb +41 -0
- data/lib/cape/util.rb +2 -0
- data/lib/cape/version.rb +1 -1
- data/lib/cape/xterm.rb +326 -0
- data/spec/cape/deprecation/base_sharedspec.rb +18 -0
- data/spec/cape/deprecation/capistrano_deprecated_define_rake_wrapper_spec.rb +157 -0
- data/spec/cape/deprecation/dsl_deprecated_mirror_rake_tasks_spec.rb +153 -0
- data/spec/cape/dsl_deprecated_spec.rb +307 -0
- data/spec/cape/dsl_spec.rb +10 -43
- data/spec/cape/recipe_definition_spec.rb +53 -0
- data/spec/cape/xterm_spec.rb +72 -0
- metadata +97 -28
- data/features/dsl/each_rake_task/with_undefined_argument.feature +0 -53
- data/features/dsl/mirror_rake_tasks/with_valid_options_arguments_and_environment_variables.feature +0 -26
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'cape/deprecation/base'
|
|
3
|
+
|
|
4
|
+
shared_examples_for "a #{Cape::Deprecation::Base.name}" do
|
|
5
|
+
describe '-- without specified attributes --' do
|
|
6
|
+
its(:stream) { should == $stderr }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe '-- with a different #stream --' do
|
|
10
|
+
before :each do
|
|
11
|
+
subject.stream = different_stream
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:different_stream) { StringIO.new }
|
|
15
|
+
|
|
16
|
+
its(:stream) { should == different_stream }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'cape/deprecation/capistrano_deprecated_define_rake_wrapper'
|
|
3
|
+
require 'cape/deprecation/base_sharedspec'
|
|
4
|
+
require 'cape/xterm'
|
|
5
|
+
|
|
6
|
+
describe Cape::Deprecation::CapistranoDeprecatedDefineRakeWrapper do
|
|
7
|
+
it_should_behave_like "a #{Cape::Deprecation::Base.name}"
|
|
8
|
+
|
|
9
|
+
let(:deprecation_preamble) {
|
|
10
|
+
Cape::XTerm.bold_and_foreground_red('*** DEPRECATED:') + ' '
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe '-- without specified attributes --' do
|
|
14
|
+
its(:formatted_message) {
|
|
15
|
+
should == deprecation_preamble +
|
|
16
|
+
Cape::XTerm.bold('`define_rake_wrapper`. ' +
|
|
17
|
+
'Use this instead: `define_rake_wrapper`')
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '-- with #task' do
|
|
22
|
+
before :each do
|
|
23
|
+
subject.task = {:name => :foo}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
its(:formatted_message) {
|
|
27
|
+
should == deprecation_preamble +
|
|
28
|
+
Cape::XTerm.bold('`define_rake_wrapper {:name=>:foo}`. ' +
|
|
29
|
+
'Use this instead: ' +
|
|
30
|
+
'`define_rake_wrapper {:name=>:foo}`')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe 'and with #named_arguments' do
|
|
34
|
+
before :each do
|
|
35
|
+
subject.named_arguments = {:bar => :baz}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
its(:formatted_message) {
|
|
39
|
+
should == deprecation_preamble +
|
|
40
|
+
Cape::XTerm.bold('`' +
|
|
41
|
+
'define_rake_wrapper {:name=>:foo}, ' +
|
|
42
|
+
':bar => :baz' +
|
|
43
|
+
'`. ' +
|
|
44
|
+
'Use this instead: ' +
|
|
45
|
+
'`' +
|
|
46
|
+
'define_rake_wrapper({:name=>:foo}) { |recipes| ' +
|
|
47
|
+
'recipes.options[:bar] = :baz ' +
|
|
48
|
+
'}' +
|
|
49
|
+
'`')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describe 'and with #env --' do
|
|
53
|
+
before :each do
|
|
54
|
+
subject.env['QUX'] = 'quux'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
its(:formatted_message) {
|
|
58
|
+
should == deprecation_preamble +
|
|
59
|
+
Cape::XTerm.bold('`' +
|
|
60
|
+
'define_rake_wrapper({:name=>:foo}, ' +
|
|
61
|
+
':bar => :baz) { |env| ' +
|
|
62
|
+
'env["QUX"] = "quux" ' +
|
|
63
|
+
'}' +
|
|
64
|
+
'`. ' +
|
|
65
|
+
'Use this instead: ' +
|
|
66
|
+
'`' +
|
|
67
|
+
'define_rake_wrapper({:name=>:foo}) { |recipes| ' +
|
|
68
|
+
'recipes.options[:bar] = :baz; ' +
|
|
69
|
+
'recipes.env["QUX"] = "quux" ' +
|
|
70
|
+
'}' +
|
|
71
|
+
'`')
|
|
72
|
+
}
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe 'and with #env --' do
|
|
77
|
+
before :each do
|
|
78
|
+
subject.env['BAR'] = 'baz'
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
its(:formatted_message) {
|
|
82
|
+
should == deprecation_preamble +
|
|
83
|
+
Cape::XTerm.bold('`' +
|
|
84
|
+
'define_rake_wrapper({:name=>:foo}) { |env| ' +
|
|
85
|
+
'env["BAR"] = "baz" ' +
|
|
86
|
+
'}' +
|
|
87
|
+
'`. ' +
|
|
88
|
+
'Use this instead: ' +
|
|
89
|
+
'`' +
|
|
90
|
+
'define_rake_wrapper({:name=>:foo}) { |recipes| ' +
|
|
91
|
+
'recipes.env["BAR"] = "baz" ' +
|
|
92
|
+
'}' +
|
|
93
|
+
'`')
|
|
94
|
+
}
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe '-- with #named_arguments' do
|
|
99
|
+
before :each do
|
|
100
|
+
subject.named_arguments = {:foo => :bar}
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
its(:formatted_message) {
|
|
104
|
+
should == deprecation_preamble +
|
|
105
|
+
Cape::XTerm.bold('`define_rake_wrapper :foo => :bar`. ' +
|
|
106
|
+
'Use this instead: ' +
|
|
107
|
+
'`' +
|
|
108
|
+
'define_rake_wrapper { |recipes| ' +
|
|
109
|
+
'recipes.options[:foo] = :bar ' +
|
|
110
|
+
'}' +
|
|
111
|
+
'`')
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
describe 'and with #env --' do
|
|
115
|
+
before :each do
|
|
116
|
+
subject.env['BAZ'] = 'qux'
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
its(:formatted_message) {
|
|
120
|
+
should == deprecation_preamble +
|
|
121
|
+
Cape::XTerm.bold('`' +
|
|
122
|
+
'define_rake_wrapper(:foo => :bar) { |env| ' +
|
|
123
|
+
'env["BAZ"] = "qux" ' +
|
|
124
|
+
'}' +
|
|
125
|
+
'`. ' +
|
|
126
|
+
'Use this instead: ' +
|
|
127
|
+
'`' +
|
|
128
|
+
'define_rake_wrapper { |recipes| ' +
|
|
129
|
+
'recipes.options[:foo] = :bar; ' +
|
|
130
|
+
'recipes.env["BAZ"] = "qux" ' +
|
|
131
|
+
'}' +
|
|
132
|
+
'`')
|
|
133
|
+
}
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
describe '-- with #env --' do
|
|
138
|
+
before :each do
|
|
139
|
+
subject.env['FOO'] = 'bar'
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
its(:formatted_message) {
|
|
143
|
+
should == deprecation_preamble +
|
|
144
|
+
Cape::XTerm.bold('`' +
|
|
145
|
+
'define_rake_wrapper { |env| ' +
|
|
146
|
+
'env["FOO"] = "bar" ' +
|
|
147
|
+
'}' +
|
|
148
|
+
'`. ' +
|
|
149
|
+
'Use this instead: ' +
|
|
150
|
+
'`' +
|
|
151
|
+
'define_rake_wrapper { |recipes| ' +
|
|
152
|
+
'recipes.env["FOO"] = "bar" ' +
|
|
153
|
+
'}' +
|
|
154
|
+
'`')
|
|
155
|
+
}
|
|
156
|
+
end
|
|
157
|
+
end
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'cape/deprecation/dsl_deprecated_mirror_rake_tasks'
|
|
3
|
+
require 'cape/deprecation/base_sharedspec'
|
|
4
|
+
require 'cape/xterm'
|
|
5
|
+
|
|
6
|
+
describe Cape::Deprecation::DSLDeprecatedMirrorRakeTasks do
|
|
7
|
+
it_should_behave_like "a #{Cape::Deprecation::Base.name}"
|
|
8
|
+
|
|
9
|
+
let(:deprecation_preamble) {
|
|
10
|
+
Cape::XTerm.bold_and_foreground_red('*** DEPRECATED:') + ' '
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe '-- without specified attributes --' do
|
|
14
|
+
its(:formatted_message) {
|
|
15
|
+
should == deprecation_preamble +
|
|
16
|
+
Cape::XTerm.bold('`mirror_rake_tasks`. ' +
|
|
17
|
+
'Use this instead: `mirror_rake_tasks`')
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '-- with #task_expression' do
|
|
22
|
+
before :each do
|
|
23
|
+
subject.task_expression = :foo
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
its(:formatted_message) {
|
|
27
|
+
should == deprecation_preamble +
|
|
28
|
+
Cape::XTerm.bold('`mirror_rake_tasks :foo`. ' +
|
|
29
|
+
'Use this instead: `mirror_rake_tasks :foo`')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe 'and with #options' do
|
|
33
|
+
before :each do
|
|
34
|
+
subject.options = {:bar => :baz}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
its(:formatted_message) {
|
|
38
|
+
should == deprecation_preamble +
|
|
39
|
+
Cape::XTerm.bold('`mirror_rake_tasks :foo, :bar => :baz`. ' +
|
|
40
|
+
'Use this instead: ' +
|
|
41
|
+
'`' +
|
|
42
|
+
'mirror_rake_tasks(:foo) { |recipes| ' +
|
|
43
|
+
'recipes.options[:bar] = :baz ' +
|
|
44
|
+
'}' +
|
|
45
|
+
'`')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe 'and with #env --' do
|
|
49
|
+
before :each do
|
|
50
|
+
subject.env['QUX'] = 'quux'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
its(:formatted_message) {
|
|
54
|
+
should == deprecation_preamble +
|
|
55
|
+
Cape::XTerm.bold('`' +
|
|
56
|
+
'mirror_rake_tasks(:foo, ' +
|
|
57
|
+
':bar => :baz) { |env| ' +
|
|
58
|
+
'env["QUX"] = "quux" ' +
|
|
59
|
+
'}' +
|
|
60
|
+
'`. ' +
|
|
61
|
+
'Use this instead: ' +
|
|
62
|
+
'`' +
|
|
63
|
+
'mirror_rake_tasks(:foo) { |recipes| ' +
|
|
64
|
+
'recipes.options[:bar] = :baz; ' +
|
|
65
|
+
'recipes.env["QUX"] = "quux" ' +
|
|
66
|
+
'}' +
|
|
67
|
+
'`')
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe 'and with #env --' do
|
|
73
|
+
before :each do
|
|
74
|
+
subject.env['BAR'] = 'baz'
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
its(:formatted_message) {
|
|
78
|
+
should == deprecation_preamble +
|
|
79
|
+
Cape::XTerm.bold('`' +
|
|
80
|
+
'mirror_rake_tasks(:foo) { |env| ' +
|
|
81
|
+
'env["BAR"] = "baz" ' +
|
|
82
|
+
'}' +
|
|
83
|
+
'`. ' +
|
|
84
|
+
'Use this instead: ' +
|
|
85
|
+
'`' +
|
|
86
|
+
'mirror_rake_tasks(:foo) { |recipes| ' +
|
|
87
|
+
'recipes.env["BAR"] = "baz" ' +
|
|
88
|
+
'}' +
|
|
89
|
+
'`')
|
|
90
|
+
}
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe '-- with #options' do
|
|
95
|
+
before :each do
|
|
96
|
+
subject.options = {:foo => :bar}
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
its(:formatted_message) {
|
|
100
|
+
should == deprecation_preamble +
|
|
101
|
+
Cape::XTerm.bold('`mirror_rake_tasks :foo => :bar`. ' +
|
|
102
|
+
'Use this instead: ' +
|
|
103
|
+
'`' +
|
|
104
|
+
'mirror_rake_tasks { |recipes| ' +
|
|
105
|
+
'recipes.options[:foo] = :bar ' +
|
|
106
|
+
'}' +
|
|
107
|
+
'`')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
describe 'and with #env --' do
|
|
111
|
+
before :each do
|
|
112
|
+
subject.env['BAZ'] = 'qux'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
its(:formatted_message) {
|
|
116
|
+
should == deprecation_preamble +
|
|
117
|
+
Cape::XTerm.bold('`' +
|
|
118
|
+
'mirror_rake_tasks(:foo => :bar) { |env| ' +
|
|
119
|
+
'env["BAZ"] = "qux" ' +
|
|
120
|
+
'}' +
|
|
121
|
+
'`. ' +
|
|
122
|
+
'Use this instead: ' +
|
|
123
|
+
'`' +
|
|
124
|
+
'mirror_rake_tasks { |recipes| ' +
|
|
125
|
+
'recipes.options[:foo] = :bar; ' +
|
|
126
|
+
'recipes.env["BAZ"] = "qux" ' +
|
|
127
|
+
'}' +
|
|
128
|
+
'`')
|
|
129
|
+
}
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe '-- with #env --' do
|
|
134
|
+
before :each do
|
|
135
|
+
subject.env['FOO'] = 'bar'
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
its(:formatted_message) {
|
|
139
|
+
should == deprecation_preamble +
|
|
140
|
+
Cape::XTerm.bold('`' +
|
|
141
|
+
'mirror_rake_tasks { |env| ' +
|
|
142
|
+
'env["FOO"] = "bar" ' +
|
|
143
|
+
'}' +
|
|
144
|
+
'`. ' +
|
|
145
|
+
'Use this instead: ' +
|
|
146
|
+
'`' +
|
|
147
|
+
'mirror_rake_tasks { |recipes| ' +
|
|
148
|
+
'recipes.env["FOO"] = "bar" ' +
|
|
149
|
+
'}' +
|
|
150
|
+
'`')
|
|
151
|
+
}
|
|
152
|
+
end
|
|
153
|
+
end
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'cape/dsl'
|
|
3
|
+
require 'cape/dsl_deprecated'
|
|
4
|
+
require 'cape/capistrano'
|
|
5
|
+
require 'cape/core_ext/hash'
|
|
6
|
+
require 'cape/core_ext/symbol'
|
|
7
|
+
require 'cape/rake'
|
|
8
|
+
require 'cape/xterm'
|
|
9
|
+
|
|
10
|
+
describe Cape::DSLDeprecated do
|
|
11
|
+
subject do
|
|
12
|
+
Object.new.tap do |o|
|
|
13
|
+
o.extend Cape::DSL
|
|
14
|
+
o.extend described_class
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
let(:mock_capistrano) { mock(Cape::Capistrano).as_null_object }
|
|
19
|
+
|
|
20
|
+
let(:mock_rake) { mock(Cape::Rake).as_null_object }
|
|
21
|
+
|
|
22
|
+
let(:task_expression) { 'task:expression' }
|
|
23
|
+
|
|
24
|
+
before :each do
|
|
25
|
+
Cape::Capistrano.stub!(:new).and_return mock_capistrano
|
|
26
|
+
Cape::Rake. stub!(:new).and_return mock_rake
|
|
27
|
+
subject.deprecation.stream = StringIO.new
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '-- when sent #each_rake_task --' do
|
|
31
|
+
def do_each_rake_task(&block)
|
|
32
|
+
subject.each_rake_task(task_expression, &block)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should delegate to Rake#each_task' do
|
|
36
|
+
mock_rake.should_receive(:each_task).
|
|
37
|
+
with(task_expression).
|
|
38
|
+
and_yield({:name => task_expression})
|
|
39
|
+
do_each_rake_task do |t|
|
|
40
|
+
t.should == {:name => task_expression}
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'should return itself' do
|
|
45
|
+
do_each_rake_task.should == subject
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe '-- when sent #mirror_rake_tasks' do
|
|
50
|
+
before :each do
|
|
51
|
+
mock_rake.stub!(:each_task).and_yield({:name => task_expression})
|
|
52
|
+
subject.stub! :raise_unless_capistrano
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def do_mirror_rake_tasks(*arguments, &block)
|
|
56
|
+
subject.mirror_rake_tasks(*arguments, &block)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
let(:deprecation_preamble) {
|
|
60
|
+
Cape::XTerm.bold_and_foreground_red('*** DEPRECATED:') + ' '
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe 'with two scalar arguments --' do
|
|
64
|
+
specify do
|
|
65
|
+
lambda {
|
|
66
|
+
do_mirror_rake_tasks task_expression, task_expression
|
|
67
|
+
}.should raise_error(ArgumentError,
|
|
68
|
+
'wrong number of arguments (2 for 0 or 1, plus ' +
|
|
69
|
+
'an options hash)')
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
shared_examples_for "a successful call (#{Cape::DSLDeprecated.name})" do |task_expression_in_use,
|
|
74
|
+
options_in_use|
|
|
75
|
+
specify 'by collecting Rake#each_task' do
|
|
76
|
+
mock_rake.should_receive(:each_task).with task_expression_in_use
|
|
77
|
+
do_mirror_rake_tasks
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
specify 'by verifying that Capistrano is in use' do
|
|
81
|
+
subject.should_receive :raise_unless_capistrano
|
|
82
|
+
do_mirror_rake_tasks
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe 'by sending Capistrano#define_rake_wrapper for Rake#each_task' do
|
|
86
|
+
specify 'with the expected task' do
|
|
87
|
+
mock_capistrano.should_receive(:define_rake_wrapper).with do |task,
|
|
88
|
+
named_arguments|
|
|
89
|
+
task == {:name => task_expression}
|
|
90
|
+
end
|
|
91
|
+
do_mirror_rake_tasks
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
specify 'with the expected named options' do
|
|
95
|
+
mock_capistrano.should_receive(:define_rake_wrapper).with do |task,
|
|
96
|
+
named_arguments|
|
|
97
|
+
named_arguments.keys.sort == ([:binding] + options_in_use.keys).sort
|
|
98
|
+
end
|
|
99
|
+
do_mirror_rake_tasks
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
specify 'with a :binding option' do
|
|
103
|
+
mock_capistrano.should_receive(:define_rake_wrapper).with do |task,
|
|
104
|
+
named_arguments|
|
|
105
|
+
named_arguments[:binding].is_a? Binding
|
|
106
|
+
end
|
|
107
|
+
do_mirror_rake_tasks
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
specify 'with any provided extra options' do
|
|
111
|
+
mock_capistrano.should_receive(:define_rake_wrapper).with do |task,
|
|
112
|
+
named_arguments|
|
|
113
|
+
named_arguments.slice(*options_in_use.keys) == options_in_use
|
|
114
|
+
end
|
|
115
|
+
do_mirror_rake_tasks
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
specify 'by returning itself' do
|
|
120
|
+
do_mirror_rake_tasks.should == subject
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe 'with one scalar argument, an options hash, and a block --' do
|
|
125
|
+
def do_mirror_rake_tasks
|
|
126
|
+
super 'task:expression', :bar => :baz do |env|
|
|
127
|
+
env['AN_ENV_VAR'] = 'an environment variable'
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
should_behave_like "a successful call (#{Cape::DSLDeprecated.name})",
|
|
132
|
+
'task:expression',
|
|
133
|
+
:bar => :baz
|
|
134
|
+
|
|
135
|
+
it 'should print the expected deprecation messages to stderr' do
|
|
136
|
+
do_mirror_rake_tasks
|
|
137
|
+
subject.deprecation.stream.string.should == deprecation_preamble +
|
|
138
|
+
Cape::XTerm.bold('`' +
|
|
139
|
+
'mirror_rake_tasks "task:expression", ' +
|
|
140
|
+
':bar => :baz' +
|
|
141
|
+
'`. ' +
|
|
142
|
+
'Use this instead: ' +
|
|
143
|
+
'`' +
|
|
144
|
+
'mirror_rake_tasks("task:expression") { |recipes| ' +
|
|
145
|
+
'recipes.options[:bar] = :baz ' +
|
|
146
|
+
'}' +
|
|
147
|
+
'`') +
|
|
148
|
+
"\n"
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
describe 'with one scalar argument and an options hash --' do
|
|
153
|
+
def do_mirror_rake_tasks
|
|
154
|
+
super 'task:expression', :bar => :baz
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
should_behave_like "a successful call (#{Cape::DSLDeprecated.name})",
|
|
158
|
+
'task:expression',
|
|
159
|
+
:bar => :baz
|
|
160
|
+
|
|
161
|
+
it 'should print the expected deprecation messages to stderr' do
|
|
162
|
+
do_mirror_rake_tasks
|
|
163
|
+
subject.deprecation.stream.string.should == deprecation_preamble +
|
|
164
|
+
Cape::XTerm.bold('`' +
|
|
165
|
+
'mirror_rake_tasks "task:expression", ' +
|
|
166
|
+
':bar => :baz' +
|
|
167
|
+
'`. ' +
|
|
168
|
+
'Use this instead: ' +
|
|
169
|
+
'`' +
|
|
170
|
+
'mirror_rake_tasks("task:expression") { |recipes| ' +
|
|
171
|
+
'recipes.options[:bar] = :baz ' +
|
|
172
|
+
'}' +
|
|
173
|
+
'`') +
|
|
174
|
+
"\n"
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
describe 'with an options hash and a block --' do
|
|
179
|
+
def do_mirror_rake_tasks
|
|
180
|
+
super :bar => :baz do |env|
|
|
181
|
+
env['AN_ENV_VAR'] = 'an environment variable'
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
should_behave_like "a successful call (#{Cape::DSLDeprecated.name})",
|
|
186
|
+
nil,
|
|
187
|
+
:bar => :baz
|
|
188
|
+
|
|
189
|
+
it 'should print the expected deprecation messages to stderr' do
|
|
190
|
+
do_mirror_rake_tasks
|
|
191
|
+
subject.deprecation.stream.string.should == deprecation_preamble +
|
|
192
|
+
Cape::XTerm.bold('`' +
|
|
193
|
+
'mirror_rake_tasks :bar => :baz' +
|
|
194
|
+
'`. ' +
|
|
195
|
+
'Use this instead: ' +
|
|
196
|
+
'`' +
|
|
197
|
+
'mirror_rake_tasks { |recipes| ' +
|
|
198
|
+
'recipes.options[:bar] = :baz ' +
|
|
199
|
+
'}' +
|
|
200
|
+
'`') +
|
|
201
|
+
"\n"
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
describe 'with an options hash --' do
|
|
206
|
+
def do_mirror_rake_tasks
|
|
207
|
+
super :bar => :baz
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
should_behave_like "a successful call (#{Cape::DSLDeprecated.name})",
|
|
211
|
+
nil,
|
|
212
|
+
:bar => :baz
|
|
213
|
+
|
|
214
|
+
it 'should print the expected deprecation messages to stderr' do
|
|
215
|
+
do_mirror_rake_tasks
|
|
216
|
+
subject.deprecation.stream.string.should == deprecation_preamble +
|
|
217
|
+
Cape::XTerm.bold('`' +
|
|
218
|
+
'mirror_rake_tasks :bar => :baz' +
|
|
219
|
+
'`. ' +
|
|
220
|
+
'Use this instead: ' +
|
|
221
|
+
'`' +
|
|
222
|
+
'mirror_rake_tasks { |recipes| ' +
|
|
223
|
+
'recipes.options[:bar] = :baz ' +
|
|
224
|
+
'}' +
|
|
225
|
+
'`') +
|
|
226
|
+
"\n"
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
describe 'with one scalar argument and a block --' do
|
|
231
|
+
def do_mirror_rake_tasks
|
|
232
|
+
super 'task:expression' do |env|
|
|
233
|
+
env['AN_ENV_VAR'] = 'an environment variable'
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
should_behave_like("a successful call (#{Cape::DSLDeprecated.name})",
|
|
238
|
+
'task:expression',
|
|
239
|
+
{})
|
|
240
|
+
|
|
241
|
+
it 'should print no deprecation messages to stderr' do
|
|
242
|
+
do_mirror_rake_tasks
|
|
243
|
+
subject.deprecation.stream.string.should be_empty
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
describe 'with one scalar argument --' do
|
|
248
|
+
def do_mirror_rake_tasks
|
|
249
|
+
super 'task:expression'
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
should_behave_like("a successful call (#{Cape::DSLDeprecated.name})",
|
|
253
|
+
'task:expression',
|
|
254
|
+
{})
|
|
255
|
+
|
|
256
|
+
it 'should print no deprecation messages to stderr' do
|
|
257
|
+
do_mirror_rake_tasks
|
|
258
|
+
subject.deprecation.stream.string.should be_empty
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
describe 'without arguments --' do
|
|
263
|
+
def do_mirror_rake_tasks
|
|
264
|
+
super
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
should_behave_like("a successful call (#{Cape::DSLDeprecated.name})",
|
|
268
|
+
nil,
|
|
269
|
+
{})
|
|
270
|
+
|
|
271
|
+
it 'should print no deprecation messages to stderr' do
|
|
272
|
+
do_mirror_rake_tasks
|
|
273
|
+
subject.deprecation.stream.string.should be_empty
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
describe '-- when sent #local_rake_executable --' do
|
|
279
|
+
before :each do
|
|
280
|
+
mock_rake.stub!(:local_executable).and_return 'foo'
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
it 'should delegate to Rake#local_executable' do
|
|
284
|
+
mock_rake.should_receive :local_executable
|
|
285
|
+
subject.local_rake_executable
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
it 'should return the result of Rake#local_executable' do
|
|
289
|
+
subject.local_rake_executable.should == 'foo'
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
describe '-- when sent #remote_rake_executable --' do
|
|
294
|
+
before :each do
|
|
295
|
+
mock_rake.stub!(:remote_executable).and_return 'foo'
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
it 'should delegate to Rake#remote_executable' do
|
|
299
|
+
mock_rake.should_receive :remote_executable
|
|
300
|
+
subject.remote_rake_executable
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
it 'should return the result of Rake#remote_executable' do
|
|
304
|
+
subject.remote_rake_executable.should == 'foo'
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
end
|