minitest-capistrano 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ ## 0.1.1.dev (unreleased)
2
+
3
+
4
+ ## 0.1.0 (May 28, 2012)
5
+
6
+ ### Improvements
7
+
8
+ * Pull request [#3](https://github.com/fnichol/minitest-capistrano/pull/3): The grand modularization. ([@smdern][])
9
+ * Add CHANGELOG. ([@fnichol][])
10
+
11
+ ## Previous releases
12
+
13
+ The changelog began with version 0.0.8 so any changes prior to that can be
14
+ seen by checking the tagged releases and reading git commit messages.
15
+
16
+ [@fnichol]: https://github.com/fnichol
17
+ [@smdern]: https://github.com/smdern
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'minitest' do
2
+ watch(%r|^spec/(.*)_spec\.rb|)
3
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "spec/#{m[2]}_spec.rb" }
4
+ watch(%r|^spec/spec_helper\.rb|) { "spec" }
5
+ end
@@ -159,202 +159,4 @@ module MiniTest
159
159
  end
160
160
  end
161
161
  end
162
-
163
- ##
164
- # It's where you hide your "assertions".
165
-
166
- module Expectations
167
- ##
168
- # See MiniTest::Assertions#assert_have_run
169
- #
170
- # config.must_have_run cmd
171
- #
172
- # :method: must_have_run
173
-
174
- infect_an_assertion :assert_have_run, :must_have_run
175
-
176
- ##
177
- # See MiniTest::Assertions#refute_have_run
178
- #
179
- # config.wont_have_run cmd
180
- #
181
- # :method: wont_have_run
182
-
183
- infect_an_assertion :refute_have_run, :wont_have_run
184
-
185
- ##
186
- # See MiniTest::Assertions#assert_have_run_something
187
- #
188
- # config.must_have_run_something
189
- #
190
- # :method: must_have_run_something
191
-
192
- infect_an_assertion :assert_have_run_something, :must_have_run_something, true
193
-
194
- ##
195
- # See MiniTest::Assertions#refute_have_run_something
196
- #
197
- # config.wont_have_run_anything
198
- #
199
- # :method: wont_have_run_anything
200
-
201
- infect_an_assertion :refute_have_run_something, :wont_have_run_anything, true
202
-
203
- ##
204
- # See MiniTest::Assertions#assert_have_captured
205
- #
206
- # config.must_have_captured cmd
207
- #
208
- # :method: must_have_captured
209
-
210
- infect_an_assertion :assert_have_captured, :must_have_captured
211
-
212
- ##
213
- # See MiniTest::Assertions#refute_have_captured
214
- #
215
- # config.wont_have_captured cmd
216
- #
217
- # :method: wont_have_captured
218
-
219
- infect_an_assertion :refute_have_captured, :wont_have_captured
220
-
221
- ##
222
- # See MiniTest::Assertions#assert_have_put
223
- #
224
- # config.must_have_put path, data
225
- #
226
- # :method: must_have_put
227
-
228
- infect_an_assertion :assert_have_put, :must_have_put
229
-
230
- ##
231
- # See MiniTest::Assertions#refute_have_put
232
- #
233
- # config.wont_have_put path, data
234
- #
235
- # :method: wont_have_put
236
-
237
- infect_an_assertion :refute_have_put, :wont_have_put
238
-
239
- ##
240
- # See MiniTest::Assertions#assert_callback_before
241
- #
242
- # config.must_have_callback_before :stop, :warn_people
243
- #
244
- # :method: must_have_callback_before
245
-
246
- infect_an_assertion :assert_callback_before, :must_have_callback_before, true
247
-
248
- ##
249
- # See MiniTest::Assertions#refute_callback_before
250
- #
251
- # config.wont_have_callback_before :stop, :begin_long_job
252
- #
253
- # :method: wont_have_callback_before
254
-
255
- infect_an_assertion :refute_callback_before, :wont_have_callback_before, true
256
-
257
- ##
258
- # See MiniTest::Assertions#assert_callback_after
259
- #
260
- # config.must_have_callback_after :reload, :log_event
261
- #
262
- # :method: must_have_callback_after
263
-
264
- infect_an_assertion :assert_callback_after, :must_have_callback_after, true
265
-
266
- ##
267
- # See MiniTest::Assertions#refute_callback_after
268
- #
269
- # config.wont_have_callback_after :stop, :do_taxes
270
- #
271
- # :method: wont_have_callback_after
272
-
273
- infect_an_assertion :refute_callback_after, :wont_have_callback_after, true
274
-
275
- ##
276
- # See MiniTest::Assertions#assert_have_task
277
- #
278
- # config.must_have_task "deploy:restart"
279
- #
280
- # :method: must_have_task
281
-
282
- infect_an_assertion :assert_have_task, :must_have_task
283
-
284
- ##
285
- # See MiniTest::Assertions#refute_have_task
286
- #
287
- # config.wont_have_task "nothing:here"
288
- #
289
- # :method: wont_have_task
290
-
291
- infect_an_assertion :refute_have_task, :wont_have_task
292
- end
293
-
294
- module Capistrano
295
- ##
296
- # Patches to Capistrano::Configuration to track invocations. Taken from
297
- # the awesome capistrano-spec gem
298
- # (https://github.com/technicalpickles/capistrano-spec)
299
-
300
- module ConfigurationExtension
301
- def get(remote_path, path, options={}, &block)
302
- gets[remote_path] = {:path => path, :options => options, :block => block}
303
- end
304
-
305
- def gets
306
- @gets ||= {}
307
- end
308
-
309
- def run(cmd, options={}, &block)
310
- runs[cmd] = {:options => options, :block => block}
311
- end
312
-
313
- def runs
314
- @runs ||= {}
315
- end
316
-
317
- def upload(from, to, options={}, &block)
318
- uploads[from] = {:to => to, :options => options, :block => block}
319
- end
320
-
321
- def uploads
322
- @uploads ||= {}
323
- end
324
-
325
- def put(data, path, options={})
326
- putes[path] = {:data => data, :options => options}
327
- end
328
-
329
- def putes
330
- @putes ||= {}
331
- end
332
-
333
- def capture(command, options={})
334
- captures[command] = {:options => options}
335
- captures_responses[command]
336
- end
337
-
338
- def captures
339
- @captures ||= {}
340
- end
341
-
342
- def captures_responses
343
- @captures_responses ||= {}
344
- end
345
-
346
- def find_callback(on, task)
347
- task = find_task(task) if task.kind_of?(String)
348
-
349
- Array(callbacks[on]).select do |task_callback|
350
- task_callback.applies_to?(task) ||
351
- task_callback.source == task.fully_qualified_name
352
- end
353
- end
354
- end
355
- end
356
- end
357
-
358
- class Object # :nodoc:
359
- include MiniTest::Expectations
360
162
  end
