adzap-voice_form 0.2.0 → 0.3.0

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.
@@ -1,13 +1,13 @@
1
1
  module VoiceForm
2
2
 
3
3
  def self.included(base)
4
- base.extend MacroMethods
4
+ base.extend ClassMethods
5
5
  base.class_eval do
6
6
  include FormMethods
7
7
  end
8
8
  end
9
9
 
10
- module MacroMethods
10
+ module ClassMethods
11
11
 
12
12
  def voice_form(options={}, &block)
13
13
  raise "Voice form requires block" unless block_given?
@@ -16,24 +16,32 @@ module VoiceForm
16
16
  include InstanceMethods
17
17
 
18
18
  cattr_accessor :voice_form_options
19
- attr_accessor :form, :call_context
19
+ attr_accessor :form, :call
20
20
  end
21
21
 
22
22
  self.voice_form_options = [options, block]
23
23
  end
24
+
25
+ def start_voice_form(call)
26
+ raise "No voice form defined" unless voice_form_options
27
+ self.new.start_voice_form(call)
28
+ end
24
29
 
25
30
  end
26
31
 
27
32
  module InstanceMethods
28
-
33
+
29
34
  def start_voice_form(call)
30
- raise "No voice form defined" unless self.voice_form_options
35
+ raise "No voice form defined" unless self.class.voice_form_options
31
36
  options, block = *self.class.voice_form_options
32
- @call_context = call
37
+ @call = call
33
38
  self.form = VoiceForm::Form.new(options, &block)
34
39
  self.form.run(self)
35
40
  end
36
41
 
42
+ def as_digits(string)
43
+ string.scan(/\d/).map {|v| v.to_i }
44
+ end
37
45
  end
38
46
 
39
47
  module FormMethods
@@ -44,9 +52,7 @@ module VoiceForm
44
52
 
45
53
  form_field = VoiceForm::FormField.new(field_name, options, self, &block)
46
54
 
47
- raise 'A field requires a prompt to be defined' if form_field.prompts.empty?
48
-
49
- if self.class == VoiceForm::Form
55
+ if self.is_a?(VoiceForm::Form)
50
56
  self.form_stack << form_field
51
57
  else
52
58
  unless self.respond_to?(field_name)
@@ -3,67 +3,67 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe VoiceForm::FormField do
4
4
  include VoiceForm::FormMethods
5
5
 
6
- attr_accessor :call_context, :my_field
6
+ attr_accessor :call, :my_field
7
7
 
8
8
  before do
9
- @call_context = mock('CallContext', :play => nil, :speak => nil)
10
- @call_context.stub!(:input).with(any_args).and_return('')
9
+ @call = mock('Call', :play => nil, :speak => nil)
10
+ @call.stub!(:input).with(any_args).and_return('')
11
11
  end
12
12
 
13
13
  it "should define accessor for field in component" do
14
14
  field(:my_field) do
15
- prompt :speak => 'test'
15
+ prompt :play => 'test'
16
16
  end
17
17
  self.methods.include?(:my_field)
18
18
  end
19
19
 
20
20
  it "should raise error if no prompts defined" do
21
- item = form_field(:my_field) do
22
- end
23
- lambda { item.run }.should raise_error
21
+ lambda {
22
+ form_field(:my_field) {}
23
+ }.should raise_error
24
24
  end
25
25
 
26
26
  it "should raise error if reprompt defined before prompt" do
27
27
  lambda {
28
28
  form_field(:my_field) do
29
- reprompt :speak => 'and again'
29
+ reprompt :play => 'again'
30
30
  end
31
31
  }.should raise_error
32
32
  end
33
33
 
34
34
  it "should return same prompt for for all attempts if single prompt" do
35
35
  item = form_field(:my_field) do
36
- prompt :speak => "first"
36
+ prompt :play => "first"
37
37
  end
38
- item.send(:prompt_for_attempt, 1)[:speak].should == 'first'
39
- item.send(:prompt_for_attempt, 2)[:speak].should == 'first'
38
+ item.send(:prompt_for_attempt, 1)[:message].should == 'first'
39
+ item.send(:prompt_for_attempt, 2)[:message].should == 'first'
40
40
  end
41
41
 
42
42
  it "should return reprompt for subsequent prompts" do
43
43
  item = form_field(:my_field) do
