rsel 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +22 -8
  3. data/docs/development.md +1 -0
  4. data/docs/history.md +11 -1
  5. data/docs/index.md +1 -0
  6. data/docs/scoping.md +1 -1
  7. data/docs/studying.md +76 -0
  8. data/lib/rsel/selenium_test.rb +505 -90
  9. data/lib/rsel/study_html.rb +198 -0
  10. data/lib/rsel/support.rb +105 -4
  11. data/rsel.gemspec +1 -1
  12. data/spec/spec_helper.rb +4 -22
  13. data/spec/st_alerts.rb +48 -0
  14. data/spec/st_browser_spec.rb +58 -0
  15. data/spec/st_buttons_spec.rb +95 -0
  16. data/spec/st_checkboxes_spec.rb +235 -0
  17. data/spec/st_conditionals_spec.rb +180 -0
  18. data/spec/st_dropdowns_spec.rb +140 -0
  19. data/spec/st_field_equals_among_spec.rb +48 -0
  20. data/spec/st_fields_equal_among_spec.rb +74 -0
  21. data/spec/st_fields_equal_spec.rb +90 -0
  22. data/spec/st_fields_spec.rb +167 -0
  23. data/spec/st_initialization_spec.rb +33 -0
  24. data/spec/st_links_spec.rb +84 -0
  25. data/spec/st_method_missing_spec.rb +59 -0
  26. data/spec/st_navigation_spec.rb +56 -0
  27. data/spec/st_radiobuttons_spec.rb +123 -0
  28. data/spec/st_respond_to_spec.rb +16 -0
  29. data/spec/st_scenario_spec.rb +26 -0
  30. data/spec/st_set_field_among_spec.rb +45 -0
  31. data/spec/st_set_field_spec.rb +842 -0
  32. data/spec/st_set_fields_among_spec.rb +74 -0
  33. data/spec/st_set_fields_spec.rb +97 -0
  34. data/spec/st_spec_helper.rb +43 -0
  35. data/spec/st_stop_on_failure_spec.rb +199 -0
  36. data/spec/st_tables_spec.rb +42 -0
  37. data/spec/st_temporal_visibility_spec.rb +122 -0
  38. data/spec/st_visibility_spec.rb +125 -0
  39. data/spec/st_waiting_spec.rb +37 -0
  40. data/spec/study_html_spec.rb +310 -0
  41. data/spec/support_spec.rb +163 -13
  42. data/test/server/README.txt +3 -0
  43. data/test/views/alert.erb +15 -0
  44. data/test/views/form.erb +6 -1
  45. data/test/views/index.erb +2 -0
  46. data/test/views/slowtext.erb +1 -1
  47. metadata +38 -9
  48. data/spec/selenium_test_spec.rb +0 -2656