@@ -0,0 +1,63 @@
1
+ module MiniTest::Capistrano
2
+ ##
3
+ # Patches to Capistrano::Configuration to track invocations. Taken from
4
+ # the awesome capistrano-spec gem
5
+ # (https://github.com/technicalpickles/capistrano-spec)
6
+
7
+ module ConfigurationExtension
8
+ def get(remote_path, path, options={}, &block)
9
+ gets[remote_path] = {:path => path, :options => options, :block => block}
10
+ end
11
+
12
+ def gets
13
+ @gets ||= {}
14
+ end
15
+
16
+ def run(cmd, options={}, &block)
17
+ runs[cmd] = {:options => options, :block => block}
18
+ end
19
+
20
+ def runs
21
+ @runs ||= {}
22
+ end
23
+
24
+ def upload(from, to, options={}, &block)
25
+ uploads[from] = {:to => to, :options => options, :block => block}
26
+ end
27
+
28
+ def uploads
29
+ @uploads ||= {}
30
+ end
31
+
32
+ def put(data, path, options={})
33
+ putes[path] = {:data => data, :options => options}
34
+ end
35
+
36
+ def putes
37
+ @putes ||= {}
38
+ end
39
+
40
+ def capture(command, options={})
41
+ captures[command] = {:options => options}
42
+ captures_responses[command]
43
+ end
44
+
45
+ def captures
46
+ @captures ||= {}
47
+ end
48
+
49
+ def captures_responses
50
+ @captures_responses ||= {}
51
+ end
52
+
53
+ def find_callback(on, task)
54
+ task = find_task(task) if task.kind_of?(String)
55
+
56
+ Array(callbacks[on]).select do |task_callback|
57
+ task_callback.applies_to?(task) ||
58
+ task_callback.source == task.fully_qualified_name
59
+ end
60
+ end
61
+ end
62
+ end
63
+
@@ -1,5 +1,5 @@
1
1
  module MiniTest
2
2
  module Capistrano
3
- VERSION = "0.0.8" # :nodoc:
3
+ VERSION = "0.1.0" # :nodoc:
4
4
  end
5
5
  end
