surveyor 0.18.2 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/CHANGELOG +12 -0
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/app/helpers/surveyor_helper.rb +40 -22
- data/app/views/layouts/surveyor_default.html.erb +0 -1
- data/app/views/partials/_answer.html.haml +19 -58
- data/app/views/partials/_dependents.html.haml +5 -0
- data/app/views/partials/_question.html.haml +24 -72
- data/app/views/partials/_question_group.html.haml +30 -39
- data/app/views/partials/_section.html.haml +10 -11
- data/app/views/partials/_section_menu.html.haml +5 -0
- data/app/views/surveyor/edit.html.haml +13 -25
- data/app/views/surveyor/new.html.haml +6 -3
- data/features/{redcap.feature → redcap_parser.feature} +0 -0
- data/features/step_definitions/parser_steps.rb +71 -0
- data/features/step_definitions/surveyor_steps.rb +8 -78
- data/features/support/paths.rb +2 -0
- data/features/surveyor.feature +30 -168
- data/features/surveyor_parser.feature +157 -0
- data/generators/surveyor/surveyor_generator.rb +2 -1
- data/generators/surveyor/templates/assets/images/next.gif +0 -0
- data/generators/surveyor/templates/assets/images/prev.gif +0 -0
- data/generators/surveyor/templates/assets/javascripts/jquery.surveyor.js +46 -0
- data/generators/surveyor/templates/assets/javascripts/jquery.tools.min.js +204 -0
- data/generators/surveyor/templates/assets/stylesheets/dateinput.css +149 -0
- data/generators/surveyor/templates/assets/stylesheets/sass/surveyor.sass +84 -226
- data/generators/surveyor/templates/migrate/add_default_value_to_answers.rb +9 -0
- data/lib/formtastic/surveyor_builder.rb +83 -0
- data/lib/surveyor.rb +5 -0
- data/lib/surveyor/models/answer_methods.rb +8 -3
- data/lib/surveyor/models/question_group_methods.rb +1 -1
- data/lib/surveyor/models/question_methods.rb +6 -2
- data/lib/surveyor/models/response_methods.rb +2 -12
- data/lib/surveyor/models/response_set_methods.rb +25 -71
- data/lib/surveyor/surveyor_controller_methods.rb +29 -28
- data/lib/tasks/surveyor_tasks.rake +1 -15
- data/spec/controllers/surveyor_controller_spec.rb +40 -8
- data/spec/helpers/surveyor_helper_spec.rb +53 -0
- data/spec/models/answer_spec.rb +14 -9
- data/spec/models/dependency_condition_spec.rb +56 -61
- data/spec/models/question_group_spec.rb +3 -3
- data/spec/models/question_spec.rb +10 -0
- data/spec/models/response_set_spec.rb +72 -62
- data/surveyor.gemspec +21 -58
- data/testbed/Gemfile +1 -0
- metadata +34 -60
- data/app/helpers/survey_form_builder.rb +0 -37
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_resize_se.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_35x9_colorpicker_indicator.gif.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/dadada_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/e6e6e6_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_01_flat_0.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_02_glass_65.png +0 -0
- data/generators/surveyor/templates/assets/javascripts/accessibleUISlider.jQuery.js +0 -201
- data/generators/surveyor/templates/assets/javascripts/jquery-1.2.6.js +0 -3549
- data/generators/surveyor/templates/assets/javascripts/jquery-ui-personalized-1.5.3.js +0 -7616
- data/generators/surveyor/templates/assets/javascripts/jquery.form.js +0 -637
- data/generators/surveyor/templates/assets/javascripts/surveyor.js +0 -40
- data/generators/surveyor/templates/assets/stylesheets/jquery-ui-slider-additions.css +0 -71
- data/generators/surveyor/templates/assets/stylesheets/ui.theme.css +0 -851
- data/spec/views/surveyor/show.html.haml_spec.rb +0 -32
- data/uninstall.rb +0 -1
@@ -1,6 +1,9 @@
|
|
1
1
|
#surveyor
|
2
|
-
|
3
|
-
.
|
2
|
+
- unless (types = flash.keys.select{|k| [:notice, :error, :warning].include?(k)}).blank?
|
3
|
+
.surveyor_flash
|
4
|
+
= flash_messages(types)
|
5
|
+
.close
|
6
|
+
.survey_title= t('surveyor.take_these_surveys')
|
4
7
|
%br
|
5
8
|
#survey_list
|
6
9
|
%ul
|
@@ -10,7 +13,7 @@
|
|
10
13
|
- form_tag(take_survey_path(:survey_code => survey.access_code)) do
|
11
14
|
= survey.title
|
12
15
|
|
13
|
-
= submit_tag( t
|
16
|
+
= submit_tag( t('surveyor.take_it') )
|
14
17
|
- else
|
15
18
|
%li
|
16
19
|
No surveys
|
File without changes
|
@@ -0,0 +1,71 @@
|
|
1
|
+
Given /^I parse$|^the survey$/ do |string|
|
2
|
+
Surveyor::Parser.parse(string)
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^I parse redcap file "([^"]*)"$/ do |name|
|
6
|
+
Surveyor::RedcapParser.parse File.read(File.join(RAILS_ROOT, '..', 'features', 'support', name)), name
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^there should be (\d+) survey(?:s?) with:$/ do |x, table|
|
10
|
+
Survey.count.should == x.to_i
|
11
|
+
table.hashes.each do |hash|
|
12
|
+
Survey.find(:first, :conditions => hash).should_not be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^there should be (\d+) question groups with:$/ do |x, table|
|
17
|
+
QuestionGroup.count.should == x.to_i
|
18
|
+
table.hashes.each do |hash|
|
19
|
+
QuestionGroup.find(:first, :conditions => hash).should_not be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /^there should be (\d+) question(?:s?) with:$/ do |x, table|
|
24
|
+
Question.count.should == x.to_i
|
25
|
+
table.hashes.each do |hash|
|
26
|
+
hash["reference_identifier"] = nil if hash["reference_identifier"] == "nil"
|
27
|
+
hash["custom_class"] = nil if hash["custom_class"] == "nil"
|
28
|
+
Question.find(:first, :conditions => hash).should_not be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^there should be (\d+) answer(?:s?) with:$/ do |x, table|
|
33
|
+
Answer.count.should == x.to_i
|
34
|
+
table.hashes.each do |hash|
|
35
|
+
hash["reference_identifier"] = nil if hash["reference_identifier"] == "nil"
|
36
|
+
Answer.find(:first, :conditions => hash).should_not be_nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Then /^there should be (\d+) dependenc(?:y|ies) with:$/ do |x, table|
|
41
|
+
Dependency.count.should == x.to_i
|
42
|
+
table.hashes.each do |hash|
|
43
|
+
Dependency.find(:first, :conditions => hash).should_not be_nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
Then /^there should be (\d+) resolved dependency_condition(?:s?) with:$/ do |x, table|
|
48
|
+
DependencyCondition.count.should == x.to_i
|
49
|
+
table.hashes.each do |hash|
|
50
|
+
d = DependencyCondition.find(:first, :conditions => hash)
|
51
|
+
d.should_not be_nil
|
52
|
+
d.question.should_not be_nil
|
53
|
+
d.answer.should_not be_nil unless d.operator.match(/^count[<>=!]{1,2}\d+/)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
Then /^there should be (\d+) validation(?:s?) with:$/ do |x, table|
|
59
|
+
Validation.count.should == x.to_i
|
60
|
+
table.hashes.each do |hash|
|
61
|
+
Validation.find(:first, :conditions => hash).should_not be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Then /^there should be (\d+) validation_condition(?:s?) with:$/ do |x, table|
|
66
|
+
ValidationCondition.count.should == x.to_i
|
67
|
+
table.hashes.each do |hash|
|
68
|
+
hash["integer_value"] = nil if hash["integer_value"] == "nil"
|
69
|
+
ValidationCondition.find(:first, :conditions => hash).should_not be_nil
|
70
|
+
end
|
71
|
+
end
|
@@ -1,81 +1,11 @@
|
|
1
|
-
|
2
|
-
|
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"
|
3
5
|
end
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
Then /^there should be (\d+) survey(?:s?) with:$/ do |x, table|
|
10
|
-
Survey.count.should == x.to_i
|
11
|
-
table.hashes.each do |hash|
|
12
|
-
Survey.find(:first, :conditions => hash).should_not be_nil
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
Then /^there should be (\d+) question groups with:$/ do |x, table|
|
17
|
-
QuestionGroup.count.should == x.to_i
|
18
|
-
table.hashes.each do |hash|
|
19
|
-
QuestionGroup.find(:first, :conditions => hash).should_not be_nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
Then /^there should be (\d+) question(?:s?) with:$/ do |x, table|
|
24
|
-
Question.count.should == x.to_i
|
25
|
-
table.hashes.each do |hash|
|
26
|
-
hash["reference_identifier"] = nil if hash["reference_identifier"] == "nil"
|
27
|
-
hash["custom_class"] = nil if hash["custom_class"] == "nil"
|
28
|
-
Question.find(:first, :conditions => hash).should_not be_nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
Then /^there should be (\d+) answer(?:s?) with:$/ do |x, table|
|
33
|
-
Answer.count.should == x.to_i
|
34
|
-
table.hashes.each do |hash|
|
35
|
-
hash["reference_identifier"] = nil if hash["reference_identifier"] == "nil"
|
36
|
-
Answer.find(:first, :conditions => hash).should_not be_nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
Then /^there should be (\d+) dependenc(?:y|ies) with:$/ do |x, table|
|
41
|
-
Dependency.count.should == x.to_i
|
42
|
-
table.hashes.each do |hash|
|
43
|
-
Dependency.find(:first, :conditions => hash).should_not be_nil
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
Then /^there should be (\d+) group dependenc(?:y|ies) with:$/ do |x, table|
|
48
|
-
Dependency.count(:conditions => ["question_group_id NOT NULL"]).should == x.to_i
|
49
|
-
table.hashes.each do |hash|
|
50
|
-
(d = Dependency.find(:first, :conditions => hash)).should_not be_nil
|
51
|
-
d.question_group_id.should_not be_nil
|
52
|
-
d.question_id.should be_nil
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
Then /^there should be (\d+) resolved dependency_condition(?:s?) with:$/ do |x, table|
|
58
|
-
DependencyCondition.count.should == x.to_i
|
59
|
-
table.hashes.each do |hash|
|
60
|
-
d = DependencyCondition.find(:first, :conditions => hash)
|
61
|
-
d.should_not be_nil
|
62
|
-
d.question.should_not be_nil
|
63
|
-
d.answer.should_not be_nil unless d.operator.match(/^count[<>=!]{1,2}\d+/)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
Then /^there should be (\d+) validation(?:s?) with:$/ do |x, table|
|
69
|
-
Validation.count.should == x.to_i
|
70
|
-
table.hashes.each do |hash|
|
71
|
-
Validation.find(:first, :conditions => hash).should_not be_nil
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
Then /^there should be (\d+) validation_condition(?:s?) with:$/ do |x, table|
|
76
|
-
ValidationCondition.count.should == x.to_i
|
77
|
-
table.hashes.each do |hash|
|
78
|
-
hash["integer_value"] = nil if hash["integer_value"] == "nil"
|
79
|
-
ValidationCondition.find(:first, :conditions => hash).should_not be_nil
|
80
|
-
end
|
7
|
+
Then /^there should be (\d+) response set with (\d+) responses with:$/ do |rs_num, r_num, table|
|
8
|
+
ResponseSet.count.should == rs_num.to_i
|
9
|
+
Response.count.should == r_num.to_i
|
10
|
+
# table is a Cucumber::Ast::Table
|
81
11
|
end
|
data/features/support/paths.rb
CHANGED
data/features/surveyor.feature
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
Feature: Survey creation
|
2
|
-
As a
|
3
|
-
I want to
|
4
|
-
So that I can
|
2
|
+
As a survey participant
|
3
|
+
I want to take a survey
|
4
|
+
So that I can get paid
|
5
5
|
|
6
6
|
Scenario: Basic questions
|
7
|
-
Given
|
7
|
+
Given the survey
|
8
8
|
"""
|
9
|
-
survey "
|
10
|
-
section "
|
11
|
-
label "
|
9
|
+
survey "Favorites" do
|
10
|
+
section "Colors" do
|
11
|
+
label "You with the sad eyes don't be discouraged"
|
12
12
|
|
13
13
|
question_1 "What is your favorite color?", :pick => :one
|
14
14
|
answer "red"
|
@@ -24,168 +24,30 @@ Feature: Survey creation
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
"""
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
And
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
|
35
|
-
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
| 1 | orange | answer |
|
42
|
-
| 2 | purple | answer |
|
43
|
-
| 3 | brown | answer |
|
44
|
-
| nil | Omit | answer |
|
45
|
-
|
46
|
-
Scenario: More complex questions
|
47
|
-
Given I parse
|
48
|
-
"""
|
49
|
-
survey "Complex survey" do
|
50
|
-
section "Complicated questions" do
|
51
|
-
grid "Tell us how you feel today" do
|
52
|
-
a "-2"
|
53
|
-
a "-1"
|
54
|
-
a "0"
|
55
|
-
a "1"
|
56
|
-
a "2"
|
57
|
-
q "down|up" , :pick => :one
|
58
|
-
q "sad|happy", :pick => :one
|
59
|
-
q "limp|perky", :pick => :one
|
60
|
-
end
|
61
|
-
|
62
|
-
q "Choose your favorite utensils and enter frequency of use (daily, weekly, monthly, etc...)", :pick => :any
|
63
|
-
a "spoon", :string
|
64
|
-
a "fork", :string
|
65
|
-
a "knife", :string
|
66
|
-
a :other, :string
|
67
|
-
|
68
|
-
repeater "Tell us about the cars you own" do
|
69
|
-
q "Make", :pick => :one, :display_type => :dropdown
|
70
|
-
a "Toyota"
|
71
|
-
a "Ford"
|
72
|
-
a "GMChevy"
|
73
|
-
a "Ferrari"
|
74
|
-
a "Tesla"
|
75
|
-
a "Honda"
|
76
|
-
a "Other weak brand"
|
77
|
-
q "Model"
|
78
|
-
a :string
|
79
|
-
q "Year"
|
80
|
-
a :string
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
"""
|
85
|
-
Then there should be 1 survey with:
|
86
|
-
| title |
|
87
|
-
| Complex survey |
|
88
|
-
And there should be 2 question groups with:
|
89
|
-
| text | display_type |
|
90
|
-
| Tell us how you feel today | grid |
|
91
|
-
| Tell us about the cars you own | repeater |
|
92
|
-
And there should be 7 questions with:
|
93
|
-
| text | pick | display_type |
|
94
|
-
| Make | one | dropdown |
|
95
|
-
And there should be 28 answers with:
|
96
|
-
| text | response_class |
|
97
|
-
| -2 | answer |
|
98
|
-
| Other | string |
|
99
|
-
|
100
|
-
Scenario: Dependencies and validations
|
101
|
-
Given I parse
|
102
|
-
"""
|
103
|
-
survey "Dependency and validation survey" do
|
104
|
-
section "Conditionals" do
|
105
|
-
q_montypython3 "What... is your name? (e.g. It is 'Arthur', King of the Britons)"
|
106
|
-
a_1 :string
|
107
|
-
|
108
|
-
q_montypython4 "What... is your quest? (e.g. To seek the Holy Grail)"
|
109
|
-
a_1 :string
|
110
|
-
dependency :rule => "A"
|
111
|
-
condition_A :q_montypython3, "==", {:string_value => "It is 'Arthur', King of the Britons", :answer_reference => "1"}
|
112
|
-
|
113
|
-
q "How many pets do you own?"
|
114
|
-
a :integer
|
115
|
-
validation :rule => "A"
|
116
|
-
condition_A ">=", :integer_value => 0
|
117
|
-
|
118
|
-
q "What is your address?", :custom_class => 'address'
|
119
|
-
a :text, :custom_class => 'mapper'
|
120
|
-
validation :rule => "AC"
|
121
|
-
vcondition_AC "=~", :regexp => /[0-9a-zA-z\. #]/
|
122
|
-
|
123
|
-
q_2 "Which colors do you loathe?", :pick => :any
|
124
|
-
a_1 "red"
|
125
|
-
a_2 "blue"
|
126
|
-
a_3 "green"
|
127
|
-
a_4 "yellow"
|
128
|
-
|
129
|
-
q_2a "Please explain why you hate so many colors?"
|
130
|
-
a_1 "explanation", :text
|
131
|
-
dependency :rule => "Z"
|
132
|
-
condition_Z :q_2, "count>2"
|
133
|
-
end
|
134
|
-
end
|
135
|
-
"""
|
136
|
-
Then there should be 1 survey with:
|
137
|
-
| title |
|
138
|
-
| Dependency and validation survey |
|
139
|
-
And there should be 6 questions with:
|
140
|
-
| text | pick | display_type | custom_class |
|
141
|
-
| What... is your name? (e.g. It is 'Arthur', King of the Britons) | none | default | nil |
|
142
|
-
| What is your address? | none | default | address |
|
143
|
-
And there should be 2 dependency with:
|
144
|
-
| rule |
|
145
|
-
| A |
|
146
|
-
| Z |
|
147
|
-
And there should be 2 resolved dependency_condition with:
|
148
|
-
| rule_key |
|
149
|
-
| A |
|
150
|
-
| Z |
|
151
|
-
And there should be 2 validations with:
|
152
|
-
| rule |
|
153
|
-
| A |
|
154
|
-
| AC |
|
155
|
-
And there should be 2 validation_conditions with:
|
156
|
-
| rule_key | integer_value |
|
157
|
-
| A | 0 |
|
158
|
-
Scenario: Group dependencies
|
159
|
-
Given I parse
|
27
|
+
When I start the "Favorites" survey
|
28
|
+
And I choose "red"
|
29
|
+
And I choose "blue"
|
30
|
+
And I check "orange"
|
31
|
+
And I check "brown"
|
32
|
+
And I press "Click here to finish"
|
33
|
+
Then there should be 1 response set with 3 responses with:
|
34
|
+
| to_s |
|
35
|
+
| blue |
|
36
|
+
| orange |
|
37
|
+
| brown |
|
38
|
+
|
39
|
+
Scenario: Default answers
|
40
|
+
Given the survey
|
160
41
|
"""
|
161
|
-
survey "
|
162
|
-
section "
|
163
|
-
|
164
|
-
|
165
|
-
condition_A :q_dayone_1, "==", :a_2
|
166
|
-
q_dayone_2 "Medication", :pick=> :one, :display_type => :dropdown
|
167
|
-
a_0 "None"
|
168
|
-
a_1 "Dexlansoprazole (Kapidex)"
|
169
|
-
a_2 "Esomeprazole (Nexium)"
|
170
|
-
a_3 "Lansoprazole (Prevacid)"
|
171
|
-
a_4 "Omeprazole (Prilosec)"
|
172
|
-
a_5 "Omeprazole, Sodium Bicarbonate (Zegerid)"
|
173
|
-
a_6 "Pantoprazole (Protonix)"
|
174
|
-
a_7 "Rabeprazole (Aciphex)"
|
175
|
-
a_8 "Other", :string
|
176
|
-
|
177
|
-
q_dayone_3 "Dose (mg)"
|
178
|
-
a :string
|
179
|
-
q_dayone_4 "Frequency", :pick => :one, :display_type => :dropdown
|
180
|
-
a_1 "Daily (AM)"
|
181
|
-
a_2 "Daily (PM)"
|
182
|
-
a_3 "Twice daily"
|
183
|
-
end
|
42
|
+
survey "Favorites" do
|
43
|
+
section "Foods" do
|
44
|
+
question_1 "What is your favorite food?"
|
45
|
+
answer :string, :default_value => "beef"
|
184
46
|
end
|
185
47
|
end
|
186
48
|
"""
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
49
|
+
When I start the "Favorites" survey
|
50
|
+
And I press "Click here to finish"
|
51
|
+
Then there should be 1 response set with 1 responses with:
|
52
|
+
| to_s |
|
53
|
+
| clear |
|
@@ -0,0 +1,157 @@
|
|
1
|
+
Feature: Survey creation
|
2
|
+
As a
|
3
|
+
I want to write out the survey in the DSL
|
4
|
+
So that I can give it to survey participants
|
5
|
+
|
6
|
+
Scenario: Basic questions
|
7
|
+
Given I parse
|
8
|
+
"""
|
9
|
+
survey "Simple survey" 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 there should be 1 survey with:
|
28
|
+
| title |
|
29
|
+
| Simple survey |
|
30
|
+
And there should be 3 questions with:
|
31
|
+
| reference_identifier | text | pick | display_type |
|
32
|
+
| nil | These questions are examples of the basic supported input types | none | label |
|
33
|
+
| 1 | What is your favorite color? | one | default |
|
34
|
+
| 2b | Choose the colors you don't like | any | default |
|
35
|
+
And there should be 8 answers with:
|
36
|
+
| reference_identifier | text | response_class |
|
37
|
+
| nil | red | answer |
|
38
|
+
| nil | blue | answer |
|
39
|
+
| nil | green | answer |
|
40
|
+
| nil | Other | answer |
|
41
|
+
| 1 | orange | answer |
|
42
|
+
| 2 | purple | answer |
|
43
|
+
| 3 | brown | answer |
|
44
|
+
| nil | Omit | answer |
|
45
|
+
|
46
|
+
Scenario: More complex questions
|
47
|
+
Given I parse
|
48
|
+
"""
|
49
|
+
survey "Complex survey" do
|
50
|
+
section "Complicated questions" do
|
51
|
+
grid "Tell us how you feel today" do
|
52
|
+
a "-2"
|
53
|
+
a "-1"
|
54
|
+
a "0"
|
55
|
+
a "1"
|
56
|
+
a "2"
|
57
|
+
q "down|up" , :pick => :one
|
58
|
+
q "sad|happy", :pick => :one
|
59
|
+
q "limp|perky", :pick => :one
|
60
|
+
end
|
61
|
+
|
62
|
+
q "Choose your favorite utensils and enter frequency of use (daily, weekly, monthly, etc...)", :pick => :any
|
63
|
+
a "spoon", :string
|
64
|
+
a "fork", :string
|
65
|
+
a "knife", :string
|
66
|
+
a :other, :string
|
67
|
+
|
68
|
+
repeater "Tell us about the cars you own" do
|
69
|
+
q "Make", :pick => :one, :display_type => :dropdown
|
70
|
+
a "Toyota"
|
71
|
+
a "Ford"
|
72
|
+
a "GMChevy"
|
73
|
+
a "Ferrari"
|
74
|
+
a "Tesla"
|
75
|
+
a "Honda"
|
76
|
+
a "Other weak brand"
|
77
|
+
q "Model"
|
78
|
+
a :string
|
79
|
+
q "Year"
|
80
|
+
a :string
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
"""
|
85
|
+
Then there should be 1 survey with:
|
86
|
+
| title |
|
87
|
+
| Complex survey |
|
88
|
+
And there should be 2 question groups with:
|
89
|
+
| text | display_type |
|
90
|
+
| Tell us how you feel today | grid |
|
91
|
+
| Tell us about the cars you own | repeater |
|
92
|
+
And there should be 7 questions with:
|
93
|
+
| text | pick | display_type |
|
94
|
+
| Make | one | dropdown |
|
95
|
+
And there should be 28 answers with:
|
96
|
+
| text | response_class |
|
97
|
+
| -2 | answer |
|
98
|
+
| Other | string |
|
99
|
+
|
100
|
+
Scenario: Dependencies and validations
|
101
|
+
Given I parse
|
102
|
+
"""
|
103
|
+
survey "Dependency and validation survey" do
|
104
|
+
section "Conditionals" do
|
105
|
+
q_montypython3 "What... is your name? (e.g. It is 'Arthur', King of the Britons)"
|
106
|
+
a_1 :string
|
107
|
+
|
108
|
+
q_montypython4 "What... is your quest? (e.g. To seek the Holy Grail)"
|
109
|
+
a_1 :string
|
110
|
+
dependency :rule => "A"
|
111
|
+
condition_A :q_montypython3, "==", {:string_value => "It is 'Arthur', King of the Britons", :answer_reference => "1"}
|
112
|
+
|
113
|
+
q "How many pets do you own?"
|
114
|
+
a :integer
|
115
|
+
validation :rule => "A"
|
116
|
+
condition_A ">=", :integer_value => 0
|
117
|
+
|
118
|
+
q "What is your address?", :custom_class => 'address'
|
119
|
+
a :text, :custom_class => 'mapper'
|
120
|
+
validation :rule => "AC"
|
121
|
+
vcondition_AC "=~", :regexp => /[0-9a-zA-z\. #]/
|
122
|
+
|
123
|
+
q_2 "Which colors do you loathe?", :pick => :any
|
124
|
+
a_1 "red"
|
125
|
+
a_2 "blue"
|
126
|
+
a_3 "green"
|
127
|
+
a_4 "yellow"
|
128
|
+
|
129
|
+
q_2a "Please explain why you hate so many colors?"
|
130
|
+
a_1 "explanation", :text
|
131
|
+
dependency :rule => "Z"
|
132
|
+
condition_Z :q_2, "count>2"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
"""
|
136
|
+
Then there should be 1 survey with:
|
137
|
+
| title |
|
138
|
+
| Dependency and validation survey |
|
139
|
+
And there should be 6 questions with:
|
140
|
+
| text | pick | display_type | custom_class |
|
141
|
+
| What... is your name? (e.g. It is 'Arthur', King of the Britons) | none | default | nil |
|
142
|
+
| What is your address? | none | default | address |
|
143
|
+
And there should be 2 dependency with:
|
144
|
+
| rule |
|
145
|
+
| A |
|
146
|
+
| Z |
|
147
|
+
And there should be 2 resolved dependency_condition with:
|
148
|
+
| rule_key |
|
149
|
+
| A |
|
150
|
+
| Z |
|
151
|
+
And there should be 2 validations with:
|
152
|
+
| rule |
|
153
|
+
| A |
|
154
|
+
| AC |
|
155
|
+
And there should be 2 validation_conditions with:
|
156
|
+
| rule_key | integer_value |
|
157
|
+
| A | 0 |
|