surveyor 0.22.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +1 -0
  3. data/CHANGELOG.md +83 -0
  4. data/Gemfile.rails_version +7 -1
  5. data/README.md +114 -16
  6. data/Rakefile +15 -9
  7. data/app/inputs/quiet_input.rb +5 -0
  8. data/app/inputs/surveyor_check_boxes_input.rb +35 -0
  9. data/app/inputs/surveyor_radio_input.rb +18 -0
  10. data/app/views/partials/_answer.html.haml +4 -4
  11. data/app/views/partials/_question.html.haml +7 -7
  12. data/app/views/partials/_question_group.html.haml +9 -8
  13. data/app/views/surveyor/export.json.rabl +28 -25
  14. data/app/views/surveyor/new.html.haml +8 -5
  15. data/app/views/surveyor/show.json.rabl +3 -2
  16. data/ci-exec.sh +13 -7
  17. data/cucumber.yml +3 -3
  18. data/doc/REPRESENTATIONS.md +34 -0
  19. data/doc/api_id_schema.json +7 -0
  20. data/doc/response_set_schema.json +54 -0
  21. data/doc/surveyor question combinations.png +0 -0
  22. data/doc/surveyor_timestamp_schema.json +9 -0
  23. data/features/ajax_submissions.feature +140 -0
  24. data/features/export_to_json.feature +182 -34
  25. data/features/no_duplicates.feature +110 -0
  26. data/features/show_survey.feature +1 -1
  27. data/features/step_definitions/parser_steps.rb +25 -2
  28. data/features/step_definitions/surveyor_steps.rb +145 -20
  29. data/features/step_definitions/ui_steps.rb +3 -0
  30. data/features/support/database_cleaner.rb +16 -0
  31. data/features/support/env.rb +21 -17
  32. data/features/support/simultaneous_ajax.rb +101 -0
  33. data/features/support/single_quit_selenium_driver.rb +23 -0
  34. data/features/support/slow_updates.rb +18 -0
  35. data/features/surveyor.feature +174 -44
  36. data/features/surveyor_dependencies.feature +80 -39
  37. data/features/surveyor_parser.feature +114 -20
  38. data/features/z_redcap_parser.feature +0 -1
  39. data/lib/{generators/surveyor/templates/public → assets}/images/surveyor/next.gif +0 -0
  40. data/lib/{generators/surveyor/templates/public → assets}/images/surveyor/prev.gif +0 -0
  41. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  42. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  43. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_glass_65_ffffff_1x400.png +0 -0
  44. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  45. data/lib/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  46. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  47. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-icons_ef8c08_256x240.png +0 -0
  48. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-icons_ffffff_256x240.png +0 -0
  49. data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery-ui-timepicker-addon.js +23 -23
  50. data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery-ui.js +125 -125
  51. data/lib/assets/javascripts/surveyor/jquery.selectToUISlider.js +240 -0
  52. data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery.surveyor.js +52 -57
  53. data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery.tools.min.js +7 -7
  54. data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/dateinput.css +13 -13
  55. data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/jquery-ui-timepicker-addon.css +0 -0
  56. data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/jquery-ui.custom.css +17 -17
  57. data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/reset.css +1 -1
  58. data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/results.css +0 -0
  59. data/lib/assets/stylesheets/surveyor/ui.slider.extras.css +110 -0
  60. data/lib/{generators/surveyor/templates/public/stylesheets/sass → assets/stylesheets}/surveyor.sass +15 -7
  61. data/lib/generators/surveyor/custom_generator.rb +3 -2
  62. data/lib/generators/surveyor/install_generator.rb +59 -17
  63. data/lib/generators/surveyor/templates/app/assets/javascripts/surveyor_all.js +5 -0
  64. data/lib/generators/surveyor/templates/app/assets/stylesheets/surveyor_all.css +9 -0
  65. data/lib/generators/surveyor/templates/app/controllers/surveyor_controller.rb +2 -1
  66. data/lib/generators/surveyor/templates/app/views/layouts/surveyor_custom.html.erb +1 -0
  67. data/lib/generators/surveyor/templates/config/locales/surveyor_es.yml +1 -0
  68. data/lib/generators/surveyor/templates/config/locales/surveyor_he.yml +1 -0
  69. data/lib/generators/surveyor/templates/db/migrate/add_api_id_to_question_groups.rb +1 -0
  70. data/lib/generators/surveyor/templates/db/migrate/add_api_ids.rb +1 -0
  71. data/lib/generators/surveyor/templates/db/migrate/add_api_ids_to_response_sets_and_responses.rb +1 -0
  72. data/lib/generators/surveyor/templates/db/migrate/add_correct_answer_id_to_questions.rb +1 -0
  73. data/lib/generators/surveyor/templates/db/migrate/add_default_value_to_answers.rb +1 -0
  74. data/lib/generators/surveyor/templates/db/migrate/add_display_order_to_surveys.rb +1 -0
  75. data/lib/generators/surveyor/templates/db/migrate/add_display_type_to_answers.rb +1 -0
  76. data/lib/generators/surveyor/templates/db/migrate/add_index_to_response_sets.rb +1 -0
  77. data/lib/generators/surveyor/templates/db/migrate/add_index_to_surveys.rb +1 -0
  78. data/lib/generators/surveyor/templates/db/migrate/add_section_id_to_responses.rb +1 -0
  79. data/lib/generators/surveyor/templates/db/migrate/add_unique_index_on_access_code_and_version_in_surveys.rb +10 -0
  80. data/lib/generators/surveyor/templates/db/migrate/add_unique_indicies.rb +3 -2
  81. data/lib/generators/surveyor/templates/db/migrate/add_version_to_surveys.rb +10 -0
  82. data/lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb +23 -0
  83. data/lib/generators/surveyor/templates/db/migrate/create_answers.rb +6 -5
  84. data/lib/generators/surveyor/templates/db/migrate/create_dependencies.rb +2 -1
  85. data/lib/generators/surveyor/templates/db/migrate/create_dependency_conditions.rb +2 -1
  86. data/lib/generators/surveyor/templates/db/migrate/create_question_groups.rb +5 -4
  87. data/lib/generators/surveyor/templates/db/migrate/create_questions.rb +4 -3
  88. data/lib/generators/surveyor/templates/db/migrate/create_response_sets.rb +1 -0
  89. data/lib/generators/surveyor/templates/db/migrate/create_responses.rb +10 -9
  90. data/lib/generators/surveyor/templates/db/migrate/create_survey_sections.rb +5 -4
  91. data/lib/generators/surveyor/templates/db/migrate/create_surveys.rb +4 -3
  92. data/lib/generators/surveyor/templates/db/migrate/create_validation_conditions.rb +5 -4
  93. data/lib/generators/surveyor/templates/db/migrate/create_validations.rb +3 -2
  94. data/lib/generators/surveyor/templates/db/migrate/drop_unique_index_on_access_code_in_surveys.rb +10 -0
  95. data/lib/generators/surveyor/templates/db/migrate/update_blank_api_ids_on_question_group.rb +22 -0
  96. data/lib/generators/surveyor/templates/db/migrate/update_blank_versions_on_surveys.rb +13 -0
  97. data/lib/generators/surveyor/templates/surveys/date_survey.rb +1 -0
  98. data/lib/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +54 -24
  99. data/lib/generators/surveyor/templates/surveys/quiz.rb +1 -0
  100. data/lib/generators/surveyor/templates/{public/stylesheets/sass → vendor/assets/stylesheets}/custom.sass +1 -1
  101. data/lib/surveyor/common.rb +16 -31
  102. data/lib/surveyor/engine.rb +2 -4
  103. data/lib/surveyor/helpers/asset_pipeline.rb +13 -0
  104. data/lib/surveyor/helpers/formtastic_custom_input.rb +17 -0
  105. data/lib/surveyor/helpers/surveyor_helper_methods.rb +10 -8
  106. data/lib/surveyor/models/answer_methods.rb +3 -0
  107. data/lib/surveyor/models/dependency_condition_methods.rb +27 -28
  108. data/lib/surveyor/models/dependency_methods.rb +3 -0
  109. data/lib/surveyor/models/question_group_methods.rb +3 -0
  110. data/lib/surveyor/models/question_methods.rb +10 -7
  111. data/lib/surveyor/models/response_methods.rb +16 -0
  112. data/lib/surveyor/models/response_set_methods.rb +71 -64
  113. data/lib/surveyor/models/survey_methods.rb +19 -28
  114. data/lib/surveyor/models/survey_section_methods.rb +3 -0
  115. data/lib/surveyor/models/validation_condition_methods.rb +4 -2
  116. data/lib/surveyor/models/validation_methods.rb +3 -0
  117. data/lib/surveyor/parser.rb +198 -148
  118. data/lib/surveyor/redcap_parser.rb +120 -80
  119. data/lib/surveyor/surveyor_controller_methods.rb +86 -37
  120. data/lib/surveyor/version.rb +2 -2
  121. data/lib/surveyor.rb +5 -6
  122. data/lib/tasks/surveyor_tasks.rake +19 -7
  123. data/spec/controllers/surveyor_controller_spec.rb +166 -92
  124. data/spec/factories.rb +33 -32
  125. data/spec/helpers/formtastic_custom_input_spec.rb +16 -0
  126. data/spec/lib/common_spec.rb +0 -39
  127. data/spec/lib/redcap_parser_spec.rb +24 -24
  128. data/spec/models/answer_spec.rb +12 -0
  129. data/spec/models/dependency_condition_spec.rb +279 -323
  130. data/spec/models/dependency_spec.rb +10 -0
  131. data/spec/models/question_group_spec.rb +12 -0
  132. data/spec/models/question_spec.rb +12 -0
  133. data/spec/models/response_set_spec.rb +189 -139
  134. data/spec/models/response_spec.rb +60 -0
  135. data/spec/models/survey_section_spec.rb +9 -0
  136. data/spec/models/survey_spec.rb +72 -9
  137. data/spec/models/validation_condition_spec.rb +9 -1
  138. data/spec/models/validation_spec.rb +10 -0
  139. data/spec/spec_helper.rb +25 -6
  140. data/surveyor.gemspec +5 -4
  141. metadata +332 -291
  142. data/features/step_definitions/common_steps.rb +0 -3
  143. data/lib/formtastic/surveyor_builder.rb +0 -82
  144. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery.blockUI.js +0 -499