@@ -0,0 +1,138 @@
1
+ require 'minitest/spec'
2
+
3
+ module MiniTest
4
+ ##
5
+ # It's where you hide your "assertions".
6
+
7
+ module Expectations
8
+ ##
9
+ # See MiniTest::Assertions#assert_have_run
10
+ #
11
+ # config.must_have_run cmd
12
+ #
13
+ # :method: must_have_run
14
+
15
+ infect_an_assertion :assert_have_run, :must_have_run
16
+
17
+ ##
18
+ # See MiniTest::Assertions#refute_have_run
19
+ #
20
+ # config.wont_have_run cmd
21
+ #
22
+ # :method: wont_have_run
23
+
24
+ infect_an_assertion :refute_have_run, :wont_have_run
25
+
26
+ ##
27
+ # See MiniTest::Assertions#assert_have_run_something
28
+ #
29
+ # config.must_have_run_something
30
+ #
31
+ # :method: must_have_run_something
32
+
33
+ infect_an_assertion :assert_have_run_something, :must_have_run_something, true
34
+
35
+ ##
36
+ # See MiniTest::Assertions#refute_have_run_something
37
+ #
38
+ # config.wont_have_run_anything
39
+ #
40
+ # :method: wont_have_run_anything
41
+
42
+ infect_an_assertion :refute_have_run_something, :wont_have_run_anything, true
43
+
44
+ ##
45
+ # See MiniTest::Assertions#assert_have_captured
46
+ #
47
+ # config.must_have_captured cmd
48
+ #
49
+ # :method: must_have_captured
50
+
51
+ infect_an_assertion :assert_have_captured, :must_have_captured
52
+
53
+ ##
54
+ # See MiniTest::Assertions#refute_have_captured
55
+ #
56
+ # config.wont_have_captured cmd
57
+ #
58
+ # :method: wont_have_captured
59
+
60
+ infect_an_assertion :refute_have_captured, :wont_have_captured
61
+
62
+ ##
63
+ # See MiniTest::Assertions#assert_have_put
64
+ #
65
+ # config.must_have_put path, data
66
+ #
67
+ # :method: must_have_put
68
+
69
+ infect_an_assertion :assert_have_put, :must_have_put
70
+
71
+ ##
72
+ # See MiniTest::Assertions#refute_have_put
73
+ #
74
+ # config.wont_have_put path, data
75
+ #
76
+ # :method: wont_have_put
77
+
78
+ infect_an_assertion :refute_have_put, :wont_have_put
79
+
80
+ ##
81
+ # See MiniTest::Assertions#assert_callback_before
82
+ #
83
+ # config.must_have_callback_before :stop, :warn_people
84
+ #
85
+ # :method: must_have_callback_before
86
+
87
+ infect_an_assertion :assert_callback_before, :must_have_callback_before, true
88
+
89
+ ##
90
+ # See MiniTest::Assertions#refute_callback_before
91
+ #
92
+ # config.wont_have_callback_before :stop, :begin_long_job
93
+ #
94
+ # :method: wont_have_callback_before
95
+
96
+ infect_an_assertion :refute_callback_before, :wont_have_callback_before, true
97
+
98
+ ##
99
+ # See MiniTest::Assertions#assert_callback_after
100
+ #
101
+ # config.must_have_callback_after :reload, :log_event
102
+ #
103
+ # :method: must_have_callback_after
104
+
105
+ infect_an_assertion :assert_callback_after, :must_have_callback_after, true
106
+
107
+ ##
108
+ # See MiniTest::Assertions#refute_callback_after
109
+ #
110
+ # config.wont_have_callback_after :stop, :do_taxes
111
+ #
112
+ # :method: wont_have_callback_after
113
+
114
+ infect_an_assertion :refute_callback_after, :wont_have_callback_after, true
115
+
116
+ ##
117
+ # See MiniTest::Assertions#assert_have_task
118
+ #
119
+ # config.must_have_task "deploy:restart"
120
+ #
121
+ # :method: must_have_task
122
+
123
+ infect_an_assertion :assert_have_task, :must_have_task
124
+
125
+ ##
126
+ # See MiniTest::Assertions#refute_have_task
127
+ #
128
+ # config.wont_have_task "nothing:here"
129
+ #
130
+ # :method: wont_have_task
131
+
132
+ infect_an_assertion :refute_have_task, :wont_have_task
133
+ end
134
+ end
135
+
136
+ class Object # :nodoc:
137
+ include MiniTest::Expectations
138
+ end
@@ -1,2 +1,21 @@
1
- require "minitest/capistrano"
1
+ require "minitest/assertions"
2
+ require "minitest/expectations"
3
+ require "minitest/capistrano/configuration_extension"
2
4
  require "minitest/capistrano/version"
5
+
6
+ def load_capistrano_recipe(recipe)
7
+ before do
8
+ @config = Capistrano::Configuration.new
9
+ @config.extend(MiniTest::Capistrano::ConfigurationExtension)
10
+ @orig_config = Capistrano::Configuration.instance
11
+ Capistrano::Configuration.instance = @config
12
+ recipe.send(:load_into, @config)
13
+ end
14
+
15
+ after do
16
+ Capistrano::Configuration.instance = @orig_config
17
+ end
18
+
19
+ subject {@config}
20
+ let(:recipe) { @config }
21
+ end
@@ -17,4 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_dependency "minitest", "~> 2.12"
19
19
  gem.add_dependency "capistrano", "~> 2.9"