44
- prompt :speak => "first"
45
- reprompt :speak => 'next'
44
+ prompt :play => "first"
45
+ reprompt :play => 'next'
46
46
  end
47
- item.send(:prompt_for_attempt, 1)[:speak].should == 'first'
48
- item.send(:prompt_for_attempt, 2)[:speak].should == 'next'
49
- item.send(:prompt_for_attempt, 3)[:speak].should == 'next'
47
+ item.send(:prompt_for_attempt, 1)[:message].should == 'first'
48
+ item.send(:prompt_for_attempt, 2)[:message].should == 'next'
49
+ item.send(:prompt_for_attempt, 3)[:message].should == 'next'
50
50
  end
51
51
 
52
52
  it "should return prompt for given number of repeats before subsequent prompts" do
53
53
  item = form_field(:my_field) do
54
- prompt :speak => "first", :repeats => 2
55
- reprompt :speak => 'next'
54
+ prompt :play => "first", :repeats => 2
55
+ reprompt :play => 'next'
56
56
  end
57
- item.send(:prompt_for_attempt, 1)[:speak].should == 'first'
58
- item.send(:prompt_for_attempt, 2)[:speak].should == 'first'
59
- item.send(:prompt_for_attempt, 3)[:speak].should == 'next'
57
+ item.send(:prompt_for_attempt, 1)[:message].should == 'first'
58
+ item.send(:prompt_for_attempt, 2)[:message].should == 'first'
59
+ item.send(:prompt_for_attempt, 3)[:message].should == 'next'
60
60
  end
61
61
 
62
62
  it "should set input value in component" do
63
63
  item = form_field(:my_field, :length => 3) do
64
- prompt :speak => "first"
64
+ prompt :play => "first"
65
65
  end
66
- call_context.stub!(:input).and_return('123')
66
+ call.stub!(:input).and_return('123')
67
67
  item.run
68
68
 
69
69
  my_field.should == '123'
@@ -72,10 +72,10 @@ describe VoiceForm::FormField do
72
72
  it "should run setup callback once" do
73
73
  call_me = i_should_be_called
74
74
  item = form_field(:my_field, :attempts => 3) do
75
- prompt :speak => "first"
75
+ prompt :play => "first"
76
76
  setup { call_me.call }
77
77
  end
78
- call_context.should_receive(:input).and_return('')
78
+ call.should_receive(:input).and_return('')
79
79
 
80
80
  item.run
81
81
  end
@@ -83,38 +83,49 @@ describe VoiceForm::FormField do
83
83
  it "should run timeout callback if no input" do
84
84
  call_me = i_should_be_called
85
85
  item = form_field(:my_field, :attempts => 1) do
86
- prompt :speak => "first"
86
+ prompt :play => "first"
87
87
  timeout { call_me.call }
88
88
  end
89
- call_context.should_receive(:input).and_return('')
89
+ call.should_receive(:input).and_return('')
90
+
91
+ item.run
92
+ end
93
+
94
+ it "should run timeout callback if input not valid length" do
95
+ call_me = i_should_be_called
96
+ item = form_field(:my_field, :attempts => 1, :length => 3) do
97
+ prompt :play => "first"
98
+ timeout { call_me.call }
99
+ end
100
+ call.should_receive(:input).and_return('12')
90
101
 
91
102
  item.run
92
103
  end
93
104
 
94
105
  it "should make all attempts to get valid input" do
95
106
  item = form_field(:my_field) do
96
- prompt :speak => "first"
107
+ prompt :play => "first"
97
108
  end
98
- call_context.should_receive(:input).exactly(3).times
109
+ call.should_receive(:input).exactly(3).times
99
110
 
100
111
  item.run
101
112
  end
102
113
 
103
114
  it "should make one attempt if input is valid" do
104
115
  item = form_field(:my_field) do
105
- prompt :speak => "first"
116
+ prompt :play => "first"
106
117
  end
107
118
  item.stub!(:input_valid?).and_return(true)
108
- call_context.should_receive(:input).once
119
+ call.should_receive(:input).once
109
120
 
110
121
  item.run
111
122
  end
112
123
 
113
124
  it "should check if input_valid?" do
114
125
  item = form_field(:my_field, :length => 3) do
115
- prompt :speak => "first"
126
+ prompt :play => "first"
116
127
  end
117
- call_context.should_receive(:input).and_return('123')
128
+ call.should_receive(:input).and_return('123')
118
129
  item.should_receive(:input_valid?)
