minitest-capistrano 0.0.3 → 0.0.4
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/lib/minitest/capistrano/version.rb +1 -1
- data/lib/minitest/capistrano.rb +46 -8
- data/spec/minitest_capistrano_spec.rb +51 -52
- metadata +34 -63
data/lib/minitest/capistrano.rb
CHANGED
@@ -12,7 +12,7 @@ module MiniTest
|
|
12
12
|
# assert_have_run "echo hi", configuration
|
13
13
|
|
14
14
|
def assert_have_run(cmd, configuration, msg = nil)
|
15
|
-
msg
|
15
|
+
msg ||= "Expected configuration to run #{cmd}, but did not"
|
16
16
|
refute_nil configuration.runs[cmd], msg
|
17
17
|
end
|
18
18
|
|
@@ -20,7 +20,7 @@ module MiniTest
|
|
20
20
|
# Fails if +configuration+ has run +cmd+.
|
21
21
|
|
22
22
|
def refute_have_run(cmd, configuration, msg = nil)
|
23
|
-
msg
|
23
|
+
msg ||= "Expected configuration to not run #{cmd}, but did"
|
24
24
|
assert_nil configuration.runs[cmd], msg
|
25
25
|
end
|
26
26
|
|
@@ -30,7 +30,7 @@ module MiniTest
|
|
30
30
|
# assert_have_run_something configuration
|
31
31
|
|
32
32
|
def assert_have_run_something(configuration, msg = nil)
|
33
|
-
msg
|
33
|
+
msg ||= "Expected configuration to have run something, but did not"
|
34
34
|
refute_empty configuration.runs, msg
|
35
35
|
end
|
36
36
|
|
@@ -40,7 +40,7 @@ module MiniTest
|
|
40
40
|
# refute_have_run_something configuration
|
41
41
|
|
42
42
|
def refute_have_run_something(configuration, msg = nil)
|
43
|
-
msg
|
43
|
+
msg ||= "Expected configuration to have run nothing, but did"
|
44
44
|
assert_empty configuration.runs, msg
|
45
45
|
end
|
46
46
|
|
@@ -51,7 +51,7 @@ module MiniTest
|
|
51
51
|
# assert_callback_before configuration, :stop, :finalize
|
52
52
|
|
53
53
|
def assert_callback_before(configuration, task_name, before_task_name, msg = nil)
|
54
|
-
msg
|
54
|
+
msg ||= "Expected configuration to callback #{task_name.inspect} before #{before_task_name.inspect} but did not"
|
55
55
|
test_callback_on(true, configuration, task_name, :before, before_task_name, msg)
|
56
56
|
end
|
57
57
|
|
@@ -62,7 +62,7 @@ module MiniTest
|
|
62
62
|
# refute_callback_before configuration, :stop, :start
|
63
63
|
|
64
64
|
def refute_callback_before(configuration, task_name, before_task_name, msg = nil)
|
65
|
-
msg
|
65
|
+
msg ||= "Expected configuration to not have a callback #{task_name.inspect} before #{before_task_name.inspect} but did"
|
66
66
|
test_callback_on(false, configuration, task_name, :before, before_task_name, msg)
|
67
67
|
end
|
68
68
|
|
@@ -73,7 +73,7 @@ module MiniTest
|
|
73
73
|
# assert_callback_after configuration, :reload, :log_event
|
74
74
|
|
75
75
|
def assert_callback_after(configuration, task_name, after_task_name, msg = nil)
|
76
|
-
msg
|
76
|
+
msg ||= "Expected configuration to callback #{task_name.inspect} after #{after_task_name.inspect} but did not"
|
77
77
|
test_callback_on(true, configuration, task_name, :after, after_task_name, msg)
|
78
78
|
end
|
79
79
|
|
@@ -84,10 +84,30 @@ module MiniTest
|
|
84
84
|
# refute_callback_after configuration, :start, :stop
|
85
85
|
|
86
86
|
def refute_callback_after(configuration, task_name, after_task_name, msg = nil)
|
87
|
-
msg
|
87
|
+
msg ||= "Expected configuration to not have a callback #{task_name.inspect} after #{after_task_name.inspect} but did"
|
88
88
|
test_callback_on(false, configuration, task_name, :after, after_task_name, msg)
|
89
89
|
end
|
90
90
|
|
91
|
+
##
|
92
|
+
# Fails unless +configuration+ has a task called +task_name+.
|
93
|
+
#
|
94
|
+
# assert_have_task "deploy:restart", configuration
|
95
|
+
|
96
|
+
def assert_have_task(task_name, configuration, msg = nil)
|
97
|
+
msg ||= "Expected configuration to have task #{task_name} but did not"
|
98
|
+
refute_nil configuration.find_task(task_name), msg
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# Fails if +configuration+ has a task called +task_name+.
|
103
|
+
#
|
104
|
+
# refute_have_task "deploy:nothing", configuration
|
105
|
+
|
106
|
+
def refute_have_task(task_name, configuration, msg = nil)
|
107
|
+
msg ||= "Expected configuration to not have task #{task_name} but did"
|
108
|
+
assert_nil configuration.find_task(task_name), msg
|
109
|
+
end
|
110
|
+
|
91
111
|
private
|
92
112
|
|
93
113
|
def test_callback_on(positive, configuration, task_name, on, other_task_name, msg)
|
@@ -178,6 +198,24 @@ module MiniTest
|
|
178
198
|
# :method: wont_have_callback_after
|
179
199
|
|
180
200
|
infect_an_assertion :refute_callback_after, :wont_have_callback_after, true
|
201
|
+
|
202
|
+
##
|
203
|
+
# See MiniTest::Assertions#assert_have_task
|
204
|
+
#
|
205
|
+
# config.must_have_task "deploy:restart"
|
206
|
+
#
|
207
|
+
# :method: must_have_task
|
208
|
+
|
209
|
+
infect_an_assertion :assert_have_task, :must_have_task
|
210
|
+
|
211
|
+
##
|
212
|
+
# See MiniTest::Assertions#refute_have_task
|
213
|
+
#
|
214
|
+
# config.wont_have_task "nothing:here"
|
215
|
+
#
|
216
|
+
# :method: wont_have_task
|
217
|
+
|
218
|
+
infect_an_assertion :refute_have_task, :wont_have_task
|
181
219
|
end
|
182
220
|
|
183
221
|
module Capistrano
|
@@ -5,8 +5,10 @@ require 'capistrano'
|
|
5
5
|
|
6
6
|
describe MiniTest::Capistrano::ConfigurationExtension do
|
7
7
|
before do
|
8
|
-
@config =
|
8
|
+
@config = Capistrano::Configuration.new
|
9
9
|
@config.extend(MiniTest::Capistrano::ConfigurationExtension)
|
10
|
+
@config.task(:startup) { run "rails server" }
|
11
|
+
@config.task(:announce_startup) { run "echo starting up"}
|
10
12
|
end
|
11
13
|
|
12
14
|
describe "#get" do
|
@@ -72,13 +74,6 @@ describe MiniTest::Capistrano::ConfigurationExtension do
|
|
72
74
|
end
|
73
75
|
|
74
76
|
describe "#find_callback" do
|
75
|
-
before do
|
76
|
-
@config = Capistrano::Configuration.new
|
77
|
-
@config.extend(MiniTest::Capistrano::ConfigurationExtension)
|
78
|
-
@config.task(:startup) { run "rails server" }
|
79
|
-
@config.task(:announce_startup) { run "echo starting up"}
|
80
|
-
end
|
81
|
-
|
82
77
|
it "returns an empty array when no callbacks are found" do
|
83
78
|
@config.find_callback(:before, @config.find_task("startup")).must_equal []
|
84
79
|
end
|
@@ -94,8 +89,10 @@ end
|
|
94
89
|
|
95
90
|
describe MiniTest::Assertions do
|
96
91
|
before do
|
97
|
-
@config =
|
92
|
+
@config = Capistrano::Configuration.new
|
98
93
|
@config.extend(MiniTest::Capistrano::ConfigurationExtension)
|
94
|
+
@config.task(:startup) { run "rails server" }
|
95
|
+
@config.task(:announce_startup) { run "echo starting up"}
|
99
96
|
end
|
100
97
|
|
101
98
|
subject { MiniTest::Unit::TestCase.new 'fake tc' }
|
@@ -119,40 +116,43 @@ describe MiniTest::Assertions do
|
|
119
116
|
subject.refute_have_run_something @config
|
120
117
|
end
|
121
118
|
|
122
|
-
|
123
|
-
before
|
124
|
-
@config = Capistrano::Configuration.new
|
125
|
-
@config.extend(MiniTest::Capistrano::ConfigurationExtension)
|
126
|
-
@config.task(:startup) { run "rails server" }
|
127
|
-
@config.task(:announce_startup) { run "echo starting up"}
|
128
|
-
end
|
119
|
+
it "asserts a callback exists for one task before another" do
|
120
|
+
@config.before :startup, :announce_startup
|
129
121
|
|
130
|
-
|
131
|
-
|
122
|
+
subject.assert_callback_before @config, :startup, :announce_startup
|
123
|
+
end
|
132
124
|
|
133
|
-
|
134
|
-
|
125
|
+
it "refutes a callback exists for one task before another" do
|
126
|
+
subject.refute_callback_before @config, :startup, :nadda
|
127
|
+
end
|
135
128
|
|
136
|
-
|
137
|
-
|
138
|
-
end
|
129
|
+
it "asserts a callback exists for one task after another" do
|
130
|
+
@config.after :start, :intialize
|
139
131
|
|
140
|
-
|
141
|
-
|
132
|
+
subject.assert_callback_after @config, :start, :intialize
|
133
|
+
end
|
142
134
|
|
143
|
-
|
144
|
-
|
135
|
+
it "refutes a callback exists for one task after another" do
|
136
|
+
subject.refute_callback_after @config, :clone, :nadda
|
137
|
+
end
|
145
138
|
|
146
|
-
|
147
|
-
|
148
|
-
|
139
|
+
it "asserts a task exists" do
|
140
|
+
@config.namespace(:one) { task(:two) {} }
|
141
|
+
|
142
|
+
subject.assert_have_task "one:two", @config
|
143
|
+
end
|
144
|
+
|
145
|
+
it "refute a task exists" do
|
146
|
+
subject.refute_have_task "three:four", @config
|
149
147
|
end
|
150
148
|
end
|
151
149
|
|
152
150
|
describe MiniTest::Expectations do
|
153
151
|
before do
|
154
|
-
@config =
|
152
|
+
@config = Capistrano::Configuration.new
|
155
153
|
@config.extend(MiniTest::Capistrano::ConfigurationExtension)
|
154
|
+
@config.task(:startup) { run "rails server" }
|
155
|
+
@config.task(:announce_startup) { run "echo starting up"}
|
156
156
|
end
|
157
157
|
|
158
158
|
it "needs to verify a command has run" do
|
@@ -174,32 +174,31 @@ describe MiniTest::Expectations do
|
|
174
174
|
@config.wont_have_run_anything
|
175
175
|
end
|
176
176
|
|
177
|
-
|
178
|
-
before
|
179
|
-
@config = Capistrano::Configuration.new
|
180
|
-
@config.extend(MiniTest::Capistrano::ConfigurationExtension)
|
181
|
-
@config.task(:startup) { run "rails server" }
|
182
|
-
@config.task(:announce_startup) { run "echo starting up"}
|
183
|
-
end
|
177
|
+
it "needs to verify a callback exists for a task before another" do
|
178
|
+
@config.before :stop, :warn_people
|
184
179
|
|
185
|
-
|
186
|
-
|
180
|
+
@config.must_have_callback_before :stop, :warn_people
|
181
|
+
end
|
187
182
|
|
188
|
-
|
189
|
-
|
183
|
+
it "needs to verify no callback exists for a task before another" do
|
184
|
+
@config.wont_have_callback_before :reload, :stop
|
185
|
+
end
|
190
186
|
|
191
|
-
|
192
|
-
|
193
|
-
end
|
187
|
+
it "needs to verify a callback exists for a task after another" do
|
188
|
+
@config.after :start, :init_database
|
194
189
|
|
195
|
-
|
196
|
-
|
190
|
+
@config.must_have_callback_after :start, :init_database
|
191
|
+
end
|
197
192
|
|
198
|
-
|
199
|
-
|
193
|
+
it "needs to verify no callback exists for a task after another" do
|
194
|
+
@config.wont_have_callback_after :stop, :do_taxes
|
195
|
+
end
|
200
196
|
|
201
|
-
|
202
|
-
|
203
|
-
|
197
|
+
it "needs to verify a task exists by name" do
|
198
|
+
@config.must_have_task "startup"
|
199
|
+
end
|
200
|
+
|
201
|
+
it "needs to verify no task exists by name" do
|
202
|
+
@config.wont_have_task "doofus"
|
204
203
|
end
|
205
204
|
end
|
metadata
CHANGED
@@ -1,64 +1,45 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-capistrano
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 0.0.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Fletcher Nichol
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-01-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: minitest
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70263388193960 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 4549645503570588592
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 10
|
33
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 2.10.0
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: capistrano
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *70263388193960
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: capistrano
|
27
|
+
requirement: &70263388193460 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
29
|
+
requirements:
|
43
30
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 9
|
49
|
-
version: "2.9"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.9'
|
50
33
|
type: :runtime
|
51
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70263388193460
|
52
36
|
description: MiniTest assertions and expectations for testing Capistrano recipes
|
53
|
-
email:
|
37
|
+
email:
|
54
38
|
- fnichol@nichol.ca
|
55
39
|
executables: []
|
56
|
-
|
57
40
|
extensions: []
|
58
|
-
|
59
41
|
extra_rdoc_files: []
|
60
|
-
|
61
|
-
files:
|
42
|
+
files:
|
62
43
|
- .gitignore
|
63
44
|
- .travis.yml
|
64
45
|
- Gemfile
|
@@ -70,39 +51,29 @@ files:
|
|
70
51
|
- lib/minitest/capistrano/version.rb
|
71
52
|
- minitest-capistrano.gemspec
|
72
53
|
- spec/minitest_capistrano_spec.rb
|
73
|
-
has_rdoc: true
|
74
54
|
homepage: https://github.com/fnichol/minitest-capistrano
|
75
55
|
licenses: []
|
76
|
-
|
77
56
|
post_install_message:
|
78
57
|
rdoc_options: []
|
79
|
-
|
80
|
-
require_paths:
|
58
|
+
require_paths:
|
81
59
|
- lib
|
82
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
61
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
|
89
|
-
- 0
|
90
|
-
version: "0"
|
91
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
67
|
none: false
|
93
|
-
requirements:
|
94
|
-
- -
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
97
|
-
segments:
|
98
|
-
- 0
|
99
|
-
version: "0"
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
100
72
|
requirements: []
|
101
|
-
|
102
73
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 1.8.10
|
104
75
|
signing_key:
|
105
76
|
specification_version: 3
|
106
77
|
summary: MiniTest assertions and expectations for testing Capistrano recipes
|
107
|
-
test_files:
|
78
|
+
test_files:
|
108
79
|
- spec/minitest_capistrano_spec.rb
|