form_input 0.9.0.pre1

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 (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/LICENSE +19 -0
  4. data/README.md +3160 -0
  5. data/Rakefile +19 -0
  6. data/example/controllers/ramaze/press_release.rb +104 -0
  7. data/example/controllers/ramaze/profile.rb +38 -0
  8. data/example/controllers/sinatra/press_release.rb +114 -0
  9. data/example/controllers/sinatra/profile.rb +39 -0
  10. data/example/forms/change_password_form.rb +17 -0
  11. data/example/forms/login_form.rb +14 -0
  12. data/example/forms/lost_password_form.rb +14 -0
  13. data/example/forms/new_password_form.rb +15 -0
  14. data/example/forms/password_form.rb +18 -0
  15. data/example/forms/press_release_form.rb +153 -0
  16. data/example/forms/profile_form.rb +21 -0
  17. data/example/forms/signup_form.rb +25 -0
  18. data/example/views/press_release.slim +65 -0
  19. data/example/views/profile.slim +28 -0
  20. data/example/views/snippets/form_block.slim +27 -0
  21. data/example/views/snippets/form_chunked.slim +25 -0
  22. data/example/views/snippets/form_hidden.slim +21 -0
  23. data/example/views/snippets/form_panel.slim +89 -0
  24. data/form_input.gemspec +32 -0
  25. data/lib/form_input/core.rb +1165 -0
  26. data/lib/form_input/localize.rb +49 -0
  27. data/lib/form_input/r18n/cs.yml +97 -0
  28. data/lib/form_input/r18n/en.yml +70 -0
  29. data/lib/form_input/r18n/pl.yml +122 -0
  30. data/lib/form_input/r18n/sk.yml +120 -0
  31. data/lib/form_input/r18n.rb +163 -0
  32. data/lib/form_input/steps.rb +365 -0
  33. data/lib/form_input/types.rb +176 -0
  34. data/lib/form_input/version.rb +12 -0
  35. data/lib/form_input.rb +5 -0
  36. data/test/helper.rb +21 -0
  37. data/test/localize/en.yml +63 -0
  38. data/test/r18n/cs.yml +60 -0
  39. data/test/r18n/xx.yml +51 -0
  40. data/test/reference/cs.txt +352 -0
  41. data/test/reference/cs.yml +14 -0
  42. data/test/reference/en.txt +76 -0
  43. data/test/reference/en.yml +8 -0
  44. data/test/reference/pl.txt +440 -0
  45. data/test/reference/pl.yml +16 -0
  46. data/test/reference/sk.txt +352 -0
  47. data/test/reference/sk.yml +14 -0
  48. data/test/test_core.rb +1272 -0
  49. data/test/test_localize.rb +27 -0
  50. data/test/test_r18n.rb +373 -0
  51. data/test/test_steps.rb +482 -0
  52. data/test/test_types.rb +307 -0
  53. metadata +145 -0
@@ -0,0 +1,482 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative 'helper'
4
+
5
+ require 'form_input/core'
6
+ require 'form_input/steps'
7
+ require 'rack/test'
8
+
9
+ class TestStepsForm < FormInput
10
+
11
+ define_steps(
12
+ intro: "Intro",
13
+ email: "Email",
14
+ name: "Name",
15
+ address: "Address",
16
+ message: "Message",
17
+ post: nil,
18
+ )
19
+
20
+ param! :email, tag: :email
21
+
22
+ param :first_name, tag: :name
23
+ param :last_name, tag: :name
24
+
25
+ param :street, tag: :address
26
+ param :city, tag: :address
27
+ param :zip, tag: :address
28
+
29
+ param! :message, tag: :message
30
+ param :comment, tag: :message
31
+
32
+ param :url, type: :hidden
33
+
34
+ end
35
+
36
+ describe FormInput do
37
+
38
+ STEP_PARAMS = {
39
+ email: "email=john@foo.com",
40
+ message: "message=blah",
41
+ }
42
+
43
+ def request( query )
44
+ Rack::Request.new( Rack::MockRequest.env_for( query ) )
45
+ end
46
+
47
+ def names( params )
48
+ params.map{ |x| x && x.name }
49
+ end
50
+
51
+ should 'make it possible to define steps' do
52
+ ->{ Class.new( FormInput ).define_steps( a: "A" ) }.should.not.raise
53
+ end
54
+
55
+ should 'only define step methods for step forms' do
56
+ f = FormInput.new
57
+ t = TestStepsForm.new
58
+ for name in FormInput::StepMethods.instance_methods
59
+ f.should.not.respond_to name
60
+ t.should.respond_to name
61
+ end
62
+ end
63
+
64
+ should 'provide parameters for keeping track of step state' do
65
+ f = Class.new( FormInput ).define_steps( a: "A" ).new
66
+ names( f.optional_params ).should == [ :step, :next, :last, :seen ]
67
+ names( f.enabled_params ).should == [ :step, :next, :last, :seen ]
68
+ names( f.hidden_params ).should == [ :step, :last, :seen ]
69
+ names( f.ignored_params ).should == [ :next ]
70
+ names( f.visible_params ).should == []
71
+ names( f.scalar_params ).should == [ :step, :next, :last, :seen ]
72
+ end
73
+
74
+ should 'accept valid step parameters' do
75
+ t = TestStepsForm.new( request( "?step=email&next=name&seen=intro&last=email" ) )
76
+ t.step.should == :email
77
+ t.next.should == :name
78
+ t.seen.should == :email
79
+ t.last.should == :email
80
+ end
81
+
82
+ should 'silently ignore invalid step parameters' do
83
+ t = TestStepsForm.new( request( "?step=a&next=b&seen=c&last=d" ) )
84
+ t.step.should == :intro
85
+ t.next.should == :intro
86
+ t.seen.should == nil
87
+ t.last.should == :intro
88
+ end
89
+
90
+ should 'allow progressing through all steps in turn' do
91
+ seen = []
92
+ ref = [
93
+ "step=intro&next=intro&last=intro",
94
+ "step=email&next=email&last=email&seen=intro",
95
+ "step=name&next=name&last=name&seen=email&email=john%40foo.com",
96
+ "step=address&next=address&last=address&seen=name&email=john%40foo.com",
97
+ "step=message&next=message&last=message&seen=address&email=john%40foo.com",
98
+ "step=post&next=post&last=post&seen=message&email=john%40foo.com&message=blah",
99
+ "step=post&next=post&last=post&seen=post&email=john%40foo.com&message=blah",
100
+ ]
101
+
102
+ t = TestStepsForm.new
103
+ until t.seen == :post
104
+ t.url_query.should == ref.shift
105
+
106
+ t.step.should == t.next_step( seen.last )
107
+ t.next.should == t.step
108
+ t.seen.should == seen.last
109
+ t.last.should == t.step
110
+
111
+ seen << t.step
112
+
113
+ params = STEP_PARAMS[ t.step ]
114
+
115
+ t.next = t.next_step
116
+ t = TestStepsForm.new( request( t.extend_url( "?#{params}" ) ) )
117
+ end
118
+
119
+ t.url_query.should == ref.shift
120
+ ref.should.be.empty?
121
+ seen.should == t.steps
122
+ end
123
+
124
+ should 'refuse progressing until all step parameters are valid' do
125
+ ref = [
126
+ "step=intro&next=intro&last=intro",
127
+ "step=email&next=email&last=email&seen=intro",
128
+ "step=email&next=name&last=email&seen=email",
129
+ "step=name&next=name&last=name&seen=email&email=john%40foo.com",
130
+ "step=address&next=address&last=address&seen=name&email=john%40foo.com",
131
+ "step=message&next=message&last=message&seen=address&email=john%40foo.com",
132
+ "step=message&next=post&last=message&seen=message&email=john%40foo.com",
133
+ "step=post&next=post&last=post&seen=message&email=john%40foo.com&message=blah",
134
+ "step=post&next=post&last=post&seen=post&email=john%40foo.com&message=blah",
135
+ "step=post&next=post&last=post&seen=post&email=john%40foo.com&message=blah",
136
+ ]
137
+
138
+ t = TestStepsForm.new
139
+ until ref.empty?
140
+ t.url_query.should == ref.shift
141
+ params = STEP_PARAMS[ t.seen ]
142
+ t.next = t.next_step
143
+ t = TestStepsForm.new( request( t.extend_url( "?#{params}" ) ) )
144
+ end
145
+ end
146
+
147
+ should 'allow stepping back through all steps in turn' do
148
+ seen = []
149
+ ref = [
150
+ "step=post&next=post&last=post&seen=post&email=john%40foo.com&message=blah",
151
+ "step=message&next=message&last=post&seen=post&email=john%40foo.com&message=blah",
152
+ "step=address&next=address&last=post&seen=post&email=john%40foo.com&message=blah",
153
+ "step=name&next=name&last=post&seen=post&email=john%40foo.com&message=blah",
154
+ "step=email&next=email&last=post&seen=post&email=john%40foo.com&message=blah",
155
+ "step=intro&next=intro&last=post&seen=post&email=john%40foo.com&message=blah",
156
+ "step=intro&next=intro&last=post&seen=post&email=john%40foo.com&message=blah",
157
+ ]
158
+
159
+ t = TestStepsForm.new( request( "?#{ref.first}" ) )
160
+ until ref.size == 1
161
+ t.url_query.should == ref.shift
162
+ seen << t.step
163
+ t.next = t.previous_step
164
+ t = TestStepsForm.new( request( t.extend_url( "?" ) ) )
165
+ end
166
+
167
+ t.url_query.should == ref.shift
168
+ ref.should.be.empty?
169
+ seen.should == t.steps.reverse
170
+ end
171
+
172
+ should 'refuse stepping back across invalid steps' do
173
+ ref = [
174
+ "step=post&next=intro&last=post&seen=post",
175
+ "step=message&next=message&last=post&seen=post",
176
+ "step=message&next=address&last=post&seen=post",
177
+ "step=address&next=address&last=post&seen=post&message=blah",
178
+ "step=name&next=name&last=post&seen=post&message=blah",
179
+ "step=email&next=email&last=post&seen=post&message=blah",
180
+ "step=email&next=intro&last=post&seen=post&message=blah",
181
+ "step=intro&next=intro&last=post&seen=post&email=john%40foo.com&message=blah",
182
+ "step=intro&next=intro&last=post&seen=post&email=john%40foo.com&message=blah",
183
+ ]
184
+
185
+ t = TestStepsForm.new.unlock_steps
186
+ t.step = t.last_step
187
+ until ref.empty?
188
+ t.url_query.should == ref.shift
189
+ params = STEP_PARAMS[ t.step ] if t.step != t.next
190
+ t.next = t.previous_step
191
+ t = TestStepsForm.new( request( t.extend_url( "?#{params}" ) ) )
192
+ end
193
+ end
194
+
195
+ should 'allow getting parameters of individual steps' do
196
+ t = TestStepsForm.new( request( "?step=name&next=address&seen=message&last=message" ) )
197
+ names( t.current_params ).should == [ :street, :city, :zip ]
198
+ names( t.other_params ).should == [ :step, :next, :last, :seen, :email, :first_name, :last_name, :message, :comment, :url ]
199
+ names( t.step_params( :email ) ).should == [ :email ]
200
+ names( t.step_params( :name ) ).should == [ :first_name, :last_name ]
201
+ names( t.step_params( :post ) ).should == []
202
+ ->{ t.step_params( :foo ) }.should.raise ArgumentError
203
+ ->{ t.step_params( nil ) }.should.raise ArgumentError
204
+ end
205
+
206
+ should 'provide methods for getting details about steps' do
207
+ t = TestStepsForm.new( request( "?step=name&next=address&seen=name&last=name&first_name=John&comment=Blah" ) )
208
+
209
+ t.form_steps.should == { intro: "Intro", email: "Email", name: "Name", address: "Address", message: "Message", post: nil }
210
+ t.steps.should == [ :intro, :email, :name, :address, :message, :post ]
211
+
212
+ t.step_name.should == "Address"
213
+ t.step_name( :email ).should == "Email"
214
+ t.step_name( :foo ).should == nil
215
+ t.step_name( nil ).should == nil
216
+ t.step_names.should == { intro: "Intro", email: "Email", name: "Name", address: "Address", message: "Message" }
217
+
218
+ t.step_index.should == 3
219
+ t.step_index( :intro ).should == 0
220
+ t.step_index( :post ).should == 5
221
+ ->{ t.step_index( :foo ) }.should.raise ArgumentError
222
+ ->{ t.step_index( nil ) }.should.raise ArgumentError
223
+
224
+ t.step_before?( :intro ).should.be.false
225
+ t.step_before?( :name ).should.be.false
226
+ t.step_before?( :address ).should.be.false
227
+ t.step_before?( :message ).should.be.true
228
+ t.step_before?( :post ).should.be.true
229
+
230
+ t.step_after?( :intro ).should.be.true
231
+ t.step_after?( :name ).should.be.true
232
+ t.step_after?( :address ).should.be.false
233
+ t.step_after?( :message ).should.be.false
234
+ t.step_after?( :post ).should.be.false
235
+
236
+ t.first_step.should == :intro
237
+ t.first_step( nil ).should == nil
238
+ t.first_step( nil, nil ).should == nil
239
+ t.first_step( :post ).should == :post
240
+ t.first_step( :address, :email ).should == :email
241
+ t.first_step( nil, :name, :address ).should == :name
242
+ t.first_step( [ :post, nil, :email ] ).should == :email
243
+ ->{ t.first_step( :foo ) }.should.raise ArgumentError
244
+ ->{ t.first_step( :email, :foo ) }.should.raise ArgumentError
245
+ ->{ t.first_step( [ nil, :foo, :address] ) }.should.raise ArgumentError
246
+
247
+ t.last_step.should == :post
248
+ t.last_step( nil ).should == nil
249
+ t.last_step( nil, nil ).should == nil
250
+ t.last_step( :post ).should == :post
251
+ t.last_step( :address, :email ).should == :address
252
+ t.last_step( nil, :name, :address ).should == :address
253
+ t.last_step( [ :post, nil, :email ] ).should == :post
254
+ ->{ t.last_step( :foo ) }.should.raise ArgumentError
255
+ ->{ t.last_step( :email, :foo ) }.should.raise ArgumentError
256
+ ->{ t.last_step( [ nil, :foo, :address] ) }.should.raise ArgumentError
257
+
258
+ t.first_step?.should.be.false
259
+ t.first_step?( :intro ).should.be.true
260
+ t.first_step?( :email ).should.be.false
261
+ t.first_step?( :name ).should.be.false
262
+ t.first_step?( :address ).should.be.false
263
+ t.first_step?( :message ).should.be.false
264
+ t.first_step?( :post ).should.be.false
265
+ t.first_step?( nil ).should.be.false
266
+ t.first_step?( :foo ).should.be.false
267
+
268
+ t.last_step?.should.be.false
269
+ t.last_step?( :intro ).should.be.false
270
+ t.last_step?( :email ).should.be.false
271
+ t.last_step?( :name ).should.be.false
272
+ t.last_step?( :address ).should.be.false
273
+ t.last_step?( :message ).should.be.false
274
+ t.last_step?( :post ).should.be.true
275
+ t.last_step?( nil ).should.be.false
276
+ t.last_step?( :foo ).should.be.false
277
+
278
+ t.previous_steps.should == [ :intro, :email, :name ]
279
+ t.previous_steps( nil ).should == []
280
+ t.previous_steps( :intro ).should == []
281
+ t.previous_steps( :name ).should == [ :intro, :email ]
282
+ t.previous_steps( :post ).should == [ :intro, :email, :name, :address, :message ]
283
+ t.previous_steps( :foo ).should == []
284
+
285
+ t.next_steps.should == [ :message, :post ]
286
+ t.next_steps( nil ).should == [ :intro, :email, :name, :address, :message, :post ]
287
+ t.next_steps( :intro ).should == [ :email, :name, :address, :message, :post ]
288
+ t.next_steps( :name ).should == [ :address, :message, :post ]
289
+ t.next_steps( :post ).should == []
290
+ t.next_steps( :foo ).should == [ :intro, :email, :name, :address, :message, :post ]
291
+
292
+ t.previous_step.should == :name
293
+ t.previous_step( nil ).should == nil
294
+ t.previous_step( :intro ).should == nil
295
+ t.previous_step( :name ).should == :email
296
+ t.previous_step( :post ).should == :message
297
+ t.previous_step( :foo ).should == nil
298
+
299
+ t.next_step.should == :message
300
+ t.next_step( nil ).should == :intro
301
+ t.next_step( :intro ).should == :email
302
+ t.next_step( :name ).should == :address
303
+ t.next_step( :post ).should == nil
304
+ t.next_step( :foo ).should == :intro
305
+
306
+ t.previous_step_name.should == "Name"
307
+ t.next_step_name.should == "Message"
308
+
309
+ t.extra_step?.should.be.false
310
+ t.extra_step?( :intro ).should.be.true
311
+ t.extra_step?( :email ).should.be.false
312
+ t.extra_step?( :name ).should.be.false
313
+ t.extra_step?( :address ).should.be.false
314
+ t.extra_step?( :message ).should.be.false
315
+ t.extra_step?( :post ).should.be.true
316
+ ->{ t.extra_step?( nil ) }.should.raise ArgumentError
317
+ ->{ t.extra_step?( :foo ) }.should.raise ArgumentError
318
+
319
+ t.regular_step?.should.be.true
320
+ t.regular_step?( :intro ).should.be.false
321
+ t.regular_step?( :email ).should.be.true
322
+ t.regular_step?( :name ).should.be.true
323
+ t.regular_step?( :address ).should.be.true
324
+ t.regular_step?( :message ).should.be.true
325
+ t.regular_step?( :post ).should.be.false
326
+ ->{ t.regular_step?( nil ) }.should.raise ArgumentError
327
+ ->{ t.regular_step?( :foo ) }.should.raise ArgumentError
328
+
329
+ t.extra_steps.should == [ :intro, :post ]
330
+ t.regular_steps.should == [ :email, :name, :address, :message ]
331
+
332
+ t.required_step?.should.be.false
333
+ t.required_step?( :intro ).should.be.false
334
+ t.required_step?( :email ).should.be.true
335
+ t.required_step?( :name ).should.be.false
336
+ t.required_step?( :address ).should.be.false
337
+ t.required_step?( :message ).should.be.true
338
+ t.required_step?( :post ).should.be.false
339
+ ->{ t.required_step?( nil ) }.should.raise ArgumentError
340
+ ->{ t.required_step?( :foo ) }.should.raise ArgumentError
341
+
342
+ t.optional_step?.should.be.true
343
+ t.optional_step?( :intro ).should.be.true
344
+ t.optional_step?( :email ).should.be.false
345
+ t.optional_step?( :name ).should.be.true
346
+ t.optional_step?( :address ).should.be.true
347
+ t.optional_step?( :message ).should.be.false
348
+ t.optional_step?( :post ).should.be.true
349
+ ->{ t.optional_step?( nil ) }.should.raise ArgumentError
350
+ ->{ t.optional_step?( :foo ) }.should.raise ArgumentError
351
+
352
+ t.required_steps.should == [ :email, :message ]
353
+ t.optional_steps.should == [ :name, :address ]
354
+
355
+ t.filled_step?.should.be.false
356
+ t.filled_step?( :intro ).should.be.true
357
+ t.filled_step?( :email ).should.be.false
358
+ t.filled_step?( :name ).should.be.true
359
+ t.filled_step?( :address ).should.be.false
360
+ t.filled_step?( :message ).should.be.true
361
+ t.filled_step?( :post ).should.be.true
362
+ ->{ t.filled_step?( nil ) }.should.raise ArgumentError
363
+ ->{ t.filled_step?( :foo ) }.should.raise ArgumentError
364
+
365
+ t.unfilled_step?.should.be.true
366
+ t.unfilled_step?( :intro ).should.be.false
367
+ t.unfilled_step?( :email ).should.be.true
368
+ t.unfilled_step?( :name ).should.be.false
369
+ t.unfilled_step?( :address ).should.be.true
370
+ t.unfilled_step?( :message ).should.be.false
371
+ t.unfilled_step?( :post ).should.be.false
372
+ ->{ t.unfilled_step?( nil ) }.should.raise ArgumentError
373
+ ->{ t.unfilled_step?( :foo ) }.should.raise ArgumentError
374
+
375
+ t.filled_steps.should == [ :name, :message ]
376
+ t.unfilled_steps.should == [ :email, :address ]
377
+
378
+ t.correct_step?.should.be.true
379
+ t.correct_step?( :intro ).should.be.true
380
+ t.correct_step?( :email ).should.be.false
381
+ t.correct_step?( :name ).should.be.true
382
+ t.correct_step?( :address ).should.be.true
383
+ t.correct_step?( :message ).should.be.false
384
+ t.correct_step?( :post ).should.be.true
385
+ ->{ t.correct_step?( nil ) }.should.raise ArgumentError
386
+ ->{ t.correct_step?( :foo ) }.should.raise ArgumentError
387
+
388
+ t.incorrect_step?.should.be.false
389
+ t.incorrect_step?( :intro ).should.be.false
390
+ t.incorrect_step?( :email ).should.be.true
391
+ t.incorrect_step?( :name ).should.be.false
392
+ t.incorrect_step?( :address ).should.be.false
393
+ t.incorrect_step?( :message ).should.be.true
394
+ t.incorrect_step?( :post ).should.be.false
395
+ ->{ t.incorrect_step?( nil ) }.should.raise ArgumentError
396
+ ->{ t.incorrect_step?( :foo ) }.should.raise ArgumentError
397
+
398
+ t.correct_steps.should == [ :name, :address ]
399
+ t.incorrect_steps.should == [ :email, :message ]
400
+ t.incorrect_step.should == :email
401
+ t.dup.set( email: "x@foo.com" ).incorrect_step.should == :message
402
+ t.dup.set( email: "x@foo.com", message: "bar" ).incorrect_step.should == nil
403
+
404
+ t.enabled_step?.should.be.true
405
+ t.enabled_step?( :intro ).should.be.true
406
+ t.enabled_step?( :email ).should.be.true
407
+ t.enabled_step?( :name ).should.be.true
408
+ t.enabled_step?( :address ).should.be.true
409
+ t.enabled_step?( :message ).should.be.true
410
+ t.enabled_step?( :post ).should.be.true
411
+ ->{ t.enabled_step?( nil ) }.should.raise ArgumentError
412
+ ->{ t.enabled_step?( :foo ) }.should.raise ArgumentError
413
+
414
+ t.disabled_step?.should.be.false
415
+ t.disabled_step?( :intro ).should.be.false
416
+ t.disabled_step?( :email ).should.be.false
417
+ t.disabled_step?( :name ).should.be.false
418
+ t.disabled_step?( :address ).should.be.false
419
+ t.disabled_step?( :message ).should.be.false
420
+ t.disabled_step?( :post ).should.be.false
421
+ ->{ t.disabled_step?( nil ) }.should.raise ArgumentError
422
+ ->{ t.disabled_step?( :foo ) }.should.raise ArgumentError
423
+
424
+ t.enabled_steps.should == [ :email, :name, :address, :message ]
425
+ t.disabled_steps.should == []
426
+ c = Class.new( FormInput )
427
+ c.define_steps( TestStepsForm.form_steps )
428
+ c.copy( t.visible_params, disabled: ->{ [ :first_name, :last_name, :comment ].include? name } )
429
+ f = c.new
430
+ names( f.disabled_params ).should == [ :first_name, :last_name, :comment ]
431
+ f.enabled_steps.should == [ :email, :address, :message ]
432
+ f.disabled_steps.should == [ :name ]
433
+
434
+ t.finished_steps.should == [ :intro, :email, :name ]
435
+ t.unfinished_steps.should == [ :address, :message, :post ]
436
+ t.accessible_steps.should == [ :intro, :email, :name, :address ]
437
+ t.inaccessible_steps.should == [ :message, :post ]
438
+ t.complete_steps.should == [ :intro, :name ]
439
+ t.incomplete_steps.should == [ :email ]
440
+ t.good_steps.should == [ :name ]
441
+ t.bad_steps.should == [ :email ]
442
+
443
+ check = ->( form ){
444
+ %w[ finished_step unfinished_step accessible_step inaccessible_step complete_step incomplete_step good_step bad_step ].each do |name|
445
+ method = "#{name}?"
446
+ form.send( method ).should == form.send( method, form.step )
447
+ form.steps.each{ |x| form.send( method, x ).should == form.send( "#{name}s" ).include?( x ) }
448
+ ->{ form.send( method, nil ) }.should.raise ArgumentError
449
+ ->{ form.send( method, :foo ) }.should.raise ArgumentError
450
+ end
451
+ }
452
+
453
+ check.call(t)
454
+
455
+ t = TestStepsForm.new
456
+ t.finished_steps.should == []
457
+ t.unfinished_steps.should == [ :intro, :email, :name, :address, :message, :post ]
458
+ t.accessible_steps.should == [ :intro ]
459
+ t.inaccessible_steps.should == [ :email, :name, :address, :message, :post ]
460
+ t.complete_steps.should == []
461
+ t.incomplete_steps.should == []
462
+ t.good_steps.should == []
463
+ t.bad_steps.should == []
464
+
465
+ check.call(t)
466
+
467
+ t = TestStepsForm.new.unlock_steps
468
+ t.finished_steps.should == [ :intro, :email, :name, :address, :message, :post ]
469
+ t.unfinished_steps.should == []
470
+ t.accessible_steps.should == [ :intro, :email, :name, :address, :message, :post ]
471
+ t.inaccessible_steps.should == []
472
+ t.complete_steps.should == [ :intro, :name, :address, :post ]
473
+ t.incomplete_steps.should == [ :email, :message ]
474
+ t.good_steps.should == []
475
+ t.bad_steps.should == [ :email, :message ]
476
+
477
+ check.call(t)
478
+ end
479
+
480
+ end
481
+
482
+ # EOF #