surveyor 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/CHANGELOG.md +26 -0
  2. data/README.md +67 -168
  3. data/app/models/survey_translation.rb +5 -0
  4. data/app/views/partials/_answer.html.haml +9 -5
  5. data/app/views/partials/_question.html.haml +3 -3
  6. data/app/views/partials/_question_group.html.haml +9 -8
  7. data/app/views/partials/_section.html.haml +1 -1
  8. data/app/views/surveyor/edit.html.haml +3 -3
  9. data/app/views/surveyor/export.json.rabl +12 -8
  10. data/app/views/surveyor/new.html.haml +9 -14
  11. data/app/views/surveyor/show.html.haml +2 -2
  12. data/doc/surveyor_models.png +0 -0
  13. data/doc/surveyor_models2.png +0 -0
  14. data/features/export_to_json.feature +97 -1
  15. data/features/internationalization.feature +55 -0
  16. data/features/step_definitions/parser_steps.rb +7 -0
  17. data/features/step_definitions/surveyor_steps.rb +43 -6
  18. data/features/step_definitions/ui_steps.rb +22 -0
  19. data/features/support/env.rb +2 -0
  20. data/features/support/hooks.rb +4 -0
  21. data/features/surveyor.feature +117 -1
  22. data/features/surveyor_dependencies.feature +56 -2
  23. data/features/surveyor_parser.feature +10 -10
  24. data/lib/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  25. data/lib/assets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  26. data/lib/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  27. data/lib/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  28. data/lib/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  29. data/lib/assets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  30. data/lib/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  31. data/lib/assets/images/{ui-icons_ef8c08_256x240.png → ui-icons_222222_256x240.png} +0 -0
  32. data/lib/assets/images/ui-icons_2e83ff_256x240.png +0 -0
  33. data/lib/assets/images/{ui-icons_ffffff_256x240.png → ui-icons_454545_256x240.png} +0 -0
  34. data/lib/assets/images/ui-icons_888888_256x240.png +0 -0
  35. data/lib/assets/images/ui-icons_cd0a0a_256x240.png +0 -0
  36. data/lib/assets/javascripts/surveyor/jquery-1.9.0.js +9555 -0
  37. data/lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js +14850 -0
  38. data/lib/assets/javascripts/surveyor/jquery-ui-timepicker-addon.js +1795 -1153
  39. data/lib/assets/javascripts/surveyor/jquery.maskedinput.js +338 -0
  40. data/lib/assets/javascripts/surveyor/jquery.surveyor.js +8 -0
  41. data/lib/assets/stylesheets/surveyor.sass +2 -2
  42. data/lib/assets/stylesheets/surveyor/jquery-ui-1.10.0.custom.css +1174 -0
  43. data/lib/assets/stylesheets/surveyor/jquery-ui-timepicker-addon.css +7 -2
  44. data/lib/assets/stylesheets/surveyor/reset.css +24 -26
  45. data/lib/generators/surveyor/install_generator.rb +4 -0
  46. data/lib/generators/surveyor/templates/app/assets/javascripts/surveyor_all.js +4 -3
  47. data/lib/generators/surveyor/templates/app/assets/stylesheets/surveyor_all.css +2 -2
  48. data/lib/generators/surveyor/templates/config/locales/surveyor_en.yml +1 -0
  49. data/lib/generators/surveyor/templates/config/locales/surveyor_he.yml +1 -1
  50. data/lib/generators/surveyor/templates/config/locales/surveyor_ko.yml +18 -0
  51. data/lib/generators/surveyor/templates/db/migrate/add_input_mask_attributes_to_answer.rb +12 -0
  52. data/lib/generators/surveyor/templates/db/migrate/create_survey_translations.rb +19 -0
  53. data/lib/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +5 -0
  54. data/lib/generators/surveyor/templates/surveys/languages.rb +10 -0
  55. data/lib/generators/surveyor/templates/surveys/translations/languages.es.yml +14 -0
  56. data/lib/generators/surveyor/templates/surveys/translations/languages.he.yml +14 -0
  57. data/lib/generators/surveyor/templates/surveys/translations/languages.ko.yml +14 -0
  58. data/lib/surveyor/helpers/formtastic_custom_input.rb +4 -8
  59. data/lib/surveyor/helpers/surveyor_helper_methods.rb +22 -26
  60. data/lib/surveyor/models/answer_methods.rb +41 -10
  61. data/lib/surveyor/models/question_group_methods.rb +17 -3
  62. data/lib/surveyor/models/question_methods.rb +32 -5
  63. data/lib/surveyor/models/response_methods.rb +7 -7
  64. data/lib/surveyor/models/survey_methods.rb +20 -4
  65. data/lib/surveyor/models/survey_section_methods.rb +10 -5
  66. data/lib/surveyor/models/survey_translation_methods.rb +33 -0
  67. data/lib/surveyor/mustache_context.rb +11 -0
  68. data/lib/surveyor/parser.rb +15 -2
  69. data/lib/surveyor/surveyor_controller_methods.rb +19 -17
  70. data/lib/surveyor/version.rb +1 -1
  71. data/spec/controllers/surveyor_controller_spec.rb +3 -3
  72. data/spec/factories.rb +21 -7
  73. data/spec/helpers/formtastic_custom_input_spec.rb +2 -3
  74. data/spec/helpers/surveyor_helper_spec.rb +64 -100
  75. data/spec/models/answer_spec.rb +166 -58
  76. data/spec/models/question_group_spec.rb +84 -38
  77. data/spec/models/question_spec.rb +188 -116
  78. data/spec/models/survey_section_spec.rb +77 -40
  79. data/spec/models/survey_spec.rb +176 -145
  80. data/spec/spec_helper.rb +3 -0
  81. data/stacktests.sh +52 -0
  82. metadata +36 -18
  83. data/lib/assets/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  84. data/lib/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  85. data/lib/assets/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  86. data/lib/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  87. data/lib/assets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  88. data/lib/assets/javascripts/surveyor/jquery-ui.js +0 -11729
  89. data/lib/assets/javascripts/surveyor/jquery.tools.min.js +0 -204
  90. data/lib/assets/stylesheets/surveyor/dateinput.css +0 -149
  91. data/lib/assets/stylesheets/surveyor/jquery-ui.custom.css +0 -572
  92. data/lib/surveyor/render_text.rb +0 -23
  93. data/lib/surveyor/surveyor_admin_controller_methods.rb +0 -55