@@ -4,7 +4,7 @@ Feature: Survey creation
4
4
  So that I can get paid
5
5
 
6
6
  Scenario: Creating basic questions
7
- Given the survey
7
+ Given I parse
8
8
  """
9
9
  survey "Favorites" do
10
10
  section "Colors" do
@@ -38,7 +38,7 @@ Feature: Survey creation
38
38
  | brown |
39
39
 
40
40
  Scenario: Creating default answers
41
- Given the survey
41
+ Given I parse
42
42
  """
43
43
  survey "Favorites" do
44
44
  section "Foods" do
@@ -68,8 +68,9 @@ Feature: Survey creation
68
68
  | string_value |
69
69
  | chicken |
70
70
 
71
+ @quiz
71
72
  Scenario: Creating, it's quiz time
72
- Given the survey
73
+ Given I parse
73
74
  """
74
75
  survey "Favorites" do
75
76
  section "Foods" do
@@ -83,7 +84,7 @@ Feature: Survey creation
83
84
  Then question "1" should have correct answer "oink"
84
85
 
85
86
  Scenario: Creating custom css class
86
- Given the survey
87
+ Given I parse
87
88
  """
88
89
  survey "Movies" do
89
90
  section "First" do
@@ -105,7 +106,7 @@ Feature: Survey creation
105
106
  And the element "input[type='text'].other_other_custom_class" should exist
