surveyor 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +0 -6
  3. data/README.md +40 -14
  4. data/app/helpers/surveyor_helper.rb +1 -85
  5. data/app/views/partials/_answer.html.haml +5 -4
  6. data/app/views/partials/_question.html.haml +7 -5
  7. data/app/views/partials/_question_group.html.haml +2 -2
  8. data/app/views/surveyor/export.json.rabl +75 -0
  9. data/app/views/surveyor/show.html.haml +75 -13
  10. data/app/views/surveyor/show.json.rabl +14 -0
  11. data/config/routes.rb +2 -3
  12. data/doc/surveyor reject or delete decision matrix.png +0 -0
  13. data/features/export_to_json.feature +96 -0
  14. data/features/show_survey.feature +42 -0
  15. data/features/step_definitions/{common_setps.rb → common_steps.rb} +0 -0
  16. data/features/step_definitions/surveyor_steps.rb +46 -12
  17. data/features/step_definitions/web_steps.rb +15 -5
  18. data/features/support/paths.rb +2 -1
  19. data/features/surveyor.feature +192 -41
  20. data/features/surveyor_parser.feature +10 -10
  21. data/features/{redcap_parser.feature → z_redcap_parser.feature} +9 -6
  22. data/lib/formtastic/surveyor_builder.rb +1 -4
  23. data/lib/generators/surveyor/install_generator.rb +6 -5
  24. data/lib/generators/surveyor/templates/db/migrate/add_api_id_to_question_groups.rb +9 -0
  25. data/lib/generators/surveyor/templates/db/migrate/add_api_ids_to_response_sets_and_responses.rb +11 -0
  26. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery-ui-timepicker-addon.js +1277 -0
  27. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery-ui.js +11729 -0
  28. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery.surveyor.js +54 -10
  29. data/lib/generators/surveyor/templates/public/stylesheets/sass/surveyor.sass +1 -1
  30. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/jquery-ui-timepicker-addon.css +6 -0
  31. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/jquery-ui.custom.css +572 -0
  32. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  33. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  34. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-bg_glass_65_ffffff_1x400.png +0 -0
  35. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  36. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  37. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-icons_ef8c08_256x240.png +0 -0
  38. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-icons_ffffff_256x240.png +0 -0
  39. data/lib/generators/surveyor/templates/surveys/EXTENDING_SURVEYOR.md +14 -0
  40. data/lib/generators/surveyor/templates/surveys/MODIFYING_SURVEYOR.md +91 -0
  41. data/lib/generators/surveyor/templates/surveys/date_survey.rb +15 -0
  42. data/lib/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +2 -2
  43. data/lib/surveyor/common.rb +31 -4
  44. data/lib/surveyor/helpers/surveyor_helper_methods.rb +99 -0
  45. data/lib/surveyor/models/answer_methods.rb +6 -5
  46. data/lib/surveyor/models/dependency_condition_methods.rb +0 -1
  47. data/lib/surveyor/models/dependency_methods.rb +1 -1
  48. data/lib/surveyor/models/question_group_methods.rb +5 -0
  49. data/lib/surveyor/models/question_methods.rb +5 -2
  50. data/lib/surveyor/models/response_methods.rb +44 -3
  51. data/lib/surveyor/models/response_set_methods.rb +14 -4
  52. data/lib/surveyor/models/survey_methods.rb +8 -2
  53. data/lib/surveyor/models/survey_section_methods.rb +13 -1
  54. data/lib/surveyor/parser.rb +18 -11
  55. data/lib/surveyor/render_text.rb +19 -0
  56. data/lib/surveyor/surveyor_controller_methods.rb +19 -1
  57. data/lib/surveyor/unparser.rb +1 -1
  58. data/lib/surveyor/version.rb +1 -1
  59. data/lib/tasks/surveyor_tasks.rake +1 -1
  60. data/spec/controllers/surveyor_controller_spec.rb +7 -3
  61. data/spec/helpers/surveyor_helper_spec.rb +104 -9
  62. data/spec/lib/chinese_survey.rb +14 -0
  63. data/spec/lib/common_spec.rb +52 -1
  64. data/spec/lib/rake_kitchen_sink.rb +40 -0
  65. data/spec/models/answer_spec.rb +11 -0
  66. data/spec/models/question_spec.rb +15 -0
  67. data/spec/models/response_set_spec.rb +45 -1
  68. data/spec/models/response_spec.rb +7 -4
  69. data/surveyor.gemspec +4 -2
  70. metadata +99 -40
  71. data/app/controllers/results_controller.rb +0 -13
  72. data/app/views/results/index.html.erb +0 -17
  73. data/app/views/results/show.html.erb +0 -25