20
+
21
+ gem.add_development_dependency "minitest-colorize", "~> 0.0.4"
22
+ gem.add_development_dependency "guard-minitest", "~> 0.5.0"
20
23
  end
@@ -0,0 +1,14 @@
1
+ require 'capistrano'
2
+
3
+ module Capistrano::Recipes
4
+ module Bark
5
+ def self.load_into(configuration)
6
+ configuration.load do
7
+ task :bark do
8
+ set :message, 'ruff ruff'
9
+ message
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
+
3
+
4
+ describe '#load_capistrano_recipe' do
5
+ Capistrano::Configuration.instance = Capistrano::Configuration.new
6
+ load_capistrano_recipe(Capistrano::Recipes::Bark)
7
+
8
+ it 'extends the config' do
9
+ Capistrano::Configuration.instance.must_respond_to :uploads
10
+ end
11
+
12
+ it 'loads the specified recipe into the instance configuration' do
13
+ Capistrano::Configuration.instance.must_have_task "bark"
14
+ end
15
+
16
+ it 'sets the capistrano instance to the extend config' do
17
+ Capistrano::Configuration.instance.must_equal recipe
18
+ end
19
+
20
+ it 'sets recipe to the config for reference' do
21
+ recipe.must_equal Capistrano::Configuration.instance
22
+ end
23
+
24
+ it 'sets subject to the config for reference' do
25
+ subject.must_equal Capistrano::Configuration.instance
26
+ end
27
+
28
+ it 'holds onto the original config' do
29
+ @orig_config.must_be_instance_of Capistrano::Configuration.instance.class
30
+ @orig_config.wont_equal Capistrano::Configuration.instance
31
+ end
32
+ end
@@ -0,0 +1,83 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe MiniTest::Assertions do
4
+ before do
5
+ @config = Capistrano::Configuration.new
6
+ @config.extend(MiniTest::Capistrano::ConfigurationExtension)
7
+ @config.task(:startup) { run "rails server" }
8
+ @config.task(:announce_startup) { run "echo starting up"}
9
+ end
10
+
11
+ subject { MiniTest::Unit::TestCase.new 'fake tc' }
12
+
13
+ it "asserts a command has run" do
14
+ @config.run "yabba dabba"
15
+ subject.assert_have_run "yabba dabba", @config
16
+ end
17
+
18
+ it "refutes a command has been run" do
19
+ @config.run "nothing"
20
+ subject.refute_have_run "yoyodyne", @config
21
+ end
22
+
23
+ it "asserts any command has run" do
24
+ @config.run "yo"
25
+ subject.assert_have_run_something @config
26
+ end
27
+
28
+ it "refute any command has run" do
29
+ subject.refute_have_run_something @config
30
+ end
31
+
32
+ it "assert a command has been captured" do
33
+ @config.capture "cat /tmp/surprise.txt"
34
+ subject.assert_have_captured "cat /tmp/surprise.txt", @config
35
+ end
36
+
37
+ it "refutes a command has been captured" do
38
+ subject.refute_have_captured "cat /tmp/anything", @config
39
+ end
40
+
41
+ it "assert a file has been put" do
42
+ @config.put "#!/usr/bin/env ruby", "/tmp/server.rb"
43
+ subject.assert_have_put "/tmp/server.rb", @config, "#!/usr/bin/env ruby"
44
+ end
45
+
46
+ it "refutes a file has been put with data" do
47
+ subject.refute_have_put "/tmp/anything", @config, "data"
48
+ end
49
+
50
+ it "refutes a file has been put with no data" do
51
+ subject.refute_have_put "/tmp/anything", @config
52
+ end
53
+
54
+ it "asserts a callback exists for one task before another" do
55
+ @config.before :startup, :announce_startup
56
+
57
+ subject.assert_callback_before @config, :startup, :announce_startup
58
+ end
59
+
60
+ it "refutes a callback exists for one task before another" do
61
+ subject.refute_callback_before @config, :startup, :nadda
62
+ end
63
+
64
+ it "asserts a callback exists for one task after another" do
65
+ @config.after :start, :intialize
66
+
67
+ subject.assert_callback_after @config, :start, :intialize
68
+ end
69
+
70
+ it "refutes a callback exists for one task after another" do
71
+ subject.refute_callback_after @config, :clone, :nadda
72
+ end
73
+
74
+ it "asserts a task exists" do
75
+ @config.namespace(:one) { task(:two) {} }
76
+
77
+ subject.assert_have_task "one:two", @config
78
+ end
79
+
80
+ it "refute a task exists" do
81
+ subject.refute_have_task "three:four", @config
82
+ end
83
+ end
@@ -0,0 +1,98 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe MiniTest::Capistrano::ConfigurationExtension do
4
+ before do
5
+ @config = Capistrano::Configuration.new
6
+ @config.extend(MiniTest::Capistrano::ConfigurationExtension)
7
+ @config.task(:startup) { run "rails server" }
8
+ @config.task(:announce_startup) { run "echo starting up"}
9
+ end
10
+
11
+ describe "#get" do
12
+ it "starts with an empty hash" do
13
+ @config.gets.must_be_empty
14
+ end
15
+
16
+ it "adds an entry to the hash when called" do
17
+ @config.gets.must_be_empty
18
+ @config.get "hurdy", "gurdy"
19
+ @config.gets.wont_be_empty
20
+ @config.gets["hurdy"].wont_be_nil
21
+ end
22
+ end
23
+
24
+ describe "#run" do
25
+ it "starts with an empty hash" do
26
+ @config.runs.must_be_empty
27
+ end
28
+
29
+ it "adds an entry to the hash when called" do
30
+ @config.runs.must_be_empty
31
+ @config.run "echo hi"
32
+ @config.runs.wont_be_empty
33
+ @config.runs["echo hi"].wont_be_nil
34
+ end
35
+ end
36
+
37
+ describe "#upload" do
38
+ it "starts with an empty hash" do
39
+ @config.uploads.must_be_empty
40
+ end
41
+
42
+ it "adds an entry to the hash when called" do
43
+ @config.uploads.must_be_empty
44
+ @config.upload "path_to", "nowhere"
45
+ @config.uploads.wont_be_empty
46
+ @config.uploads["path_to"].wont_be_nil
47
+ end
48
+ end
49
+
50
+ describe "#put" do
51
+ it "starts with an empty hash" do
52
+ @config.putes.must_be_empty
53
+ end
54
+
55
+ it "adds an entry to the hash when called" do
56
+ @config.putes.must_be_empty
57
+ @config.put "data", "path"
58
+ @config.putes.wont_be_empty
59
+ @config.putes["path"].wont_be_nil
60
+ end
61
+ end
62
+
63
+ describe "#capture" do
64
+ it "starts with an empty hash" do
65
+ @config.captures.must_be_empty
66
+ end
67
+
68
+ it "adds an entry to the hash when called" do
69
+ @config.captures.must_be_empty
70
+ @config.capture "cat /tmp/secrets.txt"
71
+ @config.captures.wont_be_empty
72
+ @config.captures["cat /tmp/secrets.txt"].wont_be_nil
73
+ end
74
+
75
+ it "retuns a nil response if one is not pre-set" do
76
+ @config.capture("cat /nope").must_be_nil
77
+ end
78
+
79
+ it "returns a response if one is pre-set" do
80
+ @config.captures_responses["cat /tmp/file"] = "blah bleh"
81
+
82
+ @config.capture("cat /tmp/file").must_equal "blah bleh"
83
+ end
84
+ end
85
+
86
+ describe "#find_callback" do
87
+ it "returns an empty array when no callbacks are found" do
88
+ @config.find_callback(:before, @config.find_task("startup")).must_equal []
89
+ end
90
+
91
+ it "returns an array of callbacks that apply to the task" do
92
+ @config.before :startup, :announce_startup
93
+
94
+ @config.find_callback(:before, @config.find_task("startup")).
95
+ first.source.must_equal :announce_startup
96
+ end
97
+ end
98
+ end
@@ -1,259 +1,31 @@
1
- gem 'minitest'
2
- require 'minitest/autorun'
3
- require 'minitest/capistrano'
4
- require 'capistrano'
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
5
2
 