106
107
 
107
108
  Scenario: Creating a pick one question with an option for other
108
- Given the survey
109
+ Given I parse
109
110
  """
110
111
  survey "Favorites" do
111
112
  section "Foods" do
@@ -124,7 +125,7 @@ Feature: Survey creation
124
125
  | bacon |
125
126
 
126
127
  Scenario: Creating a repeater with a dropdown
127
- Given the survey
128
+ Given I parse
128
129
  """
129
130
  survey "Movies" do
130
131
  section "Preferences" do
@@ -142,7 +143,7 @@ Feature: Survey creation
142
143
 
143
144
  # Issue 251 - text field with checkbox
144
145
  Scenario: Creating a group with a dropdown
145
- Given the survey
146
+ Given I parse
146
147
  """
147
148
  survey "All Holidays" do
148
149
  section "Favorites" do
@@ -159,7 +160,7 @@ Feature: Survey creation
159
160
  Then a dropdown should exist with the options "Christmas, New Year, March 8th"
160
161
 
161
162
  Scenario: Creating another pick one question with an option for other
162
- Given the survey
163
+ Given I parse
163
164
  """
164
165
  survey "Favorites" do
165
166
  section "Foods" do
@@ -179,7 +180,7 @@ Feature: Survey creation
179
180
  | shrimp |
180
181
 
181
182
  Scenario: Creating checkboxes with text area
