surveyor 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/.gitignore +26 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.rails_version +13 -0
  4. data/README.md +40 -22
  5. data/Rakefile +92 -29
  6. data/app/helpers/survey_form_builder.rb +37 -0
  7. data/app/helpers/surveyor_helper.rb +9 -9
  8. data/app/views/partials/_answer.html.haml +1 -1
  9. data/app/views/partials/_question.html.haml +3 -3
  10. data/app/views/partials/_question_group.html.haml +2 -2
  11. data/app/views/partials/_section.html.haml +1 -1
  12. data/app/views/surveyor/edit.html.haml +11 -3
  13. data/app/views/surveyor/new.html.haml +8 -1
  14. data/ci-exec.sh +50 -0
  15. data/config/routes.rb +9 -13
  16. data/cucumber.yml +10 -0
  17. data/doc/question types.png +0 -0
  18. data/features/redcap_parser.feature +1 -1
  19. data/features/step_definitions/common_setps.rb +3 -0
  20. data/features/step_definitions/parser_steps.rb +8 -1
  21. data/features/step_definitions/surveyor_steps.rb +33 -9
  22. data/features/step_definitions/web_steps.rb +85 -165
  23. data/features/support/env.rb +40 -46
  24. data/features/support/paths.rb +4 -4
  25. data/features/support/selectors.rb +39 -0
  26. data/features/surveyor.feature +63 -13
  27. data/features/surveyor_dependencies.feature +289 -0
  28. data/features/surveyor_parser.feature +29 -20
  29. data/lib/formtastic/surveyor_builder.rb +9 -9
  30. data/lib/generators/surveyor/custom_generator.rb +17 -0
  31. data/lib/generators/surveyor/install_generator.rb +50 -0
  32. data/{generators/extend_surveyor/templates/extensions → lib/generators/surveyor/templates/app/controllers}/surveyor_controller.rb +0 -0
  33. data/{generators/extend_surveyor/templates/extensions → lib/generators/surveyor/templates/app/views/layouts}/surveyor_custom.html.erb +0 -0
  34. data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_en.yml +0 -0
  35. data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_es.yml +0 -0
  36. data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_he.yml +0 -0
  37. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_api_ids.rb +0 -0
  38. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_correct_answer_id_to_questions.rb +0 -0
  39. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_default_value_to_answers.rb +0 -0
  40. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_display_order_to_surveys.rb +0 -0
  41. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_display_type_to_answers.rb +0 -0
  42. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_index_to_response_sets.rb +0 -0
  43. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_index_to_surveys.rb +0 -0
  44. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_section_id_to_responses.rb +0 -0
  45. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_unique_indicies.rb +0 -0
  46. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_answers.rb +0 -0
  47. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_dependencies.rb +0 -0
  48. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_dependency_conditions.rb +0 -0
  49. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_question_groups.rb +0 -0
  50. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_questions.rb +0 -0
  51. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_response_sets.rb +0 -0
  52. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_responses.rb +0 -0
  53. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_survey_sections.rb +0 -0
  54. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_surveys.rb +0 -0
  55. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_validation_conditions.rb +0 -0
  56. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_validations.rb +0 -0
  57. data/{generators/surveyor/templates/assets/images → lib/generators/surveyor/templates/public/images/surveyor}/next.gif +0 -0
  58. data/{generators/surveyor/templates/assets/images → lib/generators/surveyor/templates/public/images/surveyor}/prev.gif +0 -0
  59. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery.blockUI.js +499 -0
  60. data/{generators/surveyor/templates/assets/javascripts → lib/generators/surveyor/templates/public/javascripts/surveyor}/jquery.surveyor.js +47 -4
  61. data/{generators/surveyor/templates/assets/javascripts → lib/generators/surveyor/templates/public/javascripts/surveyor}/jquery.tools.min.js +0 -0
  62. data/{generators/surveyor/templates/assets → lib/generators/surveyor/templates/public}/stylesheets/sass/custom.sass +0 -0
  63. data/{generators/surveyor/templates/assets → lib/generators/surveyor/templates/public}/stylesheets/sass/surveyor.sass +2 -2
  64. data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/dateinput.css +0 -0
  65. data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/reset.css +0 -0
  66. data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/results.css +0 -0
  67. data/{generators/extend_surveyor/templates/EXTENDING_SURVEYOR → lib/generators/surveyor/templates/surveys/EXTENDING_SURVEYOR.md} +0 -0
  68. data/{generators → lib/generators}/surveyor/templates/surveys/kitchen_sink_survey.rb +0 -0
  69. data/{generators → lib/generators}/surveyor/templates/surveys/quiz.rb +0 -0
  70. data/lib/surveyor.rb +7 -0
  71. data/lib/surveyor/engine.rb +12 -0
  72. data/lib/surveyor/models/answer_methods.rb +0 -1
  73. data/lib/surveyor/models/dependency_condition_methods.rb +1 -3
  74. data/lib/surveyor/models/question_methods.rb +0 -1
  75. data/lib/surveyor/models/response_methods.rb +2 -2
  76. data/lib/surveyor/models/response_set_methods.rb +30 -14
  77. data/lib/surveyor/models/survey_methods.rb +2 -1
  78. data/lib/surveyor/models/survey_section_methods.rb +1 -2
  79. data/lib/surveyor/parser.rb +9 -7
  80. data/lib/surveyor/redcap_parser.rb +10 -7
  81. data/lib/surveyor/surveyor_controller_methods.rb +45 -11
  82. data/lib/surveyor/version.rb +3 -0
  83. data/lib/tasks/surveyor_tasks.rake +2 -2
  84. data/rails/init.rb +0 -1
  85. data/spec/controllers/surveyor_controller_spec.rb +81 -35
  86. data/spec/helpers/surveyor_helper_spec.rb +7 -1
  87. data/spec/models/dependency_condition_spec.rb +76 -63
  88. data/spec/models/response_set_spec.rb +52 -47
  89. data/spec/models/response_spec.rb +19 -16
  90. data/spec/spec_helper.rb +21 -44
  91. data/surveyor.gemspec +25 -176
  92. metadata +302 -77
  93. data/CHANGELOG +0 -335
  94. data/VERSION +0 -1
  95. data/ci-env.sh +0 -29
  96. data/generators/extend_surveyor/extend_surveyor_generator.rb +0 -21
  97. data/generators/surveyor/surveyor_generator.rb +0 -69
  98. data/generators/surveyor/templates/README +0 -10
  99. data/generators/surveyor/templates/tasks/surveyor.rb +0 -4
  100. data/hudson.rakefile +0 -33
  101. data/init_testbed.rakefile +0 -55
  102. data/testbed/Gemfile +0 -13