@@ -0,0 +1,96 @@
1
+ Feature: Survey export
2
+ As an api consumer
3
+ I want to represent a survey in JSON
4
+ So that I can use it offline
5
+
6
+ Scenario: Exporting basic questions
7
+ Given I parse
8
+ """
9
+ survey "Simple json" do
10
+ section "Basic questions" do
11
+ label "These questions are examples of the basic supported input types"
12
+
13
+ question_1 "What is your favorite color?", :pick => :one
14
+ answer "red"
15
+ answer "blue"
16
+ answer "green"
17
+ answer :other
18
+
19
+ q_2b "Choose the colors you don't like", :pick => :any
20
+ a_1 "orange"
21
+ a_2 "purple"
22
+ a_3 "brown"
23
+ a :omit
24
+ end
25
+ end
26
+ """
27
+ Then the json for "Simple json" should be
28
+ """
29
+ {
30
+ "title": "Simple json",
31
+ "uuid": "*",
32
+ "sections": [{
33
+ "title": "Basic questions",
34
+ "display_order":0,
35
+ "questions_and_groups": [
36
+ { "uuid": "*", "type": "label", "text": "These questions are examples of the basic supported input types" },
37
+ { "uuid": "*", "reference_identifier": "1", "pick": "one", "text": "What is your favorite color?", "answers": [{"text": "red", "uuid": "*"}, {"text": "blue", "uuid": "*"}, {"text": "green", "uuid": "*"}, {"text": "Other", "uuid": "*"}]},
38
+ { "uuid": "*", "reference_identifier": "2b", "pick": "any", "text": "Choose the colors you don't like", "answers": [{"text": "orange", "uuid": "*"},{"text": "purple", "uuid": "*"},{"text": "brown", "uuid": "*"},{"text": "Omit", "exclusive":true, "uuid": "*"}]}]
39
+ }]
40
+ }
41
+ """
42
+
43
+ Scenario: Exporting response sets
44
+ Given I parse
45
+ """
46
+ survey "Simple json response sets" do
47
+ section "Colors" do
48
+
49
+ question_1 "What is your favorite color?", :pick => :one
50
+ answer "red"
51
+ answer "blue"
52
+ answer "green"
53
+ answer :other
54
+
55
+ q_2b "What color don't you like?"
56
+ a_1 "color", :string
57
+ end
58
+ section "Other" do
59
+ label "no"
60
+ end
61
+ end
62
+ """
63
+ When I start the "Simple json response sets" survey
64
+ And I choose "red"
65
+ And I press "Other"
66
+ And I wait 1 seconds
67
+ And I press "Colors"
68
+ And I fill in "color" with "orange"
69
+ And I press "Other"
70
+ And I press "Click here to finish"
71
+ Then there should be 1 response set with 2 responses with:
72
+ | answer |
73
+ | red |
74
+ And the json for the last response set for "Simple json response sets" should be
75
+ """
76
+ {
77
+ "uuid":"*",
78
+ "survey_id":"*",
79
+ "created_at":"*",
80
+ "completed_at":"*",
81
+ "responses":[{
82
+ "uuid":"*",
83
+ "answer_id":"*",
84
+ "question_id":"*",
85
+ "created_at":"*",
86
+ "modified_at":"*"
87
+ },{
88
+ "uuid":"*",
89
+ "answer_id":"*",
90
+ "question_id":"*",
91
+ "created_at":"*",
92
+ "modified_at":"*",
93
+ "value":"orange"
94
+ }]
95
+ }
96
+ """
@@ -0,0 +1,42 @@
1
+ Feature: showing a survey
2
+ As a survey administrator
3
+ I want to see a survey that a participant has taken
4
+ So that I can understand the data
5
+
6
+ Scenario: Take a survey, then look at it
7
+ Given the survey
8
+ """
9
+ survey "Favorites" do
10
+ section "Colors" do
11
+ label "You with the sad eyes don't be discouraged"
12
+
13
+ question_1 "What is your favorite color?", :pick => :one
14
+ answer "red"
15
+ answer "blue"
16
+ answer "green"
17
+ answer :other
18
+
19
+ q_2b "Choose the colors you don't like", :pick => :any
20
+ a_1 "orange"
21
+ a_2 "purple"
22
+ a_3 "brown"
23
+ a :omit
24
+ end
25
+ end
26
+ """
27
+ When I start the "Favorites" survey
28
+ Then I should see "You with the sad eyes don't be discouraged"
29
+ And I choose "red"
30
+ And I choose "blue"
31
+ And I check "orange"
32
+ And I check "brown"
33
+ And I press "Click here to finish"
34
+ Then there should be 1 response set with 3 responses with:
35
+ | answer |
36
+ | blue |
37
+ | orange |
38
+ | brown |
39
+ When I go to the last response set show page
40
+ Then the "blue" radiobutton should be checked
41
+ And the "orange" checkbox should be checked
42
+ And the "brown" checkbox should be checked
@@ -1,7 +1,9 @@
1
1
  When /^I start the "([^"]*)" survey$/ do |name|
