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