stair_master 0.0.1 → 0.0.2
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/.rspec +1 -0
- data/Gemfile.lock +86 -14
- data/Guardfile +16 -0
- data/Rakefile +29 -1
- data/app/concerns/stair_master/controller.rb +11 -0
- data/lib/stair_master/concerns/getters.rb +26 -16
- data/lib/stair_master/concerns/tests.rb +12 -2
- data/lib/stair_master/concerns/traversal.rb +8 -0
- data/lib/stair_master/engine.rb +3 -0
- data/lib/stair_master/step.rb +8 -2
- data/lib/stair_master/version.rb +1 -1
- data/lib/stair_master/workflow_map.rb +1 -1
- data/spec/controllers/base/getters_spec.rb +9 -0
- data/spec/controllers/base/ordering_spec.rb +40 -0
- data/spec/controllers/base/tests_spec.rb +139 -0
- data/spec/controllers/base/traversal_spec.rb +256 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/base/step_one_controller.rb +10 -0
- data/spec/dummy/app/controllers/base/step_three_controller.rb +10 -0
- data/spec/dummy/app/controllers/base/step_two_controller.rb +10 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/steps/available_if_map.rb +13 -0
- data/spec/dummy/app/steps/base_map.rb +11 -0
- data/spec/dummy/app/views/application/show.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +16 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/log/development.log +227 -0
- data/spec/dummy/log/test.log +1606 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/spec_helper.rb +35 -0
- data/stair_master.gemspec +11 -8
- metadata +193 -15
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile.lock
CHANGED
@@ -1,56 +1,102 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stair_master (0.0.
|
4
|
+
stair_master (0.0.2)
|
5
5
|
activesupport (>= 3.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
10
|
+
actionmailer (4.0.2)
|
11
|
+
actionpack (= 4.0.2)
|
12
|
+
mail (~> 2.5.4)
|
13
|
+
actionpack (4.0.2)
|
14
|
+
activesupport (= 4.0.2)
|
15
|
+
builder (~> 3.1.0)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
rack (~> 1.5.2)
|
18
|
+
rack-test (~> 0.6.2)
|
19
|
+
activemodel (4.0.2)
|
20
|
+
activesupport (= 4.0.2)
|
21
|
+
builder (~> 3.1.0)
|
22
|
+
activerecord (4.0.2)
|
23
|
+
activemodel (= 4.0.2)
|
24
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
25
|
+
activesupport (= 4.0.2)
|
26
|
+
arel (~> 4.0.0)
|
27
|
+
activerecord-deprecated_finders (1.0.3)
|
28
|
+
activesupport (4.0.2)
|
11
29
|
i18n (~> 0.6, >= 0.6.4)
|
12
30
|
minitest (~> 4.2)
|
13
31
|
multi_json (~> 1.3)
|
14
32
|
thread_safe (~> 0.1)
|
15
33
|
tzinfo (~> 0.3.37)
|
34
|
+
arel (4.0.1)
|
16
35
|
atomic (1.1.14)
|
36
|
+
builder (3.1.4)
|
17
37
|
celluloid (0.15.2)
|
18
38
|
timers (~> 1.1.0)
|
19
39
|
childprocess (0.3.9)
|
20
40
|
ffi (~> 1.0, >= 1.0.11)
|
21
41
|
coderay (1.1.0)
|
22
42
|
diff-lcs (1.2.5)
|
43
|
+
erubis (2.7.0)
|
23
44
|
ffi (1.9.3)
|
24
45
|
formatador (0.2.4)
|
25
|
-
guard (2.2.
|
46
|
+
guard (2.2.5)
|
26
47
|
formatador (>= 0.2.4)
|
27
48
|
listen (~> 2.1)
|
28
49
|
lumberjack (~> 1.0)
|
29
50
|
pry (>= 0.9.12)
|
30
51
|
thor (>= 0.18.1)
|
31
|
-
guard-rspec (
|
32
|
-
guard (>=
|
33
|
-
rspec (~> 2.
|
52
|
+
guard-rspec (2.3.3)
|
53
|
+
guard (>= 1.1)
|
54
|
+
rspec (~> 2.11)
|
34
55
|
guard-spork (1.5.1)
|
35
56
|
childprocess (>= 0.2.3)
|
36
57
|
guard (>= 1.1)
|
37
58
|
spork (>= 0.8.4)
|
59
|
+
hike (1.2.3)
|
38
60
|
i18n (0.6.9)
|
39
|
-
listen (2.
|
61
|
+
listen (2.4.0)
|
40
62
|
celluloid (>= 0.15.2)
|
41
63
|
rb-fsevent (>= 0.9.3)
|
42
64
|
rb-inotify (>= 0.9)
|
43
65
|
lumberjack (1.0.4)
|
66
|
+
mail (2.5.4)
|
67
|
+
mime-types (~> 1.16)
|
68
|
+
treetop (~> 1.4.8)
|
69
|
+
metaclass (0.0.2)
|
44
70
|
method_source (0.8.2)
|
71
|
+
mime-types (1.25.1)
|
45
72
|
minitest (4.7.5)
|
73
|
+
mocha (0.13.3)
|
74
|
+
metaclass (~> 0.0.1)
|
46
75
|
multi_json (1.8.4)
|
47
|
-
|
76
|
+
polyglot (0.3.3)
|
77
|
+
pry (0.9.12.4)
|
48
78
|
coderay (~> 1.0)
|
49
79
|
method_source (~> 0.8)
|
50
80
|
slop (~> 3.4)
|
81
|
+
rack (1.5.2)
|
82
|
+
rack-test (0.6.2)
|
83
|
+
rack (>= 1.0)
|
84
|
+
rails (4.0.2)
|
85
|
+
actionmailer (= 4.0.2)
|
86
|
+
actionpack (= 4.0.2)
|
87
|
+
activerecord (= 4.0.2)
|
88
|
+
activesupport (= 4.0.2)
|
89
|
+
bundler (>= 1.3.0, < 2.0)
|
90
|
+
railties (= 4.0.2)
|
91
|
+
sprockets-rails (~> 2.0.0)
|
92
|
+
railties (4.0.2)
|
93
|
+
actionpack (= 4.0.2)
|
94
|
+
activesupport (= 4.0.2)
|
95
|
+
rake (>= 0.8.7)
|
96
|
+
thor (>= 0.18.1, < 2.0)
|
51
97
|
rake (10.1.1)
|
52
|
-
rb-fsevent (0.9.
|
53
|
-
rb-inotify (0.9.
|
98
|
+
rb-fsevent (0.9.4)
|
99
|
+
rb-inotify (0.9.3)
|
54
100
|
ffi (>= 0.5.0)
|
55
101
|
rspec (2.14.1)
|
56
102
|
rspec-core (~> 2.14.0)
|
@@ -60,12 +106,34 @@ GEM
|
|
60
106
|
rspec-expectations (2.14.4)
|
61
107
|
diff-lcs (>= 1.1.3, < 2.0)
|
62
108
|
rspec-mocks (2.14.4)
|
63
|
-
|
109
|
+
rspec-rails (2.14.1)
|
110
|
+
actionpack (>= 3.0)
|
111
|
+
activemodel (>= 3.0)
|
112
|
+
activesupport (>= 3.0)
|
113
|
+
railties (>= 3.0)
|
114
|
+
rspec-core (~> 2.14.0)
|
115
|
+
rspec-expectations (~> 2.14.0)
|
116
|
+
rspec-mocks (~> 2.14.0)
|
117
|
+
slop (3.4.7)
|
64
118
|
spork (0.9.2)
|
119
|
+
sprockets (2.10.1)
|
120
|
+
hike (~> 1.2)
|
121
|
+
multi_json (~> 1.0)
|
122
|
+
rack (~> 1.0)
|
123
|
+
tilt (~> 1.1, != 1.3.0)
|
124
|
+
sprockets-rails (2.0.1)
|
125
|
+
actionpack (>= 3.0)
|
126
|
+
activesupport (>= 3.0)
|
127
|
+
sprockets (~> 2.8)
|
128
|
+
sqlite3 (1.3.8)
|
65
129
|
thor (0.18.1)
|
66
130
|
thread_safe (0.1.3)
|
67
131
|
atomic
|
132
|
+
tilt (1.4.1)
|
68
133
|
timers (1.1.0)
|
134
|
+
treetop (1.4.15)
|
135
|
+
polyglot
|
136
|
+
polyglot (>= 0.3.1)
|
69
137
|
tzinfo (0.3.38)
|
70
138
|
|
71
139
|
PLATFORMS
|
@@ -73,8 +141,12 @@ PLATFORMS
|
|
73
141
|
|
74
142
|
DEPENDENCIES
|
75
143
|
bundler (~> 1.3)
|
76
|
-
guard-rspec
|
144
|
+
guard-rspec (~> 2.3.3)
|
77
145
|
guard-spork (~> 1.5.0)
|
78
|
-
|
79
|
-
|
146
|
+
mocha (~> 0.13.1)
|
147
|
+
rails (~> 4.0.0)
|
148
|
+
rake (~> 10.1.0)
|
149
|
+
rspec (~> 2.14.1)
|
150
|
+
rspec-rails (~> 2.14.1)
|
151
|
+
sqlite3
|
80
152
|
stair_master!
|
data/Guardfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do
|
5
|
+
watch('Gemfile')
|
6
|
+
watch('Guardfile')
|
7
|
+
watch('Gemfile.lock')
|
8
|
+
watch('lib/stair_master.rb')
|
9
|
+
watch('spec/spec_helper.rb') { :rspec }
|
10
|
+
end
|
11
|
+
|
12
|
+
guard :rspec, :all_after_pass => false, :all_on_start => false, :cli => '--drb' do
|
13
|
+
watch(%r{^spec/.+_spec\.rb$})
|
14
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
15
|
+
watch(%r{^lib/digital_opera/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
16
|
+
end
|
data/Rakefile
CHANGED
@@ -1 +1,29 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'StairMaster'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rspec/core'
|
23
|
+
require 'rspec/core/rake_task'
|
24
|
+
|
25
|
+
Dir[File.join(File.dirname(__FILE__), 'lib/tasks/**/*.rake')].each {|f| load f }
|
26
|
+
|
27
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
28
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
29
|
+
task :default => :spec
|
@@ -13,12 +13,23 @@ module StairMaster
|
|
13
13
|
|
14
14
|
included do
|
15
15
|
helper_method :workflow_map
|
16
|
+
before_filter :check_step_availability
|
16
17
|
end
|
17
18
|
|
18
19
|
def workflow_map
|
19
20
|
@stair_master_workflow_map ||= self.class.workflow_map.new
|
20
21
|
end
|
21
22
|
|
23
|
+
private # ---------------------------------------------
|
24
|
+
|
25
|
+
def check_step_availability
|
26
|
+
if is_available_step?
|
27
|
+
redirect_to next_step.url_for if step_should_be_skipped?
|
28
|
+
else
|
29
|
+
redirect_to first_step.url_for
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
22
33
|
module ClassMethods
|
23
34
|
def workflow_map(map_class=nil)
|
24
35
|
return (@@stair_master_workflow_map || ::StairMaster::WorkflowMap) if map_class.nil?
|
@@ -7,6 +7,8 @@ module StairMaster
|
|
7
7
|
module Getters
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
|
+
private # -------------------------------------------
|
11
|
+
|
10
12
|
def get_step_index_by_name(step_name)
|
11
13
|
available_steps.find_index step_name
|
12
14
|
end
|
@@ -23,39 +25,47 @@ module StairMaster
|
|
23
25
|
workflow_map.steps[step_name]
|
24
26
|
end
|
25
27
|
|
28
|
+
## NEXT STEP ----------------------------------------
|
26
29
|
def get_next_step_index
|
27
30
|
on_last_step? ? nil : find_next_step_index
|
28
31
|
end
|
29
32
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
private # -------------------------------------------
|
35
|
-
|
36
|
-
def find_previous_step_index(step_index=nil)
|
37
|
-
previous_index = step_index.nil? ? current_step_index.pred : step_index.pred
|
38
|
-
step = get_step_by_index previous_index
|
33
|
+
def find_next_step_index(step_index=nil)
|
34
|
+
next_index = step_index.nil? ? current_step_index.next : step_index.next
|
35
|
+
step = get_step_by_index next_index
|
39
36
|
|
40
37
|
if step.nil?
|
41
38
|
nil
|
42
39
|
elsif step.skip?(self)
|
43
|
-
|
40
|
+
if is_last_step?(step.key)
|
41
|
+
return nil
|
42
|
+
else
|
43
|
+
find_next_step_index(next_index)
|
44
|
+
end
|
44
45
|
else
|
45
|
-
|
46
|
+
next_index
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
## GET PREVIOIUS STEP INDEX -------------------------
|
51
|
+
def get_previous_step_index(step_index=nil)
|
52
|
+
on_first_step? ? nil : find_previous_step_index
|
53
|
+
end
|
54
|
+
|
55
|
+
def find_previous_step_index(step_index=nil)
|
56
|
+
previous_index = step_index.nil? ? current_step_index.pred : step_index.pred
|
57
|
+
step = get_step_by_index previous_index
|
52
58
|
|
53
59
|
if step.nil?
|
54
60
|
nil
|
55
61
|
elsif step.skip?(self)
|
56
|
-
|
62
|
+
if is_first_step?(step.key)
|
63
|
+
return nil
|
64
|
+
else
|
65
|
+
find_previous_step_index(previous_index)
|
66
|
+
end
|
57
67
|
else
|
58
|
-
|
68
|
+
previous_index
|
59
69
|
end
|
60
70
|
end
|
61
71
|
end
|
@@ -14,11 +14,11 @@ module StairMaster
|
|
14
14
|
|
15
15
|
## Methods ------------------------------------------
|
16
16
|
def on_last_step?
|
17
|
-
@stair_master_on_last_step ||= current_step_name
|
17
|
+
@stair_master_on_last_step ||= is_last_step?(current_step_name)
|
18
18
|
end
|
19
19
|
|
20
20
|
def on_first_step?
|
21
|
-
@stair_master_on_first_step ||= current_step_name
|
21
|
+
@stair_master_on_first_step ||= is_first_step?(current_step_name)
|
22
22
|
end
|
23
23
|
|
24
24
|
def is_last_step?(step_name)
|
@@ -28,6 +28,16 @@ module StairMaster
|
|
28
28
|
def is_first_step?(step_name)
|
29
29
|
step_name == available_steps.first
|
30
30
|
end
|
31
|
+
|
32
|
+
def is_available_step?(step=nil)
|
33
|
+
step_name = step.nil? ? controller_name.to_sym : step.key
|
34
|
+
available_steps.include? step_name
|
35
|
+
end
|
36
|
+
|
37
|
+
def step_should_be_skipped?(step=nil)
|
38
|
+
step = step.nil? ? current_step : step
|
39
|
+
step.skip?(self)
|
40
|
+
end
|
31
41
|
end
|
32
42
|
end
|
33
43
|
end
|
@@ -19,6 +19,14 @@ module StairMaster
|
|
19
19
|
:previous_step_name
|
20
20
|
end
|
21
21
|
|
22
|
+
def first_step
|
23
|
+
@stair_master_first_step ||= get_step_by_name available_steps.first
|
24
|
+
end
|
25
|
+
|
26
|
+
def last_step
|
27
|
+
@stair_master_last_step ||= get_step_by_name available_steps.last
|
28
|
+
end
|
29
|
+
|
22
30
|
## Current Step -------------------------------------
|
23
31
|
def current_step_index
|
24
32
|
@stair_master_current_step_index ||= get_step_index_by_name current_step_name
|
data/lib/stair_master/engine.rb
CHANGED
data/lib/stair_master/step.rb
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
module StairMaster
|
3
3
|
class Step
|
4
4
|
attr_accessor :label, :path, :conditions
|
5
|
+
attr_reader :key
|
5
6
|
|
6
|
-
def initialize(label, path, conditions)
|
7
|
+
def initialize(key, label, path, conditions)
|
8
|
+
@key = key
|
7
9
|
@label = label
|
8
10
|
@path = path
|
9
11
|
@conditions = build_conditions conditions
|
@@ -12,7 +14,7 @@ module StairMaster
|
|
12
14
|
## Methods --------------------------------------------
|
13
15
|
|
14
16
|
def available?(context)
|
15
|
-
rules
|
17
|
+
rules = @conditions[:availability]
|
16
18
|
( rules.empty? ? [true] : test_rules(rules, context) ).all?
|
17
19
|
end
|
18
20
|
|
@@ -35,6 +37,10 @@ module StairMaster
|
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
40
|
+
def to_s
|
41
|
+
label
|
42
|
+
end
|
43
|
+
|
38
44
|
private # ---------------------------------------------
|
39
45
|
|
40
46
|
def build_conditions(conditions)
|
data/lib/stair_master/version.rb
CHANGED
@@ -19,7 +19,7 @@ module StairMaster
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def add_step(controller_name, label, named_path, *conditions)
|
22
|
-
@steps[controller_name] = ::StairMaster::Step.new(label, named_path, conditions)
|
22
|
+
@steps[controller_name] = ::StairMaster::Step.new(controller_name, label, named_path, conditions)
|
23
23
|
end
|
24
24
|
|
25
25
|
def set_order(*steps)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'ordering methods' do
|
4
|
+
describe '#available_steps' do
|
5
|
+
before(:all){
|
6
|
+
@controller = Base::StepOneController.new
|
7
|
+
}
|
8
|
+
|
9
|
+
describe '#available_steps' do
|
10
|
+
it 'should contain all steps' do
|
11
|
+
get :show
|
12
|
+
|
13
|
+
subject.available_steps.should eq [:step_one, :step_two, :step_three]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#step_is_available?' do
|
18
|
+
it 'should return true if in list' do
|
19
|
+
get :show
|
20
|
+
|
21
|
+
subject.should be_step_is_available(:step_one)
|
22
|
+
subject.should be_step_is_available(:step_two)
|
23
|
+
subject.should be_step_is_available(:step_three)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should return false if not available' do
|
27
|
+
StairMaster::Step.any_instance.stubs(:available?).returns(false)
|
28
|
+
get :show
|
29
|
+
|
30
|
+
subject.should_not be_step_is_available(:step_one)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should throw error if not apart of inital list' do
|
34
|
+
get :show
|
35
|
+
|
36
|
+
expect{ subject.step_is_available?(:step_four) }.to raise_error
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'test methods' do
|
4
|
+
describe '#on_last_step?' do
|
5
|
+
context 'if first item' do
|
6
|
+
before(:all){
|
7
|
+
@controller = Base::StepOneController.new
|
8
|
+
}
|
9
|
+
|
10
|
+
it 'should return false' do
|
11
|
+
get :show
|
12
|
+
|
13
|
+
subject.should_not be_on_last_step
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'if middle item' do
|
18
|
+
before(:all){
|
19
|
+
@controller = Base::StepTwoController.new
|
20
|
+
}
|
21
|
+
|
22
|
+
it 'should return false' do
|
23
|
+
get :show
|
24
|
+
|
25
|
+
subject.should_not be_on_last_step
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'if last item' do
|
30
|
+
before(:all){
|
31
|
+
@controller = Base::StepThreeController.new
|
32
|
+
}
|
33
|
+
|
34
|
+
it 'should return true' do
|
35
|
+
get :show
|
36
|
+
|
37
|
+
subject.should be_on_last_step
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#on_first_step?' do
|
43
|
+
context 'if first item' do
|
44
|
+
before(:all){
|
45
|
+
@controller = Base::StepOneController.new
|
46
|
+
}
|
47
|
+
|
48
|
+
it 'should return true' do
|
49
|
+
get :show
|
50
|
+
|
51
|
+
subject.should be_on_first_step
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'if middle item' do
|
56
|
+
before(:all){
|
57
|
+
@controller = Base::StepTwoController.new
|
58
|
+
}
|
59
|
+
|
60
|
+
it 'should return false' do
|
61
|
+
get :show
|
62
|
+
|
63
|
+
subject.should_not be_on_first_step
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'if last item' do
|
68
|
+
before(:all){
|
69
|
+
@controller = Base::StepTwoController.new
|
70
|
+
}
|
71
|
+
|
72
|
+
it 'should return false' do
|
73
|
+
get :show
|
74
|
+
|
75
|
+
subject.should_not be_on_first_step
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#is_last_step?' do
|
81
|
+
before(:all){
|
82
|
+
@controller = Base::StepOneController.new
|
83
|
+
}
|
84
|
+
|
85
|
+
context 'if first item' do
|
86
|
+
it 'should return false' do
|
87
|
+
get :show
|
88
|
+
|
89
|
+
subject.should_not be_is_last_step(:step_one)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'if middle item' do
|
94
|
+
it 'should return false' do
|
95
|
+
get :show
|
96
|
+
|
97
|
+
subject.should_not be_is_last_step(:step_two)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'if last item' do
|
102
|
+
it 'should return true' do
|
103
|
+
get :show
|
104
|
+
|
105
|
+
subject.should be_is_last_step(:step_three)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#is_first_step?' do
|
111
|
+
before(:all){
|
112
|
+
@controller = Base::StepOneController.new
|
113
|
+
}
|
114
|
+
|
115
|
+
context 'if first item' do
|
116
|
+
it 'should return true' do
|
117
|
+
get :show
|
118
|
+
|
119
|
+
subject.should be_is_first_step(:step_one)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'if middle item' do
|
124
|
+
it 'should return false' do
|
125
|
+
get :show
|
126
|
+
|
127
|
+
subject.should_not be_is_first_step(:step_two)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'if last item' do
|
132
|
+
it 'should return false' do
|
133
|
+
get :show
|
134
|
+
|
135
|
+
subject.should_not be_is_first_step(:step_three)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|