119
130
 
120
131
  item.run
@@ -123,10 +134,10 @@ describe VoiceForm::FormField do
123
134
  it "should run validation callback if defined" do
124
135
  call_me = i_should_be_called
125
136
  item = form_field(:my_field, :length => 3, :attempts => 1) do
126
- prompt :speak => "first"
137
+ prompt :play => "first"
127
138
  validate { call_me.call }
128
139
  end
129
- call_context.stub!(:input).and_return('123')
140
+ call.stub!(:input).and_return('123')
130
141
 
131
142
  item.run
132
143
  end
@@ -134,10 +145,10 @@ describe VoiceForm::FormField do
134
145
  it "should run confirm callback if defined" do
135
146
  call_me = i_should_be_called
136
147
  item = form_field(:my_field, :length => 3, :attempts => 1) do
137
- prompt :speak => "first"
148
+ prompt :play => "first"
138
149
  confirm { call_me.call; [] }
139
150
  end
140
- call_context.stub!(:input).and_return('123')
151
+ call.stub!(:input).and_return('123')
141
152
 
142
153
  item.run
143
154
  end
@@ -147,81 +158,81 @@ describe VoiceForm::FormField do
147
158
  it "should not run if not valid input" do
148
159
  dont_call_me = i_should_not_be_called
149
160
  item = form_field(:my_field, :length => 3, :attempts => 1) do
150
- prompt :speak => "first"
161
+ prompt :play => "first"
151
162
  validate { false }
152
163
  confirm { dont_call_me.call }
153
164
  end
154
- call_context.stub!(:input).and_return('123')
165
+ call.stub!(:input).and_return('123')
155
166
 
156
167
  item.run
157
168
  end
158
169
 
159
170
  it "should be run the number of attempts if no valid response" do
160
- call_context.should_receive(:input).with(3, anything).and_return('123')
171
+ call.should_receive(:input).with(3, anything).and_return('123')
161
172
  item = form_field(:my_field, :length => 3, :attempts => 1) do
162
- prompt :speak => "first"
173
+ prompt :play => "first"
163
174
 
164
175
  confirm(:attempts => 3) { [] }
165
176
  end
166
- call_context.should_receive(:input).with(1, anything).exactly(3).times.and_return('')
177
+ call.should_receive(:input).with(1, anything).exactly(3).times.and_return('')
167
178
 
168
179
  item.run
169
180
  end
170
181
 
171
182
  it "should run success callback if accept value entered" do
172
183
  call_me = i_should_be_called
173
- call_context.should_receive(:input).with(3, anything).and_return('123')
184
+ call.should_receive(:input).with(3, anything).and_return('123')
174
185
  item = form_field(:my_field, :length => 3, :attempts => 1) do
175
- prompt :speak => "first"
186
+ prompt :play => "first"
176
187
 
177
188
  success { call_me.call }
178
189
  confirm(:accept => '1', :reject => '2') { [] }
179
190
  end
180
- call_context.should_receive(:input).with(1, anything).and_return('1')
191
+ call.should_receive(:input).with(1, anything).and_return('1')
181
192
 
182
193
  item.run
183
194
  end
184
195
 
185
196
  it "should run failure callback if reject value entered" do
186
197
  call_me = i_should_be_called
187
- call_context.should_receive(:input).with(3, anything).and_return('123')
198
+ call.should_receive(:input).with(3, anything).and_return('123')
188
199
  item = form_field(:my_field, :length => 3, :attempts => 1) do
189
- prompt :speak => "first"
200
+ prompt :play => "first"
190
201
 
191
202
  failure { call_me.call }
192
203
  confirm(:accept => '1', :reject => '2') { [] }
193
204
  end
194
- call_context.should_receive(:input).with(1, anything).and_return('2')
205
+ call.should_receive(:input).with(1, anything).and_return('2')
195
206
 
196
207
  item.run
197
208
  end
198
209
 
199
210
  it "should play confirmation input prompt if confirm block return value is array" do
200
211
  call_me = i_should_be_called
201
- call_context.should_receive(:input).with(3, anything).and_return('123')
212
+ call.should_receive(:input).with(3, anything).and_return('123')
202
213
 
203
214
  item = form_field(:my_field, :length => 3, :attempts => 1) do
204
- prompt :speak => "first"
215
+ prompt :play => "first"
205
216
 
206
217
  success { call_me.call }