182
- Given the survey
183
+ Given I parse
183
184
  """
184
185
  survey "Websites" do
185
186
  section "Search engines" do
@@ -195,7 +196,7 @@ Feature: Survey creation
195
196
  And there should be 3 text areas
196
197
 
197
198
  Scenario: Creating double letter rule keys
198
- Given the survey
199
+ Given I parse
199
200
  """
200
201
  survey "Doubles" do
201
202
  section "Two" do
@@ -229,7 +230,7 @@ Feature: Survey creation
229
230
  Then the question "Do you want to be part of an SNL skit?" should be triggered
230
231
 
231
232
  Scenario: Creating and changing dropdowns
232
- Given the survey
233
+ Given I parse
233
234
  """
234
235
  survey "Drop" do
235
236
  section "Like it is hot" do
@@ -258,7 +259,7 @@ Feature: Survey creation
258
259
  # Issue 234 - text field with checkbox
259
260
  @javascript
260
261
  Scenario: Creating a question with an option checkbox for other and text input
261
- Given the survey
262
+ Given I parse
262
263
  """
263
264
  survey "Favorite Cuisine" do
264
265
  section "Foods" do
@@ -271,14 +272,13 @@ Feature: Survey creation
271
272
  end
272
273
  """
273
274
  When I start the "Favorite Cuisine" survey
274
- And I wait 2 seconds
275
275
  And I change "r_4_string_value" to "thai"
276
276
  Then the "other" checkbox should be checked
277
277
 
278
278
  # Issue 234 - empty text field with checkbox
279
279
  @javascript
280
280
  Scenario: Creating a question with an option checkbox for other and an empty text input
281
- Given the survey
281
+ Given I parse
282
282
  """
283
283
  survey "Favorite Cuisine" do
284
284
  section "Foods" do
@@ -291,14 +291,13 @@ Feature: Survey creation
291
291
  end
292
292
  """
293
293
  When I start the "Favorite Cuisine" survey
294
- And I wait 2 seconds
295
294
  And I change "r_4_string_value" to ""
296
295
  Then the "other" checkbox should not be checked
297
296
 
298
297
  # Issue 234 - text field with radio buttons
299
298
  @javascript
300
299
  Scenario: Creating a question with an option radio button for other and text input
301
- Given the survey
300
+ Given I parse
302
301
  """
303
302
  survey "Favorite Cuisine" do
304
303
  section "Foods" do
@@ -311,14 +310,13 @@ Feature: Survey creation
311
310
  end
312
311
  """
313
312
  When I start the "Favorite Cuisine" survey
314
- And I wait 2 seconds
315
313
  And I change "r_1_string_value" to "thai"
316
314
  Then the "other" radiobutton should be checked
317
315
 
318
316
  # Issue 234 - empty text field with radio buttons
319
317
  @javascript
320
318
  Scenario: Creating another question with an option radio button for other and text input
321
- Given the survey
319
+ Given I parse
322
320
  """
323
321
  survey "Favorite Cuisine" do
324
322
  section "Foods" do
@@ -331,17 +329,15 @@ Feature: Survey creation
331
329
  end
332
330
  """
333
331
  When I start the "Favorite Cuisine" survey
334
- And I wait 2 seconds
335
332
  And I change "r_1_string_value" to ""
336
333
  Then the "other" radiobutton should not be checked
337
334
 
338
335
 
339
336
  # Issue 259 - substitution of the text with Mustache
340
- @wip
341
337
  @javascript
342
338
  Scenario: Creating a question with an mustache syntax
343
339
  Given I have survey context of "FakeMustacheContext"
344
- Given the survey
340
+ Given I parse
345
341
  """
346
342
  survey "Overall info" do
347
343
  section "Group of questions" do
@@ -358,7 +354,6 @@ Feature: Survey creation
358
354
  end
359
355
  """
360
356
  When I start the "Overall info" survey
361
- And I wait 5 seconds
362
357
  Then I should see "Information on Santa Claus"
363
358
  And I should see "Answer all you know on Santa Claus"
364
359
  And I should see "Santa Claus does not work for Northwestern!"
@@ -371,7 +366,7 @@ Feature: Survey creation
371
366
 
372
367
 
373
368
  Scenario: Creating and saving grids
374
- Given the survey
369
+ Given I parse
375
370
  """
376
371
  survey "Grid" do
377
372
  section "One" do
@@ -399,7 +394,7 @@ Feature: Survey creation
399
394
  Then there should be 1 response with answer "1"
