bubble-wrap 1.2.0 → 1.3.0.osx
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.
- checksums.yaml +8 -8
- data/CHANGELOG.md +4 -2
- data/Gemfile.lock +1 -1
- data/README.md +217 -7
- data/Rakefile +23 -2
- data/lib/bubble-wrap/camera.rb +10 -6
- data/lib/bubble-wrap/core.rb +14 -1
- data/lib/bubble-wrap/ext/motion_project_app.rb +8 -0
- data/lib/bubble-wrap/font.rb +3 -1
- data/lib/bubble-wrap/http.rb +2 -0
- data/lib/bubble-wrap/loader.rb +17 -2
- data/lib/bubble-wrap/location.rb +9 -6
- data/lib/bubble-wrap/media.rb +10 -6
- data/lib/bubble-wrap/test.rb +6 -1
- data/lib/bubble-wrap/ui.rb +5 -2
- data/lib/bubble-wrap/version.rb +2 -7
- data/motion/core.rb +6 -1
- data/motion/core/app.rb +3 -64
- data/motion/core/device.rb +0 -55
- data/motion/core/device/{camera.rb → ios/camera.rb} +0 -0
- data/motion/core/device/{camera_wrapper.rb → ios/camera_wrapper.rb} +0 -0
- data/motion/core/device/ios/screen.rb +75 -0
- data/motion/core/device/osx/screen.rb +18 -0
- data/motion/core/device/screen.rb +1 -69
- data/motion/core/ios/app.rb +71 -0
- data/motion/core/ios/device.rb +59 -0
- data/motion/core/osx/app.rb +15 -0
- data/motion/core/osx/device.rb +6 -0
- data/motion/core/string.rb +3 -2
- data/motion/http.rb +0 -364
- data/motion/http/query.rb +367 -0
- data/motion/http/response.rb +32 -0
- data/motion/test_suite_delegate.rb +58 -0
- data/motion/ui/ui_alert_view.rb +169 -0
- data/motion/ui/ui_bar_button_item.rb +55 -53
- data/motion/util/constants.rb +34 -32
- data/samples/alert/.gitignore +16 -0
- data/samples/alert/Gemfile +3 -0
- data/samples/alert/Rakefile +10 -0
- data/samples/alert/app/app_delegate.rb +8 -0
- data/samples/alert/app/controllers/alert_view_controller.rb +74 -0
- data/samples/alert/resources/Default-568h@2x.png +0 -0
- data/samples/alert/spec/main_spec.rb +9 -0
- data/samples/media/.gitignore +16 -0
- data/samples/media/Rakefile +11 -0
- data/samples/media/app/app_delegate.rb +8 -0
- data/samples/media/app/controllers/play_controller.rb +46 -0
- data/samples/media/resources/Default-568h@2x.png +0 -0
- data/samples/media/resources/test.mp3 +0 -0
- data/samples/media/spec/main_spec.rb +9 -0
- data/samples/osx/Gemfile +3 -0
- data/samples/osx/Gemfile.lock +10 -0
- data/samples/osx/Rakefile +11 -0
- data/samples/osx/app/app_delegate.rb +69 -0
- data/samples/osx/app/menu.rb +108 -0
- data/samples/osx/resources/Credits.rtf +29 -0
- data/samples/osx/spec/main_spec.rb +9 -0
- data/spec/motion/core/app_spec.rb +5 -164
- data/spec/motion/core/device/{camera_spec.rb → ios/camera_spec.rb} +0 -0
- data/spec/motion/core/device/{camera_wrapper_spec.rb → ios/camera_wrapper_spec.rb} +0 -0
- data/spec/motion/core/device/ios/device_spec.rb +74 -0
- data/spec/motion/core/device/{screen_spec.rb → ios/screen_spec.rb} +2 -1
- data/spec/motion/core/device/osx/screen_spec.rb +26 -0
- data/spec/motion/core/device_spec.rb +0 -71
- data/spec/motion/core/ios/app_spec.rb +180 -0
- data/spec/motion/core/kvo_spec.rb +23 -7
- data/spec/motion/core/ns_index_path_spec.rb +10 -2
- data/spec/motion/core/osx/app_spec.rb +15 -0
- data/spec/motion/core/string_spec.rb +11 -5
- data/spec/motion/core_spec.rb +13 -2
- data/spec/motion/http/query_spec.rb +731 -0
- data/spec/motion/http/response_spec.rb +44 -0
- data/spec/motion/http_spec.rb +0 -722
- data/spec/motion/{core → ui}/gestures_spec.rb +0 -0
- data/spec/motion/ui/ui_alert_view_spec.rb +1188 -0
- data/spec/motion/{core → ui}/ui_bar_button_item_spec.rb +80 -24
- data/spec/motion/{core → ui}/ui_control_spec.rb +0 -0
- data/spec/motion/util/constants_spec.rb +4 -4
- metadata +86 -26
File without changes
|
@@ -0,0 +1,1188 @@
|
|
1
|
+
shared "an instance with no options" do
|
2
|
+
it "has the correct class" do
|
3
|
+
@subject.class.should.equal(BW::UIAlertView)
|
4
|
+
end
|
5
|
+
|
6
|
+
it "has the correct superclass" do
|
7
|
+
@subject.superclass.should.equal(::UIAlertView)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has no title" do
|
11
|
+
@subject.title.should.be.nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has no message" do
|
15
|
+
@subject.message.should.be.nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has the correct delegate" do
|
19
|
+
@subject.delegate.should.equal(@subject)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has no clicked button" do
|
23
|
+
@subject.clicked_button.should.be.nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has no will_present handler" do
|
27
|
+
@subject.will_present.should.be.nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has no did_present handler" do
|
31
|
+
@subject.did_present.should.be.nil
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has no on_system_cancel handler" do
|
35
|
+
@subject.on_system_cancel.should.be.nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has no will_dismiss handler" do
|
39
|
+
@subject.will_dismiss.should.be.nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "has no did_dismiss handler" do
|
43
|
+
@subject.did_dismiss.should.be.nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it "has no enable_first_other_button? handler" do
|
47
|
+
@subject.enable_first_other_button?.should.be.nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
###################################################################################################
|
52
|
+
|
53
|
+
shared "an instance with a full set of options" do
|
54
|
+
it "has the correct title" do
|
55
|
+
@subject.title.should.equal(@options[:title])
|
56
|
+
end
|
57
|
+
|
58
|
+
it "has the correct message" do
|
59
|
+
@subject.message.should.equal(@options[:message])
|
60
|
+
end
|
61
|
+
|
62
|
+
it "has the correct delegate" do
|
63
|
+
@subject.delegate.should.equal(@subject)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "has the correct cancel button index" do
|
67
|
+
@subject.cancel_button_index.should.equal(@options[:cancel_button_index])
|
68
|
+
end
|
69
|
+
|
70
|
+
it "has the correct buttons" do
|
71
|
+
@subject.numberOfButtons.should.equal(1)
|
72
|
+
@subject.buttonTitleAtIndex(0).should.equal(@options[:buttons])
|
73
|
+
end
|
74
|
+
|
75
|
+
it "has no clicked button" do
|
76
|
+
@subject.clicked_button.should.be.nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it "has no will_present handler" do
|
80
|
+
@subject.will_present.should.equal(@options[:will_present])
|
81
|
+
end
|
82
|
+
|
83
|
+
it "has no did_present handler" do
|
84
|
+
@subject.did_present.should.equal(@options[:did_present])
|
85
|
+
end
|
86
|
+
|
87
|
+
it "has no on_system_cancel handler" do
|
88
|
+
@subject.on_system_cancel.should.equal(@options[:on_system_cancel])
|
89
|
+
end
|
90
|
+
|
91
|
+
it "has the correct on_click handler" do
|
92
|
+
@subject.on_click.should.equal(@options[:on_click])
|
93
|
+
end
|
94
|
+
|
95
|
+
it "has no will_dismiss handler" do
|
96
|
+
@subject.will_dismiss.should.equal(@options[:will_dismiss])
|
97
|
+
end
|
98
|
+
|
99
|
+
it "has no did_dismiss handler" do
|
100
|
+
@subject.did_dismiss.should.equal(@options[:did_dismiss])
|
101
|
+
end
|
102
|
+
|
103
|
+
it "has no enable_first_other_button? handler" do
|
104
|
+
@subject.enable_first_other_button?.should.equal(@options[:enable_first_other_button?])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
###################################################################################################
|
109
|
+
|
110
|
+
describe BW::UIAlertView do
|
111
|
+
describe ".new" do
|
112
|
+
describe "given no options" do
|
113
|
+
before do
|
114
|
+
@subject = BW::UIAlertView.new
|
115
|
+
end
|
116
|
+
|
117
|
+
behaves_like "an instance with no options"
|
118
|
+
|
119
|
+
it "has the correct style" do
|
120
|
+
@subject.style.should.equal(UIAlertViewStyleDefault)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "has no buttons" do
|
124
|
+
@subject.numberOfButtons.should.equal(0)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "has the correct cancel button index" do
|
128
|
+
@subject.cancel_button_index.should.equal(-1)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "has no on_click handler" do
|
132
|
+
@subject.on_click.should.be.nil
|
133
|
+
end
|
134
|
+
|
135
|
+
it "has no plain text field" do
|
136
|
+
@subject.plain_text_field.should.be.nil
|
137
|
+
end
|
138
|
+
|
139
|
+
it "has no secure text field" do
|
140
|
+
@subject.secure_text_field.should.be.nil
|
141
|
+
end
|
142
|
+
|
143
|
+
it "has no login text field" do
|
144
|
+
@subject.login_text_field.should.be.nil
|
145
|
+
end
|
146
|
+
|
147
|
+
it "has no password text field" do
|
148
|
+
@subject.password_text_field.should.be.nil
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
###############################################################################################
|
153
|
+
|
154
|
+
describe "given no options with a block" do
|
155
|
+
before do
|
156
|
+
@options = {}
|
157
|
+
@block = -> { true }
|
158
|
+
@subject = BW::UIAlertView.new(@options, &@block)
|
159
|
+
end
|
160
|
+
|
161
|
+
behaves_like "an instance with no options"
|
162
|
+
|
163
|
+
it "has the correct style" do
|
164
|
+
@subject.style.should.equal(UIAlertViewStyleDefault)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "has no buttons" do
|
168
|
+
@subject.numberOfButtons.should.equal(0)
|
169
|
+
end
|
170
|
+
|
171
|
+
it "has the correct cancel button index" do
|
172
|
+
@subject.cancel_button_index.should.equal(-1)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "has the correct on_click handler" do
|
176
|
+
@subject.on_click.should.equal(@block)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
###############################################################################################
|
181
|
+
|
182
|
+
describe "given a complete set of options" do
|
183
|
+
before do
|
184
|
+
@options = {
|
185
|
+
:title => "title",
|
186
|
+
:message => "message",
|
187
|
+
:style => :plain_text_input,
|
188
|
+
:buttons => "button title",
|
189
|
+
:cancel_button_index => 0,
|
190
|
+
:will_present => -> { true },
|
191
|
+
:did_present => -> { true },
|
192
|
+
:on_system_cancel => -> { true },
|
193
|
+
:on_click => -> { true },
|
194
|
+
:will_dismiss => -> { true },
|
195
|
+
:did_dismiss => -> { true },
|
196
|
+
:enable_first_other_button? => -> { true }
|
197
|
+
}
|
198
|
+
@subject = BW::UIAlertView.new(@options)
|
199
|
+
end
|
200
|
+
|
201
|
+
behaves_like "an instance with a full set of options"
|
202
|
+
end
|
203
|
+
|
204
|
+
###############################################################################################
|
205
|
+
|
206
|
+
describe "given options with multiple button titles" do
|
207
|
+
before do
|
208
|
+
@options = { buttons: ["first button", "second button"] }
|
209
|
+
@subject = BW::UIAlertView.new(@options)
|
210
|
+
end
|
211
|
+
|
212
|
+
it "has the correct buttons" do
|
213
|
+
@subject.numberOfButtons.should.equal(2)
|
214
|
+
@subject.buttonTitleAtIndex(0).should.equal(@options[:buttons][0])
|
215
|
+
@subject.buttonTitleAtIndex(1).should.equal(@options[:buttons][1])
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
###############################################################################################
|
220
|
+
|
221
|
+
describe "given options with both an on_click handler and a block" do
|
222
|
+
before do
|
223
|
+
@options = { on_click: -> { true }}
|
224
|
+
@block = -> { true }
|
225
|
+
@subject = BW::UIAlertView.new(@options, &@block)
|
226
|
+
end
|
227
|
+
|
228
|
+
it "has the correct on_click handler" do
|
229
|
+
@subject.on_click.should.equal(@options[:on_click])
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
#################################################################################################
|
235
|
+
|
236
|
+
describe ".default" do
|
237
|
+
describe "given no options" do
|
238
|
+
before do
|
239
|
+
@subject = BW::UIAlertView.default
|
240
|
+
end
|
241
|
+
|
242
|
+
behaves_like "an instance with no options"
|
243
|
+
|
244
|
+
it "has the correct style" do
|
245
|
+
@subject.style.should.equal(UIAlertViewStyleDefault)
|
246
|
+
end
|
247
|
+
|
248
|
+
it "has the correct buttons" do
|
249
|
+
@subject.numberOfButtons.should.equal(1)
|
250
|
+
@subject.buttonTitleAtIndex(0).should.equal("OK")
|
251
|
+
end
|
252
|
+
|
253
|
+
it "has the correct cancel button index" do
|
254
|
+
@subject.cancel_button_index.should.equal(-1)
|
255
|
+
end
|
256
|
+
|
257
|
+
it "has no on_click handler" do
|
258
|
+
@subject.on_click.should.be.nil
|
259
|
+
end
|
260
|
+
|
261
|
+
it "has no plain text field" do
|
262
|
+
@subject.plain_text_field.should.be.nil
|
263
|
+
end
|
264
|
+
|
265
|
+
it "has no secure text field" do
|
266
|
+
@subject.secure_text_field.should.be.nil
|
267
|
+
end
|
268
|
+
|
269
|
+
it "has no login text field" do
|
270
|
+
@subject.login_text_field.should.be.nil
|
271
|
+
end
|
272
|
+
|
273
|
+
it "has no password text field" do
|
274
|
+
@subject.password_text_field.should.be.nil
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
###############################################################################################
|
279
|
+
|
280
|
+
describe "given no options with a block" do
|
281
|
+
before do
|
282
|
+
@options = {}
|
283
|
+
@block = -> { true }
|
284
|
+
@subject = BW::UIAlertView.default(@options, &@block)
|
285
|
+
end
|
286
|
+
|
287
|
+
behaves_like "an instance with no options"
|
288
|
+
|
289
|
+
it "has the correct style" do
|
290
|
+
@subject.style.should.equal(UIAlertViewStyleDefault)
|
291
|
+
end
|
292
|
+
|
293
|
+
it "has the correct buttons" do
|
294
|
+
@subject.numberOfButtons.should.equal(1)
|
295
|
+
@subject.buttonTitleAtIndex(0).should.equal("OK")
|
296
|
+
end
|
297
|
+
|
298
|
+
it "has the correct cancel button index" do
|
299
|
+
@subject.cancel_button_index.should.equal(-1)
|
300
|
+
end
|
301
|
+
|
302
|
+
it "has the correct on_click handler" do
|
303
|
+
@subject.on_click.should.equal(@block)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
###############################################################################################
|
308
|
+
|
309
|
+
describe "given a complete set of options" do
|
310
|
+
before do
|
311
|
+
@options = {
|
312
|
+
:title => "title",
|
313
|
+
:message => "message",
|
314
|
+
:style => :plain_text_input,
|
315
|
+
:buttons => "button title",
|
316
|
+
:cancel_button_index => 0,
|
317
|
+
:will_present => -> { true },
|
318
|
+
:did_present => -> { true },
|
319
|
+
:on_system_cancel => -> { true },
|
320
|
+
:on_click => -> { true },
|
321
|
+
:will_dismiss => -> { true },
|
322
|
+
:did_dismiss => -> { true },
|
323
|
+
:enable_first_other_button? => -> { true }
|
324
|
+
}
|
325
|
+
@subject = BW::UIAlertView.default(@options)
|
326
|
+
end
|
327
|
+
|
328
|
+
behaves_like "an instance with a full set of options"
|
329
|
+
end
|
330
|
+
|
331
|
+
###############################################################################################
|
332
|
+
|
333
|
+
describe "given options with multiple button titles" do
|
334
|
+
before do
|
335
|
+
@options = { buttons: ["first button", "second button"] }
|
336
|
+
@subject = BW::UIAlertView.new(@options)
|
337
|
+
end
|
338
|
+
|
339
|
+
it "has the correct buttons" do
|
340
|
+
@subject.numberOfButtons.should.equal(2)
|
341
|
+
@subject.buttonTitleAtIndex(0).should.equal(@options[:buttons][0])
|
342
|
+
@subject.buttonTitleAtIndex(1).should.equal(@options[:buttons][1])
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
###############################################################################################
|
347
|
+
|
348
|
+
describe "given options with a cancel button index" do
|
349
|
+
before do
|
350
|
+
@options = { cancel_button_index: 0 }
|
351
|
+
@subject = BW::UIAlertView.new(@options)
|
352
|
+
end
|
353
|
+
|
354
|
+
it "has the correct cancel button index" do
|
355
|
+
@subject.cancel_button_index.should.equal(0)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
###############################################################################################
|
360
|
+
|
361
|
+
describe "given options with both an on_click handler and a block" do
|
362
|
+
before do
|
363
|
+
@options = { on_click: -> { true }}
|
364
|
+
@block = -> { true }
|
365
|
+
@subject = BW::UIAlertView.default(@options, &@block)
|
366
|
+
end
|
367
|
+
|
368
|
+
it "has the correct on_click handler" do
|
369
|
+
@subject.on_click.should.equal(@options[:on_click])
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
#################################################################################################
|
375
|
+
|
376
|
+
describe ".plain_text_input" do
|
377
|
+
describe "given no options" do
|
378
|
+
before do
|
379
|
+
@subject = BW::UIAlertView.plain_text_input
|
380
|
+
end
|
381
|
+
|
382
|
+
behaves_like "an instance with no options"
|
383
|
+
|
384
|
+
it "has the correct style" do
|
385
|
+
@subject.style.should.equal(UIAlertViewStylePlainTextInput)
|
386
|
+
end
|
387
|
+
|
388
|
+
it "has the correct buttons" do
|
389
|
+
@subject.numberOfButtons.should.equal(2)
|
390
|
+
@subject.buttonTitleAtIndex(0).should.equal("Cancel")
|
391
|
+
@subject.buttonTitleAtIndex(1).should.equal("OK")
|
392
|
+
end
|
393
|
+
|
394
|
+
it "has the correct cancel button index" do
|
395
|
+
@subject.cancel_button_index.should.equal(0)
|
396
|
+
end
|
397
|
+
|
398
|
+
it "has no on_click handler" do
|
399
|
+
@subject.on_click.should.be.nil
|
400
|
+
end
|
401
|
+
|
402
|
+
it "has a plain text field" do
|
403
|
+
@subject.plain_text_field.should.be.kind_of(UITextField)
|
404
|
+
end
|
405
|
+
|
406
|
+
it "has no secure text field" do
|
407
|
+
@subject.secure_text_field.should.be.nil
|
408
|
+
end
|
409
|
+
|
410
|
+
it "has no login text field" do
|
411
|
+
@subject.login_text_field.should.be.nil
|
412
|
+
end
|
413
|
+
|
414
|
+
it "has no password text field" do
|
415
|
+
@subject.password_text_field.should.be.nil
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
###############################################################################################
|
420
|
+
|
421
|
+
describe "given no options with a block" do
|
422
|
+
before do
|
423
|
+
@options = {}
|
424
|
+
@block = -> { true }
|
425
|
+
@subject = BW::UIAlertView.plain_text_input(@options, &@block)
|
426
|
+
end
|
427
|
+
|
428
|
+
behaves_like "an instance with no options"
|
429
|
+
|
430
|
+
it "has the correct style" do
|
431
|
+
@subject.style.should.equal(UIAlertViewStylePlainTextInput)
|
432
|
+
end
|
433
|
+
|
434
|
+
it "has the correct buttons" do
|
435
|
+
@subject.numberOfButtons.should.equal(2)
|
436
|
+
@subject.buttonTitleAtIndex(0).should.equal("Cancel")
|
437
|
+
@subject.buttonTitleAtIndex(1).should.equal("OK")
|
438
|
+
end
|
439
|
+
|
440
|
+
it "has the correct cancel button index" do
|
441
|
+
@subject.cancel_button_index.should.equal(0)
|
442
|
+
end
|
443
|
+
|
444
|
+
it "has the correct on_click handler" do
|
445
|
+
@subject.on_click.should.equal(@block)
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
###############################################################################################
|
450
|
+
|
451
|
+
describe "given a complete set of options" do
|
452
|
+
before do
|
453
|
+
@options = {
|
454
|
+
:title => "title",
|
455
|
+
:message => "message",
|
456
|
+
:style => :default,
|
457
|
+
:buttons => "button title",
|
458
|
+
:cancel_button_index => 0,
|
459
|
+
:will_present => -> { true },
|
460
|
+
:did_present => -> { true },
|
461
|
+
:on_system_cancel => -> { true },
|
462
|
+
:on_click => -> { true },
|
463
|
+
:will_dismiss => -> { true },
|
464
|
+
:did_dismiss => -> { true },
|
465
|
+
:enable_first_other_button? => -> { true }
|
466
|
+
}
|
467
|
+
@subject = BW::UIAlertView.plain_text_input(@options)
|
468
|
+
end
|
469
|
+
|
470
|
+
behaves_like "an instance with a full set of options"
|
471
|
+
end
|
472
|
+
|
473
|
+
###############################################################################################
|
474
|
+
|
475
|
+
describe "given options with multiple button titles" do
|
476
|
+
before do
|
477
|
+
@options = { buttons: ["first button", "second button"] }
|
478
|
+
@subject = BW::UIAlertView.new(@options)
|
479
|
+
end
|
480
|
+
|
481
|
+
it "has the correct buttons" do
|
482
|
+
@subject.numberOfButtons.should.equal(2)
|
483
|
+
@subject.buttonTitleAtIndex(0).should.equal(@options[:buttons][0])
|
484
|
+
@subject.buttonTitleAtIndex(1).should.equal(@options[:buttons][1])
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
###############################################################################################
|
489
|
+
|
490
|
+
describe "given options with a cancel button index" do
|
491
|
+
before do
|
492
|
+
@options = { cancel_button_index: -1 }
|
493
|
+
@subject = BW::UIAlertView.plain_text_input(@options)
|
494
|
+
end
|
495
|
+
|
496
|
+
it "has the correct cancel button index" do
|
497
|
+
@subject.cancel_button_index.should.equal(-1)
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
###############################################################################################
|
502
|
+
|
503
|
+
describe "given options with both an on_click handler and a block" do
|
504
|
+
before do
|
505
|
+
@options = { on_click: -> { true }}
|
506
|
+
@block = -> { true }
|
507
|
+
@subject = BW::UIAlertView.plain_text_input(@options, &@block)
|
508
|
+
end
|
509
|
+
|
510
|
+
it "has the correct on_click handler" do
|
511
|
+
@subject.on_click.should.equal(@options[:on_click])
|
512
|
+
end
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
#################################################################################################
|
517
|
+
|
518
|
+
describe ".secure_text_input" do
|
519
|
+
describe "given no options" do
|
520
|
+
before do
|
521
|
+
@subject = BW::UIAlertView.secure_text_input
|
522
|
+
end
|
523
|
+
|
524
|
+
behaves_like "an instance with no options"
|
525
|
+
|
526
|
+
it "has the correct style" do
|
527
|
+
@subject.style.should.equal(UIAlertViewStyleSecureTextInput)
|
528
|
+
end
|
529
|
+
|
530
|
+
it "has the correct buttons" do
|
531
|
+
@subject.numberOfButtons.should.equal(2)
|
532
|
+
@subject.buttonTitleAtIndex(0).should.equal("Cancel")
|
533
|
+
@subject.buttonTitleAtIndex(1).should.equal("OK")
|
534
|
+
end
|
535
|
+
|
536
|
+
it "has the correct cancel button index" do
|
537
|
+
@subject.cancel_button_index.should.equal(0)
|
538
|
+
end
|
539
|
+
|
540
|
+
it "has no on_click handler" do
|
541
|
+
@subject.on_click.should.be.nil
|
542
|
+
end
|
543
|
+
|
544
|
+
it "has no plain text field" do
|
545
|
+
@subject.plain_text_field.should.be.nil
|
546
|
+
end
|
547
|
+
|
548
|
+
it "has a secure text field" do
|
549
|
+
@subject.secure_text_field.should.be.kind_of(UITextField)
|
550
|
+
end
|
551
|
+
|
552
|
+
it "has no login text field" do
|
553
|
+
@subject.login_text_field.should.be.nil
|
554
|
+
end
|
555
|
+
|
556
|
+
it "has no password text field" do
|
557
|
+
@subject.password_text_field.should.be.nil
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
561
|
+
###############################################################################################
|
562
|
+
|
563
|
+
describe "given no options with a block" do
|
564
|
+
before do
|
565
|
+
@options = {}
|
566
|
+
@block = -> { true }
|
567
|
+
@subject = BW::UIAlertView.secure_text_input(@options, &@block)
|
568
|
+
end
|
569
|
+
|
570
|
+
behaves_like "an instance with no options"
|
571
|
+
|
572
|
+
it "has the correct style" do
|
573
|
+
@subject.style.should.equal(UIAlertViewStyleSecureTextInput)
|
574
|
+
end
|
575
|
+
|
576
|
+
it "has the correct buttons" do
|
577
|
+
@subject.numberOfButtons.should.equal(2)
|
578
|
+
@subject.buttonTitleAtIndex(0).should.equal("Cancel")
|
579
|
+
@subject.buttonTitleAtIndex(1).should.equal("OK")
|
580
|
+
end
|
581
|
+
|
582
|
+
it "has the correct cancel button index" do
|
583
|
+
@subject.cancel_button_index.should.equal(0)
|
584
|
+
end
|
585
|
+
|
586
|
+
it "has the correct on_click handler" do
|
587
|
+
@subject.on_click.should.equal(@block)
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
###############################################################################################
|
592
|
+
|
593
|
+
describe "given a complete set of options" do
|
594
|
+
before do
|
595
|
+
@options = {
|
596
|
+
:title => "title",
|
597
|
+
:message => "message",
|
598
|
+
:style => :default,
|
599
|
+
:buttons => "button title",
|
600
|
+
:cancel_button_index => 0,
|
601
|
+
:will_present => -> { true },
|
602
|
+
:did_present => -> { true },
|
603
|
+
:on_system_cancel => -> { true },
|
604
|
+
:on_click => -> { true },
|
605
|
+
:will_dismiss => -> { true },
|
606
|
+
:did_dismiss => -> { true },
|
607
|
+
:enable_first_other_button? => -> { true }
|
608
|
+
}
|
609
|
+
@subject = BW::UIAlertView.secure_text_input(@options)
|
610
|
+
end
|
611
|
+
|
612
|
+
behaves_like "an instance with a full set of options"
|
613
|
+
end
|
614
|
+
|
615
|
+
###############################################################################################
|
616
|
+
|
617
|
+
describe "given options with multiple button titles" do
|
618
|
+
before do
|
619
|
+
@options = { buttons: ["first button", "second button"] }
|
620
|
+
@subject = BW::UIAlertView.new(@options)
|
621
|
+
end
|
622
|
+
|
623
|
+
it "has the correct buttons" do
|
624
|
+
@subject.numberOfButtons.should.equal(2)
|
625
|
+
@subject.buttonTitleAtIndex(0).should.equal(@options[:buttons][0])
|
626
|
+
@subject.buttonTitleAtIndex(1).should.equal(@options[:buttons][1])
|
627
|
+
end
|
628
|
+
end
|
629
|
+
|
630
|
+
###############################################################################################
|
631
|
+
|
632
|
+
describe "given options with a cancel button index" do
|
633
|
+
before do
|
634
|
+
@options = { cancel_button_index: -1 }
|
635
|
+
@subject = BW::UIAlertView.secure_text_input(@options)
|
636
|
+
end
|
637
|
+
|
638
|
+
it "has the correct cancel button index" do
|
639
|
+
@subject.cancel_button_index.should.equal(-1)
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
###############################################################################################
|
644
|
+
|
645
|
+
describe "given options with both an on_click handler and a block" do
|
646
|
+
before do
|
647
|
+
@options = { on_click: -> { true }}
|
648
|
+
@block = -> { true }
|
649
|
+
@subject = BW::UIAlertView.secure_text_input(@options, &@block)
|
650
|
+
end
|
651
|
+
|
652
|
+
it "has the correct on_click handler" do
|
653
|
+
@subject.on_click.should.equal(@options[:on_click])
|
654
|
+
end
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
#################################################################################################
|
659
|
+
|
660
|
+
describe ".login_and_password_input" do
|
661
|
+
describe "given no options" do
|
662
|
+
before do
|
663
|
+
@subject = BW::UIAlertView.login_and_password_input
|
664
|
+
end
|
665
|
+
|
666
|
+
behaves_like "an instance with no options"
|
667
|
+
|
668
|
+
it "has the correct style" do
|
669
|
+
@subject.style.should.equal(UIAlertViewStyleLoginAndPasswordInput)
|
670
|
+
end
|
671
|
+
|
672
|
+
it "has the correct buttons" do
|
673
|
+
@subject.numberOfButtons.should.equal(2)
|
674
|
+
@subject.buttonTitleAtIndex(0).should.equal("Cancel")
|
675
|
+
@subject.buttonTitleAtIndex(1).should.equal("Log in")
|
676
|
+
end
|
677
|
+
|
678
|
+
it "has the correct cancel button index" do
|
679
|
+
@subject.cancel_button_index.should.equal(0)
|
680
|
+
end
|
681
|
+
|
682
|
+
it "has no on_click handler" do
|
683
|
+
@subject.on_click.should.be.nil
|
684
|
+
end
|
685
|
+
|
686
|
+
it "has no plain text field" do
|
687
|
+
@subject.plain_text_field.should.be.nil
|
688
|
+
end
|
689
|
+
|
690
|
+
it "has no secure text field" do
|
691
|
+
@subject.secure_text_field.should.be.nil
|
692
|
+
end
|
693
|
+
|
694
|
+
it "has a login text field" do
|
695
|
+
@subject.login_text_field.should.be.kind_of(UITextField)
|
696
|
+
end
|
697
|
+
|
698
|
+
it "has a password text field" do
|
699
|
+
@subject.password_text_field.should.be.kind_of(UITextField)
|
700
|
+
end
|
701
|
+
end
|
702
|
+
|
703
|
+
###############################################################################################
|
704
|
+
|
705
|
+
describe "given no options with a block" do
|
706
|
+
before do
|
707
|
+
@options = {}
|
708
|
+
@block = -> { true }
|
709
|
+
@subject = BW::UIAlertView.login_and_password_input(@options, &@block)
|
710
|
+
end
|
711
|
+
|
712
|
+
behaves_like "an instance with no options"
|
713
|
+
|
714
|
+
it "has the correct style" do
|
715
|
+
@subject.style.should.equal(UIAlertViewStyleLoginAndPasswordInput)
|
716
|
+
end
|
717
|
+
|
718
|
+
it "has the correct buttons" do
|
719
|
+
@subject.numberOfButtons.should.equal(2)
|
720
|
+
@subject.buttonTitleAtIndex(0).should.equal("Cancel")
|
721
|
+
@subject.buttonTitleAtIndex(1).should.equal("Log in")
|
722
|
+
end
|
723
|
+
|
724
|
+
it "has the correct cancel button index" do
|
725
|
+
@subject.cancel_button_index.should.equal(0)
|
726
|
+
end
|
727
|
+
|
728
|
+
it "has the correct on_click handler" do
|
729
|
+
@subject.on_click.should.equal(@block)
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
###############################################################################################
|
734
|
+
|
735
|
+
describe "given a complete set of options" do
|
736
|
+
before do
|
737
|
+
@options = {
|
738
|
+
:title => "title",
|
739
|
+
:message => "message",
|
740
|
+
:style => :default,
|
741
|
+
:buttons => "button title",
|
742
|
+
:cancel_button_index => 0,
|
743
|
+
:will_present => -> { true },
|
744
|
+
:did_present => -> { true },
|
745
|
+
:on_system_cancel => -> { true },
|
746
|
+
:on_click => -> { true },
|
747
|
+
:will_dismiss => -> { true },
|
748
|
+
:did_dismiss => -> { true },
|
749
|
+
:enable_first_other_button? => -> { true }
|
750
|
+
}
|
751
|
+
@subject = BW::UIAlertView.login_and_password_input(@options)
|
752
|
+
end
|
753
|
+
|
754
|
+
behaves_like "an instance with a full set of options"
|
755
|
+
end
|
756
|
+
|
757
|
+
###############################################################################################
|
758
|
+
|
759
|
+
describe "given options with multiple button titles" do
|
760
|
+
before do
|
761
|
+
@options = { buttons: ["first button", "second button"] }
|
762
|
+
@subject = BW::UIAlertView.new(@options)
|
763
|
+
end
|
764
|
+
|
765
|
+
it "has the correct buttons" do
|
766
|
+
@subject.numberOfButtons.should.equal(2)
|
767
|
+
@subject.buttonTitleAtIndex(0).should.equal(@options[:buttons][0])
|
768
|
+
@subject.buttonTitleAtIndex(1).should.equal(@options[:buttons][1])
|
769
|
+
end
|
770
|
+
end
|
771
|
+
|
772
|
+
###############################################################################################
|
773
|
+
|
774
|
+
describe "given options with a cancel button index" do
|
775
|
+
before do
|
776
|
+
@options = { cancel_button_index: -1 }
|
777
|
+
@subject = BW::UIAlertView.login_and_password_input(@options)
|
778
|
+
end
|
779
|
+
|
780
|
+
it "has the correct cancel button index" do
|
781
|
+
@subject.cancel_button_index.should.equal(-1)
|
782
|
+
end
|
783
|
+
end
|
784
|
+
|
785
|
+
###############################################################################################
|
786
|
+
|
787
|
+
describe "given options with both an on_click handler and a block" do
|
788
|
+
before do
|
789
|
+
@options = { on_click: -> { true }}
|
790
|
+
@block = -> { true }
|
791
|
+
@subject = BW::UIAlertView.login_and_password_input(@options, &@block)
|
792
|
+
end
|
793
|
+
|
794
|
+
it "has the correct on_click handler" do
|
795
|
+
@subject.on_click.should.equal(@options[:on_click])
|
796
|
+
end
|
797
|
+
end
|
798
|
+
end
|
799
|
+
|
800
|
+
#################################################################################################
|
801
|
+
|
802
|
+
BW::UIAlertView.callbacks.each do |callback|
|
803
|
+
describe ".#{callback}" do
|
804
|
+
before do
|
805
|
+
@subject = BW::UIAlertView.new
|
806
|
+
end
|
807
|
+
|
808
|
+
describe "given no block" do
|
809
|
+
before do
|
810
|
+
@return = @subject.send(callback)
|
811
|
+
end
|
812
|
+
|
813
|
+
it "returns no handler" do
|
814
|
+
@return.should.be.nil
|
815
|
+
end
|
816
|
+
|
817
|
+
it "has no handler" do
|
818
|
+
@subject.send(callback).should.be.nil
|
819
|
+
end
|
820
|
+
end
|
821
|
+
|
822
|
+
###############################################################################################
|
823
|
+
|
824
|
+
describe "given a block" do
|
825
|
+
before do
|
826
|
+
@block = -> { true }
|
827
|
+
@return = @subject.send(callback, &@block)
|
828
|
+
end
|
829
|
+
|
830
|
+
it "returns the subject" do
|
831
|
+
@return.should.equal(@subject)
|
832
|
+
end
|
833
|
+
|
834
|
+
it "has the correct handler" do
|
835
|
+
@subject.send(callback).should.equal(@block)
|
836
|
+
end
|
837
|
+
end
|
838
|
+
end
|
839
|
+
end
|
840
|
+
|
841
|
+
#################################################################################################
|
842
|
+
|
843
|
+
describe "#style=" do
|
844
|
+
before do
|
845
|
+
@subject = BW::UIAlertView.new
|
846
|
+
end
|
847
|
+
|
848
|
+
describe "given no style" do
|
849
|
+
before do
|
850
|
+
@subject.style = nil
|
851
|
+
end
|
852
|
+
|
853
|
+
it "has the correct style" do
|
854
|
+
@subject.style.should.equal(UIAlertViewStyleDefault)
|
855
|
+
end
|
856
|
+
end
|
857
|
+
|
858
|
+
###############################################################################################
|
859
|
+
|
860
|
+
describe "given a style" do
|
861
|
+
before do
|
862
|
+
@subject.style = :plain_text_input
|
863
|
+
end
|
864
|
+
|
865
|
+
it "has the correct style" do
|
866
|
+
@subject.style.should.equal(UIAlertViewStylePlainTextInput)
|
867
|
+
end
|
868
|
+
end
|
869
|
+
end
|
870
|
+
|
871
|
+
#################################################################################################
|
872
|
+
|
873
|
+
describe "#cancel_button_index=" do
|
874
|
+
before do
|
875
|
+
@subject = BW::UIAlertView.new
|
876
|
+
end
|
877
|
+
|
878
|
+
describe "given no cancel button index" do
|
879
|
+
before do
|
880
|
+
@subject.cancel_button_index = nil
|
881
|
+
end
|
882
|
+
|
883
|
+
it "has the correct cancel button index" do
|
884
|
+
@subject.cancel_button_index.should.equal(-1)
|
885
|
+
end
|
886
|
+
end
|
887
|
+
|
888
|
+
###############################################################################################
|
889
|
+
|
890
|
+
describe "given a cancel button index" do
|
891
|
+
before do
|
892
|
+
@subject.cancel_button_index = 0
|
893
|
+
end
|
894
|
+
|
895
|
+
it "has the correct cancel button index" do
|
896
|
+
@subject.cancel_button_index.should.equal(0)
|
897
|
+
end
|
898
|
+
end
|
899
|
+
end
|
900
|
+
|
901
|
+
#################################################################################################
|
902
|
+
|
903
|
+
describe "-willPresentAlertView:" do
|
904
|
+
before do
|
905
|
+
@subject = BW::UIAlertView.new
|
906
|
+
end
|
907
|
+
|
908
|
+
describe "given no will_present handler" do
|
909
|
+
it "returns noting" do
|
910
|
+
@subject.willPresentAlertView(@subject).should.be.nil
|
911
|
+
end
|
912
|
+
end
|
913
|
+
|
914
|
+
###############################################################################################
|
915
|
+
|
916
|
+
describe "given a will_present handler" do
|
917
|
+
before do
|
918
|
+
@subject.will_present do |alert|
|
919
|
+
alert.should.equal(@subject)
|
920
|
+
alert.clicked_button.should.be.nil
|
921
|
+
:will_present
|
922
|
+
end
|
923
|
+
end
|
924
|
+
|
925
|
+
it "returns correctly" do
|
926
|
+
@subject.willPresentAlertView(@subject).should.equal(:will_present)
|
927
|
+
end
|
928
|
+
end
|
929
|
+
end
|
930
|
+
|
931
|
+
#################################################################################################
|
932
|
+
|
933
|
+
describe "-didPresentAlertView:" do
|
934
|
+
before do
|
935
|
+
@subject = BW::UIAlertView.new
|
936
|
+
end
|
937
|
+
|
938
|
+
describe "given no did_present handler" do
|
939
|
+
it "returns noting" do
|
940
|
+
@subject.didPresentAlertView(@subject).should.be.nil
|
941
|
+
end
|
942
|
+
end
|
943
|
+
|
944
|
+
###############################################################################################
|
945
|
+
|
946
|
+
describe "given a did_present handler" do
|
947
|
+
before do
|
948
|
+
@subject.did_present do |alert|
|
949
|
+
alert.should.equal(@subject)
|
950
|
+
alert.clicked_button.should.be.nil
|
951
|
+
:did_present
|
952
|
+
end
|
953
|
+
end
|
954
|
+
|
955
|
+
it "returns correctly" do
|
956
|
+
@subject.didPresentAlertView(@subject).should.equal(:did_present)
|
957
|
+
end
|
958
|
+
end
|
959
|
+
end
|
960
|
+
|
961
|
+
#################################################################################################
|
962
|
+
|
963
|
+
describe "-alertViewCancel:" do
|
964
|
+
before do
|
965
|
+
@subject = BW::UIAlertView.new
|
966
|
+
end
|
967
|
+
|
968
|
+
describe "given no on_system_cancel handler" do
|
969
|
+
it "returns noting" do
|
970
|
+
@subject.alertViewCancel(@subject).should.be.nil
|
971
|
+
end
|
972
|
+
end
|
973
|
+
|
974
|
+
###############################################################################################
|
975
|
+
|
976
|
+
describe "given an on_system_cancel handler" do
|
977
|
+
before do
|
978
|
+
@subject.on_system_cancel do |alert|
|
979
|
+
alert.should.equal(@subject)
|
980
|
+
alert.clicked_button.should.be.nil
|
981
|
+
:on_system_cancel
|
982
|
+
end
|
983
|
+
end
|
984
|
+
|
985
|
+
it "returns correctly" do
|
986
|
+
@subject.alertViewCancel(@subject).should.equal(:on_system_cancel)
|
987
|
+
end
|
988
|
+
end
|
989
|
+
end
|
990
|
+
|
991
|
+
#################################################################################################
|
992
|
+
|
993
|
+
describe "-alertViewShouldEnableFirstOtherButton:" do
|
994
|
+
before do
|
995
|
+
@subject = BW::UIAlertView.new
|
996
|
+
end
|
997
|
+
|
998
|
+
describe "given no enable_first_other_button? handler" do
|
999
|
+
it "returns noting" do
|
1000
|
+
@subject.alertViewShouldEnableFirstOtherButton(@subject).should.be.nil
|
1001
|
+
end
|
1002
|
+
end
|
1003
|
+
|
1004
|
+
###############################################################################################
|
1005
|
+
|
1006
|
+
describe "given an enable_first_other_button? handler" do
|
1007
|
+
before do
|
1008
|
+
@subject.enable_first_other_button? do |alert|
|
1009
|
+
alert.should.equal(@subject)
|
1010
|
+
alert.clicked_button.should.be.nil
|
1011
|
+
true
|
1012
|
+
end
|
1013
|
+
end
|
1014
|
+
|
1015
|
+
it "returns correctly" do
|
1016
|
+
@subject.alertViewShouldEnableFirstOtherButton(@subject).should.equal(true)
|
1017
|
+
end
|
1018
|
+
end
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
#################################################################################################
|
1022
|
+
|
1023
|
+
describe "-alertView:clickedButtonAtIndex:" do
|
1024
|
+
before do
|
1025
|
+
@index = 0
|
1026
|
+
@button = "button title"
|
1027
|
+
@subject = BW::UIAlertView.new(buttons: @button)
|
1028
|
+
end
|
1029
|
+
|
1030
|
+
describe "given no on_click handler" do
|
1031
|
+
it "returns noting" do
|
1032
|
+
@subject.alertView(@subject, clickedButtonAtIndex:@index).should.be.nil
|
1033
|
+
end
|
1034
|
+
end
|
1035
|
+
|
1036
|
+
###############################################################################################
|
1037
|
+
|
1038
|
+
describe "given an on_click handler" do
|
1039
|
+
before do
|
1040
|
+
@subject.on_click do |alert|
|
1041
|
+
alert.should.equal(@subject)
|
1042
|
+
alert.clicked_button.should.not.be.nil
|
1043
|
+
alert.clicked_button.index.should.equal(@index)
|
1044
|
+
alert.clicked_button.title.should.equal(@button)
|
1045
|
+
alert.clicked_button.should.not.be.cancel
|
1046
|
+
:on_click
|
1047
|
+
end
|
1048
|
+
end
|
1049
|
+
|
1050
|
+
it "returns correctly" do
|
1051
|
+
@subject.alertView(@subject, clickedButtonAtIndex:@index).should.equal(:on_click)
|
1052
|
+
end
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
###############################################################################################
|
1056
|
+
|
1057
|
+
describe "given an on_click handler with a cancel button index" do
|
1058
|
+
before do
|
1059
|
+
@subject.cancel_button_index = @index
|
1060
|
+
|
1061
|
+
@subject.on_click do |alert|
|
1062
|
+
alert.should.equal(@subject)
|
1063
|
+
alert.clicked_button.should.not.be.nil
|
1064
|
+
alert.clicked_button.index.should.equal(@index)
|
1065
|
+
alert.clicked_button.title.should.equal(@button)
|
1066
|
+
alert.clicked_button.should.be.cancel
|
1067
|
+
:on_click
|
1068
|
+
end
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
it "returns correctly" do
|
1072
|
+
@subject.alertView(@subject, clickedButtonAtIndex:@index).should.equal(:on_click)
|
1073
|
+
end
|
1074
|
+
end
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
#################################################################################################
|
1078
|
+
|
1079
|
+
describe "-alertView:willDismissWithButtonIndex:" do
|
1080
|
+
before do
|
1081
|
+
@index = 0
|
1082
|
+
@button = "button title"
|
1083
|
+
@subject = BW::UIAlertView.new(buttons: @button)
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
describe "given no will_dismiss handler" do
|
1087
|
+
it "returns noting" do
|
1088
|
+
@subject.alertView(@subject, willDismissWithButtonIndex:@index).should.be.nil
|
1089
|
+
end
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
###############################################################################################
|
1093
|
+
|
1094
|
+
describe "given a will_dismiss handler" do
|
1095
|
+
before do
|
1096
|
+
@subject.will_dismiss do |alert|
|
1097
|
+
alert.should.equal(@subject)
|
1098
|
+
alert.clicked_button.should.not.be.nil
|
1099
|
+
alert.clicked_button.index.should.equal(@index)
|
1100
|
+
alert.clicked_button.title.should.equal(@button)
|
1101
|
+
alert.clicked_button.should.not.be.cancel
|
1102
|
+
:will_dismiss
|
1103
|
+
end
|
1104
|
+
end
|
1105
|
+
|
1106
|
+
it "returns correctly" do
|
1107
|
+
@subject.alertView(@subject, willDismissWithButtonIndex:@index).should.equal(:will_dismiss)
|
1108
|
+
end
|
1109
|
+
end
|
1110
|
+
|
1111
|
+
###############################################################################################
|
1112
|
+
|
1113
|
+
describe "given a will_dismiss handler with a cancel button index" do
|
1114
|
+
before do
|
1115
|
+
@subject.cancel_button_index = @index
|
1116
|
+
|
1117
|
+
@subject.will_dismiss do |alert|
|
1118
|
+
alert.should.equal(@subject)
|
1119
|
+
alert.clicked_button.should.not.be.nil
|
1120
|
+
alert.clicked_button.index.should.equal(@index)
|
1121
|
+
alert.clicked_button.title.should.equal(@button)
|
1122
|
+
alert.clicked_button.should.be.cancel
|
1123
|
+
:will_dismiss
|
1124
|
+
end
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
it "returns correctly" do
|
1128
|
+
@subject.alertView(@subject, willDismissWithButtonIndex:@index).should.equal(:will_dismiss)
|
1129
|
+
end
|
1130
|
+
end
|
1131
|
+
end
|
1132
|
+
|
1133
|
+
#################################################################################################
|
1134
|
+
|
1135
|
+
describe "-alertView:didDismissWithButtonIndex:" do
|
1136
|
+
before do
|
1137
|
+
@index = 0
|
1138
|
+
@button = "button title"
|
1139
|
+
@subject = BW::UIAlertView.new(buttons: @button)
|
1140
|
+
end
|
1141
|
+
|
1142
|
+
describe "given no did_dismiss handler" do
|
1143
|
+
it "returns noting" do
|
1144
|
+
@subject.alertView(@subject, didDismissWithButtonIndex:@index).should.be.nil
|
1145
|
+
end
|
1146
|
+
end
|
1147
|
+
|
1148
|
+
###############################################################################################
|
1149
|
+
|
1150
|
+
describe "given a did_dismiss handler" do
|
1151
|
+
before do
|
1152
|
+
@subject.did_dismiss do |alert|
|
1153
|
+
alert.should.equal(@subject)
|
1154
|
+
alert.clicked_button.should.not.be.nil
|
1155
|
+
alert.clicked_button.index.should.equal(@index)
|
1156
|
+
alert.clicked_button.title.should.equal(@button)
|
1157
|
+
alert.clicked_button.should.not.be.cancel
|
1158
|
+
:did_dismiss
|
1159
|
+
end
|
1160
|
+
end
|
1161
|
+
|
1162
|
+
it "returns correctly" do
|
1163
|
+
@subject.alertView(@subject, didDismissWithButtonIndex:@index).should.equal(:did_dismiss)
|
1164
|
+
end
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
###############################################################################################
|
1168
|
+
|
1169
|
+
describe "given a did_dismiss handler with a cancel button index" do
|
1170
|
+
before do
|
1171
|
+
@subject.cancel_button_index = @index
|
1172
|
+
|
1173
|
+
@subject.did_dismiss do |alert|
|
1174
|
+
alert.should.equal(@subject)
|
1175
|
+
alert.clicked_button.should.not.be.nil
|
1176
|
+
alert.clicked_button.index.should.equal(@index)
|
1177
|
+
alert.clicked_button.title.should.equal(@button)
|
1178
|
+
alert.clicked_button.should.be.cancel
|
1179
|
+
:did_dismiss
|
1180
|
+
end
|
1181
|
+
end
|
1182
|
+
|
1183
|
+
it "returns correctly" do
|
1184
|
+
@subject.alertView(@subject, didDismissWithButtonIndex:@index).should.equal(:did_dismiss)
|
1185
|
+
end
|
1186
|
+
end
|
1187
|
+
end
|
1188
|
+
end
|