207
218
  confirm(:timeout => 3) { [] }
208
219
  end
209
- call_context.should_receive(:input).with(1, {:play => [], :timeout => 3}).and_return('1')
220
+ call.should_receive(:input).with(1, {:play => [], :timeout => 3}).and_return('1')
210
221
 
211
222
  item.run
212
223
  end
213
224
 
214
225
  it "should speak confirmation input prompt if confirm block return value is string" do
215
226
  call_me = i_should_be_called
216
- call_context.should_receive(:input).with(3, anything).and_return('123')
227
+ call.should_receive(:input).with(3, anything).and_return('123')
217
228
 
218
229
  item = form_field(:my_field, :length => 3, :attempts => 1) do
219
- prompt :speak => "first"
230
+ prompt :play => "first"
220
231
 
221
232
  success { call_me.call }
222
- confirm(:timeout => 3) { '' }
233
+ confirm(:timeout => 3) { 'speak me' }
223
234
  end
224
- call_context.should_receive(:input).with(1, {:speak => '', :timeout => 3}).and_return('1')
235
+ call.should_receive(:input).with(1, {:speak => 'speak me', :timeout => 3}).and_return('1')
225
236
 
226
237
  item.run
227
238
  end
@@ -230,10 +241,10 @@ describe VoiceForm::FormField do
230
241
  it "should run failure callback if no input" do
231
242
  call_me = i_should_be_called
232
243
  item = form_field(:my_field, :length => 3) do
233
- prompt :speak => "first"
244
+ prompt :play => "first"
234
245
  failure { call_me.call }
235
246
  end
236
- call_context.should_receive(:input).and_return('')
247
+ call.should_receive(:input).and_return('')
237
248
 
238
249
  item.run
239
250
  end
@@ -241,10 +252,10 @@ describe VoiceForm::FormField do
241
252
  it "should run success callback if input valid length" do
242
253
  call_me = i_should_be_called
243
254
  item = form_field(:my_field, :length => 3) do
244
- prompt :speak => "first"
255
+ prompt :play => "first"
245
256
  success { call_me.call }
246
257
  end
247
- call_context.should_receive(:input).and_return('123')
258
+ call.should_receive(:input).and_return('123')
248
259
 
249
260
  item.run
250
261
  end
@@ -253,14 +264,34 @@ describe VoiceForm::FormField do
253
264
  validate_me = i_should_be_called
254
265
  call_me = i_should_be_called
255
266
  item = form_field(:my_field, :length => 3) do
256
- prompt :speak => "first"
267
+ prompt :play => "first"
257
268
  validate do
258
269
  validate_me.call
259
270
  my_field.to_i > 100
260
271
  end
261
272
  success { call_me.call }
262
273
  end
263
- call_context.should_receive(:input).and_return('123')
274
+ call.should_receive(:input).and_return('123')
275
+
276
+ item.run
277
+ end
278
+
279
+ it "should execute input with message when bargein is true" do
280
+ item = form_field(:my_field, :length => 3) do
281
+ prompt :play => "first", :bargein => true
282
+ end
283
+ call.should_not_receive(:play)
284
+ call.should_receive(:input).with(3, :play => "first", :timeout => 5)
285
+
286
+ item.run
287
+ end
288
+
289
+ it "should execute playback method with message and input without message when bargein is false" do
290
+ item = form_field(:my_field, :length => 3) do
291
+ prompt :play => "first", :bargein => false
292
+ end
293
+ call.should_receive(:play).with('first')
294
+ call.should_receive(:input).with(3, :timeout => 5)
264
295
 
265
296
  item.run
266
297
  end
@@ -3,36 +3,41 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe VoiceForm::Form do
4
4
  include VoiceForm
5
5
 
6
- attr_accessor :call_context
6
+ attr_accessor :call
7
7
 
8
8
  before do
9
- new_voice_form
10
- @call_context = mock('CallContext', :play => nil, :speak => nil)
11
- @call_context.stub!(:input).with(any_args).and_return('')
9
+ @call = mock('CallContext', :play => nil, :speak => nil)
10
+ @call.stub!(:input).with(any_args).and_return('')
12
11
  end
13
12
 
14
13
  it "should define form and run it" do
15
14
  call_me = i_should_be_called