6
- describe MiniTest::Capistrano::ConfigurationExtension do
7
- before do
8
- @config = Capistrano::Configuration.new
9
- @config.extend(MiniTest::Capistrano::ConfigurationExtension)
10
- @config.task(:startup) { run "rails server" }
11
- @config.task(:announce_startup) { run "echo starting up"}
12
- end
13
-
14
- describe "#get" do
15
- it "starts with an empty hash" do
16
- @config.gets.must_be_empty
17
- end
18
-
19
- it "adds an entry to the hash when called" do
20
- @config.gets.must_be_empty
21
- @config.get "hurdy", "gurdy"
22
- @config.gets.wont_be_empty
23
- @config.gets["hurdy"].wont_be_nil
24
- end
25
- end
26
-
27
- describe "#run" do
28
- it "starts with an empty hash" do
29
- @config.runs.must_be_empty
30
- end
31
-
32
- it "adds an entry to the hash when called" do
33
- @config.runs.must_be_empty
34
- @config.run "echo hi"
35
- @config.runs.wont_be_empty
36
- @config.runs["echo hi"].wont_be_nil
37
- end
38
- end
39
-
40
- describe "#upload" do
41
- it "starts with an empty hash" do
42
- @config.uploads.must_be_empty
43
- end
44
-
45
- it "adds an entry to the hash when called" do
46
- @config.uploads.must_be_empty
47
- @config.upload "path_to", "nowhere"
48
- @config.uploads.wont_be_empty
49
- @config.uploads["path_to"].wont_be_nil
50
- end
51
- end
52
-
53
- describe "#put" do
54
- it "starts with an empty hash" do
55
- @config.putes.must_be_empty
56
- end
57
-
58
- it "adds an entry to the hash when called" do
59
- @config.putes.must_be_empty
60
- @config.put "data", "path"
61
- @config.putes.wont_be_empty
62
- @config.putes["path"].wont_be_nil
63
- end
64
- end
65
-
66
- describe "#capture" do
67
- it "starts with an empty hash" do
68
- @config.captures.must_be_empty
69
- end
70
-
71
- it "adds an entry to the hash when called" do
72
- @config.captures.must_be_empty
73
- @config.capture "cat /tmp/secrets.txt"
74
- @config.captures.wont_be_empty
75
- @config.captures["cat /tmp/secrets.txt"].wont_be_nil
76
- end
77
-
78
- it "retuns a nil response if one is not pre-set" do
79
- @config.capture("cat /nope").must_be_nil
80
- end
81
-
82
- it "returns a response if one is pre-set" do
83
- @config.captures_responses["cat /tmp/file"] = "blah bleh"
84
-
85
- @config.capture("cat /tmp/file").must_equal "blah bleh"
86
- end
87
- end
88
-
89
- describe "#find_callback" do
90
- it "returns an empty array when no callbacks are found" do
91
- @config.find_callback(:before, @config.find_task("startup")).must_equal []
92
- end
93
-
94
- it "returns an array of callbacks that apply to the task" do
95
- @config.before :startup, :announce_startup
96
-
97
- @config.find_callback(:before, @config.find_task("startup")).
98
- first.source.must_equal :announce_startup
99
- end
100
- end
101
- end
102
-
103
- describe MiniTest::Assertions do
104
- before do
105
- @config = Capistrano::Configuration.new
106
- @config.extend(MiniTest::Capistrano::ConfigurationExtension)
107
- @config.task(:startup) { run "rails server" }
108
- @config.task(:announce_startup) { run "echo starting up"}
109
- end
110
-
111
- subject { MiniTest::Unit::TestCase.new 'fake tc' }
112
-
113
- it "asserts a command has run" do
114
- @config.run "yabba dabba"
115
- subject.assert_have_run "yabba dabba", @config
116
- end
117
-
118
- it "refutes a command has been run" do
119
- @config.run "nothing"
120
- subject.refute_have_run "yoyodyne", @config
121
- end
122
-
123
- it "asserts any command has run" do
124
- @config.run "yo"
125
- subject.assert_have_run_something @config
126
- end
127
-
128
- it "refute any command has run" do
129
- subject.refute_have_run_something @config
130
- end
131
-
132
- it "assert a command has been captured" do
133
- @config.capture "cat /tmp/surprise.txt"
134
- subject.assert_have_captured "cat /tmp/surprise.txt", @config
135
- end
136
-
137
- it "refutes a command has been captured" do
138
- subject.refute_have_captured "cat /tmp/anything", @config
139
- end
140
-
141
- it "assert a file has been put" do
142
- @config.put "#!/usr/bin/env ruby", "/tmp/server.rb"
143
- subject.assert_have_put "/tmp/server.rb", @config, "#!/usr/bin/env ruby"
144
- end
3
+ describe '#load_capistrano_recipe' do
4
+ Capistrano::Configuration.instance = Capistrano::Configuration.new
5
+ load_capistrano_recipe(Capistrano::Recipes::Bark)
145
6
 