@@ -12,7 +12,7 @@ child :sections => :sections do
12
12
  child :questions_and_groups => :questions_and_groups do
13
13
  # both questions and question_groups have uuid, text, help_text, reference_identifier, and type
14
14
  attribute :api_id => :uuid
15
- node(:text, :if => lambda { |q| q.is_a?(Question)}){ |q| q.split_text(:pre) }
15
+ node(:text, :if => lambda { |q| q.is_a?(Question)}){ |q| q.split(q.text, :pre) }
16
16
  node(:text, :if => lambda { |q| q.is_a?(QuestionGroup)}){ |q| q.text }
17
17
  node(:help_text, :if => lambda { |q| !q.help_text.blank? }){ |q| q.help_text }
18
18
  node(:reference_identifier, :if => lambda { |q| !q.reference_identifier.blank? }){ |q| q.reference_identifier }
@@ -21,17 +21,19 @@ child :sections => :sections do
21
21
 
22
22
  # only questions
23
23
  node(:pick, :if => lambda { |q| q.is_a?(Question) && q.pick != "none" }){ |q| q.pick }
24
- node(:post_text, :if => lambda { |q| q.is_a?(Question) && !q.split_text(:post).blank? }){ |q| q.split_text(:post) }
24
+ node(:post_text, :if => lambda { |q| q.is_a?(Question) && !q.split(q.text, :post).blank? }){ |q| q.split(q.text, :post) }
25
25
 