16
-
17
- self.class.voice_form &call_me
18
-
19
- start_voice_form(@call_context)
15
+ voice_form do
16
+ field(:my_field) { prompt :play => nil }
17
+ setup { call_me.call }
18
+ end
19
+ start_voice_form(@call)
20
20
  end
21
21
 
22
22
  it "should call setup block" do
23
- form.setup &i_should_be_called
24
-
23
+ call_me = i_should_be_called
24
+ voice_form do
25
+ setup { call_me.call }
26
+ field(:my_field) { prompt :play => nil }
27
+ end
25
28
  run_form
26
29
  end
27
30
 
28
31
  it "should run single form field" do
29
32
  call_me = i_should_be_called
30
33
 
31
- form.field(:my_field) do
32
- prompt :speak => 'enter value'
33
- setup { call_me.call }
34
+ voice_form do
35
+ field(:my_field) do
36
+ prompt :play => nil
37
+ setup { call_me.call }
38
+ end
34
39
  end
35
-
40
+
36
41
  run_form
37
42
  end
38
43
 
@@ -40,14 +45,16 @@ describe VoiceForm::Form do
40
45
  first_call_me = i_should_be_called
41
46
  second_call_me = i_should_be_called
42
47
 
43
- form.field(:first_field) do
44
- prompt :speak => 'enter value'
45
- setup { first_call_me.call }
46
- end
47
- form.field(:second_field) do
48
- prompt :speak => 'enter value'
49
- setup { second_call_me.call }
50
- end
48
+ voice_form do
49
+ field(:first_field) do
50
+ prompt :play => nil
51
+ setup { first_call_me.call }
52
+ end
53
+ field(:second_field) do
54
+ prompt :play => nil
55
+ setup { second_call_me.call }
56
+ end
57
+ end
51
58
 
52
59
  run_form
53
60
  end
@@ -55,7 +62,10 @@ describe VoiceForm::Form do
55
62
  it "should run do_blocks" do
56
63
  do_block_call_me = i_should_be_called
57
64
 
58
- form.do_block { do_block_call_me.call }
65
+ voice_form do
66
+ do_block { do_block_call_me.call }
67
+ field(:my_field) { prompt :play => nil }
68
+ end
59
69
 
60
70
  run_form
61
71
  end
@@ -64,11 +74,13 @@ describe VoiceForm::Form do
64
74
  field_call_me = i_should_be_called
65
75
  do_block_call_me = i_should_be_called
66
76
 
67
- form.field(:first_field) do
68
- prompt :speak => 'enter value'
69
- setup { field_call_me.call }
77
+ voice_form do
78
+ field(:first_field) do
79
+ prompt :play => nil
80
+ setup { field_call_me.call }
81
+ end
82
+ do_block { do_block_call_me.call }
70
83
  end
71
- form.do_block { do_block_call_me.call }
72
84
 
73
85
  run_form
74
86
  end
@@ -78,17 +90,19 @@ describe VoiceForm::Form do
78
90
  do_block_call_me = i_should_not_be_called
79
91
  second_call_me = i_should_be_called
80
92
 
81
- form.field(:first_field, :attempts => 1) do
82
- prompt :speak => 'enter value'
83
- setup { first_call_me.call }
84
- failure { form.goto :second_field }
85
- end
86
-
87
- form.do_block { do_block_call_me.call }
93
+ voice_form do
94
+ field(:first_field, :attempts => 1) do
95
+ prompt :play => nil
96
+ setup { first_call_me.call }
97
+ failure { form.goto :second_field }
98
+ end
99
+
100
+ do_block { do_block_call_me.call }
88
101
 
89
- form.field(:second_field) do
90
- prompt :speak => 'enter value'
91
- setup { second_call_me.call }
102
+ field(:second_field) do
103
+ prompt :play => nil
104
+ setup { second_call_me.call }
105
+ end
92
106
  end
93
107
 
94
108
  run_form
@@ -99,22 +113,24 @@ describe VoiceForm::Form do
99
113
  do_block_call_me = i_should_be_called(2)
100
114
  second_call_me = i_should_be_called(2)
101
115
 
102
- form.field(:first_field, :attempts => 1) do
103
- prompt :speak => 'enter value'
104
- setup { first_call_me.call }
105
- end
116
+ voice_form do
117
+ field(:first_field, :attempts => 1) do
118
+ prompt :play => nil
119
+ setup { first_call_me.call }
120
+ end
106
121
 
107
- form.do_block { do_block_call_me.call }
122
+ do_block { do_block_call_me.call }
108
123
 