400
395
 
401
396
  Scenario: Creating dates
402
- Given the survey
397
+ Given I parse
403
398
  """
404
399
  survey "When" do
405
400
  section "One" do
@@ -453,8 +448,8 @@ Feature: Survey creation
453
448
  Then the "When phone" field should contain "2011-02-15 17:00:00"
454
449
 
455
450
  @javascript
456
- Scenario: Creating a date
457
- Given the survey
451
+ Scenario: Creating a date using the JS datepicker
452
+ Given I parse
458
453
  """
459
454
  survey "When" do
460
455
  section "One" do
@@ -464,13 +459,15 @@ Feature: Survey creation
464
459
  end
465
460
  """
466
461
  When I start the "When" survey
467
- And I click "Give me a date"
468
- And I follow today's date
469
- And I press "Click here to finish"
470
- Then there should be a datetime response with today's date
462
+ And I click "Give me a date"
463
+ And I select "May" as the datepicker's month
464
+ And I select "2013" as the datepicker's year
465
+ And I follow "18"
466
+ And I press "Click here to finish"
467
+ Then there should be a date response with value "2013-05-18"
471
468
 
472
469
  Scenario: Creating images
473
- Given the survey
470
+ Given I parse
474
471
  """
475
472
  survey "Images" do
476
473
  section "One" do
@@ -486,7 +483,7 @@ Feature: Survey creation
486
483
 
487
484
  @javascript
488
485
  Scenario: Creating and unchecking checkboxes
489
- Given the survey
486
+ Given I parse
490
487
  """
491
488
  survey "Travels" do
492
489
  section "Countries" do
@@ -504,29 +501,162 @@ Feature: Survey creation
504
501
  end
505
502
  """
506
503
  When I go to the surveys page
507
- And I wait 1 seconds
508
504
  And I start the "Travels" survey
509
- And I wait 1 seconds
510
505
  Then there should be 3 checkboxes
511
- And I wait 1 seconds
512
506
  When I check "Singapore"
513
- And I wait 1 seconds
514
507
  And I press "Activities"
515
- And I wait 1 seconds
516
508
  And I press "Countries"
517
- And I wait 1 seconds
518
509
  Then the "Singapore" checkbox should be checked
519
- And I wait 1 seconds
520
510
  When I uncheck "Singapore"
521
- And I wait 1 seconds
522
511
  And I press "Activities"
523
- And I wait 1 seconds
524
512
  And I press "Countries"
525
- And I wait 1 seconds
526
513
  Then the "Singapore" checkbox should not be checked
527
514
  When I check "Singapore"
528
- And I wait 1 seconds
529
515
  Then 1 responses should exist
530
516
  When I uncheck "Singapore"
531
- And I wait 1 seconds
532
517
  Then 0 responses should exist