26
26
  child :answers, :if => lambda { |q| q.is_a?(Question) && !q.answers.blank? } do
27
27
  attribute :api_id => :uuid
28
28
  node(:help_text, :if => lambda { |a| !a.help_text.blank? }){ |a| a.help_text }
29
29
  node(:exclusive, :if => lambda { |a| a.is_exclusive }){ |a| a.is_exclusive }
30
- node(:text){ |a| a.split_or_hidden_text(:pre) }
31
- node(:post_text, :if => lambda { |a| !a.split_or_hidden_text(:post).blank? }){ |a| a.split_or_hidden_text(:post) }
30
+ node(:text){ |a| a.split(a.text, :pre) }
31
+ node(:post_text, :if => lambda { |a| !a.split(a.text, :post).blank? }){ |a| a.split(a.text, :post) }
32
32
  node(:type, :if => lambda { |a| a.response_class != "answer" }){ |a| a.response_class }
33
33
  node(:reference_identifier, :if => lambda { |a| !a.reference_identifier.blank? }){ |a| a.reference_identifier }
34
34
  node(:data_export_identifier, :if => lambda { |a| !a.data_export_identifier.blank? }){ |a| a.data_export_identifier }
35
+ node(:input_mask, :if => lambda { |a| !a.input_mask.blank? }){ |a| a.input_mask }
36
+ node(:input_mask_placeholder, :if => lambda { |a| !a.input_mask_placeholder.blank? }){ |a| a.input_mask_placeholder }
35
37
  end
36
38
 
37
39
  # both questions and question_groups have dependencies
@@ -47,8 +49,8 @@ child :sections => :sections do
47
49
 
48
50
  child(:questions, :if => lambda{|x| x.is_a?(QuestionGroup)}) do
49
51
  attributes :api_id => :uuid
50
- node(:text){ |q| q.split_text(:pre) }
51
- node(:post_text, :if => lambda { |q| !q.split_text(:post).blank? }){ |q| q.split_text(:post) }
52
+ node(:text){ |q| q.split(q.text, :pre) }
53
+ node(:post_text, :if => lambda { |q| !q.split(q.text, :post).blank? }){ |q| q.split(q.text, :post) }
52
54
  node(:help_text, :if => lambda { |q| !q.help_text.blank? }){ |q| q.help_text }
53
55
  node(:reference_identifier, :if => lambda { |q| !q.reference_identifier.blank? }){ |q| q.reference_identifier }
54
56
  node(:data_export_identifier, :if => lambda { |q| !q.data_export_identifier.blank? }){ |q| q.data_export_identifier }
@@ -59,11 +61,13 @@ child :sections => :sections do
59
61
  attributes :api_id => :uuid
60
62
  node(:help_text, :if => lambda { |a| !a.help_text.blank? }){ |a| a.help_text }
61
63
  node(:is_exclusive, :if => lambda { |a| a.is_exclusive }){ |a| a.is_exclusive }
62
- node(:text){ |a| a.split_or_hidden_text(:pre) }
63
- node(:post_text, :if => lambda { |a| !a.split_or_hidden_text(:post).blank? }){ |a| a.split_or_hidden_text(:post) }
64
+ node(:text){ |a| a.split(a.text, :pre) }
65
+ node(:post_text, :if => lambda { |a| !a.split(a.text, :post).blank? }){ |a| a.split(a.text, :post) }
64
66
  node(:type, :if => lambda { |a| a.response_class != "answer" }){ |a| a.response_class }
65
67
  node(:reference_identifier, :if => lambda { |a| !a.reference_identifier.blank? }){ |a| a.reference_identifier }
66
68
  node(:data_export_identifier, :if => lambda { |a| !a.data_export_identifier.blank? }){ |a| a.data_export_identifier }