146
- it "refutes a file has been put with data" do
147
- subject.refute_have_put "/tmp/anything", @config, "data"
7
+ it 'extends the config' do
8
+ Capistrano::Configuration.instance.must_respond_to :uploads
148
9
  end
149
10
 
150
- it "refutes a file has been put with no data" do
151
- subject.refute_have_put "/tmp/anything", @config
11
+ it 'loads the specified recipe into the instance configuration' do
12
+ Capistrano::Configuration.instance.must_have_task "bark"
152
13
  end
153
14
 
154
- it "asserts a callback exists for one task before another" do
155
- @config.before :startup, :announce_startup
156
-
157
- subject.assert_callback_before @config, :startup, :announce_startup
158
- end
159
-
160
- it "refutes a callback exists for one task before another" do
161
- subject.refute_callback_before @config, :startup, :nadda
162
- end
163
-
164
- it "asserts a callback exists for one task after another" do
165
- @config.after :start, :intialize
166
-
167
- subject.assert_callback_after @config, :start, :intialize
168
- end
169
-
170
- it "refutes a callback exists for one task after another" do
171
- subject.refute_callback_after @config, :clone, :nadda
172
- end
173
-
174
- it "asserts a task exists" do
175
- @config.namespace(:one) { task(:two) {} }
176
-
177
- subject.assert_have_task "one:two", @config
178
- end
179
-
180
- it "refute a task exists" do
181
- subject.refute_have_task "three:four", @config
182
- end
183
- end
184
-
185
- describe MiniTest::Expectations do
186
- before do
187
- @config = Capistrano::Configuration.new
188
- @config.extend(MiniTest::Capistrano::ConfigurationExtension)
189
- @config.task(:startup) { run "rails server" }
190
- @config.task(:announce_startup) { run "echo starting up"}
191
- end
192
-
193
- it "needs to verify a command has run" do
194
- @config.run "yabba dabba"
195
- @config.must_have_run "yabba dabba"
196
- end
197
-
198
- it "needs to verify a command has not been run" do
199
- @config.run "wot?"
200
- @config.wont_have_run "yabba dabba"
201
- end
202
-
203
- it "needs to verify something has run" do
204
- @config.run "woah"
205
- @config.must_have_run_something
206
- end
207
-
208
- it "needs to verify no command has been run" do
209
- @config.wont_have_run_anything
210
- end
211
-
212
- it "needs to verify a command has captured" do
213
- @config.capture "yabba dabba"
214
- @config.must_have_captured "yabba dabba"
215
- end
216
-
217
- it "needs to verify a command has not been captured" do
218
- @config.capture "wot?"
219
- @config.wont_have_captured "yabba dabba"
220
- end
221
-
222
- it "needs to verify a file has been put" do
223
- @config.put "thedata", "thepath"
224
- @config.must_have_put "thepath", "thedata"
225
- end
226
-
227
- it "needs to verify a file has not been put" do
228
- @config.put "yabbadabbadata", "yepperspath"
229
- @config.wont_have_put "nopath"
230
- end
231
-
232
- it "needs to verify a callback exists for a task before another" do
233
- @config.before :stop, :warn_people
234
-
235
- @config.must_have_callback_before :stop, :warn_people
236
- end
237
-
238
- it "needs to verify no callback exists for a task before another" do
239
- @config.wont_have_callback_before :reload, :stop
240
- end
241
-
242
- it "needs to verify a callback exists for a task after another" do
243
- @config.after :start, :init_database
244
-
245
- @config.must_have_callback_after :start, :init_database
15
+ it 'sets the capistrano instance to the extend config' do
16
+ Capistrano::Configuration.instance.must_equal recipe
246
17
  end