@@ -1,56 +1,50 @@
1
1
  # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
- # It is recommended to regenerate this file in the future when you upgrade to a
3
- # newer version of cucumber-rails. Consider adding your own code to a new file
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
4
  # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
5
  # files.
6
+ ENV["RAILS_ROOT"] ||= File.expand_path(File.dirname(__FILE__) + '/../../testbed')
7
+ require 'cucumber/rails'
8
+ # require File.expand_path(File.dirname(__FILE__) + '/../../testbed/config/environment.rb')
9
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
10
+ # order to ease the transition to Capybara we set the default here. If you'd
11
+ # prefer to use XPath just remove this line and adjust any selectors in your
12
+ # steps to use the XPath syntax.
13
+ Capybara.default_selector = :css
6
14
 
7
- ENV["RAILS_ENV"] ||= "cucumber"
8
- require File.expand_path(File.dirname(__FILE__) + '/../../testbed/config/environment')
9
-
10
- require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
11
- require 'cucumber/rails/world'
12
- require 'cucumber/rails/active_record'
13
- require 'cucumber/web/tableish'
14
-
15
- require 'webrat'
16
- require 'webrat/core/matchers'
15
+ # By default, any exception happening in your Rails application will bubble up
16
+ # to Cucumber so that your scenario will fail. This is a different from how
17
+ # your application behaves in the production environment, where an error page will
18
+ # be rendered instead.
19
+ #
20
+ # Sometimes we want to override this default behaviour and allow Rails to rescue
21
+ # exceptions and display an error page (just like when the app is running in production).
22
+ # Typical scenarios where you want to do this is when you test your error pages.
23
+ # There are two ways to allow Rails to rescue exceptions:
24
+ #
25
+ # 1) Tag your scenario (or feature) with @allow-rescue
26
+ #
27
+ # 2) Set the value below to true. Beware that doing this globally is not
28
+ # recommended as it will mask a lot of errors for you!
29
+ #
30
+ ActionController::Base.allow_rescue = false
17
31
 