69
+ node(:input_mask, :if => lambda { |a| !a.input_mask.blank? }){ |a| a.input_mask }
70
+ node(:input_mask_placeholder, :if => lambda { |a| !a.input_mask_placeholder.blank? }){ |a| a.input_mask_placeholder }
67
71
  end
68
72
 
69
73
  child :dependency, :if => lambda { |q| q.dependency } do
@@ -7,21 +7,16 @@
7
7
  %br
8
8
  #survey_list
9
9
  %ul
10
- - unless @codes.empty?
11
- - @codes.each do |access_code, values|
12
- %li
13
- = form_tag take_survey_path(:survey_code => access_code) do
14
- = hidden_field_tag :surveyor_javascript_enabled, false
15
-
16
- = values[:title]
17
-  
18
- = label_tag :survey_version, 'version:'
19
- = select_tag(:survey_version, options_for_select([["-- Current version --", ""]] + values[:survey_versions]))
20
-  
21
- = submit_tag( t('surveyor.take_it') )
22
- - else
10
+ - @surveys_by_access_code.each do |access_code, surveys|
23
11
  %li
24
- No surveys
12
+ = form_tag take_survey_path(:survey_code => access_code) do
13
+ = hidden_field_tag :surveyor_javascript_enabled, false
14
+ = surveys.first.translation(I18n.locale)[:title]
15
+  
16
+ = label_tag :survey_version, 'version:'
17
+ = select_tag(:survey_version, options_for_select([["-- Current version --", ""]] + (surveys.map(&:survey_version) || [])))
18
+  
19
+ = submit_tag( t('surveyor.take_it'), :default => "Take it" )
25
20
 
26
21
  :javascript