2
- When "I go to the surveys page"
3
- Then "I should see \"#{name}\""
4
- click_button "Take it"
2
+ steps %Q{
3
+ When I go to the surveys page
4
+ Then I should see "#{name}\"
5
+ When I press "Take it"
6
+ }
5
7
  end
6
8
 
7
9
  Then /^there should be (\d+) response set with (\d+) responses? with:$/ do |rs_num, r_num, table|
@@ -72,14 +74,10 @@ Then /^there should be (\d+) response with answer "([^"]*)"$/ do |count, answer_
72
74
  Response.find_by_answer_id(Answer.find_by_text(answer_text)).should_not be_blank
73
75
  end
74
76
 
75
- Then /^there should be (\d+) datetime responses with$/ do |count, table|
76
- Response.count.should == count.to_i
77
- table.hashes.each do |hash|
78
- if hash.keys == ["datetime_value"]
79
- dtv = DateTime.parse( hash["datetime_value"].size == 8 ? "0001-01-01 #{hash['datetime_value']}" : hash["datetime_value"])
80
- Response.all.one?{|x| x.datetime_value == dtv}.should be_true
81
- end
82
- end
77
+ Then /^there should be a datetime response with today's date$/ do
78
+ # Response.datetime_value returns ActiveSupport::TimeWithZone
79
+ # so we call .to_date on it for the comparison with Date.today
80
+ Response.all.one?{|x| x.datetime_value.to_date == Date.today}.should be_true
83
81
  end
84
82
 
85
83
  Then /^I should see the image "([^"]*)"$/ do |src|
@@ -90,6 +88,20 @@ Then /^(\d+) responses should exist$/ do |response_count|
90
88
  Response.count.should == response_count.to_i
91
89
  end
92
90
 
91
+ Then /^the json for "([^"]*)" should be$/ do |title, string|
92
+ visit "/surveys/#{Survey.find_by_title(title).access_code}.json"
93
+ puts page.find('body').text
94
+ Surveyor::Common.equal_json_excluding_wildcards(page.find('body').text, string).should == true
95
+ end
96
+
97
+ Then /^the json for the last response set for "([^"]*)" should be$/ do |title, string|
98
+ (survey = Survey.find_by_title(title)).should_not be_nil
99
+ (response_set = ResponseSet.last(:conditions => {:survey_id => survey.id})).should_not be_nil
100
+ visit "/surveys/#{survey.access_code}/#{response_set.access_code}.json"
101
+ puts page.find('body').text
102
+ Surveyor::Common.equal_json_excluding_wildcards(page.find('body').text, string).should == true
103
+ end
104
+
93
105
  Then /the element "([^\"]*)" should be hidden$/ do |selector|
94
106
  wait_until do
95
107
  its_hidden = page.evaluate_script("$('#{selector}').is(':hidden');")