247
18
 
248
- it "needs to verify no callback exists for a task after another" do
249
- @config.wont_have_callback_after :stop, :do_taxes
19
+ it 'sets recipe to the config for reference' do
20
+ recipe.must_equal Capistrano::Configuration.instance
250
21
  end
251
22
 
252
- it "needs to verify a task exists by name" do
253
- @config.must_have_task "startup"
23
+ it 'sets subject to the config for reference' do
24
+ subject.must_equal Capistrano::Configuration.instance
254
25
  end
255
26
 
256
- it "needs to verify no task exists by name" do
257
- @config.wont_have_task "doofus"
27
+ it 'holds onto the original config' do
28
+ @orig_config.must_be_instance_of Capistrano::Configuration.instance.class
29
+ @orig_config.wont_equal Capistrano::Configuration.instance
258
30
  end
259
31
  end
@@ -0,0 +1,77 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe MiniTest::Expectations do
4
+ before do
5
+ @config = Capistrano::Configuration.new
6
+ @config.extend(MiniTest::Capistrano::ConfigurationExtension)
7
+ @config.task(:startup) { run "rails server" }
8
+ @config.task(:announce_startup) { run "echo starting up"}
9
+ end
10
+
11
+ it "needs to verify a command has run" do
12
+ @config.run "yabba dabba"
13
+ @config.must_have_run "yabba dabba"
14
+ end
15
+
16
+ it "needs to verify a command has not been run" do
17
+ @config.run "wot?"
18
+ @config.wont_have_run "yabba dabba"
19
+ end
20
+
21
+ it "needs to verify something has run" do
22
+ @config.run "woah"
23
+ @config.must_have_run_something
24
+ end
25
+
26
+ it "needs to verify no command has been run" do
27
+ @config.wont_have_run_anything
28
+ end
29
+
30
+ it "needs to verify a command has captured" do
31
+ @config.capture "yabba dabba"
32
+ @config.must_have_captured "yabba dabba"
33
+ end
34
+
35
+ it "needs to verify a command has not been captured" do
36
+ @config.capture "wot?"
37
+ @config.wont_have_captured "yabba dabba"
38
+ end
39
+
40
+ it "needs to verify a file has been put" do
41
+ @config.put "thedata", "thepath"
42
+ @config.must_have_put "thepath", "thedata"
43
+ end
44
+
45
+ it "needs to verify a file has not been put" do
46
+ @config.put "yabbadabbadata", "yepperspath"
47
+ @config.wont_have_put "nopath"
48
+ end
49
+
50
+ it "needs to verify a callback exists for a task before another" do
51
+ @config.before :stop, :warn_people
52
+
53
+ @config.must_have_callback_before :stop, :warn_people
54
+ end
55
+
56
+ it "needs to verify no callback exists for a task before another" do
57
+ @config.wont_have_callback_before :reload, :stop
58
+ end
59
+
60
+ it "needs to verify a callback exists for a task after another" do
61
+ @config.after :start, :init_database
62
+
63
+ @config.must_have_callback_after :start, :init_database
64
+ end
65
+
66
+ it "needs to verify no callback exists for a task after another" do
67
+ @config.wont_have_callback_after :stop, :do_taxes
68
+ end
69
+
70
+ it "needs to verify a task exists by name" do
71
+ @config.must_have_task "startup"
72
+ end
73
+
74
+ it "needs to verify no task exists by name" do
75
+ @config.wont_have_task "doofus"
76
+ end
77
+ end
@@ -0,0 +1,8 @@
1
+ gem 'minitest'
2
+
3
+ require 'minitest/autorun'
4
+ require 'minitest/colorize'
5
+ require 'capistrano'
6
+
7
+ require 'minitest-capistrano'
8
+ require File.expand_path(File.join(File.dirname(__FILE__), 'fixtures','recipes','bark'))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-06 00:00:00.000000000 Z
12
+ date: 2012-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &70335338254120 !ruby/object:Gem::Requirement
16
+ requirement: &70260263515060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.12'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70335338254120
24
+ version_requirements: *70260263515060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: capistrano
27
- requirement: &70335338253420 !ruby/object:Gem::Requirement
27
+ requirement: &70260263514500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,29 @@ dependencies:
32
32
  version: '2.9'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70335338253420
