stair_master 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/{LICENSE → MIT-LICENSE} +1 -1
  3. data/README.md +5 -6
  4. data/Rakefile +2 -2
  5. data/app/concerns/stair_master/controller.rb +20 -10
  6. data/lib/stair_master/concerns/ordering.rb +1 -6
  7. data/lib/stair_master/concerns/tests.rb +0 -5
  8. data/lib/stair_master/concerns/traversal.rb +1 -1
  9. data/lib/stair_master/conditions.rb +0 -1
  10. data/lib/stair_master/conditions/base.rb +0 -8
  11. data/lib/stair_master/step.rb +2 -10
  12. data/lib/stair_master/version.rb +1 -1
  13. data/spec/controllers/base/ordering_spec.rb +0 -23
  14. data/spec/controllers/base/skip_if_spec.rb +395 -0
  15. data/spec/controllers/base/skip_unless_spec.rb +151 -0
  16. data/spec/controllers/base/traversal_spec.rb +247 -158
  17. data/spec/dummy/Rakefile +1 -1
  18. data/spec/dummy/app/controllers/concerns/skip_if_methods.rb +24 -0
  19. data/spec/dummy/app/controllers/concerns/skip_unless_methods.rb +24 -0
  20. data/spec/dummy/app/controllers/skip_if/step_one_controller.rb +11 -0
  21. data/spec/dummy/app/controllers/skip_if/step_three_controller.rb +11 -0
  22. data/spec/dummy/app/controllers/skip_if/step_two_controller.rb +11 -0
  23. data/spec/dummy/app/controllers/skip_unless/step_one_controller.rb +11 -0
  24. data/spec/dummy/app/controllers/skip_unless/step_three_controller.rb +11 -0
  25. data/spec/dummy/app/controllers/skip_unless/step_two_controller.rb +11 -0
  26. data/spec/dummy/app/steps/skip_if_map.rb +11 -0
  27. data/spec/dummy/app/steps/skip_unless_map.rb +11 -0
  28. data/spec/dummy/config/routes.rb +12 -0
  29. data/spec/dummy/log/development.log +0 -227
  30. data/spec/dummy/log/test.log +14941 -875
  31. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  32. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  33. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  34. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  35. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  36. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  37. data/spec/spec_helper.rb +0 -1
  38. metadata +78 -108
  39. data/.gitignore +0 -18
  40. data/.rspec +0 -1
  41. data/Gemfile +0 -4
  42. data/Gemfile.lock +0 -152
  43. data/Guardfile +0 -16
  44. data/LICENSE.txt +0 -22
  45. data/lib/stair_master/conditions/availability.rb +0 -13
  46. data/spec/controllers/base/getters_spec.rb +0 -9
  47. data/spec/dummy/app/assets/images/.keep +0 -0
  48. data/spec/dummy/app/mailers/.keep +0 -0
  49. data/spec/dummy/app/models/.keep +0 -0
  50. data/spec/dummy/app/models/concerns/.keep +0 -0
  51. data/spec/dummy/app/steps/available_if_map.rb +0 -13
  52. data/spec/dummy/lib/assets/.keep +0 -0
  53. data/spec/dummy/log/.keep +0 -0
  54. data/stair_master.gemspec +0 -33