@@ -104,4 +116,26 @@ Then /the element "([^\"]*)" should not be hidden$/ do |selector|
104
116
  its_in_dom = page.evaluate_script("$('#{selector}').length > 0;")
105
117
  (its_not_hidden && its_in_dom).should be_true
106
118
  end
107
- end
119
+ end
120
+ Given /^I have survey context of "([^"]*)"$/ do |context|
121
+ class SurveyorController < ApplicationController
122
+ require 'mustache'
123
+ class FakeMustacheContext < ::Mustache
124
+ def name
125
+ "Santa Claus"
126
+ end
127
+ def site
128
+ "Northwestern"
129
+ end
130
+ end
131
+ def render_context
132
+ FakeMustacheContext
133
+ end
134
+ end
135
+ end
136
+
137
+ When /^I follow today's date$/ do
138
+ steps %Q{
139
+ When I follow "#{Date.today.strftime('%d').to_i}"
140
+ }
141
+ end
@@ -102,6 +102,16 @@ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
102
102
  attach_file(field, File.expand_path(path))
103
103
  end
104
104
 
105
+ When /^(?:|I )click "([^"]*)"$/ do |field|
106
+ find_field(field).click
107
+ end
108
+
109
+ When /^(?:|I )change "([^"]*)" to "([^"]*)"$/ do |field, value|
110
+ fill_in(field, :with => value)
111
+ id = "#" + find_field(field)[:id]
112
+ page.execute_script("$('#{id}').trigger('change');")
113
+ end
114
+
105
115
  Then /^(?:|I )should see "([^"]*)"$/ do |text|
106
116
  if page.respond_to? :should
107
117
  page.should have_content(text)
@@ -162,7 +172,7 @@ Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |f
162
172
  end
163
173
  end
164
174
 
165
- Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
175
+ Then /^the "([^"]*)" (checkbox|radiobutton)(?: within (.*))? should be checked$/ do |label, _, parent|
166
176
  with_scope(parent) do
167
177
  field_checked = find_field(label)['checked']
168
178
  if field_checked.respond_to? :should
@@ -173,7 +183,7 @@ Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, pa
173
183
  end
174
184
  end
175
185
 
176
- Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
186
+ Then /^the "([^"]*)" (checkbox|radiobutton)(?: within (.*))? should not be checked$/ do |label, _, parent|
177
187
  with_scope(parent) do
178
188
  field_checked = find_field(label)['checked']
179
189
  if field_checked.respond_to? :should
@@ -183,7 +193,7 @@ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label
183
193
  end
184
194
  end
185
195
  end
186
-
196
+
187
197
  Then /^(?:|I )should be on (.+)$/ do |page_name|
188
198
  current_path = URI.parse(current_url).path
189
199
  if current_path.respond_to? :should
@@ -197,8 +207,8 @@ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
197
207
  query = URI.parse(current_url).query
198
208
  actual_params = query ? CGI.parse(query) : {}
199
209
  expected_params = {}
200
- expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
201
-
210
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
211
+
202
212
  if actual_params.respond_to? :should
203
213
  actual_params.should == expected_params
204
214
  else
@@ -12,7 +12,8 @@ module NavigationHelpers
12
12
  '/'
13
13
  when /the surveys page/
14
14
  '/surveys'
15
-
15
+ when /the last response set show page/
16
+ view_my_survey_path(:survey_code => ResponseSet.last.survey.access_code, :response_set_code => ResponseSet.last.access_code)
16
17
  # Add more mappings here.
17
18
  # Here is an example that pulls values out of the Regexp:
18
19
  #
@@ -3,7 +3,7 @@ Feature: Survey creation
3
3
  I want to take a survey
4
4
  So that I can get paid
5
5
 
6
- Scenario: Basic questions
6
+ Scenario: Creating basic questions
7
7
  Given the survey
8
8
  """
9
9
  survey "Favorites" do
@@ -37,7 +37,7 @@ Feature: Survey creation
37
37
  | orange |
38
38
  | brown |
39
39
 
40
- Scenario: Default answers
40
+ Scenario: Creating default answers
41
41
  Given the survey
42
42
  """
43
43
  survey "Favorites" do
@@ -68,7 +68,7 @@ Feature: Survey creation
68
68
  | string_value |
69
69
  | chicken |
70
70
 