18
- Webrat.configure do |config|
19
- config.mode = :rails
20
- config.open_error_files = false # Set to true if you want error pages to pop up in the browser
32
+ # Remove/comment out the lines below if your app doesn't have a database.
33
+ # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
34
+ begin
35
+ DatabaseCleaner.strategy = :transaction
36
+ rescue NameError
37
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
21
38
  end
22
39
 
23
-
24
- # If you set this to false, any error raised from within your app will bubble
25
- # up to your step definition and out to cucumber unless you catch it somewhere
26
- # on the way. You can make Rails rescue errors and render error pages on a
27
- # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
40
+ # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
41
+ # See the DatabaseCleaner documentation for details. Example:
28
42
  #
29
- # If you set this to true, Rails will rescue all errors and render error
30
- # pages, more or less in the same way your application would behave in the
31
- # default production environment. It's not recommended to do this for all
32
- # of your scenarios, as this makes it hard to discover errors in your application.
33
- ActionController::Base.allow_rescue = false
34
-
35
- # If you set this to true, each scenario will run in a database transaction.
36
- # You can still turn off transactions on a per-scenario basis, simply tagging
37
- # a feature or scenario with the @no-txn tag. If you are using Capybara,
38
- # tagging with @culerity or @javascript will also turn transactions off.
43
+ # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
44
+ # DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
45
+ # end
39
46
  #
40
- # If you set this to false, transactions will be off for all scenarios,
41
- # regardless of whether you use @no-txn or not.
47
+ # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
48
+ # DatabaseCleaner.strategy = :transaction
49
+ # end
42
50
  #
43
- # Beware that turning transactions off will leave data in your database
44
- # after each scenario, which can lead to hard-to-debug failures in
45
- # subsequent scenarios. If you do this, we recommend you create a Before
46
- # block that will explicitly put your database in a known state.
47
- Cucumber::Rails::World.use_transactional_fixtures = true
48
- # How to clean your database when transactions are turned off. See
49
- # http://github.com/bmabey/database_cleaner for more info.
50
- if defined?(ActiveRecord::Base)
51
- begin
52
- require 'database_cleaner'
53
- DatabaseCleaner.strategy = :truncation
54
- rescue LoadError => ignore_if_database_cleaner_not_present
55
- end
56
- end
@@ -8,11 +8,11 @@ module NavigationHelpers
8
8
  def path_to(page_name)
9
9
  case page_name
10
10
 
11
- when /the home\s?page/
11
+ when /^the home\s?page$/
12
12
  '/'
13
13
  when /the surveys page/
14
14
  '/surveys'
15
-
15
+
16
16
  # Add more mappings here.
17
17
  # Here is an example that pulls values out of the Regexp:
18
18
  #
@@ -21,10 +21,10 @@ module NavigationHelpers
21
21
 
22
22
  else
23
23
  begin
24
- page_name =~ /the (.*) page/
24
+ page_name =~ /^the (.*) page$/
25
25
  path_components = $1.split(/\s+/)
26
26
  self.send(path_components.push('path').join('_').to_sym)
27
- rescue Object => e
27
+ rescue NoMethodError, ArgumentError
28
28
  raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
29
29
  "Now, go and add a mapping in #{__FILE__}"
30
30
  end
