methodical 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/methodical.rb +1 -0
- data/lib/methodical/action_item.rb +139 -0
- data/lib/methodical/checklist.rb +29 -0
- data/lib/methodical/disposition.rb +132 -0
- data/lib/methodical/dsl.rb +111 -0
- data/lib/methodical/executable.rb +61 -0
- data/lib/methodical/modifier.rb +43 -0
- data/lib/methodical/simple_action_item.rb +30 -0
- data/lib/methodical/walkthrough.rb +143 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/test/methodical/checklist_test.rb +79 -0
- data/test/methodical/disposition_test.rb +120 -0
- data/test/methodical/dsl_test.rb +217 -0
- data/test/methodical/modifier_test.rb +79 -0
- data/test/methodical/simple_action_item_test.rb +825 -0
- data/test/methodical/walkthrough_test.rb +387 -0
- data/test/test_helper.rb +2 -0
- metadata +147 -0
@@ -0,0 +1,387 @@
|
|
1
|
+
require File.expand_path("../test_helper", File.dirname(__FILE__))
|
2
|
+
require 'methodical/walkthrough'
|
3
|
+
require 'methodical/disposition'
|
4
|
+
require 'methodical/simple_action_item'
|
5
|
+
|
6
|
+
class ActionItemTest < Test::Unit::TestCase
|
7
|
+
def create_disposition(status)
|
8
|
+
Methodical::Disposition.new([status, "", nil])
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_step(status)
|
12
|
+
step = Methodical::SimpleActionItem.new("#{status} step") {
|
13
|
+
[status, "", nil]
|
14
|
+
}
|
15
|
+
|
16
|
+
# Making #dup return self simplifies setting expectations
|
17
|
+
def step.clone
|
18
|
+
self
|
19
|
+
end
|
20
|
+
step
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_succeeding_step
|
24
|
+
create_step(:succeeded)
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_failing_step
|
28
|
+
create_step(:failed)
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_bad_step
|
32
|
+
create_step(:bad)
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_skipped_step
|
36
|
+
create_step(:skipped)
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_sufficient_step
|
40
|
+
create_step(:sufficient)
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_aborting_step
|
44
|
+
create_step(:abort)
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_finishing_step
|
48
|
+
create_step(:finish)
|
49
|
+
end
|
50
|
+
|
51
|
+
context "given a checklist" do
|
52
|
+
specify "gets its title from the checklist" do
|
53
|
+
checklist = stub_everything("Checklist", :title => "TITLE", :map => [])
|
54
|
+
it = Methodical::Walkthrough.new(checklist)
|
55
|
+
assert_equal "TITLE", it.title
|
56
|
+
end
|
57
|
+
|
58
|
+
specify "starts in the :not_started state" do
|
59
|
+
it = Methodical::Walkthrough.new([])
|
60
|
+
assert !it.started?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "given some steps" do
|
65
|
+
specify "sets step walkthroughs to self" do
|
66
|
+
step1 = create_succeeding_step
|
67
|
+
step2 = create_succeeding_step
|
68
|
+
it = Methodical::Walkthrough.new([step1, step2])
|
69
|
+
assert_same it, it[0].walkthrough
|
70
|
+
assert_same it, it[1].walkthrough
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
context "#perform!" do
|
76
|
+
specify "updates status callback before and after each step" do
|
77
|
+
step1 = create_skipped_step
|
78
|
+
step2 = create_succeeding_step
|
79
|
+
step3 = create_aborting_step
|
80
|
+
step4 = create_succeeding_step
|
81
|
+
|
82
|
+
sensor = stub("Sensor")
|
83
|
+
baton = stub("Baton")
|
84
|
+
|
85
|
+
it = Methodical::Walkthrough.new([
|
86
|
+
step1, step2, step3, step4
|
87
|
+
])
|
88
|
+
|
89
|
+
sensor.expects(:update).with(it, 0, step1, baton).in_sequence
|
90
|
+
step1.expects(:call).returns(create_disposition(:skipped)).in_sequence
|
91
|
+
sensor.expects(:update).with(it, 0, step1, baton).in_sequence
|
92
|
+
|
93
|
+
sensor.expects(:update).with(it, 1, step2, baton).in_sequence
|
94
|
+
step2.expects(:call).returns(create_disposition(:succeeded)).in_sequence
|
95
|
+
sensor.expects(:update).with(it, 1, step2, baton).in_sequence
|
96
|
+
|
97
|
+
sensor.expects(:update).with(it, 2, step3, baton).in_sequence
|
98
|
+
step3.expects(:call).returns(create_disposition(:abort)).in_sequence
|
99
|
+
sensor.expects(:update).with(it, 2, step3, baton).in_sequence
|
100
|
+
|
101
|
+
sensor.expects(:update).with(it, 3, step4, baton).in_sequence
|
102
|
+
step4.expects(:call).never
|
103
|
+
sensor.expects(:update).with(it, 3, step4, baton).in_sequence
|
104
|
+
|
105
|
+
it.perform!(baton) do |*args|
|
106
|
+
sensor.update(*args)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
specify "saves baton" do
|
111
|
+
baton = stub("Baton")
|
112
|
+
|
113
|
+
it = Methodical::Walkthrough.new([])
|
114
|
+
it.perform!(baton)
|
115
|
+
assert_same baton, it.baton
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "#basic_report" do
|
120
|
+
specify "includes a list of synopses" do
|
121
|
+
it = Methodical::Walkthrough.new([
|
122
|
+
stub(:clone => stub_everything(:synopsis => "SYNOPSIS1")),
|
123
|
+
stub(:clone => stub_everything(:synopsis => "SYNOPSIS2")),
|
124
|
+
stub(:clone => stub_everything(:synopsis => "SYNOPSIS3")),
|
125
|
+
])
|
126
|
+
assert_equal "SYNOPSIS1\nSYNOPSIS2\nSYNOPSIS3\n", it.basic_report
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "with no steps" do
|
131
|
+
specify "ends in the :succeeded state" do
|
132
|
+
it = Methodical::Walkthrough.new([])
|
133
|
+
it.perform!
|
134
|
+
assert it.succeeded?
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "with succeeding steps" do
|
139
|
+
specify "ends in the :succeeded state" do
|
140
|
+
it = Methodical::Walkthrough.new([create_succeeding_step])
|
141
|
+
it.perform!
|
142
|
+
assert it.succeeded?
|
143
|
+
end
|
144
|
+
|
145
|
+
specify "considers the last step decisive" do
|
146
|
+
it = Methodical::Walkthrough.new([create_succeeding_step])
|
147
|
+
it.perform!
|
148
|
+
assert_equal 0, it.decisive_index
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context "interrupted in the middle" do
|
153
|
+
specify "is in the :in_progress state" do
|
154
|
+
step = create_succeeding_step
|
155
|
+
step.stubs(:call).raises(SignalException.new("INT"))
|
156
|
+
it = Methodical::Walkthrough.new([step])
|
157
|
+
begin
|
158
|
+
it.perform!
|
159
|
+
rescue SignalException
|
160
|
+
end
|
161
|
+
assert_equal :in_progress, it.status
|
162
|
+
assert it.in_progress?
|
163
|
+
assert !it.succeeded?
|
164
|
+
assert !it.failed?
|
165
|
+
assert !it.finished?
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context "with a failing step" do
|
170
|
+
specify "ends in the :failed state" do
|
171
|
+
it = Methodical::Walkthrough.new([create_failing_step])
|
172
|
+
it.perform!
|
173
|
+
assert_equal :failed, it.status
|
174
|
+
end
|
175
|
+
|
176
|
+
specify "considers the last step decisive" do
|
177
|
+
it = Methodical::Walkthrough.new([create_failing_step])
|
178
|
+
it.perform!
|
179
|
+
assert_equal 0, it.decisive_index
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context "with a bad step" do
|
184
|
+
specify "ends in the :failed state" do
|
185
|
+
it = Methodical::Walkthrough.new([create_bad_step])
|
186
|
+
it.perform!
|
187
|
+
assert_equal :failed, it.status
|
188
|
+
end
|
189
|
+
|
190
|
+
specify "considers the last step decisive" do
|
191
|
+
it = Methodical::Walkthrough.new([create_failing_step])
|
192
|
+
it.perform!
|
193
|
+
assert_equal 0, it.decisive_index
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context "with steps that fail, then succeed" do
|
198
|
+
specify "ends in the :failed state" do
|
199
|
+
it = Methodical::Walkthrough.new([
|
200
|
+
create_failing_step,
|
201
|
+
create_succeeding_step
|
202
|
+
])
|
203
|
+
it.perform!
|
204
|
+
assert_equal :failed, it.status
|
205
|
+
end
|
206
|
+
|
207
|
+
specify "has one failed step" do
|
208
|
+
it = Methodical::Walkthrough.new([
|
209
|
+
fail_step = create_failing_step,
|
210
|
+
create_succeeding_step
|
211
|
+
])
|
212
|
+
it.perform!
|
213
|
+
assert_equal [fail_step], it.failed_steps
|
214
|
+
end
|
215
|
+
|
216
|
+
# specify "does not set the ignore bit on the second step" do
|
217
|
+
# it = Methodical::Walkthrough.new([
|
218
|
+
# create_failing_step,
|
219
|
+
# step2 = stub_everything(:call => create_disposition(:succeeded))
|
220
|
+
# ])
|
221
|
+
# step2.expects(:ignored=).never
|
222
|
+
# it.perform!
|
223
|
+
# end
|
224
|
+
|
225
|
+
specify "considers the first step to be the decisive step" do
|
226
|
+
it = Methodical::Walkthrough.new([
|
227
|
+
create_failing_step,
|
228
|
+
create_succeeding_step
|
229
|
+
])
|
230
|
+
it.perform!
|
231
|
+
assert_equal 0, it.decisive_index
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
context "with steps that succeed, then fail" do
|
237
|
+
specify "ends in the :failed state" do
|
238
|
+
it = Methodical::Walkthrough.new([
|
239
|
+
create_succeeding_step,
|
240
|
+
create_failing_step,
|
241
|
+
])
|
242
|
+
it.perform!
|
243
|
+
assert_equal :failed, it.status
|
244
|
+
end
|
245
|
+
|
246
|
+
specify "considers the last step to be the decisive step" do
|
247
|
+
it = Methodical::Walkthrough.new([
|
248
|
+
create_succeeding_step,
|
249
|
+
create_failing_step,
|
250
|
+
])
|
251
|
+
it.perform!
|
252
|
+
assert_equal 1, it.decisive_index
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
context "with a skipped step" do
|
257
|
+
specify "ends in the :succeeded state" do
|
258
|
+
it = Methodical::Walkthrough.new([
|
259
|
+
create_skipped_step
|
260
|
+
])
|
261
|
+
it.perform!
|
262
|
+
assert_equal :succeeded, it.status
|
263
|
+
end
|
264
|
+
|
265
|
+
end
|
266
|
+
|
267
|
+
context "with an aborting step preceding a succeding step" do
|
268
|
+
specify "ends in the :failed state" do
|
269
|
+
it = Methodical::Walkthrough.new([
|
270
|
+
create_aborting_step,
|
271
|
+
create_succeeding_step
|
272
|
+
])
|
273
|
+
it.perform!
|
274
|
+
assert_equal :failed, it.status
|
275
|
+
end
|
276
|
+
|
277
|
+
specify "does not execute second step" do
|
278
|
+
it = Methodical::Walkthrough.new([
|
279
|
+
create_aborting_step,
|
280
|
+
step2 = stub_everything("Succeeding Step")
|
281
|
+
])
|
282
|
+
step2.expects(:call).never
|
283
|
+
it.perform!
|
284
|
+
end
|
285
|
+
|
286
|
+
specify "updates status of skipped step" do
|
287
|
+
it = Methodical::Walkthrough.new([
|
288
|
+
create_aborting_step,
|
289
|
+
step2 = stub_everything("Succeeding Step")
|
290
|
+
])
|
291
|
+
step2.expects(:update!).
|
292
|
+
with(:skipped, "Run aborted by prior step", nil)
|
293
|
+
it.perform!
|
294
|
+
end
|
295
|
+
|
296
|
+
specify "considers the aborted step the decisive step" do
|
297
|
+
it = Methodical::Walkthrough.new([
|
298
|
+
create_aborting_step,
|
299
|
+
create_succeeding_step
|
300
|
+
])
|
301
|
+
it.perform!
|
302
|
+
assert_equal 0, it.decisive_index
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
context "with a finishing step preceding a succeding step" do
|
307
|
+
specify "ends in the :succeeded state" do
|
308
|
+
it = Methodical::Walkthrough.new([
|
309
|
+
create_finishing_step,
|
310
|
+
create_succeeding_step
|
311
|
+
])
|
312
|
+
it.perform!
|
313
|
+
assert_equal :succeeded, it.status
|
314
|
+
end
|
315
|
+
|
316
|
+
specify "does not execute second step" do
|
317
|
+
it = Methodical::Walkthrough.new([
|
318
|
+
create_finishing_step,
|
319
|
+
step2 = stub_everything("Succeeding Step")
|
320
|
+
])
|
321
|
+
step2.expects(:call).never
|
322
|
+
it.perform!
|
323
|
+
end
|
324
|
+
|
325
|
+
specify "updates status of skipped step" do
|
326
|
+
it = Methodical::Walkthrough.new([
|
327
|
+
create_finishing_step,
|
328
|
+
step2 = stub_everything("Succeeding Step")
|
329
|
+
])
|
330
|
+
step2.expects(:update!).
|
331
|
+
with(:skipped, "Satisfied by prior step", nil)
|
332
|
+
it.perform!
|
333
|
+
end
|
334
|
+
|
335
|
+
specify "considers the finishing step the decisive step" do
|
336
|
+
it = Methodical::Walkthrough.new([
|
337
|
+
create_finishing_step,
|
338
|
+
create_succeeding_step
|
339
|
+
])
|
340
|
+
it.perform!
|
341
|
+
assert_equal 0, it.decisive_index
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
context "with a sufficient step preceding a failing step" do
|
346
|
+
specify "ends in the :succeeded state" do
|
347
|
+
it = Methodical::Walkthrough.new([
|
348
|
+
create_sufficient_step,
|
349
|
+
create_failing_step
|
350
|
+
])
|
351
|
+
it.perform!
|
352
|
+
assert_equal :succeeded, it.status
|
353
|
+
end
|
354
|
+
|
355
|
+
specify "executes second step" do
|
356
|
+
it = Methodical::Walkthrough.new([
|
357
|
+
create_sufficient_step,
|
358
|
+
step2 = stub_everything("Failing Step")
|
359
|
+
])
|
360
|
+
step2.expects(:execute!).
|
361
|
+
returns(create_disposition(:failed))
|
362
|
+
it.perform!
|
363
|
+
end
|
364
|
+
|
365
|
+
specify "sets ignore bit on second step" do
|
366
|
+
it = Methodical::Walkthrough.new([
|
367
|
+
create_sufficient_step,
|
368
|
+
step2 = stub_everything("Failing Step",
|
369
|
+
:execute! => create_disposition(:failed))
|
370
|
+
])
|
371
|
+
step2.expects(:ignored=).with(true)
|
372
|
+
it.perform!
|
373
|
+
end
|
374
|
+
|
375
|
+
specify "considers the sufficient step the decisive step" do
|
376
|
+
it = Methodical::Walkthrough.new([
|
377
|
+
create_sufficient_step,
|
378
|
+
create_succeeding_step
|
379
|
+
])
|
380
|
+
it.perform!
|
381
|
+
assert_equal 0, it.decisive_index
|
382
|
+
end
|
383
|
+
|
384
|
+
|
385
|
+
end
|
386
|
+
|
387
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: methodical
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Avdi Grimm
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-31 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: extlib
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 9
|
30
|
+
- 14
|
31
|
+
version: 0.9.14
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: arrayfields
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 4
|
43
|
+
- 7
|
44
|
+
version: "4.7"
|
45
|
+
type: :runtime
|
46
|
+
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
prerelease: false
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 1
|
56
|
+
- 2
|
57
|
+
- 9
|
58
|
+
version: 1.2.9
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id003
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: mocha
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
- 9
|
71
|
+
- 8
|
72
|
+
version: 0.9.8
|
73
|
+
type: :development
|
74
|
+
version_requirements: *id004
|
75
|
+
description: Sorry, no description yet
|
76
|
+
email: avdi@avdi.org
|
77
|
+
executables: []
|
78
|
+
|
79
|
+
extensions: []
|
80
|
+
|
81
|
+
extra_rdoc_files:
|
82
|
+
- LICENSE
|
83
|
+
- README.rdoc
|
84
|
+
files:
|
85
|
+
- .document
|
86
|
+
- .gitignore
|
87
|
+
- LICENSE
|
88
|
+
- README.rdoc
|
89
|
+
- Rakefile
|
90
|
+
- VERSION
|
91
|
+
- lib/methodical.rb
|
92
|
+
- lib/methodical/action_item.rb
|
93
|
+
- lib/methodical/checklist.rb
|
94
|
+
- lib/methodical/disposition.rb
|
95
|
+
- lib/methodical/dsl.rb
|
96
|
+
- lib/methodical/executable.rb
|
97
|
+
- lib/methodical/modifier.rb
|
98
|
+
- lib/methodical/simple_action_item.rb
|
99
|
+
- lib/methodical/walkthrough.rb
|
100
|
+
- spec/spec.opts
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
- test/methodical/checklist_test.rb
|
103
|
+
- test/methodical/disposition_test.rb
|
104
|
+
- test/methodical/dsl_test.rb
|
105
|
+
- test/methodical/modifier_test.rb
|
106
|
+
- test/methodical/simple_action_item_test.rb
|
107
|
+
- test/methodical/walkthrough_test.rb
|
108
|
+
- test/test_helper.rb
|
109
|
+
has_rdoc: true
|
110
|
+
homepage: http://github.com/avdi/methodical
|
111
|
+
licenses: []
|
112
|
+
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options:
|
115
|
+
- --charset=UTF-8
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
version: "0"
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
version: "0"
|
132
|
+
requirements: []
|
133
|
+
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 1.3.6
|
136
|
+
signing_key:
|
137
|
+
specification_version: 3
|
138
|
+
summary: Automation framework for sequential operations
|
139
|
+
test_files:
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
- test/methodical/dsl_test.rb
|
142
|
+
- test/methodical/simple_action_item_test.rb
|
143
|
+
- test/methodical/disposition_test.rb
|
144
|
+
- test/methodical/modifier_test.rb
|
145
|
+
- test/methodical/checklist_test.rb
|
146
|
+
- test/methodical/walkthrough_test.rb
|
147
|
+
- test/test_helper.rb
|