27
22
  $(document).ready(function() {
@@ -48,10 +48,10 @@
48
48
  - if q.pick == "one"
49
49
  - r = response_for(@response_set, q, nil, g)
50
50
  - j = response_idx # increment the response index since the answer partial skips for q.pick == one
51
- %th= q.split_text(:pre)
51
+ %th= q.split(q.text, :pre)
52
52
  - q.answers.each do |a|
53
53
  %td= render a.custom_renderer || '/partials/answer', :g => g, :q => q, :a => a, :f => f, :disableFlag => true
54
- %th= q.split_text(:post)
54
+ %th= q.split(q.text, :post)
55
55
  - when :repeater
56
56
  - (@response_set.count_group_responses(group_questions) + 1).times do |rg|
57
57
  %li
Binary file
Binary file
@@ -146,6 +146,43 @@ Feature: Survey export
146
146
  }
147
147
  """
148
148
 
149
+ Scenario: Exporting input mask and mask placeholder
150
+ Given I parse
151
+ """
152
+ survey "Personal" do
153
+ section "Guy" do
154
+ q "What is your phone number?"
155
+ a :string, :input_mask => '(999)999-9999', :input_mask_placeholder => '#'
156
+ end
157
+ end
158
+ """
159
+ And I visit "/surveys/personal.json"
160
+ Then the JSON should be:
161
+ """
162
+ {
163
+ "title": "Personal",
164
+ "uuid": "*",
165
+ "sections": [{
166
+ "display_order": 0,
167
+ "title": "Guy",
168
+ "questions_and_groups": [
169
+ {
170
+ "uuid": "*",
171
+ "text": "What is your phone number?",
172
+ "answers": [
173
+ {
174
+ "input_mask": "(999)999-9999",
175
+ "input_mask_placeholder": "#",
176
+ "text": "String",
177
+ "type": "string",
178
+ "uuid": "*"
179
+ }
180
+ ]
181
+ }]
182
+ }]
183
+ }
184
+ """
185
+
149
186
  Scenario: Exporting response sets
150
187
  Given I parse
151
188
  """
@@ -243,6 +280,65 @@ Feature: Survey export
243
280
  And the JSON response at "responses/0/value" should be "blueish"
244
281
  And the JSON response at "responses/0/answer_id" should correspond to an answer with text "most favorite color"
245
282
 
283
+ Scenario: Exporting null datetime response
284
+ Given I parse
285
+ """
286
+ survey "Health" do
287
+ section "Doctor" do
288
+ question "When did you visit?", :pick => :one
289
+ a "Date", :date
290
+ a "Not sure"
291
+ end
292
+ end
293
+ """
294
+ And I start the "Health" survey
295
+ And I choose "Date"
296
+ And I press "Click here to finish"
297
+ And I export the response set
298
+ Then the JSON at "responses" should have 1 entry
299
+ And the JSON response at "responses/0/value" should be null
300
+
246
301
  Scenario: Exporting non-existent surveys
247
302
  When I visit "/surveys/simple-json.json"
248
- Then I should get a "404" response
303
+ Then I should get a "404" response
304
+
305
+ Scenario: Exporting with survey modifications
306
+ Given I parse
307
+ """
308
+ survey "Simple" do
309
+ section "Colors" do
310
+ question "What is your least favorite color?"
311
+ a "least favorite color", :string
312
+ end
313
+ end
314
+ """
315
+ When I prefix the titles of exported surveys with "NUBIC - "
316
+ Then the JSON representation for "Simple" should be:
317
+ """
318
+ {
319
+ "title": "NUBIC - Simple",
320
+ "uuid": "*",
321
+ "sections": [{
322
+ "title": "Colors",
323
+ "display_order":0,
324
+ "questions_and_groups": [
325
+ { "uuid": "*", "text": "What is your least favorite color?", "answers": [{"text": "least favorite color", "uuid": "*", "type": "string"}]}
326
+ ]
327
+ }]
328
+ }
329
+ """
330
+ When I visit "/surveys/simple.json"
331
+ Then the JSON should be:
332
+ """
333
+ {
334
+ "title": "NUBIC - Simple",
335
+ "uuid": "*",
336
+ "sections": [{
337
+ "title": "Colors",
338
+ "display_order":0,
339
+ "questions_and_groups": [
340
+ { "uuid": "*", "text": "What is your least favorite color?", "answers": [{"text": "least favorite color", "uuid": "*", "type": "string"}]}
341
+ ]
342
+ }]
343
+ }
344
+ """
@@ -0,0 +1,55 @@
1
+ # encoding: UTF-8
2
+ Feature: Internationalization
3
+ As survey taker
4
+ I want to see surveys in my own language
5
+ So that I understand what they're asking
6
+
7
+ Scenario:
8
+ Given I parse
9
+ """
10
+ survey "One language is never enough" do
11
+ translations :es => "translations/languages.es.yml", :he => "translations/languages.he.yml", :ko => "translations/languages.ko.yml"
12
+ section_one "One" do
13
+ g_hello "Hello" do
14
+ q_name "What is your name?"
15
+ a_name :string, :help_text => "My name is..."
16
+ end
17
+ end
18
+ end
19
+ """
20
+ Then there should be 3 translations with
21
+ | locale |
22
+ | es |
23
+ | he |
24
+ | ko |
25
+ When I start the survey
26
+ Then I should see "One language is never enough"
27
+ And I should see "One"
28
+ And I should see "Hello"
29
+ And I should see "What is your name?"
30
+ And I should see "My name is..."
31
+ When I start the survey in "es"
32
+ Then I should see "Un idioma nunca es suficiente"
33
+ And I should see "Uno"
34
+ And I should see "¡Hola!"
35
+ And I should see "¿Cómo se llama Usted?"
36
+ And I should see "Mi nombre es..."
37
+ When I start the survey in "he"
38
+ Then I should see "ידיעת שפה אחת אינה מספיקה"
39
+ And I should see "אחת"
40
+ And I should see "שלום"
41
+ And I should see "מה שמך?"
42
+ And I should see "שמי..."
43
+ When I start the survey in "ko"
44
+ Then I should see "한가지 언어로는 충분치 않습니다."
45
+ And I should see "하나"
46
+ And I should see "안녕하십니까"
47
+ And I should see "성함이 어떻게 되십니까?"
48
+ And I should see "제 이름은 ... 입니다"
49
+ When I start the survey
50
+ Then I should see "One language is never enough"
51
+ And I should see "One"
52
+ And I should see "Hello"
53
+ And I should see "What is your name?"
54
+ And I should see "My name is..."
55
+
@@ -31,6 +31,13 @@ Then /^there should be (\d+) survey(?:s?) with:$/ do |x, table|
31
31
  end
32
32
  end
33
33
 
34
+ Then /^there should be (\d+) translations with$/ do |x, table|
35
+ SurveyTranslation.count.should == x.to_i
36
+ table.hashes.each do |hash|
37
+ SurveyTranslation.find(:first, :conditions => hash).should_not be_nil
38
+ end
39
+ end
40
+
34
41
  Then /^there should be (\d+) section(?:s?) with:$/ do |x, table|
35
42
  SurveySection.count.should == x.to_i
36
43
  table.hashes.each do |hash|
@@ -11,12 +11,20 @@ end
11
11
  When /^I start the survey$/ do
12
12
  steps %Q{
13
13
  When I go to the surveys page
14
- And I press "Take it"
14
+ And I press "Take it"
15
15
  }
16
16
  @survey_code = current_path.split("/")[2] # /surveys/:survey_code/:response_set_code/take
17
17
  @response_set_code = current_path.split("/")[3] # /surveys/:survey_code/:response_set_code/take
18
18
  end
19
19
 
20
+ When /^I start the survey in "(.*?)"$/ do |locale|
21
+ visit(available_surveys_path(:locale => locale))
22
+ steps %Q{
23
+ And I press "#{I18n.t 'surveyor.take_it'}"
24
+ }
25
+ end
26
+
27
+
20
28
  # When I fill in the (nth) (string) for "(ref_id)" with "(value to fill)"
21
29
  When /^I fill in the (\d+[a-z]{0,2} )?(\w+) for "([^"]+)" with "([^"]+)"$/ do |index, type, answer_reference_id, value|
22
30
  answer = Answer.where(:reference_identifier => answer_reference_id).first
@@ -188,6 +196,23 @@ Then /^the JSON response at "(.*?)" should correspond to an answer with text "(.
188
196
  last_json.should be_json_eql(JsonSpec.remember("\"#{Answer.find_by_text(text).api_id}\"")).at_path(path)
189
197
  end
190
198
 
199
+ Then /^the JSON representation for "(.*?)" should be:$/ do |title, string|
200
+ Survey.find_by_title(title).as_json.to_json.should be_json_eql(string)
201
+ end
202
+
203
+ Given /^I prefix the titles of exported surveys with "(.*?)"$/ do |prefix|
204
+ PREFIX = prefix
205
+ class Survey < ActiveRecord::Base
206
+ include Surveyor::Models::SurveyMethods
207
+ def filtered_for_json
208
+ dolly = self.clone
209
+ dolly.sections = self.sections
210
+ dolly.title = "#{PREFIX}#{dolly.title}"
211
+ dolly
212
+ end
213
+ end
214
+ end
215
+
191
216
  ## Hidden and shown elements
192
217
 
193
218
  Then /the element "([^\"]*)" should be hidden$/ do |selector|
@@ -244,15 +269,22 @@ Given /^I replace question numbers with letters$/ do
244
269
  end
245
270
  end
246
271
 
247
-
248
272
  ## Various input elements
249
273
 
250
- Then /^I should see (\d+) textareas on the page$/ do |i|
251
- page.has_css?('textarea', :count => i)
274
+ Then /^I should see (\d+) textarea(?:s?) on the page$/ do |i|
275
+ page.has_css?('textarea', :count => i).should == true
276
+ end
277
+
278
+ Then /^I should see (\d+) text input(?:s?) on the page$/ do |i|
279
+ page.has_css?('input[type="text"]', :count => i).should == true
252
280
  end
253
281
 
254
- Then /^I should see (\d+) "(.*?)" input on the page$/ do |i, css_class|
255
- page.has_css?("input.#{css_class}", :count => i)
282
+ Then /^I should see no text input(?:s?) on the page$/ do
283
+ page.has_css?('input[type="text"]').should == false
284
+ end
285
+
286
+ Then /^I should see (\d+) "(.*?)" input(?:s?) on the page$/ do |i, css_class|
287
+ page.has_css?("input.#{css_class}", :count => i).should == true
256
288
  end
257
289
 
258
290
  Then /^I should see (\d+) select on the page$/ do |i|
@@ -284,3 +316,8 @@ end
284
316
  Then /^the question "(.*?)" should have correct answer "(.*?)"$/ do |q, a|
285
317
  Question.find_by_reference_identifier(q).correct_answer.reference_identifier.should == a
286
318
  end
319
+
320
+ ## for Rails 3.0
321
+ Then /^I set the asset directory$/ do
322
+ ActionController::Base.helpers.config.assets_dir = "public" unless asset_pipeline_enabled?
323
+ end
@@ -1,3 +1,25 @@
1
1
  When /^I select "([^"]+)" as the datepicker's (\w+)$/ do |selection, type|