@@ -0,0 +1,151 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'when skip_unless condition is defined' do
4
+ describe '#previous_step' do
5
+ context 'when first step' do
6
+ before(:all) {
7
+ @controller = SkipUnless::StepOneController.new
8
+ }
9
+
10
+ it 'should be nil' do
11
+ SkipUnless::StepOneController.any_instance.stubs(:dont_skip_step_one?).returns(true)
12
+ get :show
13
+
14
+ expect(subject.previous_step).to be_nil
15
+ end
16
+ end
17
+
18
+ context 'when second step' do
19
+ context 'when should NOT be skipped' do
20
+ before(:all) {
21
+ @controller = SkipUnless::StepTwoController.new
22
+ }
23
+
24
+ it 'should get step 1' do
25
+ SkipUnless::StepTwoController.any_instance.stubs(:dont_skip_step_one?).returns(true)
26
+ SkipUnless::StepTwoController.any_instance.stubs(:dont_skip_step_two?).returns(true)
27
+ get :show
28
+
29
+ expect(subject.previous_step.label).to eq 'Step 1'
30
+ end
31
+ end
32
+
33
+ context 'when should be skipped' do
34
+ before(:all) {
35
+ @controller = SkipUnless::StepTwoController.new
36
+ }
37
+
38
+ it 'should return nil' do
39
+ SkipUnless::StepTwoController.any_instance.stubs(:dont_skip_step_two?).returns(true)
40
+ get :show
41
+
42
+ expect(subject.previous_step).to be_nil
43
+ end
44
+ end
45
+ end
46
+
47
+ context 'when third step' do
48
+ context 'when should NOT be skipped' do
49
+ before(:all) {
50
+ @controller = SkipUnless::StepThreeController.new
51
+ }
52
+
53
+ it 'should get step 2' do
54
+ SkipUnless::StepThreeController.any_instance.stubs(:dont_skip_step_two?).returns(true)
55
+ SkipUnless::StepThreeController.any_instance.stubs(:dont_skip_step_three?).returns(true)
56
+ get :show
57
+
58
+ expect(subject.previous_step.label).to eq 'Step 2'
59
+ end
60
+ end
61
+
62
+ context 'when should be skipped' do
63
+ before(:all) {
64
+ @controller = SkipUnless::StepThreeController.new
65
+ }
66
+
67
+ it 'should be step 1' do
68
+ SkipUnless::StepThreeController.any_instance.stubs(:dont_skip_step_one?).returns(true)
69
+ SkipUnless::StepThreeController.any_instance.stubs(:dont_skip_step_three?).returns(true)
70
+ get :show
71
+
72
+ expect(subject.previous_step.label).to eq 'Step 1'
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ describe '#next_step' do
79
+ context 'when first step' do
80
+ context 'when should NOT be skipped' do
81
+ before(:all) {
82
+ @controller = SkipUnless::StepOneController.new
83
+ }
84
+
85
+ it 'should get step 2' do
86
+ SkipUnless::StepOneController.any_instance.stubs(:dont_skip_step_one?).returns(true)
87
+ SkipUnless::StepOneController.any_instance.stubs(:dont_skip_step_two?).returns(true)
88
+ get :show
89
+
90
+ expect(subject.next_step.label).to eq 'Step 2'
91
+ end
92
+ end
93
+
94
+ context 'when should be skipped' do
95
+ before(:all) {
96
+ @controller = SkipUnless::StepOneController.new
97
+ }
98
+
99
+ it 'should get step 3' do
100
+ SkipUnless::StepOneController.any_instance.stubs(:dont_skip_step_one?).returns(true)
101
+ SkipUnless::StepOneController.any_instance.stubs(:dont_skip_step_three?).returns(true)
102
+ get :show
103
+
104
+ expect(subject.next_step.label).to eq 'Step 3'
105
+ end
106
+ end
107
+ end
108
+
109
+ context 'when second step' do
110
+ context 'when should NOT be skipped' do
111
+ before(:all) {
112
+ @controller = SkipUnless::StepTwoController.new
113
+ }
114
+
115
+ it 'should be step 3' do
116
+ SkipUnless::StepTwoController.any_instance.stubs(:dont_skip_step_two?).returns(true)
117
+ SkipUnless::StepTwoController.any_instance.stubs(:dont_skip_step_three?).returns(true)
118
+ get :show
119
+
120
+ expect(subject.next_step.label).to eq 'Step 3'
121
+ end
122
+ end
123
+
124
+ context 'when should be skipped' do
125
+ before(:all) {
126
+ @controller = SkipUnless::StepTwoController.new
127
+ }
128
+
129
+ it 'should return nil' do
130
+ SkipUnless::StepTwoController.any_instance.stubs(:dont_skip_step_two?).returns(true)
131
+ get :show
132
+
133
+ expect(subject.next_step).to be_nil
134
+ end
135
+ end
136
+ end
137
+
138
+ context 'when third step' do
139
+ before(:all) {
140
+ @controller = SkipUnless::StepThreeController.new
141
+ }
142
+
143
+ it 'should get step 2' do
144
+ SkipUnless::StepThreeController.any_instance.stubs(:dont_skip_step_three?).returns(true)
145
+ get :show
146
+
147
+ expect(subject.next_step).to be_nil
148
+ end
149
+ end
150
+ end
151
+ end
@@ -1,255 +1,344 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'traversal' do
4
- context 'when first step' do
5
- before(:all){
6
- @controller = Base::StepOneController.new
7
- }
8
-
9
- describe 'current_step methods' do
10
- describe '#current_step' do
11
- it 'should be "Step 1"' do
12
- get :show
13
-
14
- expect(subject.current_step.label).to eq 'Step 1'
15
- end
4
+ describe '#current_step' do
5
+ context 'when first step' do
6
+ before(:all){
7
+ @controller = Base::StepOneController.new
8
+ }
9
+
10
+ it 'should get step' do
11
+ get :show
12
+
13
+ expect(subject.current_step.label).to eq 'Step 1'
16
14
  end