@@ -0,0 +1,842 @@
1
+ require 'spec/st_spec_helper'
2
+
3
+ describe "#set_field" do
4
+ context "fields" do
5
+ before(:each) do
6
+ @st.visit("/form").should be_true
7
+ end
8
+
9
+ context "#set_field with #type_into_field" do
10
+ context "passes when" do
11
+ context "text field with label" do
12
+ it "exists" do
13
+ @st.set_field("First name", "Eric").should be_true
14
+ @st.set_field("Last name", "Pierce").should be_true
15
+ @st.field_contains("First name", "Eric").should be_true
16
+ @st.field_contains("Last name", "Pierce").should be_true
17
+ end
18
+ it "exists within scope" do
19
+ @st.set_field("First name", "Eric", :within => 'person_form').should be_true
20
+ @st.set_field("First name", "Andrea", :within => 'spouse_form').should be_true
21
+ end
22
+ end
23
+
24
+ context "text field with id" do
25
+ it "exists" do
26
+ @st.set_field("first_name", "Eric").should be_true
27
+ @st.set_field("last_name", "Pierce").should be_true
28
+ @st.field_contains("first_name", "Eric").should be_true
29
+ @st.field_contains("last_name", "Pierce").should be_true
30
+ end
31
+ end
32
+
33
+ context "textarea with label" do
34
+ it "exists" do
35
+ @st.set_field("Life story", "Blah blah blah").should be_true
36
+ @st.set_field("Life story", "Jibber jabber").should be_true
37
+ @st.field_contains("Life story", "Jibber jabber").should be_true
38
+ end
39
+ end
40
+
41
+ context "textarea with id" do
42
+ it "exists" do
43
+ @st.set_field("biography", "Blah blah blah").should be_true
44
+ @st.set_field("biography", "Jibber jabber").should be_true
45
+ @st.field_contains("biography", "Jibber jabber").should be_true
46
+ end
47
+ end
48
+
49
+ context "text field with name but duplicate id" do
50
+ it "exists" do
51
+ @st.set_field("second_duplicate", "Jibber jabber").should be_true
52
+ @st.field_contains("first_duplicate", "").should be_true
53
+ @st.field_contains("second_duplicate", "Jibber jabber").should be_true
54
+ end
55
+ end
56
+
57
+ it "clears a field" do
58
+ @st.field_contains("message", "Your message goes here").should be_true
59
+ @st.set_field("message","").should be_true
60
+ @st.field_contains("message", "").should be_true
61
+ end
62
+ end
63
+
64
+ context "fails when" do
65
+ it "no field with the given label or id exists" do
66
+ @st.set_field("Middle name", "Matthew").should be_false
67
+ @st.set_field("middle_name", "Matthew").should be_false
68
+ end
69
+
70
+ it "field exists, but not within scope" do
71
+ @st.set_field("Life story", "Long story",
72
+ :within => 'spouse_form').should be_false
73
+ end
74
+
75
+ it "field exists, but is read-only" do
76
+ @st.visit("/readonly_form").should be_true
77
+ @st.set_field("First name", "Eric").should be_false
78
+ end
79
+
80
+ it "field exists but is hidden" do
81
+ #pending "selenium-client thinks hidden fields are editable" do
82
+ # FIXME: This test fails, because the selenium-client 'is_editable'
83
+ # method returns true for hidden fields. Rsel should work around
84
+ # this; hidden fields should not be editable.
85
+ @st.set_field("secret", "whisper").should be_false
86
+ #end
87
+ end
88
+ end
89
+ end # set_field with type_into_field
90
+
91
+ context "#set_field with #field_contains" do
92
+ context "passes when" do
93
+ context "text field with label" do
94
+ it "equals the text" do
95
+ @st.set_field("First name", "Marcus")
96
+ @st.field_contains("First name", "Marcus").should be_true
97
+ end
98
+
99
+ it "contains the text" do
100
+ @st.set_field("First name", "Marcus")
101
+ @st.field_contains("First name", "Marc").should be_true
102
+ end
103
+ end
104
+
105
+ context "textarea with label" do
106
+ it "contains the text" do
107
+ @st.set_field("Life story", "Blah dee blah")
108
+ @st.field_contains("Life story", "blah").should be_true
109
+ end
110
+ end
111
+ end
112
+
113
+ context "fails when" do
114
+ context "text field with label" do
115
+ it "does not contain the text" do
116
+ @st.set_field("First name", "Marcus")
117
+ @st.field_contains("First name", "Eric").should be_false
118
+ end
119
+ end
120
+
121
+ context "textarea with label" do
122
+ it "does not contain the text" do
123
+ @st.set_field("Life story", "Blah dee blah")
124
+ @st.field_contains("Life story", "spam").should be_false
125
+ end
126
+ end
127
+ end
128
+ end # set_field with field_contains
129
+
130
+ context "#set_field with #generic_field_equals" do
131
+ context "passes when" do
132
+ context "text field with label" do
133
+ it "equals the text" do
134
+ @st.set_field("First name", "Ken")
135
+ @st.generic_field_equals("First name", "Ken").should be_true
136
+ end
137
+
138
+ it "equals the text, and is within scope" do
139
+ @st.set_field("First name", "Eric", :within => "person_form")
140
+ @st.generic_field_equals("First name", "Eric", :within => "person_form")
141
+ end
142
+ end
143
+
144
+ context "textarea with label" do
145
+ it "equals the text" do
146
+ @st.set_field("Life story", "Blah dee blah")
147
+ @st.generic_field_equals("Life story", "Blah dee blah").should be_true
148
+ end
149
+
150
+ it "equals the text, and is within scope" do
151
+ @st.set_field("Life story", "Blah dee blah",
152
+ :within => "person_form")
153
+ @st.generic_field_equals("Life story", "Blah dee blah",
154
+ :within => "person_form").should be_true
155
+ end
156
+
157
+ it "equals the text, and is in table row" do
158
+ # TODO
159
+ end
160
+ end
161
+ end
162
+
163
+ context "fails when" do
164
+ context "text field with label" do
165
+ it "does not exactly equal the text" do
166
+ @st.set_field("First name", "Marcus")
167
+ @st.generic_field_equals("First name", "Marc").should be_false
168
+ end
169
+ end
170
+
171
+ context "text field with id" do
172
+ it "exactly equals the text, but is an unsupported type" do
173
+ #pending "hidden fields should be unsupported" do
174
+ # FIXME: This test fails, because generic_field_equals does
175
+ # in fact allow inspecting the value of a hidden field.
176
+ @st.generic_field_equals("secret", "psst").should be_false
177
+ #end
178
+ end
179
+ end
180
+
181
+ context "textarea with label" do
182
+ it "does not exist" do
183
+ @st.generic_field_equals("Third name", "Smith").should be_false
184
+ end
185
+
186
+ it "does not exactly equal the text" do
187
+ @st.set_field("Life story", "Blah dee blah")
188
+ @st.generic_field_equals("Life story", "Blah dee").should be_false
189
+ end
190
+
191
+ it "exactly equals the text, but is not within scope" do
192
+ @st.set_field("First name", "Eric", :within => "person_form")
193
+ @st.generic_field_equals("First name", "Eric", :within => "spouse_form").should be_false
194
+ end
195
+
196
+ it "exactly equals the text, but is not in table row" do
197
+ # TODO
198
+ end
199
+ end
200
+ end
201
+ end # set_field with generic_field_equals
202
+ end # fields
203
+
204
+
205
+ context "checkboxes" do
206
+ before(:each) do
207
+ @st.visit("/form").should be_true
208
+ end
209
+
210
+ context "#set_field with #enable_checkbox" do
211
+ context "passes when" do
212
+ context "checkbox with label" do
213
+ it "exists" do
214
+ @st.set_field("I like cheese", "on").should be_true
215
+ @st.set_field("I like salami", "on").should be_true
216
+ @st.generic_field_equals("I like cheese", "on").should be_true
217
+ @st.generic_field_equals("I like salami", "on").should be_true
218
+ end
219
+
220
+ it "exists and is already checked" do
221
+ @st.set_field("I like cheese", "on").should be_true
222
+ @st.set_field("I like cheese", "on").should be_true
223
+ @st.generic_field_equals("I like cheese", "on").should be_true
224
+ end
225
+
226
+ it "exists within scope" do
227
+ @st.set_field("I like cheese", "on", :within => "cheese_checkbox").should be_true
228
+ @st.set_field("I like salami", "on", :within => "salami_checkbox").should be_true
229
+ @st.generic_field_equals("I like cheese", "on", :within => "cheese_checkbox").should be_true
230
+ @st.generic_field_equals("I like salami", "on", :within => "salami_checkbox").should be_true
231
+ end
232
+
233
+ it "exists in table row" do
234
+ @st.visit("/table")
235
+ @st.set_field("Like", "on", :in_row => "Marcus").should be_true
236
+ @st.generic_field_equals("Like", "on", :in_row => "Marcus").should be_true
237
+ end
238
+ end
239
+
240
+ context "checkbox with id=" do
241
+ it "exists" do
242
+ @st.set_field("id=like_cheese", "on").should be_true
243
+ @st.generic_field_equals("id=like_cheese", "on").should be_true
244
+ end
245
+ end
246
+
247
+ context "checkbox with xpath=" do
248
+ it "exists" do
249
+ @st.set_field("xpath=//input[@id='like_cheese']", "on").should be_true
250
+ @st.generic_field_equals("xpath=//input[@id='like_cheese']", "on").should be_true
251
+ end
252
+ end
253
+ end
254
+
255
+ context "fails when" do
256
+ context "checkbox with label" do
257
+ it "does not exist" do
258
+ @st.set_field("I dislike bacon", "on").should be_false
259
+ @st.set_field("I like broccoli", "on").should be_false
260
+ end
261
+
262
+ it "exists, but not within scope" do
263
+ @st.set_field("I like cheese", "on", :within => "salami_checkbox").should be_false
264
+ @st.set_field("I like salami", "on", :within => "cheese_checkbox").should be_false
265
+ end
266
+
267
+ it "exists, but not in table row" do
268
+ @st.visit("/table")
269
+ @st.set_field("Like", "on", :in_row => "Eric").should be_false
270
+ end
271
+
272
+ it "exists, but is read-only" do
273
+ @st.visit("/readonly_form").should be_true
274
+ @st.set_field("I like salami", "on").should be_false
275
+ end
276
+ end
277
+ end
278
+ end # set_field with enable_checkbox
279
+
280
+ context "#set_field with #disable_checkbox" do
281
+ context "passes when" do
282
+ context "checkbox with label" do
283
+ it "exists" do
284
+ @st.set_field("I like cheese", "off").should be_true
285
+ @st.set_field("I like salami", "off").should be_true
286
+ @st.generic_field_equals("I like cheese", "off").should be_true
287
+ @st.generic_field_equals("I like salami", "off").should be_true
288
+ end
289
+
290
+ it "exists and is already unchecked" do
291
+ @st.set_field("I like cheese", "off").should be_true
292
+ @st.set_field("I like cheese", "off").should be_true
293
+ @st.generic_field_equals("I like cheese", "off").should be_true
294
+ end
295
+
296
+ it "exists within scope" do
297
+ @st.set_field("I like cheese", "off", :within => "cheese_checkbox").should be_true
298
+ @st.set_field("I like salami", "off", :within => "preferences_form").should be_true
299
+ @st.generic_field_equals("I like cheese", "off", :within => "cheese_checkbox").should be_true
300
+ @st.generic_field_equals("I like salami", "off", :within => "preferences_form").should be_true
301
+ end
302
+
303
+ it "exists in table row" do
304
+ @st.visit("/table")
305
+ @st.set_field("Like", "off", :in_row => "Marcus").should be_true
306
+ @st.generic_field_equals("Like", "off", :in_row => "Marcus").should be_true
307
+ end
308
+ end
309
+
310
+ context "checkbox with id=" do
311
+ it "exists" do
312
+ @st.set_field("id=like_cheese", "off").should be_true
313
+ @st.generic_field_equals("id=like_cheese", "off").should be_true
314
+ end
315
+ end
316
+
317
+ context "checkbox with xpath=" do
318
+ it "exists" do
319
+ @st.set_field("xpath=//input[@id='like_cheese']", "off").should be_true
320
+ @st.generic_field_equals("xpath=//input[@id='like_cheese']", "off").should be_true
321
+ end
322
+ end
323
+ end
324
+
325
+ context "fails when" do
326
+ context "checkbox with label" do
327
+ it "does not exist" do
328
+ @st.set_field("I dislike bacon", "off").should be_false
329
+ @st.set_field("I like broccoli", "off").should be_false
330
+ end
331
+
332
+ it "exists, but not within scope" do
333
+ @st.set_field("I like cheese", "off", :within => "salami_checkbox").should be_false
334
+ @st.set_field("I like salami", "off", :within => "cheese_checkbox").should be_false
335
+ end
336
+
337
+ it "exists, but not in table row" do
338
+ @st.visit("/table")
339
+ @st.set_field("Like", "off", :in_row => "Eric").should be_false
340
+ end
341
+
342
+ it "exists, but is read-only" do
343
+ @st.visit("/readonly_form").should be_true
344
+ @st.set_field("I like cheese", "off").should be_false
345
+ end
346
+ end
347
+ end
348
+ end # set_field with disable_checkbox
349
+
350
+ context "#set_field with #checkbox_is_enabled" do
351
+ context "passes when" do
352
+ context "checkbox with label" do
353
+ it "exists and is checked" do
354
+ @st.set_field("I like cheese", "on").should be_true
355
+ @st.checkbox_is_enabled("I like cheese").should be_true
356
+ end
357
+
358
+ it "exists within scope and is checked" do
359
+ @st.set_field("I like cheese", "on", :within => "cheese_checkbox").should be_true
360
+ @st.checkbox_is_enabled("I like cheese", :within => "cheese_checkbox").should be_true
361
+ end
362
+
363
+ it "exists in table row and is checked" do
364
+ @st.visit("/table")
365
+ @st.set_field("Like", "on", :in_row => "Ken").should be_true
366
+ @st.checkbox_is_enabled("Like", :in_row => "Ken").should be_true
367
+ end
368
+
369
+ it "exists and is checked, but read-only" do
370
+ @st.visit("/readonly_form").should be_true
371
+ @st.checkbox_is_enabled("I like cheese").should be_true
372
+ end
373
+ end
374
+ end
375
+
376
+ context "fails when" do
377
+ context "checkbox with label" do
378
+ it "does not exist" do
379
+ @st.checkbox_is_enabled("I dislike bacon").should be_false
380
+ end
381
+
382
+ it "exists but is unchecked" do
383
+ @st.set_field("I like cheese", "off").should be_true
384
+ @st.checkbox_is_enabled("I like cheese").should be_false
385
+ end
386
+
387
+ it "exists and is checked, but not within scope" do
388
+ @st.set_field("I like cheese", "on", :within => "cheese_checkbox").should be_true
389
+ @st.checkbox_is_enabled("I like cheese", :within => "salami_checkbox").should be_false
390
+ end
391
+
392
+ it "exists and is checked, but not in table row" do
393
+ @st.visit("/table")
394
+ @st.set_field("Like", "on", :in_row => "Marcus").should be_true
395
+ @st.checkbox_is_enabled("Like", :in_row => "Eric").should be_false
396
+ end
397
+ end
398
+ end
399
+ end # set_field with checkbox_is_enabled
400
+
401
+ context "#set_field with #checkbox_is_disabled" do
402
+ context "passes when" do
403
+ context "checkbox with label" do
404
+ it "exists and is unchecked" do
405
+ @st.set_field("I like cheese", "off").should be_true
406
+ @st.checkbox_is_disabled("I like cheese").should be_true
407
+ end
408
+
409
+ it "exists within scope and is unchecked" do
410
+ @st.set_field("I like cheese", "off", :within => "cheese_checkbox").should be_true
411
+ @st.checkbox_is_disabled("I like cheese", :within => "cheese_checkbox").should be_true
412
+ end
413
+
414
+ it "exists in table row and is unchecked" do
415
+ @st.visit("/table")
416
+ @st.set_field("Like", "off", :in_row => "Ken").should be_true
417
+ @st.checkbox_is_disabled("Like", :in_row => "Ken").should be_true
418
+ end
419
+
420
+ it "exists and is unchecked, but read-only" do
421
+ @st.visit("/readonly_form").should be_true
422
+ @st.checkbox_is_disabled("I like salami").should be_true
423
+ end
424
+ end
425
+ end
426
+
427
+ context "fails when" do
428
+ context "checkbox with label" do
429
+ it "does not exist" do
430
+ @st.checkbox_is_disabled("I dislike bacon").should be_false
431
+ end
432
+
433
+ it "exists but is checked" do
434
+ @st.set_field("I like cheese", "on").should be_true
435
+ @st.checkbox_is_disabled("I like cheese").should be_false
436
+ end
437
+
438
+ it "exists and is unchecked, but not within scope" do
439
+ @st.set_field("I like cheese", "off", :within => "cheese_checkbox").should be_true
440
+ @st.checkbox_is_disabled("I like cheese", :within => "salami_checkbox").should be_false
441
+ end
442
+
443
+ it "exists and is unchecked, but not in table row" do
444
+ @st.visit("/table")
445
+ @st.set_field("Like", "off", :in_row => "Marcus").should be_true
446
+ @st.checkbox_is_disabled("Like", :in_row => "Eric").should be_false
447
+ end
448
+ end
449
+ end
450
+ end # set_field with checkbox_is_disabled
451
+ end # checkboxes
452
+
453
+
454
+ context "radiobuttons" do
455
+ before(:each) do
456
+ @st.visit("/form").should be_true
457
+ end
458
+
459
+ context "#set_field with #select_radio" do
460
+ context "passes when" do
461
+ context "radiobutton with label" do
462
+ it "exists" do
463
+ @st.set_field("Briefs").should be_true
464
+ end
465
+
466
+ it "exists within scope" do
467
+ @st.set_field("Briefs", "", :within => "clothing").should be_true
468
+ end
469
+
470
+ it "exists in table row" do
471
+ # TODO
472
+ end
473
+ end
474
+ end
475
+
476
+ context "fails when" do
477
+ context "radiobutton with label" do
478
+ it "does not exist" do
479
+ @st.set_field("Naked", "").should be_false
480
+ end
481
+
482
+ it "exists, but not within scope" do
483
+ @st.set_field("Briefs", "", :within => "food").should be_false
484
+ end
485
+
486
+ it "exists, but is read-only" do
487
+ @st.visit("/readonly_form").should be_true
488
+ @st.set_field("Boxers", "").should be_false
489
+ end
490
+
491
+ it "exists, but not in table row" do
492
+ # TODO
493
+ end
494
+ end
495
+ end
496
+ end # set_field with select_radio
497
+
498
+ context "#set_field with #radio_is_enabled" do
499
+ context "passes when" do
500
+ context "radiobutton with label" do
501
+ it "exists, and is enabled" do
502
+ @st.set_field("Briefs")
503
+ @st.radio_is_enabled("Briefs").should be_true
504
+ end
505
+
506
+ it "exists within scope, and is enabled" do
507
+ @st.set_field("Briefs", "", :within => "clothing")
508
+ @st.radio_is_enabled("Briefs", :within => "clothing").should be_true
509
+ end
510
+
511
+ it "exists in table row, and is enabled" do
512
+ # TODO
513
+ end
514
+ end
515
+ end
516
+
517
+ context "fails when" do
518
+ context "radiobutton with label" do
519
+ it "does not exist" do
520
+ @st.radio_is_enabled("Naked").should be_false
521
+ end
522
+
523
+ it "exists, but is not enabled" do
524
+ @st.set_field("Briefs", "")
525
+ @st.radio_is_enabled("Boxers").should be_false
526
+ end
527
+
528
+ it "exists and is enabled, but not within scope" do
529
+ @st.set_field("Briefs", "", :within => "clothing")
530
+ @st.radio_is_enabled("Briefs", :within => "food").should be_false
531
+ end
532
+ end
533
+ end
534
+ end # set_field with radio_is_enabled
535
+
536
+ context "#set_field with #generic_field_equals for #radio_is_enabled" do
537
+ context "passes when" do
538
+ context "radiobutton with label" do
539
+ it "exists, and is enabled" do
540
+ @st.set_field("Briefs")
541
+ @st.generic_field_equals("Briefs", "on").should be_true
542
+ end
543
+
544
+ it "exists within scope, and is enabled" do
545
+ @st.set_field("Briefs", "", :within => "clothing")
546
+ @st.generic_field_equals("Briefs", "on", :within => "clothing").should be_true
547
+ end
548
+
549
+ it "exists in table row, and is enabled" do
550
+ # TODO
551
+ end
552
+ end
553
+ end
554
+
555
+ context "fails when" do
556
+ context "radiobutton with label" do
557
+ it "does not exist" do
558
+ @st.generic_field_equals("Naked", "on").should be_false
559
+ end
560
+
561
+ it "exists, but is not enabled" do
562
+ @st.set_field("Briefs", "")
563
+ @st.generic_field_equals("Boxers", "on").should be_false
564
+ end
565
+
566
+ it "exists and is enabled, but not within scope" do
567
+ @st.set_field("Briefs", "", :within => "clothing")
568
+ @st.generic_field_equals("Briefs", "on", :within => "food").should be_false
569
+ end
570
+ end
571
+ end
572
+ end # set_field with generic_field_equals for radio_is_enabled
573
+
574
+ context "#set_field with #generic_field_equals for #radio_is_disabled" do
575
+ context "passes when" do
576
+ context "radiobutton with label" do
577
+ it "exists, and is disabled" do
578
+ @st.set_field("Boxers")
579
+ @st.generic_field_equals("Briefs", "off").should be_true
580
+ end
581
+
582
+ it "exists within scope, and is disabled" do
583
+ @st.set_field("Boxers", "", :within => "clothing")
584
+ @st.generic_field_equals("Briefs", "off", :within => "clothing").should be_true
585
+ end
586
+
587
+ it "exists in table row, and is enabled" do
588
+ # TODO
589
+ end
590
+ end
591
+ end
592
+
593
+ context "fails when" do
594
+ context "radiobutton with label" do
595
+ it "does not exist" do
596
+ @st.generic_field_equals("Naked", "off").should be_false
597
+ end
598
+
599
+ it "exists, but is enabled" do
600
+ @st.set_field("Briefs", "")
601
+ @st.generic_field_equals("Briefs", "off").should be_false
602
+ end
603
+
604
+ it "exists and is disabled, but not within scope" do
605
+ @st.set_field("Boxers", "", :within => "clothing")
606
+ @st.generic_field_equals("Briefs", "off", :within => "food").should be_false
607
+ end
608
+ end
609
+ end
610
+ end # set_field with generic_field_equals for radio_is_disabled
611
+ end # radiobuttons
612
+
613
+
614
+ context "dropdowns" do
615
+ before(:each) do
616
+ @st.visit("/form").should be_true
617
+ end
618
+
619
+ context "#set_field with #select_from_dropdown" do
620
+ context "passes when" do
621
+ it "option exists in the dropdown" do
622
+ @st.set_field("Height", "Tall").should be_true
623
+ @st.set_field("Weight", "Medium").should be_true
624
+ end
625
+
626
+ it "option exists in the dropdown within scope" do
627
+ @st.set_field("Height", "Tall", :within => "spouse_form").should be_true
628
+ end
629
+
630
+ it "option exists in the dropdown in table row" do
631
+ @st.visit("/table")
632
+ @st.set_field("Gender", "Male", :in_row => "Eric").should be_true
633
+ end
634
+ end
635
+
636
+ context "fails when" do
637
+ it "no such dropdown exists" do
638
+ @st.set_field("Eggs", "Over easy").should be_false
639
+ end
640
+
641
+ it "dropdown exists, but the option doesn't" do
642
+ @st.set_field("Height", "Giant").should be_false
643
+ @st.set_field("Weight", "Obese").should be_false
644
+ end
645
+
646
+ it "dropdown exists, but is read-only" do
647
+ @st.visit("/readonly_form").should be_true
648
+ @st.set_field("Height", "Tall").should be_false
649
+ end
650
+
651
+ it "dropdown exists, but not within scope" do
652
+ @st.set_field("Weight", "Medium", :within => "spouse_form").should be_false
653
+ end
654
+
655
+ it "dropdown exists, but not in table row" do
656
+ @st.visit("/table")
657
+ @st.set_field("Gender", "Female", :in_row => "First name").should be_false
658
+ end
659
+ end
660
+ end # set_field with select_from_dropdown
661
+
662
+ context "#set_field with #dropdown_includes" do
663
+ context "passes when" do
664
+ it "option exists in the dropdown" do
665
+ @st.dropdown_includes("Height", "Tall").should be_true
666
+ @st.dropdown_includes("Weight", "Medium").should be_true
667
+ end
668
+
669
+ it "option exists in a read-only dropdown" do
670
+ @st.visit("/readonly_form").should be_true
671
+ @st.dropdown_includes("Height", "Tall").should be_true
672
+ end
673
+ end
674
+
675
+ context "fails when" do
676
+ it "dropdown exists, but the option doesn't" do
677
+ @st.dropdown_includes("Height", "Giant").should be_false
678
+ @st.dropdown_includes("Weight", "Obese").should be_false
679
+ end
680
+
681
+ it "no such dropdown exists" do
682
+ @st.dropdown_includes("Eggs", "Over easy").should be_false
683
+ end
684
+ end
685
+ end # set_field with dropdown_includes
686
+
687
+ context "#set_field with #dropdown_equals" do
688
+ context "passes when" do
689
+ it "option is selected in the dropdown" do
690
+ ["Short", "Average", "Tall"].each do |height|
691
+ @st.set_field("Height", height)
692
+ @st.dropdown_equals("Height", height).should be_true
693
+ end
694
+ end
695
+
696
+ it "option is selected in a read-only dropdown" do
697
+ @st.visit("/readonly_form").should be_true
698
+ @st.dropdown_equals("Height", "Average").should be_true
699
+ end
700
+
701
+ it "option is selected in the dropdown, within scope" do
702
+ ["Short", "Average", "Tall"].each do |height|
703
+ @st.set_field("Height", height, :within => "spouse_form")
704
+ @st.dropdown_equals("Height", height, :within => "spouse_form").should be_true
705
+ end
706
+ end
707
+
708
+ it "option is selected in the dropdown, in table row" do
709
+ @st.visit("/table")
710
+ ["Male", "Female"].each do |gender|
711
+ @st.set_field("Gender", gender, :in_row => "Eric")
712
+ @st.dropdown_equals("Gender", gender, :in_row => "Eric")
713
+ end
714
+ end
715
+ end
716
+
717
+ context "fails when" do
718
+ it "no such dropdown exists" do
719
+ @st.dropdown_equals("Eggs", "Over easy").should be_false
720
+ end
721
+
722
+ it "dropdown exists, but the option is not selected" do
723
+ @st.set_field("Height", "Short")
724
+ @st.dropdown_equals("Height", "Average").should be_false
725
+ @st.dropdown_equals("Height", "Tall").should be_false
726
+
727
+ @st.set_field("Height", "Average")
728
+ @st.dropdown_equals("Height", "Short").should be_false
729
+ @st.dropdown_equals("Height", "Tall").should be_false
730
+
731
+ @st.set_field("Height", "Tall")
732
+ @st.dropdown_equals("Height", "Short").should be_false
733
+ @st.dropdown_equals("Height", "Average").should be_false
734
+ end
735
+
736
+ it "dropdown exists, and option is selected, but not within scope" do
737
+ @st.set_field("Height", "Tall", :within => "person_form")
738
+ @st.set_field("Height", "Short", :within => "spouse_form")
739
+ @st.dropdown_equals("Height", "Tall", :within => "spouse_form").should be_false
740
+ end
741
+
742
+ it "dropdown exists, and option is selected, but not in table row" do
743
+ @st.visit("/table")
744
+ @st.set_field("Gender", "Female", :in_row => "Eric")
745
+ @st.set_field("Gender", "Male", :in_row => "Marcus")
746
+ @st.dropdown_equals("Gender", "Female", :in_row => "Marcus").should be_false
747
+ end
748
+ end
749
+ end # set_field with dropdown_equals
750
+
751
+ context "#set_field with #generic_field_equals for #dropdown_equals" do
752
+ context "passes when" do
753
+ it "option is selected in the dropdown" do
754
+ ["Short", "Average", "Tall"].each do |height|
755
+ @st.set_field("Height", height)
756
+ @st.generic_field_equals("Height", height).should be_true
757
+ end
758
+ end
759
+
760
+ it "option is selected in a read-only dropdown" do
761
+ @st.visit("/readonly_form").should be_true
762
+ @st.generic_field_equals("Height", "Average").should be_true
763
+ end
764
+
765
+ it "option is selected in the dropdown, within scope" do
766
+ ["Short", "Average", "Tall"].each do |height|
767
+ @st.set_field("Height", height, :within => "spouse_form")
768
+ @st.generic_field_equals("Height", height, :within => "spouse_form").should be_true
769
+ end
770
+ end
771
+
772
+ it "option is selected in the dropdown, in table row" do
773
+ @st.visit("/table")
774
+ ["Male", "Female"].each do |gender|
775
+ @st.set_field("Gender", gender, :in_row => "Eric").should be_true
776
+ @st.generic_field_equals("Gender", gender, :in_row => "Eric")
777
+ end
778
+ end
779
+ end
780
+
781
+ context "fails when" do
782
+ it "no such dropdown exists" do
783
+ @st.generic_field_equals("Eggs", "Over easy").should be_false
784
+ end
785
+
786
+ it "dropdown exists, but the option is not selected" do
787
+ @st.set_field("Height", "Short")
788
+ @st.generic_field_equals("Height", "Average").should be_false
789
+ @st.generic_field_equals("Height", "Tall").should be_false
790
+
791
+ @st.set_field("Height", "Average")
792
+ @st.generic_field_equals("Height", "Short").should be_false
793
+ @st.generic_field_equals("Height", "Tall").should be_false
794
+
795
+ @st.set_field("Height", "Tall")
796
+ @st.generic_field_equals("Height", "Short").should be_false
797
+ @st.generic_field_equals("Height", "Average").should be_false
798
+ end
799
+
800
+ it "dropdown exists, and option is selected, but not within scope" do
801
+ @st.set_field("Height", "Tall", :within => "person_form").should be_true
802
+ @st.set_field("Height", "Short", :within => "spouse_form").should be_true
803
+ @st.generic_field_equals("Height", "Tall", :within => "spouse_form").should be_false
804
+ end
805
+
806
+ it "dropdown exists, and option is selected, but not in table row" do
807
+ @st.visit("/table")
808
+ @st.set_field("Gender", "Female", :in_row => "Eric").should be_true
809
+ @st.set_field("Gender", "Male", :in_row => "Marcus").should be_true
810
+ @st.generic_field_equals("Gender", "Female", :in_row => "Marcus").should be_false
811
+ end
812
+ end
813
+ end # set_field with generic_field_equals for dropdown_equals
814
+ end # dropdowns
815
+
816
+
817
+ context "#set_field with button click" do
818
+ before(:each) do
819
+ @st.visit("/form").should be_true
820
+ end
821
+
822
+ it "clicks a button" do
823
+ @st.set_field("Submit person form", "clicked").should be_true
824
+ @st.page_loads_in_seconds_or_less(10).should be_true
825
+ @st.see("We appreciate your feedback").should be_true
826
+ end
827
+ end
828
+
829
+ context "#set_field with link click" do
830
+ before(:each) do
831
+ @st.visit("/").should be_true
832
+ end
833
+ it "clicks a link" do
834
+ @st.set_field("About this site", "clicked").should be_true
835
+ @st.page_loads_in_seconds_or_less(10).should be_true
836
+ @st.see("This site is really cool.").should be_true
837
+ end
838
+ end
839
+
840
+ end # set_field
841
+
842
+