518
+
519
+ Scenario: Accessing outdated survey
520
+ Given I parse
521
+ """
522
+ survey "Travels" do
523
+ section "Everything" do
524
+ q "Which of these countries have you visited?", :pick => :any
525
+ a "Italy"
526
+ a "Morocco"
527
+ a "Mexico"
528
+ end
529
+ end
530
+ """
531
+ And I parse
532
+ """
533
+ survey "Travels" do
534
+ section "Countries" do
535
+ q "Which of these countries have you visited?", :pick => :any
536
+ a "Ireland"
537
+ a "Kenya"
538
+ a "Singapore"
539
+ end
540
+ end
541
+ """
542
+ When I go to the surveys page
543
+ And I press "Take it"
544
+ Then I should see "Ireland"
545
+ And I should not see "Italy"
546
+
547
+ When I go to the surveys page
548
+ And I select "0" from "survey_version"
549
+ And I press "Take it"
550
+ Then I should see "Mexico"
551
+ And I should not see "Keniya"
552
+
553
+ # Issue 236 - ":text"- field doesn't show up in the multi-select questions
554
+ Scenario: Pick one and pick any with text areas
555
+ Given I parse
556
+ """
557
+ survey "Pick plus text" do
558
+ section "Examples" do
559
+ q "What is your best beauty secret?", :pick => :one
560
+ a "My secret is", :text
561
+ a "None of your business"
562
+ a "I don't know"
563
+
564
+ q "Who knows about this secret?", :pick => :any
565
+ a "Only you and me, because", :text
566
+ a "These other people:", :text
567
+ end
568
+ end
569
+ """
570
+ When I go to the surveys page
571
+ And I press "Take it"
572
+ Then I should see 3 textareas on the page
573
+
574
+ # Issue 207 - Create separate fields for date and time
575
+ Scenario: Pick one and pick any with dates
576
+ Given I parse
577
+ """
578
+ survey "Complex date survey" do
579
+ section "Date questions with pick one and pick any" do
580
+ q "What is your birth date?", :pick => :one
581
+ a "I was born on", :date
582
+ a "Refused"
583
+
584
+ q "At what time were you born?", :pick => :any
585
+ a "I was born at", :time
586
+ a "This time is approximate"
587
+
588
+ q "When would you like to schedule your next appointment?"
589
+ a :datetime
590
+ end
591
+ end
592
+ """
593
+ When I go to the surveys page
594
+ And I press "Take it"
595
+ Then I should see 1 "date" input on the page
596
+ And I should see 1 "time" input on the page
597
+ And I should see 1 "datetime" input on the page
598
+
599
+ # Issue #251 - Dropdowns inside of group display as radio buttons
600
+ Scenario: Dropdown within a group
601
+ Given I parse
602
+ """
603
+ survey "Dropdowns" do
604
+ section "Location" do
605
+ q "What is the address of your new home?", :pick => :one
606
+ a_1 "Address known"
607
+ a_2 "Out of the country"
608
+ a_3 "PO Box address only"
609
+ a_neg_1 "Refused"
610
+ a_neg_2 "Don't know"
611
+
612
+ group "Address information" do
613
+ q_NEW_STATE "State", :display_type => :dropdown, :pick=>:one
614
+ a_1 "AL"
615
+ a_2 "AK"
616
+ a_3 "AZ"
617
+ a_4 "AR"
618
+ a_5 "CA"
619
+ a_6 "CO"
620
+ end
621
+ end
622
+ end
623
+ """
624
+ When I go to the surveys page
625
+ And I press "Take it"
626
+ Then I should see 1 select on the page
627
+
628
+ # Issue #336 :is_exclusive doesn't disable other answers that are tagged as :is_exclusive
629
+ @javascript
630
+ Scenario: multiple exclusive checkboxes
631
+ Given I parse
632
+ """
633
+ survey "Heat" do
634
+ section "Types" do
635
+ q_heat2 "Are there any other types of heat you use regularly during the heating season
636
+ to heat your home? ", :pick => :any
637
+ a_1 "Electric"
638
+ a_2 "Gas - propane or LP"
639
+ a_3 "Oil"
640
+ a_4 "Wood"
641
+ a_5 "Kerosene or diesel"
642
+ a_6 "Coal or coke"
643
+ a_7 "Solar energy"
644
+ a_8 "Heat pump"
645
+ a_9 "No other heating source", :is_exclusive => true
646
+ a_neg_5 "Other"
647
+ a_neg_1 "Refused", :is_exclusive => true
648
+ a_neg_2 "Don't know", :is_exclusive => true
649
+ end
650
+ end
651
+ """
652
+ When I start the "Heat" survey
653
+ And I click "No other heating source"
654
+ Then the checkbox for "Refused" should be disabled
655
+ And the checkbox for "Don't know" should be disabled
656
+ When I uncheck "No other heating source"
657
+ Then the checkbox for "Refused" should be enabled
658
+ When I check "Electric"
659
+ Then the checkbox for "Refused" should be enabled
660
+ When I check "Refused"
661
+ Then the checkbox for "Electric" should be disabled
662
+ And the checkbox for "Don't know" should be disabled
@@ -2,10 +2,10 @@ Feature: Survey dependencies
2
2
  As a survey participant
3
3
  I want to see dependent question if conditions are met
4
4
  And I do now want to see dependent question if conditions are not met
5
-
5
+
6
6
  @javascript
7
7
  Scenario: "Simple question dependencies"
8
- Given the survey
8
+ Given I parse
9
9
  """
10
10
  survey "Anybody" do
11
11
  section "First" do
@@ -36,21 +36,19 @@ Feature: Survey dependencies
36
36
  And the element "#q_2" should be hidden
37
37
  And the element "#q_3" should be hidden
38
38
  When I choose "Yes"
39
- And I wait 1 seconds
40
39
  Then the element "#q_2" should not be hidden
41
40
  And the element "#q_3" should be hidden
42
41
  When I choose "No"
43
- And I wait 1 seconds
44
42
  Then the element "#q_3" should not be hidden
45
43
  And the element "#q_2" should be hidden
46
44
  When I press "Second"
47
45
  And I press "First"
48
46
  Then the element "#q_3" should not be hidden
49
47
  And the element "#q_2" should be hidden
50
-
48
+
51
49
  @javascript
52
50
  Scenario: "Dependencies inside of the question group"
53
- Given the survey
51
+ Given I parse
54
52
  """