15
+ end
16
+
17
+ context 'when middle step' do
18
+ before(:all){
19
+ @controller = Base::StepTwoController.new
20
+ }
17
21
 
18
- describe '#current_step_index' do
19
- it 'should be 0' do
20
- get :show
22
+ it 'should get step' do
23
+ get :show
21
24
 
22
- expect(subject.current_step_index).to eq 0
23
- end
25
+ expect(subject.current_step.label).to eq 'Step 2'
24
26
  end
27
+ end
28
+
29
+ context 'when last step' do
30
+ before(:all){
31
+ @controller = Base::StepThreeController.new
32
+ }
25
33
 
26
- describe '#current_step_name' do
27
- it 'should be :step_one' do
28
- get :show
34
+ it 'should get step' do
35
+ get :show
29
36
 
30
- expect(subject.current_step_name).to eq :step_one
31
- end
37
+ expect(subject.current_step.label).to eq 'Step 3'
32
38
  end
33
39
  end
40
+ end
34
41
 
35
- describe 'previous_step methods' do
42
+ describe '#current_step_index' do
43
+ context 'when first step' do
44
+ before(:all){
45
+ @controller = Base::StepOneController.new
46
+ }
36
47
 
37
- describe '#previous_step' do
38
- it 'should be nil' do
39
- get :show
48
+ it 'should get step' do
49
+ get :show
40
50
 
41
- expect(subject.previous_step).to be_nil
42
- end
51
+ expect(subject.current_step_index).to eq 0
43
52
  end
53
+ end
54
+
55
+ context 'when middle step' do
56
+ before(:all){
57
+ @controller = Base::StepTwoController.new
58
+ }
44
59
 
45
- describe '#previous_step_index' do
46
- it 'should be nil' do
47
- get :show
60
+ it 'should get step' do
61
+ get :show
48
62
 
49
- expect(subject.previous_step_index).to be_nil
50
- end
63
+ expect(subject.current_step_index).to eq 1
51
64
  end
65
+ end
52
66
 
53
- describe '#previous_step_name' do
54
- it 'should be nil' do
55
- get :show
67
+ context 'when last step' do
68
+ before(:all){
69
+ @controller = Base::StepThreeController.new
70
+ }
56
71
 
57
- expect(subject.previous_step_name).to be_nil
58
- end
72
+ it 'should get step' do
73
+ get :show
74
+
75
+ expect(subject.current_step_index).to eq 2
59
76
  end
60
77
  end
78
+ end
79
+
80
+ describe '#current_step_name' do
81
+ context 'when first step' do
82
+ before(:all){
83
+ @controller = Base::StepOneController.new
84
+ }
61
85
 
62
- describe 'next_step methods' do
63
- describe '#next_step' do
64
- it 'should "Step 2"' do
65
- get :show
86
+ it 'should get step' do
87
+ get :show
66
88
 
67
- expect(subject.next_step.label).to eq 'Step 2'
68
- end
89
+ expect(subject.current_step_name).to eq :step_one
69
90
  end
91
+ end
92
+
93
+ context 'when middle step' do
94
+ before(:all){
95
+ @controller = Base::StepTwoController.new
96
+ }
70
97
 
71
- describe '#next_step_index' do
72
- it 'should be 1' do
73
- get :show
98
+ it 'should get step' do
99
+ get :show
74
100
 
75
- expect(subject.next_step_index).to eq 1
76
- end
101
+ expect(subject.current_step_name).to eq :step_two
77
102
  end
103
+ end
78
104
 
79
- describe '#next_step_name' do
80
- it 'should be :step_two' do
81
- get :show
105
+ context 'when last step' do
106
+ before(:all){
107
+ @controller = Base::StepThreeController.new
108
+ }
82
109
 
83
- expect(subject.next_step_name).to eq :step_two
84
- end
110
+ it 'should get step' do
111
+ get :show
112
+
113
+ expect(subject.current_step_name).to eq :step_three
85
114
  end
86
115
  end
87
116
  end
88
117
 
89
- context 'when middle step' do
90
- before(:all){
91
- @controller = Base::StepTwoController.new
92
- }
118
+ describe '#previous_step' do
119
+ context 'when first step' do
120
+ before(:all){
121
+ @controller = Base::StepOneController.new
122
+ }
93
123
 