@@ -0,0 +1,39 @@
1
+ module HtmlSelectorsHelpers
2
+ # Maps a name to a selector. Used primarily by the
3
+ #
4
+ # When /^(.+) within (.+)$/ do |step, scope|
5
+ #
6
+ # step definitions in web_steps.rb
7
+ #
8
+ def selector_for(locator)
9
+ case locator
10
+
11
+ when "the page"
12
+ "html > body"
13
+
14
+ # Add more mappings here.
15
+ # Here is an example that pulls values out of the Regexp:
16
+ #
17
+ # when /^the (notice|error|info) flash$/
18
+ # ".flash.#{$1}"
19
+
20
+ # You can also return an array to use a different selector
21
+ # type, like:
22
+ #
23
+ # when /the header/
24
+ # [:xpath, "//header"]
25
+
26
+ # This allows you to provide a quoted selector as the scope
27
+ # for "within" steps as was previously the default for the
28
+ # web steps:
29
+ when /^"(.+)"$/
30
+ $1
31
+
32
+ else
33
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
34
+ "Now, go and add a mapping in #{__FILE__}"
35
+ end
36
+ end
37
+ end
38
+
39
+ World(HtmlSelectorsHelpers)
@@ -36,7 +36,7 @@ Feature: Survey creation
36
36
  | blue |
37
37
  | orange |
38
38
  | brown |
39
-
39
+
40
40
  Scenario: Default answers
41
41
  Given the survey
42
42
  """
@@ -81,7 +81,7 @@ Feature: Survey creation
81
81
  end
82
82
  """
83
83
  Then question "1" should have correct answer "oink"
84
-
84
+
85
85
  Scenario: Custom css class
86
86
  Given the survey
87
87
  """
@@ -91,13 +91,16 @@ Feature: Survey creation
91
91
  a :string, :custom_class => "my_custom_class"
92
92
  q "What is your favorite state?"
93
93
  a :string
94
+ q "Anything else to say?", :pick => :any
95
+ a "yes", :string, :custom_class => "other_custom_class"
94
96
  end
95
97
  end
96
98
  """
97
99
  When I start the "Movies" survey
98
- Then the element "input[type='text']:first" should have the class "my_custom_class"
99
- # Then the element "input[type='text']:last" should not contain the class attribute
100
-
100
+ Then the element "input[type='text']:first.my_custom_class" should exist
101
+ And the element "input[type='checkbox'].other_custom_class" should exist
102
+ And the element "input[type='text'].other_custom_class" should exist
103
+
101
104
  Scenario: A pick one question with an option for other
102
105
  Given the survey
103
106
  """
@@ -133,7 +136,7 @@ Feature: Survey creation
133
136
  """
134
137
  When I start the "Movies" survey
135
138
  Then a dropdown should exist with the options "Action, Comedy, Mystery"
136
-
139
+
137
140
  Scenario: A pick one question with an option for other
138
141
  Given the survey
139
142
  """
@@ -149,7 +152,7 @@ Feature: Survey creation
149
152
  """
150
153
  When I start the "Favorites" survey
151
154
  Then I choose "other"
152
- And I fill in "/.*string_value.*/" with "shrimp"
155
+ And I fill in "r_1_string_value" with "shrimp"
153
156
  And I press "Click here to finish"
154
157
  Then there should be 1 response set with 1 response with:
155
158
  | shrimp |
@@ -254,7 +257,7 @@ Feature: Survey creation
254
257
  end
255
258
  """
256
259
  When I start the "Grid" survey
257
- Then I choose "1"
260
+ And I choose "1"
258
261
  And I press "Two"
259
262
  And I press "One"
260
263
  Then there should be 1 response with answer "1"
@@ -296,9 +299,9 @@ Feature: Survey creation
296
299
  Then there should be 3 datetime responses with
297
300
  | datetime_value |
298
301
  | 2011-02-14 00:00:00 |
299
- | 2001-01-01 01:30:00 |
302
+ | 01:30:00 |
300
303
  | 2011-02-15 17:30:00 |
301
-
304
+
302
305
  # 2/13/11
303
306
  And I fill in "Give me a date" with "2011-02-13"
304
307
  # 1:30pm
@@ -308,11 +311,11 @@ Feature: Survey creation
308
311
  And I press "Three"
309
312
  And I select "00" from "Minute"
310
313
  And I press "Click here to finish"
311
-
314
+
312
315
  Then there should be 3 datetime responses with
313
316
  | datetime_value |
314
317
  | 2011-02-13 00:00:00 |
315
- | 2001-01-01 13:30:00 |
318
+ | 13:30:00 |
316
319
  | 2011-02-15 17:00:00 |
317
320
 
318
321
  Scenario: "Images"
@@ -328,4 +331,51 @@ Feature: Survey creation
328
331
  """