55
53
  survey "Anybody" do
56
54
  section "First" do
@@ -69,7 +67,7 @@ Feature: Survey dependencies
69
67
  condition_A :q_1, "==", :a_2
70
68
  a "Maybe"
71
69
  a "Huh?"
72
- end
70
+ end
73
71
  end
74
72
  section "Second" do
75
73
  q "Anything else?"
@@ -83,22 +81,20 @@ Feature: Survey dependencies
83
81
  And the element "#q_2" should be hidden
84
82
  And the element "#q_3" should be hidden
85
83
  When I choose "Yes"
86
- And I wait 1 seconds
87
84
  Then the element "#q_2" should not be hidden
88
85
  And the element "#q_3" should be hidden
89
86
  When I choose "No"
90
- And I wait 1 seconds
91
87
  Then the element "#q_3" should not be hidden
92
88
  And the element "#q_2" should be hidden
93
89
  When I press "Second"
94
90
  And I press "First"
95
91
  Then the element "#q_3" should not be hidden
96
92
  And the element "#q_2" should be hidden
97
-
98
-
93
+
94
+
99
95
  @javascript
100
96
  Scenario: "Dependencies inside of the 'inline' question group"
101
- Given the survey
97
+ Given I parse
102
98
  """
103
99
  survey "Anybody" do
104
100
  section "First" do
@@ -117,7 +113,7 @@ Feature: Survey dependencies
117
113
  condition_A :q_1, "==", :a_2
118
114
  a "Maybe"
119
115
  a "Huh?"
120
- end
116
+ end
121
117
  end
122
118
  section "Second" do
123
119
  q "Anything else?"
@@ -130,17 +126,15 @@ Feature: Survey dependencies
130
126
  Then I should see "Anybody there?"
131
127
  And the element "#q_2" should be hidden
132
128
  And the element "#q_3" should be hidden
133
-
129
+
134
130
  When I choose "Yes"
135
- And I wait 1 seconds
136
131
  Then the element "#q_2" should not be hidden
137
132
  And the element "#q_3" should be hidden
138
-
133
+
139
134
  When I choose "No"
140
- And I wait 1 seconds
141
135
  Then the element "#q_3" should not be hidden
142
136
  And the element "#q_2" should be hidden
143
-
137
+
144
138
  When I press "Second"
145
139
  And I press "First"
146
140
  Then the element "#q_3" should not be hidden
@@ -148,34 +142,34 @@ Feature: Survey dependencies
148
142
 
149
143
  @javascript
150
144
  Scenario: "Dependency on group"
151
- Given the survey
145
+ Given I parse
152
146
  """
153
147
  survey "Anybody" do
154
148
  section "First" do
155
149
  q_1 "Anybody there?", :pick => :one
156
150
  a_1 "Yes"
157
151
  a_2 "No"
158
-
152
+
159
153
  group "Who are you?", :display_type => :inline do
160
154
  dependency :rule => "A"
161
155
  condition_A :q_1, "==", :a_1
162
-
156
+
163
157
  q_2 "Name yourself"
164
158
  a :string
165
159
 
166
160
  q_3 "Why are you here?"
167
161
  a :string
168
162
  end
169
-
163
+
170
164
  group "" do
171
165
  dependency :rule => "A"
172
166
  condition_A :q_1, "==", :a_2
173
-
167
+
174
168
  q_4 "Who is talking?", :pick => :one
175
169
  a "You are"
176
170
  a "Are you nuts?"
177
171
  end
178
-
172
+
179
173
  end
180
174
  section "Second" do
181
175
  q "Anything else?"
@@ -189,28 +183,26 @@ Feature: Survey dependencies
189
183
  And the element "#q_2" should be hidden
190
184
  And the element "#q_3" should be hidden
191
185
  And the element "#q_4" should be hidden
192
-
186
+
193
187
  When I choose "Yes"
194
- And I wait 1 seconds
195
188
  Then the element "#q_2" should not be hidden
196
189
  And the element "#q_3" should not be hidden
197
190
  And the element "#q_4" should be hidden
198
-
191
+
199
192
  When I choose "No"