94
- describe 'current_step methods' do
95
- describe '#current_step' do
96
- it 'should be "Step 2"' do
97
- get :show
124
+ it 'should be nil' do
125
+ get :show
98
126
 
99
- expect(subject.current_step.label).to eq 'Step 2'
100
- end
127
+ expect(subject.previous_step).to be_nil
101
128
  end
129
+ end
130
+
131
+ context 'when middle step' do
132
+ before(:all){
133
+ @controller = Base::StepTwoController.new
134
+ }
102
135
 
103
- describe '#current_step_index' do
104
- it 'should be 1' do
105
- get :show
136
+ it 'should get step' do
137
+ get :show
106
138
 
107
- expect(subject.current_step_index).to eq 1
108
- end
139
+ expect(subject.previous_step.label).to eq 'Step 1'
109
140
  end
141
+ end
142
+
143
+ context 'when last step' do
144
+ before(:all){
145
+ @controller = Base::StepThreeController.new
146
+ }
110
147
 
111
- describe '#current_step_name' do
112
- it 'should be :step_one' do
113
- get :show
148
+ it 'should get step' do
149
+ get :show
114
150
 
115
- expect(subject.current_step_name).to eq :step_two
116
- end
151
+ expect(subject.previous_step.label).to eq 'Step 2'
117
152
  end
118
153
  end
154
+ end
119
155
 
120
- describe 'previous_step methods' do
121
- describe '#previous_step' do
122
- it 'should be "Step 1"' do
123
- get :show
156
+ describe '#previous_step_index' do
157
+ context 'when first step' do
158
+ before(:all){
159
+ @controller = Base::StepOneController.new
160
+ }
124
161
 
125
- expect(subject.previous_step.label).to eq 'Step 1'
126
- end
162
+ it 'should be nil' do
163
+ get :show
164
+
165
+ expect(subject.previous_step_index).to be_nil
127
166
  end
167
+ end
168
+
169
+ context 'when middle step' do
170
+ before(:all){
171
+ @controller = Base::StepTwoController.new
172
+ }
128
173
 
129
- describe '#previous_step_index' do
130
- it 'should be 0' do
131
- get :show
174
+ it 'should get step' do
175
+ get :show
132
176
 
133
- expect(subject.previous_step_index).to eq 0
134
- end
177
+ expect(subject.previous_step_index).to eq 0
135
178
  end
179
+ end
180
+
181
+ context 'when last step' do
182
+ before(:all){
183
+ @controller = Base::StepThreeController.new
184
+ }
136
185
 
137
- describe '#previous_step_name' do
138
- it 'should be :step_one' do
139
- get :show
186
+ it 'should get step' do
187
+ get :show
140
188
 
141
- expect(subject.previous_step_name).to eq :step_one
142
- end
189
+ expect(subject.previous_step_index).to eq 1
143
190
  end
144
191
  end
192
+ end
145
193
 
146
- describe 'next_step methods' do
147
- describe 'next_step' do
148
- it 'should "Step 3"' do
149
- get :show
194
+ describe '#previous_step_name' do
195
+ context 'when first step' do
196
+ before(:all){
197
+ @controller = Base::StepOneController.new
198
+ }
150
199
 
151
- expect(subject.next_step.label).to eq 'Step 3'
152
- end
200
+ it 'should be nil' do
201
+ get :show
202
+
203
+ expect(subject.previous_step_name).to be_nil
153
204
  end
205
+ end
206
+
207
+ context 'when middle step' do
208
+ before(:all){
209
+ @controller = Base::StepTwoController.new
210
+ }
154
211
 
155
- describe 'next_step_index' do
156
- it 'should be 2' do
157
- get :show
212
+ it 'should get step' do
213
+ get :show
158
214
 
159
- expect(subject.next_step_index).to eq 2
160
- end
215
+ expect(subject.previous_step_name).to eq :step_one
161
216
  end
217
+ end
218
+
219
+ context 'when last step' do
220
+ before(:all){
221
+ @controller = Base::StepThreeController.new
222
+ }
162
223
 
163
- describe '#next_step_name' do
164
- it 'should be :step_three' do
165
- get :show
224
+ it 'should get step' do
225
+ get :show
166
226
 
167
- expect(subject.next_step_name).to eq :step_three
168
- end
227
+ expect(subject.previous_step_name).to eq :step_two
169
228
  end
170
229
  end
171
230
  end
172
231
 