109
- form.field(:second_field) do
110
- prompt :speak => 'enter value'
111
- setup { second_call_me.call }
112
- failure {
113
- unless @once
114
- @once = true
115
- form.goto :first_field
116
- end
117
- }
124
+ field(:second_field) do
125
+ prompt :play => nil
126
+ setup { second_call_me.call }
127
+ failure {
128
+ unless @once
129
+ @once = true
130
+ form.goto :first_field
131
+ end
132
+ }
133
+ end
118
134
  end
119
135
 
120
136
  run_form
@@ -125,22 +141,24 @@ describe VoiceForm::Form do
125
141
  do_block_call_me = i_should_be_called(2)
126
142
  second_call_me = i_should_be_called(2)
127
143
 
128
- form.field(:first_field, :attempts => 1) do
129
- prompt :speak => 'enter value'
130
- setup { first_call_me.call }
131
- end
132
-
133
- form.do_block { do_block_call_me.call }
144
+ voice_form do
145
+ field(:first_field, :attempts => 1) do
146
+ prompt :play => nil
147
+ setup { first_call_me.call }
148
+ end
149
+
150
+ do_block { do_block_call_me.call }
134
151
 
135
- form.field(:second_field) do
136
- prompt :speak => 'enter value'
137
- setup { second_call_me.call }
138
- failure {
139
- unless @once
140
- @once = true
141
- form.restart
142
- end
143
- }
152
+ field(:second_field) do
153
+ prompt :play => nil
154
+ setup { second_call_me.call }
155
+ failure {
156
+ unless @once
157
+ @once = true
158
+ form.restart
159
+ end
160
+ }
161
+ end
144
162
  end
145
163
 
146
164
  run_form
@@ -151,31 +169,31 @@ describe VoiceForm::Form do
151
169
  do_block_call_me = i_should_not_be_called
152
170
  second_call_me = i_should_not_be_called
153
171
 
154
- form.field(:first_field, :attempts => 1) do
155
- prompt :speak => 'enter value'
156
- setup { first_call_me.call }
157
- failure { form.exit }
158
- end
159
-
160
- form.do_block { do_block_call_me.call }
172
+ voice_form do
173
+ field(:first_field, :attempts => 1) do
174
+ prompt :play => nil
175
+ setup { first_call_me.call }
176
+ failure { form.exit }
177
+ end
178
+
179
+ do_block { do_block_call_me.call }
161
180
 
162
- form.field(:second_field) do
163
- prompt :speak => 'enter value'
164
- setup { second_call_me.call }
181
+ field(:second_field) do
182
+ prompt :play => nil
183
+ setup { second_call_me.call }
184
+ end
165
185
  end
166
186
 
167
187
  run_form
168
188
  end
169
189
 
170
190
  describe "current_field" do
171
- before do
172
- @field = nil
173
- end
174
-
175
191
  it "should be name of current field being run" do
176
- form.field(:my_field) do
177
- prompt :speak => 'enter value'
178
- setup { @field = form.current_field }
192
+ voice_form do
193
+ field(:my_field) do
194
+ prompt :play => nil
195
+ setup { @field = form.current_field }
196
+ end
179
197
  end
180
198
  run_form
181
199
 
@@ -183,8 +201,9 @@ describe VoiceForm::Form do
183
201
  end
184
202
 
185
203
  it "should be nil in do_block" do
186
- form.do_block do
187
- @field = form.current_field
204
+ voice_form do
205
+ field(:my_field) { prompt :play => nil }
206
+ do_block { @field = form.current_field }
188
207
  end
189
208
  run_form
190
209
 
@@ -192,8 +211,8 @@ describe VoiceForm::Form do
192
211
  end
193
212
 
194
213
  it "should be nil after form is run" do
195
- form.field(:my_field) do
196
- prompt :speak => 'enter value'
214
+ voice_form do
215
+ field(:my_field) { prompt :play => nil }
197
216
  end
198
217
  run_form
199
218
 
@@ -201,8 +220,8 @@ describe VoiceForm::Form do
201
220
  end
202
221
  end
203
222
 
204
- def new_voice_form
205
- self.class.voice_form { }
223
+ def voice_form(&block)
224
+ self.class.voice_form &block
206
225
  options, block = *self.class.voice_form_options
207
226
  self.form = VoiceForm::Form.new(options, &block)
208
227
  end