71
- Scenario: Quiz time
71
+ Scenario: Creating, it's quiz time
72
72
  Given the survey
73
73
  """
74
74
  survey "Favorites" do
@@ -82,7 +82,7 @@ Feature: Survey creation
82
82
  """
83
83
  Then question "1" should have correct answer "oink"
84
84
 
85
- Scenario: Custom css class
85
+ Scenario: Creating custom css class
86
86
  Given the survey
87
87
  """
88
88
  survey "Movies" do
@@ -93,15 +93,18 @@ Feature: Survey creation
93
93
  a :string
94
94
  q "Anything else to say?", :pick => :any
95
95
  a "yes", :string, :custom_class => "other_custom_class"
96
+ q "Random question", :pick => :one
97
+ a "yes", :string, :custom_class => "other_other_custom_class"
96
98
  end
97
99
  end
98
100
  """
99
101
  When I start the "Movies" survey
100
- Then the element "input[type='text']:first.my_custom_class" should exist
102
+ Then the element "input[type='text'].my_custom_class" should exist
101
103
  And the element "input[type='checkbox'].other_custom_class" should exist
102
- And the element "input[type='text'].other_custom_class" should exist
104
+ And the element "input[type='radio'].other_other_custom_class" should exist
105
+ And the element "input[type='text'].other_other_custom_class" should exist
103
106
 
104
- Scenario: A pick one question with an option for other
107
+ Scenario: Creating a pick one question with an option for other
105
108
  Given the survey
106
109
  """
107
110
  survey "Favorites" do
@@ -120,7 +123,7 @@ Feature: Survey creation
120
123
  Then there should be 1 response set with 1 response with:
121
124
  | bacon |
122
125
 
123
- Scenario: Repeater with a dropdown
126
+ Scenario: Creating a repeater with a dropdown
124
127
  Given the survey
125
128
  """
126
129
  survey "Movies" do
@@ -137,7 +140,25 @@ Feature: Survey creation
137
140
  When I start the "Movies" survey
138
141
  Then a dropdown should exist with the options "Action, Comedy, Mystery"
139
142
 
140
- Scenario: A pick one question with an option for other
143
+ # Issue 251 - text field with checkbox
144
+ Scenario: Creating a group with a dropdown
145
+ Given the survey
146
+ """
147
+ survey "All Holidays" do
148
+ section "Favorites" do
149
+ group "Holidays" do
150
+ q "What is your favorite holiday?", :pick => :one, :display_type => :dropdown
151
+ a "Christmas"
152
+ a "New Year"
153
+ a "March 8th"
154
+ end
155
+ end
156
+ end
157
+ """
158
+ When I start the "All Holidays" survey
159
+ Then a dropdown should exist with the options "Christmas, New Year, March 8th"
160
+
161
+ Scenario: Creating another pick one question with an option for other
141
162
  Given the survey
142
163
  """
143
164
  survey "Favorites" do
@@ -157,7 +178,7 @@ Feature: Survey creation
157
178
  Then there should be 1 response set with 1 response with:
158
179
  | shrimp |
159
180
 
160
- Scenario: Checkboxes with text area
181
+ Scenario: Creating checkboxes with text area
161
182
  Given the survey
162
183
  """
163
184
  survey "Websites" do
@@ -173,7 +194,7 @@ Feature: Survey creation
173
194
  Then there should be 3 checkboxes
174
195
  And there should be 3 text areas
175
196
 
176
- Scenario: "Double letter rule keys"
197
+ Scenario: Creating double letter rule keys
177
198
  Given the survey
178
199
  """
179
200
  survey "Doubles" do
@@ -207,7 +228,7 @@ Feature: Survey creation
207
228
  And I press "Two"
208
229
  Then the question "Do you want to be part of an SNL skit?" should be triggered
209
230
 
210
- Scenario: "Changing dropdowns"
231
+ Scenario: Creating and changing dropdowns
211
232
  Given the survey
212
233
  """
213
234
  survey "Drop" do
@@ -234,7 +255,122 @@ Feature: Survey creation
234
255
  And I press "Two"
235
256
  Then there should be 1 response with answer "Dogg"
236
257
 