329
332
  When I start the "Images" survey
330
333
  Then I should see the image "/images/surveyor/next.gif"
331
- And I should see the image "/images/surveyor/prev.gif"
334
+ And I should see the image "/images/surveyor/prev.gif"
335
+
336
+ @javascript
337
+ Scenario: "Unchecking Checkboxes"
338
+ Given the survey
339
+ """
340
+ survey "Travels" do
341
+ section "Countries" do
342
+ q "Which of these countries have you visited?", :pick => :any
343
+ a "Ireland"
344
+ a "Kenya"
345
+ a "Singapore"
346
+ end
347
+ section "Activities" do
348
+ q "What do you like to do on vacation?", :pick => :any
349
+ a "Eat good food"
350
+ a "Lie on the beach"
351
+ a "Wander around cool neighborhoods"
352
+ end
353
+ end
354
+ """
355
+ When I go to the surveys page
356
+ And I wait 1 seconds
357
+ And I start the "Travels" survey
358
+ And I wait 1 seconds
359
+ Then there should be 3 checkboxes
360
+ And I wait 1 seconds
361
+ When I check "Singapore"
362
+ And I wait 1 seconds
363
+ And I press "Activities"
364
+ And I wait 1 seconds
365
+ And I press "Countries"
366
+ And I wait 1 seconds
367
+ Then the "Singapore" checkbox should be checked
368
+ And I wait 1 seconds
369
+ When I uncheck "Singapore"
370
+ And I wait 1 seconds
371
+ And I press "Activities"
372
+ And I wait 1 seconds
373
+ And I press "Countries"
374
+ And I wait 1 seconds
375
+ Then the "Singapore" checkbox should not be checked
376
+ When I check "Singapore"
377
+ And I wait 1 seconds
378
+ Then 1 responses should exist
379
+ When I uncheck "Singapore"
380
+ And I wait 1 seconds
381
+ Then 0 responses should exist
@@ -0,0 +1,289 @@
1
+ Feature: Survey dependencies
2
+ As a survey participant
3
+ I want to see dependent question if conditions are met
4
+ And I do now want to see dependent question if conditions are not met
5
+
6
+ @javascript
7
+ Scenario: "Simple question dependencies"
8
+ Given the survey
9
+ """
10
+ survey "Anybody" do
11
+ section "First" do
12
+ q_1 "Anybody there?", :pick => :one
13
+ a_1 "Yes"
14
+ a_2 "No"
15
+
16
+ q_2 "Who are you??"
17
+ dependency :rule => "A"
18
+ condition_A :q_1, "==", :a_1
19
+ a :string
20
+
21
+ q_3 "Weird.. Must be talking to myself..", :pick => :one
22
+ dependency :rule => "A"
23
+ condition_A :q_1, "==", :a_2
24
+ a "Maybe"
25
+ a "Huh?"
26
+ end
27
+ section "Second" do
28
+ q "Anything else?"
29
+ a :string
30
+ end
31
+ end
32
+ """
33
+ When I go to the surveys page
34
+ And I start the "Anybody" survey
35
+ Then I should see "Anybody there?"
36
+ And the element "#q_2" should be hidden
37
+ And the element "#q_3" should be hidden
38
+ When I choose "Yes"
39
+ And I wait 1 seconds
40
+ Then the element "#q_2" should not be hidden
41
+ And the element "#q_3" should be hidden
42
+ When I choose "No"
43
+ And I wait 1 seconds
44
+ Then the element "#q_3" should not be hidden
45
+ And the element "#q_2" should be hidden
46
+ When I press "Second"
47
+ And I press "First"
48
+ Then the element "#q_3" should not be hidden
49
+ And the element "#q_2" should be hidden
50
+
51
+ @javascript
52
+ Scenario: "Dependencies inside of the question group"
53
+ Given the survey
54
+ """
55
+ survey "Anybody" do
56
+ section "First" do
57
+ group "" do
58
+ q_1 "Anybody there?", :pick => :one
59
+ a_1 "Yes"
60
+ a_2 "No"
61
+
62
+ q_2 "Who are you??"
63
+ dependency :rule => "A"
64
+ condition_A :q_1, "==", :a_1
65
+ a :string
66
+
67
+ q_3 "Weird.. Must be talking to myself..", :pick => :one
68
+ dependency :rule => "A"
69
+ condition_A :q_1, "==", :a_2
70
+ a "Maybe"
71
+ a "Huh?"
72
+ end
73
+ end
74
+ section "Second" do
75
+ q "Anything else?"
76
+ a :string
77
+ end
78
+ end
79
+ """
80
+ When I go to the surveys page
81
+ And I start the "Anybody" survey
82
+ Then I should see "Anybody there?"
83
+ And the element "#q_2" should be hidden
84
+ And the element "#q_3" should be hidden
85
+ When I choose "Yes"
86
+ And I wait 1 seconds
87
+ Then the element "#q_2" should not be hidden
88
+ And the element "#q_3" should be hidden
89
+ When I choose "No"
90
+ And I wait 1 seconds
91
+ Then the element "#q_3" should not be hidden
92
+ And the element "#q_2" should be hidden
93
+ When I press "Second"
94
+ And I press "First"
95
+ Then the element "#q_3" should not be hidden
96
+ And the element "#q_2" should be hidden
97
+
98
+
99
+ @javascript
100
+ Scenario: "Dependencies inside of the 'inline' question group"
101
+ Given the survey
102
+ """
103
+ survey "Anybody" do
104
+ section "First" do
105
+ group "", :display_type => :inline do
106
+ q_1 "Anybody there?", :pick => :one
107
+ a_1 "Yes"
108
+ a_2 "No"
109
+
110
+ q_2 "Who are you??"
111
+ dependency :rule => "A"
112
+ condition_A :q_1, "==", :a_1
113
+ a :string
114
+
115
+ q_3 "Weird.. Must be talking to myself..", :pick => :one
116
+ dependency :rule => "A"
117
+ condition_A :q_1, "==", :a_2
118
+ a "Maybe"
119
+ a "Huh?"
120
+ end
121
+ end
122
+ section "Second" do
123
+ q "Anything else?"
124
+ a :string
125
+ end
126
+ end
127
+ """
128
+ When I go to the surveys page
129
+ And I start the "Anybody" survey
130
+ Then I should see "Anybody there?"
131
+ And the element "#q_2" should be hidden
132
+ And the element "#q_3" should be hidden
133
+
134
+ When I choose "Yes"
135
+ And I wait 1 seconds
136
+ Then the element "#q_2" should not be hidden
137
+ And the element "#q_3" should be hidden
138
+
139
+ When I choose "No"
140
+ And I wait 1 seconds
141
+ Then the element "#q_3" should not be hidden
142
+ And the element "#q_2" should be hidden
143
+
144
+ When I press "Second"
145
+ And I press "First"
146
+ Then the element "#q_3" should not be hidden
147
+ And the element "#q_2" should be hidden
148
+
149
+ @javascript
150
+ Scenario: "Dependency on group"
151
+ Given the survey
152
+ """
153
+ survey "Anybody" do
154
+ section "First" do
155
+ q_1 "Anybody there?", :pick => :one
156
+ a_1 "Yes"
157
+ a_2 "No"
158
+
159
+ group "Who are you?", :display_type => :inline do
160
+ dependency :rule => "A"
161
+ condition_A :q_1, "==", :a_1
162
+
163
+ q_2 "Name yourself"
164
+ a :string
165
+
166
+ q_3 "Why are you here?"
167
+ a :string
168
+ end
169
+
170
+ group "" do
171
+ dependency :rule => "A"
172
+ condition_A :q_1, "==", :a_2
173
+
174
+ q_4 "Who is talking?", :pick => :one
175
+ a "You are"
176
+ a "Are you nuts?"
177
+ end
178
+
179
+ end
180
+ section "Second" do
181
+ q "Anything else?"
182
+ a :string
183
+ end
184
+ end
185
+ """
186
+ When I go to the surveys page
187
+ And I start the "Anybody" survey
188
+ Then I should see "Anybody there?"
189
+ And the element "#q_2" should be hidden
190
+ And the element "#q_3" should be hidden
191
+ And the element "#q_4" should be hidden
192
+
193
+ When I choose "Yes"
194
+ And I wait 1 seconds
195
+ Then the element "#q_2" should not be hidden
196
+ And the element "#q_3" should not be hidden
197
+ And the element "#q_4" should be hidden
198
+
199
+ When I choose "No"
200
+ And I wait 1 seconds
201
+ Then the element "#q_2" should be hidden
202
+ And the element "#q_3" should be hidden
203
+ And the element "#q_4" should not be hidden
204
+
205
+ When I press "Second"
206
+ And I press "First"
207
+ Then the element "#q_2" should be hidden
208
+ And the element "#q_3" should be hidden
209
+ And the element "#q_4" should not be hidden
210
+
211
+ @javascript
212
+ Scenario: "Dependency on question in dependent group"
213
+ Given the survey
214
+ """
215
+ survey "Anybody" do
216
+ section "First" do
217
+ q_1 "Anybody there?", :pick => :one
218
+ a_1 "Yes"
219
+ a_2 "No"
220
+
221
+ group "Who are you?" do
222
+ dependency :rule => "A"
223
+ condition_A :q_1, "==", :a_1
224
+
225
+ q_2 "Are you..", :pick => :one
226
+ a_1 "Human"
227
+ a_2 "Dancer"
228
+ a_3 "Owner Of The World"
229
+
230
+ q_3 "Why are you here?"
231
+ dependency :rule => "A"
232
+ condition_A :q_2, "==", :a_1
233
+ a :string
234
+
235
+ q_4 "Which one?"
236
+ dependency :rule => "A"
237
+ condition_A :q_2, "==", :a_3
238
+ a :string
239
+ end
240
+
241
+ group "" do
242
+ dependency :rule => "A"
243
+ condition_A :q_1, "==", :a_2
244
+
245
+ q_5 "Who is talking?", :pick => :one
246
+ a "You are"
247
+ a "Are you nuts?"
248
+ end
249
+
250
+ end
251
+ section "Second" do
252
+ q "Anything else?"
253
+ a :string
254
+ end
255
+ end
256
+ """
257
+ When I go to the surveys page
258
+ And I start the "Anybody" survey
259
+ Then I should see "Anybody there?"
260
+ And the element "#q_2" should be hidden
261
+ And the element "#q_3" should be hidden
262
+ And the element "#q_4" should be hidden
263
+ And the element "#q_5" should be hidden
264
+
265
+ When I choose "Yes"
266
+ And I wait 1 seconds
267
+ Then the element "#q_2" should not be hidden
268
+ And the element "#q_3" should be hidden
269
+ And the element "#q_4" should be hidden
270
+ And the element "#q_5" should be hidden
271
+
272
+ When I choose "Human"
273
+ And I wait 1 seconds
274
+ Then the element "#q_3" should not be hidden
275
+ And the element "#q_4" should be hidden
276
+ And the element "#q_5" should be hidden
277
+
278
+ When I choose "Owner Of The World"
279
+ And I wait 1 seconds
280
+ Then the element "#q_3" should be hidden
281
+ And the element "#q_4" should not be hidden
282
+ And the element "#q_5" should be hidden
283
+
284
+ When I choose "No"
285
+ And I wait 1 seconds
286
+ Then the element "#q_2" should be hidden
287
+ And the element "#q_3" should be hidden
288
+ And the element "#q_4" should be hidden
289
+ And the element "#q_5" should not be hidden