173
- context 'when last step' do
174
- before(:all){
175
- @controller = Base::StepThreeController.new
176
- }
232
+ describe '#next_step' do
233
+ context 'when first step' do
234
+ before(:all){
235
+ @controller = Base::StepOneController.new
236
+ }
177
237
 
178
- describe 'current_step methods' do
179
- describe 'current_step' do
180
- it 'should be "Step 3"' do
181
- get :show
238
+ it 'should get step' do
239
+ get :show
182
240
 
183
- expect(subject.current_step.label).to eq 'Step 3'
184
- end
241
+ expect(subject.next_step.label).to eq 'Step 2'
185
242
  end
243
+ end
186
244
 
187
- describe '#current_step_index' do
188
- it 'should be 2' do
189
- get :show
245
+ context 'when middle step' do
246
+ before(:all){
247
+ @controller = Base::StepTwoController.new
248
+ }
190
249
 
191
- expect(subject.current_step_index).to eq 2
192
- end
250
+ it 'should get step' do
251
+ get :show
252
+
253
+ expect(subject.next_step.label).to eq 'Step 3'
193
254
  end
255
+ end
256
+
257
+ context 'when last step' do
258
+ before(:all){
259
+ @controller = Base::StepThreeController.new
260
+ }
194
261
 
195
- describe '#current_step_name' do
196
- it 'should be :step_three' do
197
- get :show
262
+ it 'should be nil' do
263
+ get :show
198
264
 
199
- expect(subject.current_step_name).to eq :step_three
200
- end
265
+ expect(subject.next_step).to be_nil
201
266
  end
202
267
  end
268
+ end
269
+
270
+ describe '#next_step_index' do
271
+ context 'when first step' do
272
+ before(:all){
273
+ @controller = Base::StepOneController.new
274
+ }
203
275
 
204
- describe 'previous_step methods' do
205
- describe 'previous_step' do
206
- it 'should be "Step 2"' do
207
- get :show
276
+ it 'should get step' do
277
+ get :show
208
278
 
209
- expect(subject.previous_step.label).to eq 'Step 2'
210
- end
279
+ expect(subject.next_step_index).to eq 1
211
280
  end
281
+ end
212
282
 
213
- describe '#previous_step_index' do
214
- it 'should be 1' do
215
- get :show
283
+ context 'when middle step' do
284
+ before(:all){
285
+ @controller = Base::StepTwoController.new
286
+ }
216
287
 
217
- expect(subject.previous_step_index).to eq 1
218
- end
288
+ it 'should get step' do
289
+ get :show
290
+
291
+ expect(subject.next_step_index).to eq 2
219
292
  end
293
+ end
294
+
295
+ context 'when last step' do
296
+ before(:all){
297
+ @controller = Base::StepThreeController.new
298
+ }
220
299
 
221
- describe '#previous_step_name' do
222
- it 'should be :step_two' do
223
- get :show
300
+ it 'should be nil' do
301
+ get :show
224
302
 
225
- expect(subject.previous_step_name).to eq :step_two
226
- end
303
+ expect(subject.next_step_index).to be_nil
227
304
  end
228
305
  end
306
+ end
307
+
308
+ describe '#next_step_name' do
309
+ context 'when first step' do
310
+ before(:all){
311
+ @controller = Base::StepOneController.new
312
+ }
229
313
 
230
- describe 'next_step methods' do
231
- describe 'next_step' do
232
- it 'should be nil' do
233
- get :show
314
+ it 'should get step' do
315
+ get :show
234
316
 
235
- expect(subject.next_step).to be_nil
236
- end
317
+ expect(subject.next_step_name).to eq :step_two
237
318
  end
319
+ end
238
320
 
239
- describe 'next_step_index' do
240
- it 'should be nil' do
241
- get :show
321
+ context 'when middle step' do
322
+ before(:all){
323
+ @controller = Base::StepTwoController.new
324
+ }
242
325
 
243
- expect(subject.next_step_index).to be_nil
244
- end
326
+ it 'should get step' do
327
+ get :show
328
+
329
+ expect(subject.next_step_name).to eq :step_three
245
330
  end
331
+ end
332
+
333
+ context 'when last step' do
334
+ before(:all){
335
+ @controller = Base::StepThreeController.new
336
+ }
246
337
 
247
- describe '#next_step_name' do
248
- it 'should be nil' do
249
- get :show
338
+ it 'should be nil' do
339
+ get :show
250
340
 
251
- expect(subject.next_step_name).to be_nil
252
- end
341
+ expect(subject.next_step_name).to be_nil
253
342
  end
254
343
  end
255
344
  end