200
- And I wait 1 seconds
201
193
  Then the element "#q_2" should be hidden
202
194
  And the element "#q_3" should be hidden
203
195
  And the element "#q_4" should not be hidden
204
-
196
+
205
197
  When I press "Second"
206
198
  And I press "First"
207
199
  Then the element "#q_2" should be hidden
208
200
  And the element "#q_3" should be hidden
209
201
  And the element "#q_4" should not be hidden
210
-
202
+
211
203
  @javascript
212
204
  Scenario: "Dependency on question in dependent group"
213
- Given the survey
205
+ Given I parse
214
206
  """
215
207
  survey "Anybody" do
216
208
  section "First" do
@@ -231,7 +223,7 @@ Feature: Survey dependencies
231
223
  dependency :rule => "A"
232
224
  condition_A :q_2, "==", :a_1
233
225
  a :string
234
-
226
+
235
227
  q_4 "Which one?"
236
228
  dependency :rule => "A"
237
229
  condition_A :q_2, "==", :a_3
@@ -261,29 +253,78 @@ Feature: Survey dependencies
261
253
  And the element "#q_3" should be hidden
262
254
  And the element "#q_4" should be hidden
263
255
  And the element "#q_5" should be hidden
264
-
256
+
265
257
  When I choose "Yes"
266
- And I wait 1 seconds
267
258
  Then the element "#q_2" should not be hidden
268
259
  And the element "#q_3" should be hidden
269
260
  And the element "#q_4" should be hidden
270
261
  And the element "#q_5" should be hidden
271
-
262
+
272
263
  When I choose "Human"
273
- And I wait 1 seconds
274
264
  Then the element "#q_3" should not be hidden
275
265
  And the element "#q_4" should be hidden
276
266
  And the element "#q_5" should be hidden
277
267
 
278
268
  When I choose "Owner Of The World"
279
- And I wait 1 seconds
280
269
  Then the element "#q_3" should be hidden
281
270
  And the element "#q_4" should not be hidden
282
271
  And the element "#q_5" should be hidden
283
-
272
+
284
273
  When I choose "No"
285
- And I wait 1 seconds
286
274
  Then the element "#q_2" should be hidden
287
275
  And the element "#q_3" should be hidden
288
276
  And the element "#q_4" should be hidden
289
277
  And the element "#q_5" should not be hidden
278
+
279
+ #issue #337 answer != condition returns false if question was never activated
280
+ @javascript
281
+ Scenario: Depending with != on questions without responses
282
+ Given I parse
283
+ """
284
+ survey "Cooling" do
285
+ section "Basics" do
286
+ q_cooling_1 "How do you cool your home?", :pick => :one
287
+ a_1 "Fans"
288
+ a_2 "Window AC"
289
+ a_3 "Central AC"
290
+ a_4 "Passive"
291
+
292
+ q_cooling_2 "How much does it cost to run your non-passive cooling solutions?"
293
+ dependency :rule => "A"
294
+ condition_A :q_cooling_1, "!=", :a_4
295
+ a_1 "$", :float
296
+ end
297
+ end
298
+ """
299
+ When I go to the surveys page
300
+ And I start the "Cooling" survey
301
+ Then the question "How much does it cost to run your non-passive cooling solutions?" should be triggered
302
+ And I choose "Passive"
303
+ Then the question "How much does it cost to run your non-passive cooling solutions?" should be hidden
304
+
305
+ #issue #337 answer != condition returns false if question was never activated
306
+ @javascript
307
+ Scenario: Depending with != on questions without responses
308
+ Given I parse
309
+ """
310
+ survey "Heating" do
311
+ section "Basics" do
312
+ q_heating_1 "How do you heat your home?", :pick => :one
313
+ a_1 "Force air"
314
+ a_2 "Radiators"
315
+ a_3 "Oven"
316
+ a_4 "Passive"
317
+
318
+ q_heating_2 "How much does it cost to run your non-passive heating solutions?"
319
+ dependency :rule => "A and B"
320
+ condition_A :q_heating_1, "!=", :a_4
321
+ condition_B :q_heating_1, "count>0"
322
+ a_1 "$", :float
323
+ end
324
+ end
325
+ """
326
+ When I go to the surveys page
327
+ And I start the "Heating" survey
328
+ Then the question "How much does it cost to run your non-passive heating solutions?" should be hidden
329
+ And I choose "Oven"
330
+ Then the question "How much does it cost to run your non-passive heating solutions?" should be triggered