wizardz 1.3.0 → 1.3.1
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/VERSION +1 -1
- data/lib/wizardz/wizard.rb +1 -1
- data/spec/wizardz/wizard_spec.rb +27 -2
- data/wizardz.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.1
|
data/lib/wizardz/wizard.rb
CHANGED
@@ -66,7 +66,7 @@ module Wizardz
|
|
66
66
|
@valid_states.each do |state|
|
67
67
|
results[state] = @pages[state].page_data if @pages[state].respond_to?(:page_data)
|
68
68
|
end
|
69
|
-
results[:
|
69
|
+
results[:valid_states] = @valid_states
|
70
70
|
results[:unprocessed] = @unprocessed.clone
|
71
71
|
results[:unprocessed].delete(@state)
|
72
72
|
results
|
data/spec/wizardz/wizard_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#require 'ruby-debug'
|
1
2
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
3
|
|
3
4
|
class TestClassWiz < Wizardz::Page
|
@@ -14,6 +15,11 @@ end
|
|
14
15
|
class StateRedefWiz < Wizardz::Wizard
|
15
16
|
end
|
16
17
|
|
18
|
+
class ValidStates < Wizardz::Wizard
|
19
|
+
STATES = [{:id => :first_state, :class => Wizardz::Page::First},
|
20
|
+
{:id => :test_class_wiz, :class => TestClassWiz}]
|
21
|
+
end
|
22
|
+
|
17
23
|
describe "Wizard" do
|
18
24
|
|
19
25
|
it "has minimum of 0 parameters on creation" do
|
@@ -81,14 +87,14 @@ describe "Wizard" do
|
|
81
87
|
wiz = StateRedefWiz.new()
|
82
88
|
wiz.save_data.should == {:first_state=>{},
|
83
89
|
:unprocessed=>[:second_state],
|
84
|
-
:
|
90
|
+
:valid_states=>[:first_state, :second_state]}
|
85
91
|
end
|
86
92
|
|
87
93
|
it 'returns the data_object to save from default values' do
|
88
94
|
wiz = StateRedefWiz.new({:first_state => {:value => 'test'}})
|
89
95
|
wiz.save_data.should == {:first_state=>{:value=>"test"},
|
90
96
|
:unprocessed=>[:second_state],
|
91
|
-
:
|
97
|
+
:valid_states=>[:first_state, :second_state]}
|
92
98
|
end
|
93
99
|
|
94
100
|
it 'returns the view partial for the wizard' do
|
@@ -164,6 +170,25 @@ describe "Wizard" do
|
|
164
170
|
wiz.update(1)
|
165
171
|
end
|
166
172
|
end
|
173
|
+
|
174
|
+
context "data save and load" do
|
175
|
+
before(:each) do
|
176
|
+
@page = Wizardz::Page::First.new({},false)
|
177
|
+
Wizardz::Page::First.should_receive(:new).with({},nil).twice.and_return(@page)
|
178
|
+
@wiz = ValidStates.new
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should correctly reload valid states" do
|
182
|
+
@wiz.valid_states.should == [:first_state, :test_class_wiz]
|
183
|
+
@page.should_receive(:get_valid_states).with([:first_state, :test_class_wiz]).and_return([:first_state])
|
184
|
+
@wiz.update({:first => {:value => 'aaa'}},'next')
|
185
|
+
data = @wiz.save_data
|
186
|
+
load_wiz = ValidStates.new(data)
|
187
|
+
load_wiz.valid_states.should == [:first_state]
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
167
192
|
# it 'return true for the first_look? value (indicates if page should be validated)' do
|
168
193
|
# wiz = Wizardz::Wizard.new({:unprocessed => [:first_state]})
|
169
194
|
# wiz.first_look?.should be_true
|
data/wizardz.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wizardz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 1
|
10
|
+
version: 1.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Henry
|