237
- Scenario: "Saving grids"
258
+ # Issue 234 - text field with checkbox
259
+ @javascript
260
+ Scenario: Creating a question with an option checkbox for other and text input
261
+ Given the survey
262
+ """
263
+ survey "Favorite Cuisine" do
264
+ section "Foods" do
265
+ q "What is the best cuisine?", :pick => :any
266
+ a "french"
267
+ a "italian"
268
+ a "chinese"
269
+ a "other", :string
270
+ end
271
+ end
272
+ """
273
+ When I start the "Favorite Cuisine" survey
274
+ And I wait 2 seconds
275
+ And I change "r_4_string_value" to "thai"
276
+ Then the "other" checkbox should be checked
277
+
278
+ # Issue 234 - empty text field with checkbox
279
+ @javascript
280
+ Scenario: Creating a question with an option checkbox for other and an empty text input
281
+ Given the survey
282
+ """
283
+ survey "Favorite Cuisine" do
284
+ section "Foods" do
285
+ q "What is the best cuisine?", :pick => :any
286
+ a "french"
287
+ a "italian"
288
+ a "chinese"
289
+ a "other", :string
290
+ end
291
+ end
292
+ """
293
+ When I start the "Favorite Cuisine" survey
294
+ And I wait 2 seconds
295
+ And I change "r_4_string_value" to ""
296
+ Then the "other" checkbox should not be checked
297
+
298
+ # Issue 234 - text field with radio buttons
299
+ @javascript
300
+ Scenario: Creating a question with an option radio button for other and text input
301
+ Given the survey
302
+ """
303
+ survey "Favorite Cuisine" do
304
+ section "Foods" do
305
+ q "What is the best cuisine?", :pick => :one
306
+ a "french"
307
+ a "italian"
308
+ a "chinese"
309
+ a "other", :string
310
+ end
311
+ end
312
+ """
313
+ When I start the "Favorite Cuisine" survey
314
+ And I wait 2 seconds
315
+ And I change "r_1_string_value" to "thai"
316
+ Then the "other" radiobutton should be checked
317
+
318
+ # Issue 234 - empty text field with radio buttons
319
+ @javascript
320
+ Scenario: Creating another question with an option radio button for other and text input
321
+ Given the survey
322
+ """
323
+ survey "Favorite Cuisine" do
324
+ section "Foods" do
325
+ q "What is the best cuisine?", :pick => :one
326
+ a "french"
327
+ a "italian"
328
+ a "chinese"
329
+ a "other", :string
330
+ end
331
+ end
332
+ """
333
+ When I start the "Favorite Cuisine" survey
334
+ And I wait 2 seconds
335
+ And I change "r_1_string_value" to ""
336
+ Then the "other" radiobutton should not be checked
337
+
338
+
339
+ # Issue 259 - substitution of the text with Mustache
340
+ @wip
341
+ @javascript
342
+ Scenario: Creating a question with an mustache syntax
343
+ Given I have survey context of "FakeMustacheContext"
344
+ Given the survey
345
+ """
346
+ survey "Overall info" do
347
+ section "Group of questions" do
348
+ group "Information on {{name}}?", :help_text => "Answer all you know on {{name}}" do
349
+ label "{{name}} does not work for {{site}}!", :help_text => "Make sure you sure {{name}} doesn't work for {{site}}"
350
+
351
+ q "Where does {{name}} live?", :pick => :one,
352
+ :help_text => "If you don't know where {{name}} lives, skip the question"
353
+ a "{{name}} lives on North Pole"
354
+ a "{{name}} lives on South Pole"
355
+ a "{{name}} doesn't exist"
356
+ end
357
+ end
358
+ end
359
+ """
360
+ When I start the "Overall info" survey
361
+ And I wait 5 seconds
362
+ Then I should see "Information on Santa Claus"
363
+ And I should see "Answer all you know on Santa Claus"
364
+ And I should see "Santa Claus does not work for Northwestern!"
365
+ And I should see "Make sure you sure Santa Claus doesn't work for Northwestern"
366
+ And I should see "Where does Santa Claus live?"
367
+ And I should see "If you don't know where Santa Claus lives, skip the question"
368
+ And I should see "Santa Claus lives on North Pole"
369
+ And I should see "Santa Claus lives on South Pole"
370
+ And I should see "Santa Claus doesn't exist"
371
+
372
+
373
+ Scenario: Creating and saving grids
238
374
  Given the survey