2
2
  page.find(".ui-datepicker-#{type}").select(selection)
3
3
  end
4
+
5
+ When /^I click the first date field$/ do
6
+ first(:css, "input.date[type='text']").click
7
+ end
8
+
9
+ Then /^the first date field should contain "(.*?)"$/ do |value|
10
+ field_value = first(:css, "input.date[type='text']").value
11
+ if field_value.respond_to? :should
12
+ field_value.should =~ /#{value}/
13
+ else
14
+ assert_match(/#{value}/, field_value)
15
+ end
16
+ end
17
+
18
+ Then /^the first date field should not contain "(.*?)"$/ do |value|
19
+ field_value = first(:css, "input.date[type='text']").value
20
+ if field_value.respond_to? :should_not
21
+ field_value.should_not =~ /#{value}/
22
+ else
23
+ assert_no_match(/#{value}/, field_value)
24
+ end
25
+ end
@@ -6,6 +6,8 @@
6
6
  ENV["RAILS_ROOT"] ||= File.expand_path(File.dirname(__FILE__) + '/../../testbed')
7
7
  require 'cucumber/rails'
8
8
 
9
+ # For Rails 3.0
10
+ include Surveyor::Helpers::AssetPipeline
9
11
 
10
12
  # require File.expand_path(File.dirname(__FILE__) + '/../../testbed/config/environment.rb')
11
13
  # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
@@ -0,0 +1,4 @@
1
+ AfterStep('@pause') do
2
+ print "Press Return to continue..."
3
+ STDIN.getc
4
+ end
@@ -507,9 +507,10 @@ Feature: Survey creation
507
507
  end
508
508
  end
509
509
  """
510
+ And I set the asset directory
510
511
  When I start the "Images" survey
511
512
  Then I should see the image "/images/surveyor/next.gif"
512
- And I should see the image "/images/surveyor/prev.gif"
513
+ And I should see the image "/images/surveyor/prev.gif"
513
514
 
514
515
  @javascript
515
516
  Scenario: Creating and unchecking checkboxes
@@ -777,3 +778,118 @@ Feature: Survey creation
777
778
  And I should see "the 2nd part of a round"
778
779
  And I should see "the 3rd part of a round"
779
780
  And I should see "the 4th part of a round"
781
+
782
+ Scenario: labels in groups
783
+ Given I parse
784
+ """
785
+ survey "Labels" do
786
+ section "One" do
787
+ group "Grouped" do
788
+ label "Grouped greetings"
789
+ a "Your response", :string
790
+ end
791
+ group "Inline group", :display_type => :inline do
792
+ label "Inline greetings"
793
+ a "Your response", :string
794
+ end
795
+ repeater "Repeater" do
796
+ label "Repeater greetings"
797
+ a "Your response", :string
798
+ end
799
+ grid "Grid" do
800
+ a "Grid response", :string
801
+ label "Grid greetings"
802
+ end
803
+ end
804
+ end
805
+ """
806
+ When I start the "Labels" survey
807
+ Then I should see "Grouped greetings"
808
+ And I should see "Inline greetings"
809
+ And I should see "Repeater greetings"
810
+ And I should see "Grid greetings"
811
+ And I should not see "Your response"
812
+ And I should see "Grid response"
813
+ And I should see no text inputs on the page
814
+
815
+ @javascript
816
+ Scenario: dates in pick one
817
+ Given I parse
818
+ """
819
+ survey "Dates" do
820
+ section "One" do
821
+ q_test_1 "When will you stop by?", :pick=>:one
822
+ a_date "On", :date, :custom_class => "date"
823
+ a_neg_1 "REFUSED"
824
+ a_neg_2 "DON'T KNOW"
825
+ end
826
+ section "Two" do
827
+ label "second section"
828
+ end
829
+ end
830
+ """
831
+ When I start the survey
832
+ And I click "On"
833
+ And I click the first date field
834
+ And I select "Mar" as the datepicker's month
835
+ And I select "2013" as the datepicker's year
836
+ And I follow "9"
837
+ Then there should be a date response with value "2013-03-09"
838
+ When I press "Two"
839
+ And I press "One"
840
+ Then the first date field should contain "2013-03-09"
841
+ And the first date field should not contain "2013-03-09 00:00:00.000000"
842
+
843
+ @javascript
844
+ Scenario: input mask and input mask placeholder
845
+ Given I parse
846
+ """
847
+ survey "Personal" do
848
+ section "One" do
849
+ q "What is your phone number?"
850
+ a "phone", :string, :input_mask => '(999)999-9999', :input_mask_placeholder => '#'
851
+ end
852
+ end
853
+ """
854
+ When I start the "Personal" survey
855
+ And I fill in "phone" with "1234567890"
856
+ And I press "Click here to finish"
857
+ Then there should be 1 response set with 1 responses with:
858
+ | string_value |
859
+ | (123)456-7890 |
860
+
861
+ @javascript
862
+ Scenario: numeric input mask with alphanumeric input
863
+ Given I parse
864
+ """
865
+ survey "Personal" do
866
+ section "One" do
867
+ q "What is your phone number?"
868
+ a 'phone', :string, :input_mask => '(999)999-9999'
869
+ end
870
+ end
871
+ """
872
+ When I start the "Personal" survey
873
+ And I fill in "phone" with "1a2b3c4d5e6f7g8h9i0"
874
+ And I press "Click here to finish"
875
+ Then there should be 1 response set with 1 responses with:
876
+ | string_value |
877
+ | (123)456-7890 |
878
+
879
+ @javascript
880
+ Scenario: alpha input mask with alphanumeric input
881
+ Given I parse
882
+ """
883
+ survey "Personal" do
884
+ section "One" do
885
+ q "What are your favorite letters?"
886
+ a 'letters', :string, :input_mask => 'aaaaaaaaa'
887
+ end
888
+ end
889
+ """
890
+ When I start the "Personal" survey
891
+ And I fill in "letters" with "1a2b3c4d5e6f7g8h9i0"
892
+ And I press "Click here to finish"
893
+ Then there should be 1 response set with 1 responses with:
894
+ | string_value |
895
+ | abcdefghi |