35
+ version_requirements: *70260263514500
36
+ - !ruby/object:Gem::Dependency
37
+ name: minitest-colorize
38
+ requirement: &70260263514020 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.0.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70260263514020
47
+ - !ruby/object:Gem::Dependency
48
+ name: guard-minitest
49
+ requirement: &70260263513520 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70260263513520
36
58
  description: MiniTest assertions and expectations for testing Capistrano recipes
37
59
  email:
38
60
  - fnichol@nichol.ca
@@ -42,15 +64,25 @@ extra_rdoc_files: []
42
64
  files:
43
65
  - .gitignore
44
66
  - .travis.yml
67
+ - CHANGELOG.md
45
68
  - Gemfile
69
+ - Guardfile
46
70
  - LICENSE
47
71
  - README.md
48
72
  - Rakefile
49
73
  - lib/minitest-capistrano.rb
50
- - lib/minitest/capistrano.rb
74
+ - lib/minitest/assertions.rb
75
+ - lib/minitest/capistrano/configuration_extension.rb
51
76
  - lib/minitest/capistrano/version.rb
77
+ - lib/minitest/expectations.rb
52
78
  - minitest-capistrano.gemspec
79
+ - spec/fixtures/recipes/bark.rb
80
+ - spec/minitest-capistranio_spec.rb
81
+ - spec/minitest_assertions_spec.rb
82
+ - spec/minitest_capistrano_extension_spec.rb
53
83
  - spec/minitest_capistrano_spec.rb
84
+ - spec/minitest_expectations_spec.rb
85
+ - spec/spec_helper.rb
54
86
  homepage: https://github.com/fnichol/minitest-capistrano
55
87
  licenses: []
56
88
  post_install_message:
@@ -63,23 +95,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
95
  - - ! '>='
64
96
  - !ruby/object:Gem::Version
65
97
  version: '0'
66
- segments:
67
- - 0
68
- hash: 441678345195791184
69
98
  required_rubygems_version: !ruby/object:Gem::Requirement
70
99
  none: false
71
100
  requirements:
72
101
  - - ! '>='
73
102
  - !ruby/object:Gem::Version
74
103
  version: '0'
75
- segments:
76
- - 0
77
- hash: 441678345195791184
78
104
  requirements: []
79
105
  rubyforge_project:
80
- rubygems_version: 1.8.17
106
+ rubygems_version: 1.8.15
81
107
  signing_key:
82
108
  specification_version: 3
83
109
  summary: MiniTest assertions and expectations for testing Capistrano recipes
84
110
  test_files:
111
+ - spec/fixtures/recipes/bark.rb
112
+ - spec/minitest-capistranio_spec.rb
113
+ - spec/minitest_assertions_spec.rb
114
+ - spec/minitest_capistrano_extension_spec.rb
85
115
  - spec/minitest_capistrano_spec.rb
116
+ - spec/minitest_expectations_spec.rb
117
+ - spec/spec_helper.rb