239
375
  """
240
376
  survey "Grid" do
@@ -262,7 +398,7 @@ Feature: Survey creation
262
398
  And I press "One"
263
399
  Then there should be 1 response with answer "1"
264
400
 
265
- Scenario: "Dates"
401
+ Scenario: Creating dates
266
402
  Given the survey
267
403
  """
268
404
  survey "When" do
@@ -271,12 +407,12 @@ Feature: Survey creation
271
407
  a "Give me a date", :date
272
408
  end
273
409
  section "Two" do
274
- q "Tell us when you'd like to eat"
275
- a :time
410
+ q "Tell us when you would like to eat"
411
+ a "When eat", :time
276
412
  end
277
413
  section "Three" do
278
- q "Tell us when you'd like a phone call"
279
- a :datetime
414
+ q "Tell us when you would like a phone call"
415
+ a "When phone", :datetime
280
416
  end
281
417
  end
282
418
  """
@@ -285,40 +421,55 @@ Feature: Survey creation
285
421
  And I fill in "Give me a date" with "2011-02-14"
286
422
  # 1:30am
287
423
  And I press "Two"
288
- And I select "01" from "Hour"
289
- And I select "30" from "Minute"
424
+ And I fill in "When eat" with "01:30"
290
425
  # 2/15/11 5:30pm
291
426
  And I press "Three"
292
- And I select "2011" from "Year"
293
- And I select "February" from "Month"
294
- And I select "15" from "Day"
295
- And I select "17" from "Hour"
296
- And I select "30" from "Minute"
297
- And I press "One"
427
+ And I fill in "When phone" with "2011-02-15 17:30:00"
298
428
 
299
- Then there should be 3 datetime responses with
300
- | datetime_value |
301
- | 2011-02-14 00:00:00 |
302
- | 01:30:00 |
303
- | 2011-02-15 17:30:00 |
429
+ # Verification
430
+ When I press "One"
431
+ Then the "Give me a date" field should contain "2011-02-14"
432
+ When I press "Two"
433
+ Then the "When eat" field should contain "01:30"
434
+ When I press "Three"
435
+ Then the "When phone" field should contain "2011-02-15 17:30:00"
304
436
 
305
437
  # 2/13/11
438
+ When I press "One"
306
439
  And I fill in "Give me a date" with "2011-02-13"
307
440
  # 1:30pm
308
441
  And I press "Two"
309
- And I select "13" from "Hour"
442
+ And I fill in "When eat" with "13:30"
310
443
  # 2/15/11 5:00pm
311
444
  And I press "Three"
312
- And I select "00" from "Minute"
313
- And I press "Click here to finish"
445
+ And I fill in "When phone" with "2011-02-15 17:00:00"
446
+
447
+ # Verification
448
+ When I press "One"
449
+ Then the "Give me a date" field should contain "2011-02-13"
450
+ When I press "Two"
451
+ Then the "When eat" field should contain "13:30"
452
+ When I press "Three"
453
+ Then the "When phone" field should contain "2011-02-15 17:00:00"
314
454
 
315
- Then there should be 3 datetime responses with
316
- | datetime_value |
317
- | 2011-02-13 00:00:00 |
318
- | 13:30:00 |
319
- | 2011-02-15 17:00:00 |
455
+ @javascript
456
+ Scenario: Creating a date
457
+ Given the survey
458
+ """
459
+ survey "When" do
460
+ section "One" do
461
+ q "Tell us when you want to meet"
462
+ a "Give me a date", :date
463
+ end
464
+ end
465
+ """
466
+ 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
320
471
 
321
- Scenario: "Images"
472
+ Scenario: Creating images
322
473
  Given the survey
323
474
  """
324
475
  survey "Images" do
@@ -334,7 +485,7 @@ Feature: Survey creation
334
485
  And I should see the image "/images/surveyor/prev.gif"
335
486
 
336
487
  @javascript
337
- Scenario: "Unchecking Checkboxes"
488
+ Scenario: Creating and unchecking checkboxes
338
489
  Given the survey
339
490
  """
340
491
  survey "Travels" do